From: Mikko Rasa Date: Wed, 16 Mar 2022 15:56:30 +0000 (+0200) Subject: Fix handling of descriptor set bindings when shader stages change X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a3252b69d94004bcb55a51ea1023ac0cbdbde32d;p=libs%2Fgl.git Fix handling of descriptor set bindings when shader stages change Also set only the present stages for descriptor set layouts. --- diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index 351affab..4eba2895 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -266,6 +266,7 @@ uint64_t VulkanPipelineState::compute_descriptor_set_hash(unsigned index) const const PipelineState &self = *static_cast(this); uint64_t result = hash<64>(0, 0); + bool empty = true; auto i = lower_bound_member(self.uniform_blocks, static_cast(index)<<20, &PipelineState::BoundUniformBlock::binding); for(; (i!=self.uniform_blocks.end() && static_cast(i->binding)>>20==index); ++i) @@ -274,6 +275,7 @@ uint64_t VulkanPipelineState::compute_descriptor_set_hash(unsigned index) const result = hash_update<64>(result, i->binding); result = hash_update<64>(result, reinterpret_cast(i->block)); result = hash_update<64>(result, reinterpret_cast(i->buffer->handle)); + empty = false; } auto j = lower_bound_member(self.textures, index<<20, &PipelineState::BoundTexture::binding); @@ -284,8 +286,12 @@ uint64_t VulkanPipelineState::compute_descriptor_set_hash(unsigned index) const result = hash_update<64>(result, reinterpret_cast(j->texture->handle)); result = hash_update<64>(result, reinterpret_cast(j->sampler->handle)); result = hash_update<64>(result, j->level); + empty = false; } + if(!empty) + result = hash_update<64>(result, self.shprog->stage_flags); + return result; } @@ -388,7 +394,14 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe { const PipelineState &last_ps = *static_cast(last); if(handle!=last->handle) + { unapplied |= PipelineState::SHPROG; + if(self.shprog->stage_flags!=last_ps.shprog->stage_flags) + { + unapplied |= PipelineState::UNIFORMS; + first_changed_desc_set = 0; + } + } if(self.vertex_setup!=last_ps.vertex_setup) unapplied |= PipelineState::VERTEX_SETUP; for(unsigned i=0; i