mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
vk: Unify descriptor allocation
- Pool management should be a backend implementation detail.
This commit is contained in:
parent
e0853095e3
commit
10171c19c3
10 changed files with 5 additions and 72 deletions
|
@ -119,15 +119,6 @@ namespace vk
|
|||
}
|
||||
}
|
||||
|
||||
void compute_task::free_resources()
|
||||
{
|
||||
if (m_used_descriptors == 0)
|
||||
return;
|
||||
|
||||
m_descriptor_pool.reset(0);
|
||||
m_used_descriptors = 0;
|
||||
}
|
||||
|
||||
void compute_task::load_program(const vk::command_buffer& cmd)
|
||||
{
|
||||
if (!m_program)
|
||||
|
@ -155,14 +146,7 @@ namespace vk
|
|||
|
||||
ensure(m_used_descriptors < VK_MAX_COMPUTE_TASKS);
|
||||
|
||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||
alloc_info.descriptorPool = m_descriptor_pool;
|
||||
alloc_info.descriptorSetCount = 1;
|
||||
alloc_info.pSetLayouts = &m_descriptor_layout;
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(*g_render_device, &alloc_info, m_descriptor_set.ptr()));
|
||||
m_used_descriptors++;
|
||||
m_descriptor_set = m_descriptor_pool.allocate(m_descriptor_layout, VK_TRUE, m_used_descriptors++);
|
||||
|
||||
bind_resources();
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ namespace vk
|
|||
void create();
|
||||
void destroy();
|
||||
|
||||
void free_resources();
|
||||
|
||||
virtual void bind_resources() {}
|
||||
virtual void declare_inputs() {}
|
||||
|
||||
|
|
|
@ -966,11 +966,6 @@ void VKGSRender::end()
|
|||
m_aux_frame_context.grab_resources(*m_current_frame);
|
||||
m_current_frame = &m_aux_frame_context;
|
||||
}
|
||||
else if (m_current_frame->used_descriptors)
|
||||
{
|
||||
m_current_frame->descriptor_pool.reset(0);
|
||||
m_current_frame->used_descriptors = 0;
|
||||
}
|
||||
|
||||
ensure(!m_current_frame->swap_command_buffer);
|
||||
|
||||
|
|
|
@ -1322,13 +1322,10 @@ void VKGSRender::check_descriptors()
|
|||
{
|
||||
// Ease resource pressure if the number of draw calls becomes too high or we are running low on memory resources
|
||||
const auto required_descriptors = rsx::method_registers.current_draw_clause.pass_count();
|
||||
if (!m_current_frame->descriptor_pool.can_allocate(required_descriptors, m_current_frame->used_descriptors))
|
||||
if (!m_current_frame->descriptor_pool.can_allocate(required_descriptors, 0))
|
||||
{
|
||||
// Should hard sync before resetting descriptors for spec compliance
|
||||
flush_command_queue(true);
|
||||
|
||||
m_current_frame->descriptor_pool.reset(0);
|
||||
m_current_frame->used_descriptors = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1333,7 @@ VkDescriptorSet VKGSRender::allocate_descriptor_set()
|
|||
{
|
||||
if (!m_shader_interpreter.is_interpreter(m_program)) [[likely]]
|
||||
{
|
||||
return m_current_frame->descriptor_pool.allocate(descriptor_layouts, VK_TRUE, m_current_frame->used_descriptors++);
|
||||
return m_current_frame->descriptor_pool.allocate(descriptor_layouts, VK_TRUE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -177,7 +177,6 @@ namespace vk
|
|||
|
||||
vk::descriptor_set descriptor_set;
|
||||
vk::descriptor_pool descriptor_pool;
|
||||
u32 used_descriptors = 0;
|
||||
|
||||
rsx::flags32_t flags = 0;
|
||||
|
||||
|
|
|
@ -288,12 +288,6 @@ namespace vk
|
|||
|
||||
void overlay_pass::free_resources()
|
||||
{
|
||||
if (m_used_descriptors == 0)
|
||||
return;
|
||||
|
||||
m_descriptor_pool.reset(0);
|
||||
m_used_descriptors = 0;
|
||||
|
||||
m_vao.reset_allocation_stats();
|
||||
m_ubo.reset_allocation_stats();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ namespace vk
|
|||
descriptor_set m_descriptor_set;
|
||||
VkDescriptorSetLayout m_descriptor_layout = nullptr;
|
||||
VkPipelineLayout m_pipeline_layout = nullptr;
|
||||
u32 m_used_descriptors = 0;
|
||||
|
||||
VkFilter m_sampler_filter = VK_FILTER_LINEAR;
|
||||
u32 m_num_usable_samplers = 1;
|
||||
|
|
|
@ -518,23 +518,7 @@ namespace vk
|
|||
|
||||
VkDescriptorSet shader_interpreter::allocate_descriptor_set()
|
||||
{
|
||||
if (!m_descriptor_pool.can_allocate(1u, m_used_descriptors))
|
||||
{
|
||||
m_descriptor_pool.reset(0);
|
||||
m_used_descriptors = 0;
|
||||
}
|
||||
|
||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||
alloc_info.descriptorPool = m_descriptor_pool;
|
||||
alloc_info.descriptorSetCount = 1;
|
||||
alloc_info.pSetLayouts = &m_shared_descriptor_layout;
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
|
||||
VkDescriptorSet new_descriptor_set;
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(m_device, &alloc_info, &new_descriptor_set));
|
||||
|
||||
m_used_descriptors++;
|
||||
return new_descriptor_set;
|
||||
return m_descriptor_pool.allocate(m_shared_descriptor_layout, VK_TRUE, 0);
|
||||
}
|
||||
|
||||
glsl::program* shader_interpreter::get(const vk::pipeline_props& properties, const program_hash_util::fragment_program_utils::fragment_program_metadata& metadata)
|
||||
|
|
|
@ -42,7 +42,6 @@ namespace vk
|
|||
std::unordered_map<pipeline_key, std::unique_ptr<glsl::program>, key_hasher> m_program_cache;
|
||||
std::unordered_map<u64, std::unique_ptr<glsl::shader>> m_fs_cache;
|
||||
vk::descriptor_pool m_descriptor_pool;
|
||||
u32 m_used_descriptors = 0;
|
||||
|
||||
u32 m_vertex_instruction_start = 0;
|
||||
u32 m_fragment_instruction_start = 0;
|
||||
|
|
|
@ -205,14 +205,7 @@ namespace vk
|
|||
{
|
||||
ensure(m_used_descriptors < 120);
|
||||
|
||||
VkDescriptorSetAllocateInfo alloc_info = {};
|
||||
alloc_info.descriptorPool = m_descriptor_pool;
|
||||
alloc_info.descriptorSetCount = 1;
|
||||
alloc_info.pSetLayouts = &m_descriptor_layout;
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(device, &alloc_info, m_descriptor_set.ptr()));
|
||||
m_used_descriptors++;
|
||||
m_descriptor_set = m_descriptor_pool.allocate(m_descriptor_layout, VK_TRUE, m_used_descriptors++);
|
||||
|
||||
float scale[] = { scale_x, scale_y };
|
||||
float colors[] = { color[0], color[1], color[2], color[3] };
|
||||
|
@ -360,15 +353,6 @@ namespace vk
|
|||
}
|
||||
}
|
||||
|
||||
void reset_descriptors()
|
||||
{
|
||||
if (m_used_descriptors == 0)
|
||||
return;
|
||||
|
||||
m_descriptor_pool.reset(0);
|
||||
m_used_descriptors = 0;
|
||||
}
|
||||
|
||||
void set_scale(double scale)
|
||||
{
|
||||
// Restrict scale to 2. The dots are gonna be too sparse otherwise.
|
||||
|
|
Loading…
Add table
Reference in a new issue