vk: Fix clang build and resource leak on exit

This commit is contained in:
kd-11 2025-06-15 15:01:45 +03:00 committed by kd-11
parent ffa835efac
commit 3a65359d59
5 changed files with 25 additions and 3 deletions

View file

@ -46,9 +46,10 @@ namespace vk
#define IS_DIGIT(x) (x >= '0' && x <= '9') #define IS_DIGIT(x) (x >= '0' && x <= '9')
constexpr int max_index_length = 2; constexpr int max_index_length = 2;
const int name_length = static_cast<int>(name.length());
std::string index; std::string index;
for (int char_idx = name.length() - max_index_length; char_idx < name.length(); ++char_idx) for (int char_idx = name_length - max_index_length; char_idx < name_length; ++char_idx)
{ {
if (IS_DIGIT(name[char_idx])) if (IS_DIGIT(name[char_idx]))
{ {

View file

@ -1,3 +1,4 @@
#include "Emu/RSX/VK/vkutils/descriptors.h"
#include "stdafx.h" #include "stdafx.h"
#include "../Overlays/overlay_compile_notification.h" #include "../Overlays/overlay_compile_notification.h"
#include "../Overlays/Shaders/shader_loading_dialog_native.h" #include "../Overlays/Shaders/shader_loading_dialog_native.h"
@ -854,6 +855,9 @@ VKGSRender::~VKGSRender()
m_command_buffer_pool.destroy(); m_command_buffer_pool.destroy();
m_secondary_command_buffer_pool.destroy(); m_secondary_command_buffer_pool.destroy();
// Descriptors
vk::descriptors::flush();
// Global resources // Global resources
vk::destroy_global_resources(); vk::destroy_global_resources();

View file

@ -420,7 +420,10 @@ namespace vk
} }
vkDestroyDescriptorSetLayout(m_device, m_descriptor_set_layout, nullptr); vkDestroyDescriptorSetLayout(m_device, m_descriptor_set_layout, nullptr);
vk::get_resource_manager()->dispose(m_descriptor_pool); m_descriptor_pool->destroy();
m_descriptor_pool.reset();
m_device = VK_NULL_HANDLE;
} }
void descriptor_table_t::init(VkDevice dev) void descriptor_table_t::init(VkDevice dev)

View file

@ -40,6 +40,12 @@ namespace vk
// rsx_log.notice("[descriptor_manager::deregister] Now monitoring %u descriptor sets", m_notification_list.size()); // rsx_log.notice("[descriptor_manager::deregister] Now monitoring %u descriptor sets", m_notification_list.size());
} }
void destroy()
{
std::lock_guard lock(m_notifications_lock);
m_notification_list.clear();
}
dispatch_manager() = default; dispatch_manager() = default;
private: private:
@ -60,6 +66,11 @@ namespace vk
g_fxo->get<dispatch_manager>().flush_all(); g_fxo->get<dispatch_manager>().flush_all();
} }
void destroy()
{
g_fxo->get<dispatch_manager>().destroy();
}
VkDescriptorSetLayout create_layout(const rsx::simple_array<VkDescriptorSetLayoutBinding>& bindings) VkDescriptorSetLayout create_layout(const rsx::simple_array<VkDescriptorSetLayoutBinding>& bindings)
{ {
VkDescriptorSetLayoutCreateInfo infos = {}; VkDescriptorSetLayoutCreateInfo infos = {};
@ -414,11 +425,13 @@ namespace vk
{ {
m_push_type_mask |= type_mask; m_push_type_mask |= type_mask;
#if !defined(__clang__) || (__clang_major__ >= 16)
if (m_pending_writes.empty()) [[unlikely]] if (m_pending_writes.empty()) [[unlikely]]
{ {
m_pending_writes = std::move(write_cmds); m_pending_writes = std::move(write_cmds);
} }
else else
#endif
{ {
const auto old_size = m_pending_writes.size(); const auto old_size = m_pending_writes.size();
const auto new_size = write_cmds.size() + old_size; const auto new_size = write_cmds.size() + old_size;

View file

@ -122,7 +122,7 @@ namespace vk
rsx::simple_array<VkDescriptorImageInfo> m_image_info_pool; rsx::simple_array<VkDescriptorImageInfo> m_image_info_pool;
rsx::simple_array<u32> m_dynamic_offsets; rsx::simple_array<u32> m_dynamic_offsets;
#ifdef __clang__ #if defined(__clang__) && (__clang_major__ < 16)
// Clang (pre 16.x) does not support LWG 2089, std::construct_at for POD types // Clang (pre 16.x) does not support LWG 2089, std::construct_at for POD types
struct WriteDescriptorSetT : public VkWriteDescriptorSet struct WriteDescriptorSetT : public VkWriteDescriptorSet
{ {
@ -162,6 +162,7 @@ namespace vk
{ {
void init(); void init();
void flush(); void flush();
void destroy();
VkDescriptorSetLayout create_layout(const rsx::simple_array<VkDescriptorSetLayoutBinding>& bindings); VkDescriptorSetLayout create_layout(const rsx::simple_array<VkDescriptorSetLayoutBinding>& bindings);
} }