vkd3d: Only put the mutable descriptor set once in the pipeline layout.

Currently the mutable descriptor set is repeated many times in the
pipeline layout in order to cover the indices for all the
descriptor types that would be present if mutable descriptors were
not used. This is useless and wasteful, but was necessary before
the descriptor sets backing the SRV-UAV-CBV heap were moved at the
end of the allocation table because descriptor set indices are
currently a compile-time constant in many places.

Now this is not needed any more and we can just avoid putting
many copies of the mutable descriptor set in the pipeline layout,
making it easier to meet Vulkan implementation limits.
This commit is contained in:
Giovanni Mascellani 2024-10-18 22:13:23 +02:00 committed by Henri Verbeet
parent 96b324c156
commit bc2b137df9
Notes: Henri Verbeet 2024-10-23 16:18:40 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1218
2 changed files with 15 additions and 6 deletions

View File

@ -1482,8 +1482,8 @@ static unsigned int d3d12_root_signature_copy_descriptor_set_layouts(const struc
VkDescriptorSetLayout *vk_set_layouts) VkDescriptorSetLayout *vk_set_layouts)
{ {
const struct d3d12_device *device = root_signature->device; const struct d3d12_device *device = root_signature->device;
VkDescriptorSetLayout mutable_layout, vk_set_layout;
enum vkd3d_vk_descriptor_set_index set; enum vkd3d_vk_descriptor_set_index set;
VkDescriptorSetLayout vk_set_layout;
unsigned int i; unsigned int i;
for (i = 0; i < root_signature->vk_set_count; ++i) for (i = 0; i < root_signature->vk_set_count; ++i)
@ -1492,12 +1492,15 @@ static unsigned int d3d12_root_signature_copy_descriptor_set_layouts(const struc
if (!device->use_vk_heaps) if (!device->use_vk_heaps)
return i; return i;
mutable_layout = device->vk_descriptor_heap_layouts[VKD3D_SET_INDEX_MUTABLE].vk_set_layout;
for (set = 0; set < ARRAY_SIZE(device->vk_descriptor_heap_layouts); ++set) for (set = 0; set < ARRAY_SIZE(device->vk_descriptor_heap_layouts); ++set)
{ {
vk_set_layout = device->vk_descriptor_heap_layouts[set].vk_set_layout; vk_set_layout = device->vk_descriptor_heap_layouts[set].vk_set_layout;
/* All layouts must be valid, so if null, just set it to the mutable one. */
vk_set_layouts[i++] = vk_set_layout ? vk_set_layout : mutable_layout; VKD3D_ASSERT(vk_set_layout);
vk_set_layouts[i++] = vk_set_layout;
if (device->vk_info.EXT_mutable_descriptor_type && set == VKD3D_SET_INDEX_MUTABLE)
break;
} }
return i; return i;

View File

@ -774,12 +774,18 @@ enum vkd3d_vk_descriptor_set_index
{ {
VKD3D_SET_INDEX_SAMPLER, VKD3D_SET_INDEX_SAMPLER,
VKD3D_SET_INDEX_UAV_COUNTER, VKD3D_SET_INDEX_UAV_COUNTER,
VKD3D_SET_INDEX_UNIFORM_BUFFER, VKD3D_SET_INDEX_MUTABLE,
VKD3D_SET_INDEX_MUTABLE = VKD3D_SET_INDEX_UNIFORM_BUFFER,
/* These are used when mutable descriptors are not available to back
* SRV-UAV-CBV descriptor heaps. They must stay at the end of this
* enumeration, so that they can be ignored when mutable descriptors are
* used. */
VKD3D_SET_INDEX_UNIFORM_BUFFER = VKD3D_SET_INDEX_MUTABLE,
VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER, VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER,
VKD3D_SET_INDEX_SAMPLED_IMAGE, VKD3D_SET_INDEX_SAMPLED_IMAGE,
VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER, VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER,
VKD3D_SET_INDEX_STORAGE_IMAGE, VKD3D_SET_INDEX_STORAGE_IMAGE,
VKD3D_SET_INDEX_COUNT VKD3D_SET_INDEX_COUNT
}; };