From c1faedbdc09d000a4bff5ab33db7fabb5e835346 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 16 Mar 2022 17:54:05 +0200 Subject: [PATCH] Fix binding of descriptor sets of the new pipeline has more than the last --- source/backends/vulkan/pipelinestate_backend.cpp | 16 ++++++++++++---- source/backends/vulkan/pipelinestate_backend.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index 02e7993c..351affab 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -77,9 +77,14 @@ void VulkanPipelineState::update() const if(changed_sets) { descriptor_set_slots.resize(self.shprog->get_n_descriptor_sets()); + first_changed_desc_set = descriptor_set_slots.size(); for(unsigned i=0; i(this); const VulkanFunctions &vk = device.get_functions(); - unsigned first_changed_desc_set = 0; if(!last) + { unapplied = ~0U; + first_changed_desc_set = 0; + } else if(last!=this) { const PipelineState &last_ps = *static_cast(last); @@ -384,11 +391,11 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe unapplied |= PipelineState::SHPROG; if(self.vertex_setup!=last_ps.vertex_setup) unapplied |= PipelineState::VERTEX_SETUP; - for(unsigned i=0; (idescriptor_set_slots.size()); ++i) - if(descriptor_set_slots[i]!=last->descriptor_set_slots[i]) + for(unsigned i=0; i=last->descriptor_set_slots.size() || descriptor_set_slots[i]!=last->descriptor_set_slots[i]) { unapplied |= PipelineState::UNIFORMS; - first_changed_desc_set = i; + first_changed_desc_set = min(first_changed_desc_set, i); break; } if(self.viewport!=last_ps.viewport) @@ -466,6 +473,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe } unapplied = 0; + first_changed_desc_set = descriptor_set_slots.size(); } } // namespace GL diff --git a/source/backends/vulkan/pipelinestate_backend.h b/source/backends/vulkan/pipelinestate_backend.h index ab462ed5..5570e5d9 100644 --- a/source/backends/vulkan/pipelinestate_backend.h +++ b/source/backends/vulkan/pipelinestate_backend.h @@ -21,6 +21,7 @@ protected: mutable unsigned unapplied = 0; mutable VkPipeline handle = 0; mutable std::vector descriptor_set_slots; + mutable unsigned first_changed_desc_set = 0; VulkanPipelineState(); VulkanPipelineState(VulkanPipelineState &&); -- 2.45.2