From 6aeed40af20040d557aaba7f75b06ec85da50479 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 20 Jun 2022 14:44:21 +0200 Subject: [PATCH] [dxvk] Remove old descriptor pool implementation --- src/dxvk/dxvk_cmdlist.cpp | 6 +-- src/dxvk/dxvk_cmdlist.h | 9 ---- src/dxvk/dxvk_context.cpp | 18 -------- src/dxvk/dxvk_context.h | 4 -- src/dxvk/dxvk_descriptor.cpp | 79 ------------------------------------ src/dxvk/dxvk_descriptor.h | 77 ----------------------------------- src/dxvk/dxvk_device.cpp | 15 ------- src/dxvk/dxvk_device.h | 16 +------- 8 files changed, 2 insertions(+), 222 deletions(-) diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index 169f8b442..90d3408e9 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -7,8 +7,7 @@ namespace dxvk { : m_device (device), m_vkd (device->vkd()), m_vki (device->instance()->vki()), - m_cmdBuffersUsed(0), - m_descriptorPoolTracker(device) { + m_cmdBuffersUsed(0) { const auto& graphicsQueue = m_device->queues().graphics; const auto& transferQueue = m_device->queues().transfer; @@ -173,9 +172,6 @@ namespace dxvk { // that are no longer in use m_resources.reset(); - // Recycle heavy Vulkan objects - m_descriptorPoolTracker.reset(); - // Return buffer memory slices m_bufferTracker.reset(); diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 231635651..30cc720fd 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -151,14 +151,6 @@ namespace dxvk { m_resources.trackResource(std::move(rc)); } - /** - * \brief Tracks a descriptor pool - * \param [in] pool The descriptor pool - */ - void trackDescriptorPool(Rc pool) { - m_descriptorPoolTracker.trackDescriptorPool(pool); - } - /** * \brief Tracks a GPU event * @@ -788,7 +780,6 @@ namespace dxvk { DxvkCmdBufferFlags m_cmdBuffersUsed; DxvkLifetimeTracker m_resources; - DxvkDescriptorPoolTracker m_descriptorPoolTracker; DxvkSignalTracker m_signalTracker; DxvkGpuEventTracker m_gpuEventTracker; DxvkGpuQueryTracker m_gpuQueryTracker; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 9e65f111f..06950c814 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -5256,24 +5256,6 @@ namespace dxvk { } - VkDescriptorSet DxvkContext::allocateDescriptorSet( - VkDescriptorSetLayout layout) { - if (m_descPool == nullptr) - m_descPool = m_device->createDescriptorPool(); - - VkDescriptorSet set = m_descPool->alloc(layout); - - if (set == VK_NULL_HANDLE) { - m_cmd->trackDescriptorPool(std::move(m_descPool)); - - m_descPool = m_device->createDescriptorPool(); - set = m_descPool->alloc(layout); - } - - return set; - } - - void DxvkContext::trackDrawBuffer() { if (m_flags.test(DxvkContextFlag::DirtyDrawBuffer)) { m_flags.clr(DxvkContextFlag::DirtyDrawBuffer); diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 27aa2897a..d93a2db85 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1050,7 +1050,6 @@ namespace dxvk { DxvkObjects* m_common; Rc m_cmd; - Rc m_descPool; Rc m_zeroBuffer; DxvkContextFlags m_flags; @@ -1310,9 +1309,6 @@ namespace dxvk { VkPipelineStageFlags dstStages, VkAccessFlags dstAccess); - VkDescriptorSet allocateDescriptorSet( - VkDescriptorSetLayout layout); - void trackDrawBuffer(); bool tryInvalidateDeviceLocalBuffer( diff --git a/src/dxvk/dxvk_descriptor.cpp b/src/dxvk/dxvk_descriptor.cpp index 3824cacd8..d8658db1f 100644 --- a/src/dxvk/dxvk_descriptor.cpp +++ b/src/dxvk/dxvk_descriptor.cpp @@ -2,60 +2,6 @@ #include "dxvk_device.h" namespace dxvk { - - DxvkDescriptorPool::DxvkDescriptorPool(const Rc& vkd) - : m_vkd(vkd) { - constexpr uint32_t MaxSets = 2048; - - std::array pools = {{ - { VK_DESCRIPTOR_TYPE_SAMPLER, MaxSets * 2 }, - { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MaxSets * 3 }, - { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, MaxSets / 8 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MaxSets * 3 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MaxSets / 8 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, MaxSets * 3 }, - { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, MaxSets / 8 }, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MaxSets * 2 } }}; - - VkDescriptorPoolCreateInfo info; - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - info.pNext = nullptr; - info.flags = 0; - info.maxSets = MaxSets; - info.poolSizeCount = pools.size(); - info.pPoolSizes = pools.data(); - - if (m_vkd->vkCreateDescriptorPool(m_vkd->device(), &info, nullptr, &m_pool) != VK_SUCCESS) - throw DxvkError("DxvkDescriptorPool: Failed to create descriptor pool"); - } - - - DxvkDescriptorPool::~DxvkDescriptorPool() { - m_vkd->vkDestroyDescriptorPool( - m_vkd->device(), m_pool, nullptr); - } - - - VkDescriptorSet DxvkDescriptorPool::alloc(VkDescriptorSetLayout layout) { - VkDescriptorSetAllocateInfo info; - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - info.pNext = nullptr; - info.descriptorPool = m_pool; - info.descriptorSetCount = 1; - info.pSetLayouts = &layout; - - VkDescriptorSet set = VK_NULL_HANDLE; - if (m_vkd->vkAllocateDescriptorSets(m_vkd->device(), &info, &set) != VK_SUCCESS) - return VK_NULL_HANDLE; - return set; - } - - - void DxvkDescriptorPool::reset() { - m_vkd->vkResetDescriptorPool( - m_vkd->device(), m_pool, 0); - } - DxvkPersistentDescriptorSetList::DxvkPersistentDescriptorSetList() { @@ -291,31 +237,6 @@ namespace dxvk { return pool; } - - DxvkDescriptorPoolTracker::DxvkDescriptorPoolTracker(DxvkDevice* device) - : m_device(device) { - - } - - - DxvkDescriptorPoolTracker::~DxvkDescriptorPoolTracker() { - - } - - - void DxvkDescriptorPoolTracker::trackDescriptorPool(Rc pool) { - m_pools.push_back(std::move(pool)); - } - - - void DxvkDescriptorPoolTracker::reset() { - for (const auto& pool : m_pools) { - pool->reset(); - m_device->recycleDescriptorPool(pool); - } - - m_pools.clear(); - } DxvkDescriptorManager::DxvkDescriptorManager( DxvkDevice* device, diff --git a/src/dxvk/dxvk_descriptor.h b/src/dxvk/dxvk_descriptor.h index cd5ee301b..9609ccc22 100644 --- a/src/dxvk/dxvk_descriptor.h +++ b/src/dxvk/dxvk_descriptor.h @@ -33,45 +33,6 @@ namespace dxvk { }; - /** - * \brief Descriptor pool - * - * Wrapper around a Vulkan descriptor pool that - * descriptor sets can be allocated from. - */ - class DxvkDescriptorPool : public RcObject { - - public: - - DxvkDescriptorPool( - const Rc& vkd); - ~DxvkDescriptorPool(); - - /** - * \brief Allocates a descriptor set - * - * \param [in] layout Descriptor set layout - * \returns The descriptor set - */ - VkDescriptorSet alloc( - VkDescriptorSetLayout layout); - - /** - * \brief Resets descriptor set allocator - * - * Destroys all descriptor sets and - * resets the Vulkan descriptor pools. - */ - void reset(); - - private: - - Rc m_vkd; - VkDescriptorPool m_pool; - - }; - - /** * \brief Descriptor set list */ @@ -186,44 +147,6 @@ namespace dxvk { VkDescriptorPool addPool(); }; - - - /** - * \brief Descriptor pool tracker - * - * Tracks descriptor pools that are either full - * or no longer needed by the DXVK context. The - * command list will reset and recycle all pools - * once it has completed execution on the GPU. - */ - class DxvkDescriptorPoolTracker { - - public: - - DxvkDescriptorPoolTracker(DxvkDevice* device); - ~DxvkDescriptorPoolTracker(); - - /** - * \brief Adds a descriptor pool to track - * \param [in] pool The descriptor pool - */ - void trackDescriptorPool(Rc pool); - - /** - * \brief Resets event tracker - * - * Resets all tracked descriptor pools - * and returns them to the device. - */ - void reset(); - - private: - - DxvkDevice* m_device; - - std::vector> m_pools; - - }; /* * \brief Descriptor pool manager diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index 5795455d6..87a29c568 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -84,16 +84,6 @@ namespace dxvk { } - Rc DxvkDevice::createDescriptorPool() { - Rc pool = m_recycledDescriptorPools.retrieveObject(); - - if (pool == nullptr) - pool = new DxvkDescriptorPool(m_vkd); - - return pool; - } - - Rc DxvkDevice::createContext(DxvkContextType type) { return new DxvkContext(this, type); } @@ -279,11 +269,6 @@ namespace dxvk { } - void DxvkDevice::recycleDescriptorPool(const Rc& pool) { - m_recycledDescriptorPools.returnObject(pool); - } - - DxvkDeviceQueue DxvkDevice::getQueue( uint32_t family, uint32_t index) const { diff --git a/src/dxvk/dxvk_device.h b/src/dxvk/dxvk_device.h index 0d1ac5cc7..6877b3107 100644 --- a/src/dxvk/dxvk_device.h +++ b/src/dxvk/dxvk_device.h @@ -229,16 +229,6 @@ namespace dxvk { */ Rc createCommandList(); - /** - * \brief Creates a descriptor pool - * - * Returns a previously recycled pool, or creates - * a new one if necessary. The context should take - * ownership of the returned pool. - * \returns Descriptor pool - */ - Rc createDescriptorPool(); - /** * \brief Creates a context * @@ -497,8 +487,7 @@ namespace dxvk { DxvkDeviceQueueSet m_queues; - DxvkRecycler m_recycledCommandLists; - DxvkRecycler m_recycledDescriptorPools; + DxvkRecycler m_recycledCommandLists; DxvkSubmissionQueue m_submissionQueue; @@ -507,9 +496,6 @@ namespace dxvk { void recycleCommandList( const Rc& cmdList); - void recycleDescriptorPool( - const Rc& pool); - DxvkDeviceQueue getQueue( uint32_t family, uint32_t index) const;