mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d: Put all root descriptors in a single Vulkan descriptor set when using Vulkan heaps.
Since 4a94bfc2f6 we segregate
different D3D12 descriptor types in different Vulkan descriptor sets.
This change was introduced to reduce descriptor wasting when
allocating a new descriptor pool; that can be very useful when
using virtual heaps, which have to often cycle through many
descriptors, but it is expected to have limited impact for Vulkan
heaps, given that in that case most descriptors are allocated through
the descriptor heap rather than through the command allocator.
Instead, it has a rather detrimental effect with Vulkan heaps,
because it tends to use many more Vulkan descriptor sets than
necessary, often with just a handful of descriptors each. This
causes a regression on some Vulkan implementations that support
too few descriptor sets.
With this change we revert to a situation similar to before,
stuffing all the descriptors that do not live in a root
descriptor table in as few descriptor sets as possible (at most
one or two, depending on whether push descriptors are used).
This commit is contained in:
committed by
Henri Verbeet
parent
6415c6b0e0
commit
07b7975d09
Notes:
Henri Verbeet
2025-02-19 18:03:19 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1376
@@ -1499,7 +1499,7 @@ static VkDescriptorPool d3d12_command_allocator_allocate_descriptor_pool(
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
struct VkDescriptorPoolCreateInfo pool_desc;
|
||||
VkDevice vk_device = device->vk_device;
|
||||
VkDescriptorPoolSize vk_pool_sizes[2];
|
||||
VkDescriptorPoolSize vk_pool_sizes[4];
|
||||
unsigned int pool_size, pool_limit;
|
||||
VkDescriptorPool vk_pool;
|
||||
VkResult vr;
|
||||
@@ -1530,21 +1530,43 @@ static VkDescriptorPool d3d12_command_allocator_allocate_descriptor_pool(
|
||||
}
|
||||
descriptor_count = pool_size;
|
||||
|
||||
vk_pool_sizes[0].type = vk_descriptor_type_from_vkd3d_descriptor_type(descriptor_type, true);
|
||||
vk_pool_sizes[0].descriptorCount = descriptor_count;
|
||||
|
||||
vk_pool_sizes[1].type = vk_descriptor_type_from_vkd3d_descriptor_type(descriptor_type, false);
|
||||
vk_pool_sizes[1].descriptorCount = descriptor_count;
|
||||
|
||||
pool_desc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||
pool_desc.pNext = NULL;
|
||||
pool_desc.flags = 0;
|
||||
pool_desc.maxSets = 512;
|
||||
pool_desc.poolSizeCount = 1;
|
||||
if (vk_pool_sizes[1].type != vk_pool_sizes[0].type)
|
||||
++pool_desc.poolSizeCount;
|
||||
pool_desc.pPoolSizes = vk_pool_sizes;
|
||||
|
||||
if (allocator->device->use_vk_heaps)
|
||||
{
|
||||
/* SRV root descriptors. */
|
||||
vk_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
vk_pool_sizes[0].descriptorCount = descriptor_count;
|
||||
|
||||
/* UAV root descriptors and UAV counters. */
|
||||
vk_pool_sizes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
|
||||
vk_pool_sizes[1].descriptorCount = descriptor_count;
|
||||
|
||||
/* CBV root descriptors. */
|
||||
vk_pool_sizes[2].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
vk_pool_sizes[2].descriptorCount = descriptor_count;
|
||||
|
||||
/* Static samplers. */
|
||||
vk_pool_sizes[3].type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
vk_pool_sizes[3].descriptorCount = descriptor_count;
|
||||
|
||||
pool_desc.poolSizeCount = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
vk_pool_sizes[0].type = vk_descriptor_type_from_vkd3d_descriptor_type(descriptor_type, true);
|
||||
vk_pool_sizes[0].descriptorCount = descriptor_count;
|
||||
|
||||
vk_pool_sizes[1].type = vk_descriptor_type_from_vkd3d_descriptor_type(descriptor_type, false);
|
||||
vk_pool_sizes[1].descriptorCount = descriptor_count;
|
||||
|
||||
pool_desc.poolSizeCount = 1 + (vk_pool_sizes[0].type != vk_pool_sizes[1].type);
|
||||
}
|
||||
|
||||
if ((vr = VK_CALL(vkCreateDescriptorPool(vk_device, &pool_desc, NULL, &vk_pool))) < 0)
|
||||
{
|
||||
ERR("Failed to create descriptor pool, vr %d.\n", vr);
|
||||
@@ -1578,6 +1600,10 @@ static VkDescriptorSet d3d12_command_allocator_allocate_descriptor_set(struct d3
|
||||
VkDescriptorSet vk_descriptor_set;
|
||||
VkResult vr;
|
||||
|
||||
/* With Vulkan heaps we use just one descriptor pool. */
|
||||
if (device->use_vk_heaps)
|
||||
descriptor_type = 0;
|
||||
|
||||
if (!allocator->vk_descriptor_pools[descriptor_type])
|
||||
allocator->vk_descriptor_pools[descriptor_type] = d3d12_command_allocator_allocate_descriptor_pool(allocator,
|
||||
descriptor_type, descriptor_count, unbounded);
|
||||
|
||||
Reference in New Issue
Block a user