From b4afa01e74375446c12e4bd7472412df7f0d6e48 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 16 Mar 2022 13:29:09 +0200 Subject: [PATCH] Skip binding of low-numbered descriptor sets if they haven't changed --- source/backends/vulkan/pipelinestate_backend.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index a6a548af..02e7993c 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -374,6 +374,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe const PipelineState &self = *static_cast(this); const VulkanFunctions &vk = device.get_functions(); + unsigned first_changed_desc_set = 0; if(!last) unapplied = ~0U; else if(last!=this) @@ -387,6 +388,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe if(descriptor_set_slots[i]!=last->descriptor_set_slots[i]) { unapplied |= PipelineState::UNIFORMS; + first_changed_desc_set = i; break; } if(self.viewport!=last_ps.viewport) @@ -420,12 +422,13 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer, const VulkanPipe if((unapplied&PipelineState::UNIFORMS) && !descriptor_set_slots.empty()) { vector descriptor_set_handles; - descriptor_set_handles.reserve(self.descriptor_set_slots.size()); - for(unsigned i=0; ilayout_handle, - 0, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, 0); + first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, 0); } if(unapplied&(PipelineState::VIEWPORT|PipelineState::SCISSOR)) -- 2.45.2