diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index dbd3cc0f78..f7f28f44c5 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -458,6 +458,7 @@ if(TARGET 3rdparty_vulkan) RSX/VK/vkutils/chip_class.cpp RSX/VK/vkutils/commands.cpp RSX/VK/vkutils/data_heap.cpp + RSX/VK/vkutils/descriptors.cpp RSX/VK/vkutils/image.cpp RSX/VK/vkutils/image_helpers.cpp RSX/VK/vkutils/scratch.cpp diff --git a/rpcs3/Emu/RSX/VK/VKCompute.h b/rpcs3/Emu/RSX/VK/VKCompute.h index ed58c5eef5..3bda14980d 100644 --- a/rpcs3/Emu/RSX/VK/VKCompute.h +++ b/rpcs3/Emu/RSX/VK/VKCompute.h @@ -1,6 +1,6 @@ #pragma once #include "VKPipelineCompiler.h" -#include "vkutils/descriptors.hpp" +#include "vkutils/descriptors.h" #include "vkutils/buffer_object.h" #include "Emu/IdManager.h" diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.h b/rpcs3/Emu/RSX/VK/VKGSRender.h index 27f69e90e5..6348ffdd7b 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.h +++ b/rpcs3/Emu/RSX/VK/VKGSRender.h @@ -4,7 +4,7 @@ #include "upscalers/upscaling.h" -#include "vkutils/descriptors.hpp" +#include "vkutils/descriptors.h" #include "vkutils/data_heap.h" #include "vkutils/instance.hpp" #include "vkutils/sync.h" diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.h b/rpcs3/Emu/RSX/VK/VKOverlays.h index 6a39549925..80756cf9d4 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.h +++ b/rpcs3/Emu/RSX/VK/VKOverlays.h @@ -7,7 +7,7 @@ #include "VKHelpers.h" #include "vkutils/data_heap.h" -#include "vkutils/descriptors.hpp" +#include "vkutils/descriptors.h" #include "vkutils/graphics_pipeline_state.hpp" #include "Emu/IdManager.h" diff --git a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h index 75a29579e5..db41c762db 100644 --- a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h +++ b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.h @@ -1,6 +1,6 @@ #pragma once #include "VKProgramBuffer.h" -#include "vkutils/descriptors.hpp" +#include "vkutils/descriptors.h" #include namespace vk diff --git a/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp b/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp new file mode 100644 index 0000000000..aa46ba7cf1 --- /dev/null +++ b/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp @@ -0,0 +1,56 @@ +#include "descriptors.h" + +namespace vk +{ + void descriptor_pool::create(const vk::render_device& dev, VkDescriptorPoolSize* sizes, u32 size_descriptors_count, u32 max_sets, u8 subpool_count) + { + ensure(subpool_count); + + VkDescriptorPoolCreateInfo infos = {}; + infos.flags = 0; + infos.maxSets = max_sets; + infos.poolSizeCount = size_descriptors_count; + infos.pPoolSizes = sizes; + infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; + + m_owner = &dev; + m_device_pools.resize(subpool_count); + + for (auto& pool : m_device_pools) + { + CHECK_RESULT(vkCreateDescriptorPool(dev, &infos, nullptr, &pool)); + } + + m_current_pool_handle = m_device_pools[0]; + } + + void descriptor_pool::destroy() + { + if (m_device_pools.empty()) return; + + for (auto& pool : m_device_pools) + { + vkDestroyDescriptorPool((*m_owner), pool, nullptr); + pool = VK_NULL_HANDLE; + } + + m_owner = nullptr; + } + + bool descriptor_pool::valid() const + { + return (!m_device_pools.empty()); + } + + descriptor_pool::operator VkDescriptorPool() + { + return m_current_pool_handle; + } + + void descriptor_pool::reset(VkDescriptorPoolResetFlags flags) + { + m_current_pool_index = (m_current_pool_index + 1) % u32(m_device_pools.size()); + m_current_pool_handle = m_device_pools[m_current_pool_index]; + CHECK_RESULT(vkResetDescriptorPool(*m_owner, m_current_pool_handle, flags)); + } +} diff --git a/rpcs3/Emu/RSX/VK/vkutils/descriptors.h b/rpcs3/Emu/RSX/VK/vkutils/descriptors.h new file mode 100644 index 0000000000..cec06a55b5 --- /dev/null +++ b/rpcs3/Emu/RSX/VK/vkutils/descriptors.h @@ -0,0 +1,29 @@ +#pragma once + +#include "../VulkanAPI.h" +#include "device.h" + +#include + +namespace vk +{ + class descriptor_pool + { + const vk::render_device* m_owner = nullptr; + + std::vector m_device_pools; + VkDescriptorPool m_current_pool_handle = VK_NULL_HANDLE; + u32 m_current_pool_index = 0; + + public: + descriptor_pool() = default; + ~descriptor_pool() = default; + + void create(const vk::render_device& dev, VkDescriptorPoolSize* sizes, u32 size_descriptors_count, u32 max_sets, u8 subpool_count); + void destroy(); + void reset(VkDescriptorPoolResetFlags flags); + + bool valid() const; + operator VkDescriptorPool(); + }; +} diff --git a/rpcs3/Emu/RSX/VK/vkutils/descriptors.hpp b/rpcs3/Emu/RSX/VK/vkutils/descriptors.hpp deleted file mode 100644 index 1f685845d0..0000000000 --- a/rpcs3/Emu/RSX/VK/vkutils/descriptors.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include "../VulkanAPI.h" -#include "device.h" - -#include - -namespace vk -{ - class descriptor_pool - { - const vk::render_device* m_owner = nullptr; - - std::vector m_device_pools; - VkDescriptorPool m_current_pool_handle = VK_NULL_HANDLE; - u32 m_current_pool_index = 0; - - public: - descriptor_pool() = default; - ~descriptor_pool() = default; - - void create(const vk::render_device& dev, VkDescriptorPoolSize* sizes, u32 size_descriptors_count, u32 max_sets, u8 subpool_count) - { - ensure(subpool_count); - - VkDescriptorPoolCreateInfo infos = {}; - infos.flags = 0; - infos.maxSets = max_sets; - infos.poolSizeCount = size_descriptors_count; - infos.pPoolSizes = sizes; - infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - - m_owner = &dev; - m_device_pools.resize(subpool_count); - - for (auto& pool : m_device_pools) - { - CHECK_RESULT(vkCreateDescriptorPool(dev, &infos, nullptr, &pool)); - } - - m_current_pool_handle = m_device_pools[0]; - } - - void destroy() - { - if (m_device_pools.empty()) return; - - for (auto& pool : m_device_pools) - { - vkDestroyDescriptorPool((*m_owner), pool, nullptr); - pool = VK_NULL_HANDLE; - } - - m_owner = nullptr; - } - - bool valid() - { - return (!m_device_pools.empty()); - } - - operator VkDescriptorPool() - { - return m_current_pool_handle; - } - - void reset(VkDescriptorPoolResetFlags flags) - { - m_current_pool_index = (m_current_pool_index + 1) % u32(m_device_pools.size()); - m_current_pool_handle = m_device_pools[m_current_pool_index]; - CHECK_RESULT(vkResetDescriptorPool(*m_owner, m_current_pool_handle, flags)); - } - }; -} diff --git a/rpcs3/VKGSRender.vcxproj b/rpcs3/VKGSRender.vcxproj index 4bc240f86c..5d3837d47d 100644 --- a/rpcs3/VKGSRender.vcxproj +++ b/rpcs3/VKGSRender.vcxproj @@ -40,7 +40,7 @@ - + @@ -93,6 +93,7 @@ + diff --git a/rpcs3/VKGSRender.vcxproj.filters b/rpcs3/VKGSRender.vcxproj.filters index f85a5c9d52..5775d72fea 100644 --- a/rpcs3/VKGSRender.vcxproj.filters +++ b/rpcs3/VKGSRender.vcxproj.filters @@ -44,6 +44,9 @@ vkutils + + vkutils + vkutils @@ -139,7 +142,7 @@ vkutils - + vkutils