From a27448bc76e66d54d65d19d36be5f0592500711e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 20 Jun 2022 01:32:33 +0200 Subject: [PATCH] [dxvk] Bind consecutive descriptor sets in one go Most of the time we'll be able to bind all sets in one iteration. Binding sets is expected to be cheap in the driver, but we should avoid unnecessary function call overhead for this frequently called function. --- src/dxvk/dxvk_context.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index a0426707b..af572e001 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -4384,18 +4384,19 @@ namespace dxvk { m_cmd->updateDescriptorSets(k, m_descriptorWrites.data()); // Bind all descriptor sets that need updating - uint32_t bindSetMask = layoutSetMask & ~((1u << firstUpdated) - 1); + uint32_t bindSetMask = layoutSetMask & ((~0u) << firstUpdated); while (bindSetMask) { uint32_t setIndex = bit::tzcnt(bindSetMask); + uint32_t setCount = bit::tzcnt(~(bindSetMask >> setIndex)); - VkDescriptorSet& set = m_descriptorState.getSet(setIndex); + VkDescriptorSet* sets = &m_descriptorState.getSet(setIndex); m_cmd->cmdBindDescriptorSets(BindPoint, layout->getPipelineLayout(), - setIndex, 1, &set, 0, nullptr); + setIndex, setCount, sets, 0, nullptr); - bindSetMask &= bindSetMask - 1; + bindSetMask &= (~0u) << (setIndex + setCount); } // Update pipeline if there are unbound resources