vk: Improve pipeline layout validation and fix slot allocation bugs

This commit is contained in:
kd-11 2025-06-15 23:45:11 +03:00 committed by kd-11
parent 15791cf94e
commit b3492b73ad
3 changed files with 19 additions and 6 deletions

View file

@ -57,6 +57,9 @@ void VKFragmentDecompilerThread::prepareBindingTable()
vk_prog->binding_table.tex_param_location = location++; vk_prog->binding_table.tex_param_location = location++;
vk_prog->binding_table.polygon_stipple_params_location = location++; vk_prog->binding_table.polygon_stipple_params_location = location++;
std::memset(vk_prog->binding_table.ftex_location, 0xff, sizeof(vk_prog->binding_table.ftex_location));
std::memset(vk_prog->binding_table.ftex_stencil_location, 0xff, sizeof(vk_prog->binding_table.ftex_stencil_location));
if (has_textures) [[ likely ]] if (has_textures) [[ likely ]]
{ {
unsigned num_textures = 0; unsigned num_textures = 0;

View file

@ -547,6 +547,8 @@ namespace vk
m_descriptor_pool_sizes.clear(); m_descriptor_pool_sizes.clear();
m_descriptor_pool_sizes.reserve(input_type_max_enum); m_descriptor_pool_sizes.reserve(input_type_max_enum);
std::unordered_map<u32, VkDescriptorType> descriptor_type_map;
for (const auto& type_arr : m_inputs) for (const auto& type_arr : m_inputs)
{ {
if (type_arr.empty() || type_arr.front().type == input_type_push_constant) if (type_arr.empty() || type_arr.front().type == input_type_push_constant)
@ -568,16 +570,22 @@ namespace vk
}; };
bindings.push_back(binding); bindings.push_back(binding);
if (m_descriptor_types.size() < (input.location + 1)) descriptor_type_map[input.location] = type;
{
m_descriptor_types.resize((input.location + 1));
}
m_descriptor_types[input.location] = type;
m_descriptor_pool_sizes.back().descriptorCount++; m_descriptor_pool_sizes.back().descriptorCount++;
} }
} }
m_descriptor_types.resize(::size32(m_descriptors_dirty));
for (u32 i = 0; i < ::size32(m_descriptors_dirty); ++i)
{
if (descriptor_type_map.find(i) == descriptor_type_map.end())
{
fmt::throw_exception("Invalid input structure. Some input bindings were not declared!");
}
m_descriptor_types[i] = descriptor_type_map[i];
}
m_descriptor_set_layout = vk::descriptors::create_layout(bindings); m_descriptor_set_layout = vk::descriptors::create_layout(bindings);
} }

View file

@ -38,6 +38,8 @@ void VKVertexDecompilerThread::prepareBindingTable()
vk_prog->binding_table.cr_pred_buffer_location = location++; vk_prog->binding_table.cr_pred_buffer_location = location++;
} }
std::memset(vk_prog->binding_table.vtex_location, 0xff, sizeof(vk_prog->binding_table.vtex_location));
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM]) for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
{ {
const bool is_texture_type = PT.type.starts_with("sampler"); const bool is_texture_type = PT.type.starts_with("sampler");