mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
vk: Redesign resource binding for overlay passes
This commit is contained in:
parent
63b40f8d21
commit
11484a32c1
5 changed files with 45 additions and 28 deletions
|
@ -8,7 +8,7 @@ layout(push_constant) uniform static_data
|
|||
{
|
||||
layout(offset=0) ivec2 sample_count;
|
||||
layout(offset=8) int stencil_mask;
|
||||
}
|
||||
};
|
||||
#else
|
||||
layout(binding=31) uniform usampler2DMS fs0;
|
||||
uniform ivec2 sample_count;
|
||||
|
|
|
@ -8,7 +8,7 @@ layout(push_constant) uniform static_data
|
|||
{
|
||||
layout(offset=0) ivec2 sample_count;
|
||||
layout(offset=8) int stencil_mask;
|
||||
}
|
||||
};
|
||||
#else
|
||||
layout(binding=31) uniform usampler2D fs0;
|
||||
uniform ivec2 sample_count;
|
||||
|
|
|
@ -47,9 +47,11 @@ namespace vk
|
|||
|
||||
void overlay_pass::init_descriptors()
|
||||
{
|
||||
rsx::simple_array<VkDescriptorPoolSize> descriptor_pool_sizes =
|
||||
rsx::simple_array<VkDescriptorPoolSize> descriptor_pool_sizes = {};
|
||||
|
||||
if (m_num_uniform_buffers)
|
||||
{
|
||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1 }
|
||||
descriptor_pool_sizes.push_back({ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, m_num_uniform_buffers });
|
||||
};
|
||||
|
||||
if (m_num_usable_samplers)
|
||||
|
@ -65,35 +67,38 @@ namespace vk
|
|||
// Reserve descriptor pools
|
||||
m_descriptor_pool.create(*m_device, descriptor_pool_sizes);
|
||||
|
||||
const auto num_bindings = 1 + m_num_usable_samplers + m_num_input_attachments;
|
||||
const auto num_bindings = m_num_uniform_buffers + m_num_usable_samplers + m_num_input_attachments;
|
||||
rsx::simple_array<VkDescriptorSetLayoutBinding> bindings(num_bindings);
|
||||
int binding_slot = 0;
|
||||
|
||||
bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[0].descriptorCount = 1;
|
||||
bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[0].binding = 0;
|
||||
bindings[0].pImmutableSamplers = nullptr;
|
||||
|
||||
u32 descriptor_index = 1;
|
||||
for (u32 n = 0; n < m_num_usable_samplers; ++n, ++descriptor_index)
|
||||
for (u32 n = 0; n < m_num_uniform_buffers; ++n, ++binding_slot)
|
||||
{
|
||||
bindings[descriptor_index].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
bindings[descriptor_index].descriptorCount = 1;
|
||||
bindings[descriptor_index].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[descriptor_index].binding = descriptor_index;
|
||||
bindings[descriptor_index].pImmutableSamplers = nullptr;
|
||||
bindings[binding_slot].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
bindings[binding_slot].descriptorCount = 1;
|
||||
bindings[binding_slot].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[binding_slot].binding = binding_slot;
|
||||
bindings[binding_slot].pImmutableSamplers = nullptr;
|
||||
}
|
||||
|
||||
for (u32 n = 0; n < m_num_input_attachments; ++n, ++descriptor_index)
|
||||
for (u32 n = 0; n < m_num_usable_samplers; ++n, ++binding_slot)
|
||||
{
|
||||
bindings[descriptor_index].descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
|
||||
bindings[descriptor_index].descriptorCount = 1;
|
||||
bindings[descriptor_index].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[descriptor_index].binding = descriptor_index;
|
||||
bindings[descriptor_index].pImmutableSamplers = nullptr;
|
||||
bindings[binding_slot].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
bindings[binding_slot].descriptorCount = 1;
|
||||
bindings[binding_slot].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[binding_slot].binding = binding_slot;
|
||||
bindings[binding_slot].pImmutableSamplers = nullptr;
|
||||
}
|
||||
|
||||
ensure(descriptor_index == num_bindings);
|
||||
for (u32 n = 0; n < m_num_input_attachments; ++n, ++binding_slot)
|
||||
{
|
||||
bindings[binding_slot].descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT;
|
||||
bindings[binding_slot].descriptorCount = 1;
|
||||
bindings[binding_slot].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[binding_slot].binding = binding_slot;
|
||||
bindings[binding_slot].pImmutableSamplers = nullptr;
|
||||
}
|
||||
|
||||
ensure(binding_slot == num_bindings);
|
||||
m_descriptor_layout = vk::descriptors::create_layout(bindings);
|
||||
|
||||
VkPipelineLayoutCreateInfo layout_info = {};
|
||||
|
@ -120,9 +125,14 @@ namespace vk
|
|||
std::vector<vk::glsl::program_input> overlay_pass::get_fragment_inputs()
|
||||
{
|
||||
std::vector<vk::glsl::program_input> fs_inputs;
|
||||
fs_inputs.push_back({ ::glsl::program_domain::glsl_fragment_program, vk::glsl::program_input_type::input_type_uniform_buffer,{},{}, 0, "static_data" });
|
||||
u32 binding = 0;
|
||||
|
||||
for (u32 n = 0; n < m_num_uniform_buffers; ++n, ++binding)
|
||||
{
|
||||
const std::string name = std::string("static_data") + (n > 0 ? std::to_string(n) : "");
|
||||
fs_inputs.push_back({ ::glsl::program_domain::glsl_fragment_program, vk::glsl::program_input_type::input_type_uniform_buffer,{},{}, 0, name });
|
||||
}
|
||||
|
||||
u32 binding = 1;
|
||||
for (u32 n = 0; n < m_num_usable_samplers; ++n, ++binding)
|
||||
{
|
||||
fs_inputs.push_back({ ::glsl::program_domain::glsl_fragment_program, vk::glsl::program_input_type::input_type_texture,{},{}, binding, "fs" + std::to_string(n) });
|
||||
|
@ -231,7 +241,10 @@ namespace vk
|
|||
|
||||
update_uniforms(cmd, program);
|
||||
|
||||
program->bind_uniform({ m_ubo.heap->value, m_ubo_offset, std::max(m_ubo_length, 4u) }, 0, m_descriptor_set);
|
||||
if (m_num_uniform_buffers > 0)
|
||||
{
|
||||
program->bind_uniform({ m_ubo.heap->value, m_ubo_offset, std::max(m_ubo_length, 4u) }, 0, m_descriptor_set);
|
||||
}
|
||||
|
||||
for (uint n = 0; n < src.size(); ++n)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace vk
|
|||
VkFilter m_sampler_filter = VK_FILTER_LINEAR;
|
||||
u32 m_num_usable_samplers = 1;
|
||||
u32 m_num_input_attachments = 0;
|
||||
u32 m_num_uniform_buffers = 1;
|
||||
|
||||
std::unordered_map<u64, std::unique_ptr<vk::glsl::program>> m_program_cache;
|
||||
std::unique_ptr<vk::sampler> m_sampler;
|
||||
|
|
|
@ -109,6 +109,9 @@ namespace vk
|
|||
|
||||
// Depth-stencil buffers are almost never filterable, and we do not need it here (1:1 mapping)
|
||||
m_sampler_filter = VK_FILTER_NEAREST;
|
||||
|
||||
// Do not use UBOs
|
||||
m_num_uniform_buffers = 0;
|
||||
}
|
||||
|
||||
void build(bool resolve_depth, bool resolve_stencil, bool unresolve);
|
||||
|
|
Loading…
Add table
Reference in a new issue