diff --git a/Common/GPU/Vulkan/VulkanDescSet.cpp b/Common/GPU/Vulkan/VulkanDescSet.cpp index 05ea9eadb6..cb85dd8425 100644 --- a/Common/GPU/Vulkan/VulkanDescSet.cpp +++ b/Common/GPU/Vulkan/VulkanDescSet.cpp @@ -42,19 +42,18 @@ void VulkanDescSetPool::Create(VulkanContext *vulkan, const BindingType *binding _assert_msg_(res == VK_SUCCESS, "Could not create VulkanDescSetPool %s", tag_); } -VkDescriptorSet VulkanDescSetPool::Allocate(int n, const VkDescriptorSetLayout *layouts, const char *tag) { - if (descPool_ == VK_NULL_HANDLE || usage_ + n >= info_.maxSets) { +bool VulkanDescSetPool::Allocate(VkDescriptorSet *descriptorSets, int count, const VkDescriptorSetLayout *layouts) { + if (descPool_ == VK_NULL_HANDLE || usage_ + count >= info_.maxSets) { // Missing or out of space, need to recreate. VkResult res = Recreate(grow_); _assert_msg_(res == VK_SUCCESS, "Could not grow VulkanDescSetPool %s on usage %d", tag_, (int)usage_); } - VkDescriptorSet desc; VkDescriptorSetAllocateInfo descAlloc{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; descAlloc.descriptorPool = descPool_; - descAlloc.descriptorSetCount = n; + descAlloc.descriptorSetCount = count; descAlloc.pSetLayouts = layouts; - VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc); + VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, descriptorSets); if (result == VK_ERROR_FRAGMENTED_POOL || result < 0) { WARN_LOG(G3D, "Pool %s %s - recreating", tag_, result == VK_ERROR_FRAGMENTED_POOL ? "fragmented" : "full"); @@ -66,20 +65,16 @@ VkDescriptorSet VulkanDescSetPool::Allocate(int n, const VkDescriptorSetLayout * // Need to update this pointer since we have allocated a new one. descAlloc.descriptorPool = descPool_; - result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc); + result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, descriptorSets); _assert_msg_(result == VK_SUCCESS, "Ran out of descriptor space (frag?) and failed to allocate after recreating a descriptor pool. res=%d", (int)result); } if (result != VK_SUCCESS) { - return VK_NULL_HANDLE; + return false; } - usage_++; - - if (tag) { - vulkan_->SetDebugName(desc, VK_OBJECT_TYPE_DESCRIPTOR_SET, tag); - } - return desc; + usage_ += count; + return true; } void VulkanDescSetPool::Reset() { diff --git a/Common/GPU/Vulkan/VulkanDescSet.h b/Common/GPU/Vulkan/VulkanDescSet.h index 82007962a3..3ed4673240 100644 --- a/Common/GPU/Vulkan/VulkanDescSet.h +++ b/Common/GPU/Vulkan/VulkanDescSet.h @@ -28,7 +28,7 @@ public: void Create(VulkanContext *vulkan, const BindingType *bindingTypes, uint32_t bindingTypesCount, uint32_t descriptorCount); // Allocate a new set, which may resize and empty the current sets. // Use only for the current frame, unless in a cache cleared by clear_. - VkDescriptorSet Allocate(int n, const VkDescriptorSetLayout *layouts, const char *tag); + bool Allocate(VkDescriptorSet *descriptorSets, int count, const VkDescriptorSetLayout *layouts); void Reset(); void Destroy(); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index f6af92c35c..e4dc0a20a6 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -1725,7 +1725,7 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro } // TODO: Allocate in batches. - d.set = pool.Allocate(1, &descriptorSetLayout, nullptr); + pool.Allocate(&d.set, 1, &descriptorSetLayout); // TODO: Build up bigger batches of writes. const PackedDescriptor *data = descData.begin() + d.offset; diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 8fc286f97c..f100ad24db 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -133,7 +133,8 @@ VkDescriptorSet VulkanComputeShaderManager::GetDescriptorSet(VkImageView image, int curFrame = vulkan_->GetCurFrame(); FrameData &frameData = frameData_[curFrame]; frameData.descPoolUsed = true; - VkDescriptorSet desc = frameData.descPool.Allocate(1, &descriptorSetLayout_, "compute_descset"); + VkDescriptorSet desc; + frameData.descPool.Allocate(&desc, 1, &descriptorSetLayout_); _assert_(desc != VK_NULL_HANDLE); VkWriteDescriptorSet writes[3]{};