mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-28 08:37:06 +00:00
vk: Fix descriptor-related crashes
This commit is contained in:
parent
c99ef4b09f
commit
6cfd817b5a
@ -406,6 +406,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.vertex_buffers_first_bind_slot + i;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
idx++;
|
||||
}
|
||||
|
||||
@ -413,6 +414,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_constant_buffers_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -420,6 +422,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_state_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -427,6 +430,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_texture_params_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -434,6 +438,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.vertex_constant_buffers_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -441,6 +446,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||
bindings[idx].binding = binding_table.vertex_params_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -448,6 +454,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.conditional_render_predicate_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -455,6 +462,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.rasterizer_env_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -466,6 +474,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
idx++;
|
||||
}
|
||||
|
||||
@ -475,6 +484,7 @@ namespace
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.vertex_textures_first_bind_slot + i;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
@ -244,6 +244,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.vertex_buffers_first_bind_slot + i;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
idx++;
|
||||
}
|
||||
|
||||
@ -251,6 +252,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_constant_buffers_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -258,6 +260,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_state_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -265,6 +268,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.fragment_texture_params_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -272,6 +276,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.vertex_constant_buffers_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -279,6 +284,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_ALL_GRAPHICS;
|
||||
bindings[idx].binding = binding_table.vertex_params_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -286,6 +292,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.conditional_render_predicate_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -293,6 +300,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.rasterizer_env_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -300,6 +308,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 16;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
m_fragment_textures_start = bindings[idx].binding;
|
||||
idx++;
|
||||
@ -308,6 +317,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 16;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 1;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -315,6 +325,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 16;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 2;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -322,6 +333,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 16;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 3;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -329,6 +341,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 4;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 4;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
idx++;
|
||||
|
||||
@ -336,6 +349,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 5;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
m_vertex_instruction_start = bindings[idx].binding;
|
||||
idx++;
|
||||
@ -344,6 +358,7 @@ namespace vk
|
||||
bindings[idx].descriptorCount = 1;
|
||||
bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
bindings[idx].binding = binding_table.textures_first_bind_slot + 6;
|
||||
bindings[idx].pImmutableSamplers = nullptr;
|
||||
|
||||
m_fragment_instruction_start = bindings[idx].binding;
|
||||
idx++;
|
||||
|
@ -110,18 +110,18 @@ namespace vk
|
||||
{
|
||||
ensure(max_sets > 16);
|
||||
|
||||
auto scaled_pool_sizes = pool_sizes;
|
||||
for (auto& size : scaled_pool_sizes)
|
||||
m_create_info_pool_sizes = pool_sizes;
|
||||
for (auto& size : m_create_info_pool_sizes)
|
||||
{
|
||||
ensure(size.descriptorCount < 32); // Sanity check. Remove before commit.
|
||||
ensure(size.descriptorCount < 128); // Sanity check. Remove before commit.
|
||||
size.descriptorCount *= max_sets;
|
||||
}
|
||||
|
||||
info.flags = dev.get_descriptor_update_after_bind_support() ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0;
|
||||
info.maxSets = max_sets;
|
||||
info.poolSizeCount = scaled_pool_sizes.size();
|
||||
info.pPoolSizes = scaled_pool_sizes.data();
|
||||
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||
m_create_info.flags = dev.get_descriptor_update_after_bind_support() ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0;
|
||||
m_create_info.maxSets = max_sets;
|
||||
m_create_info.poolSizeCount = m_create_info_pool_sizes.size();
|
||||
m_create_info.pPoolSizes = m_create_info_pool_sizes.data();
|
||||
m_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||
|
||||
m_owner = &dev;
|
||||
next_subpool();
|
||||
@ -181,7 +181,7 @@ namespace vk
|
||||
|
||||
if (use_cache)
|
||||
{
|
||||
const auto alloc_size = std::min<u32>(info.maxSets - m_current_subpool_offset, max_cache_size);
|
||||
const auto alloc_size = std::min<u32>(m_create_info.maxSets - m_current_subpool_offset, max_cache_size);
|
||||
m_allocation_request_cache.resize(alloc_size);
|
||||
for (auto& layout_ : m_allocation_request_cache)
|
||||
{
|
||||
@ -195,10 +195,12 @@ namespace vk
|
||||
m_descriptor_set_cache.resize(alloc_size);
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(*m_owner, &alloc_info, m_descriptor_set_cache.data()));
|
||||
|
||||
m_current_subpool_offset += alloc_size;
|
||||
new_descriptor_set = m_descriptor_set_cache.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_current_subpool_offset++;
|
||||
CHECK_RESULT(vkAllocateDescriptorSets(*m_owner, &alloc_info, &new_descriptor_set));
|
||||
}
|
||||
|
||||
@ -236,7 +238,7 @@ namespace vk
|
||||
if (m_current_subpool_index == umax)
|
||||
{
|
||||
VkDescriptorPool subpool = VK_NULL_HANDLE;
|
||||
CHECK_RESULT(vkCreateDescriptorPool(*m_owner, &info, nullptr, &subpool));
|
||||
CHECK_RESULT(vkCreateDescriptorPool(*m_owner, &m_create_info, nullptr, &subpool));
|
||||
|
||||
m_device_subpools.push_back(
|
||||
{
|
||||
@ -248,6 +250,7 @@ namespace vk
|
||||
}
|
||||
|
||||
m_device_subpools[m_current_subpool_index].busy = VK_TRUE;
|
||||
m_current_pool_handle = m_device_subpools[m_current_subpool_index].handle;
|
||||
}
|
||||
|
||||
descriptor_set::descriptor_set(VkDescriptorSet set)
|
||||
|
@ -37,10 +37,10 @@ namespace vk
|
||||
|
||||
operator VkDescriptorPool() { return m_current_pool_handle; }
|
||||
FORCE_INLINE bool valid() const { return (!m_device_subpools.empty()); }
|
||||
FORCE_INLINE u32 max_sets() const { return info.maxSets; }
|
||||
FORCE_INLINE u32 max_sets() const { return m_create_info.maxSets; }
|
||||
|
||||
private:
|
||||
FORCE_INLINE bool can_allocate(u32 required_count, u32 already_used_count = 0) const { return (required_count + already_used_count) <= info.maxSets; };
|
||||
FORCE_INLINE bool can_allocate(u32 required_count, u32 already_used_count = 0) const { return (required_count + already_used_count) <= m_create_info.maxSets; };
|
||||
void reset(u32 subpool_id, VkDescriptorPoolResetFlags flags);
|
||||
void next_subpool();
|
||||
|
||||
@ -51,7 +51,8 @@ namespace vk
|
||||
};
|
||||
|
||||
const vk::render_device* m_owner = nullptr;
|
||||
VkDescriptorPoolCreateInfo info = {};
|
||||
VkDescriptorPoolCreateInfo m_create_info = {};
|
||||
rsx::simple_array<VkDescriptorPoolSize> m_create_info_pool_sizes;
|
||||
|
||||
rsx::simple_array<logical_subpool_t> m_device_subpools;
|
||||
VkDescriptorPool m_current_pool_handle = VK_NULL_HANDLE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user