]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix binding of descriptor sets of the new pipeline has more than the last
authorMikko Rasa <tdb@tdb.fi>
Wed, 16 Mar 2022 15:54:05 +0000 (17:54 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 16 Mar 2022 15:54:05 +0000 (17:54 +0200)
source/backends/vulkan/pipelinestate_backend.cpp
source/backends/vulkan/pipelinestate_backend.h

index 02e7993c665fb52dd95e9ff3f92020cfb2584a68..351affab103a44d38706b5763ffdb578777bcac8 100644 (file)
@@ -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<descriptor_set_slots.size(); ++i)
                                if(changed_sets&(1<<i))
+                               {
                                        descriptor_set_slots[i] = device.get_descriptor_pool().get_descriptor_set_slot(self, i);
+                                       first_changed_desc_set = min(first_changed_desc_set, i);
+                               }
+
                        unapplied |= PipelineState::UNIFORMS;
                }
        }
@@ -374,9 +379,11 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe
        const PipelineState &self = *static_cast<const PipelineState *>(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<const PipelineState *>(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; (i<descriptor_set_slots.size() && i<last->descriptor_set_slots.size()); ++i)
-                       if(descriptor_set_slots[i]!=last->descriptor_set_slots[i])
+               for(unsigned i=0; i<descriptor_set_slots.size(); ++i)
+                       if(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
index ab462ed5b415e059dacad36c7476cd65bfff4ec1..5570e5d965974fc8dfe26fa3aa8f0264fcc3e157 100644 (file)
@@ -21,6 +21,7 @@ protected:
        mutable unsigned unapplied = 0;
        mutable VkPipeline handle = 0;
        mutable std::vector<unsigned> descriptor_set_slots;
+       mutable unsigned first_changed_desc_set = 0;
 
        VulkanPipelineState();
        VulkanPipelineState(VulkanPipelineState &&);