Skip to content

Commit eda65a6

Browse files
committed
PostProcessing: Fix texture hazard when stages disabled
1 parent 8c669e3 commit eda65a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/postprocessing.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,10 @@ PostProcessing::Chain::~Chain() = default;
429429

430430
GPUTexture* PostProcessing::Chain::GetTextureUnusedAtEndOfChain() const
431431
{
432-
return (m_stages.size() % 2) ? m_output_texture.get() :
433-
(m_intermediate_texture ? m_intermediate_texture.get() : m_input_texture.get());
432+
const size_t num_active_stages = std::ranges::count_if(
433+
m_stages, [](const std::unique_ptr<Shader>& shader) { return (shader && shader->IsEnabled()); });
434+
return (num_active_stages % 2) ? m_output_texture.get() :
435+
(m_intermediate_texture ? m_intermediate_texture.get() : m_input_texture.get());
434436
}
435437

436438
bool PostProcessing::Chain::IsActive() const

0 commit comments

Comments
 (0)