diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 3f6e985f20e4..99df5d242fab 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1339,6 +1339,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c case VKRRenderCommand::DRAW_INDEXED: if (pipelineOK) { VkDescriptorSet set = (*descSets)[c.drawIndexed.descSetIndex].set; + _dbg_assert_(set != VK_NULL_HANDLE); vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &set, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets); vkCmdBindIndexBuffer(cmd, c.drawIndexed.ibuffer, c.drawIndexed.ioffset, VK_INDEX_TYPE_UINT16); VkDeviceSize voffset = c.drawIndexed.voffset; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index e4dc0a20a66e..1246ff17a73a 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -1698,6 +1698,13 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro pool.Reset(); + VkDescriptorSet setCache[8]; + VkDescriptorSetLayout layoutsForAlloc[ARRAY_SIZE(setCache)]; + for (int i = 0; i < ARRAY_SIZE(setCache); i++) { + layoutsForAlloc[i] = descriptorSetLayout; + } + int setsUsed = ARRAY_SIZE(setCache); // To allocate immediately. + // This will write all descriptors. // Initially, we just do a simple look-back comparing to the previous descriptor to avoid sequential dupes. @@ -1724,8 +1731,15 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro } } - // TODO: Allocate in batches. - pool.Allocate(&d.set, 1, &descriptorSetLayout); + if (setsUsed < ARRAY_SIZE(setCache)) { + d.set = setCache[setsUsed++]; + } else { + // Allocate in small batches. + bool success = pool.Allocate(setCache, ARRAY_SIZE(setCache), layoutsForAlloc); + _dbg_assert_(success); + d.set = setCache[0]; + setsUsed = 1; + } // TODO: Build up bigger batches of writes. const PackedDescriptor *data = descData.begin() + d.offset;