mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Introduce an enumerant for the mutable descriptor set.
So we avoid hardcoding that it is number zero. There are two goals here: first making the code easier to understand and second allow reshuffling the descriptor set allocation in a later commit.
This commit is contained in:
parent
32e6a1bb4d
commit
8d030718ae
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
@ -136,7 +136,8 @@ static HRESULT vkd3d_create_vk_descriptor_heap_layout(struct d3d12_device *devic
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
};
|
||||
|
||||
if (device->vk_info.EXT_mutable_descriptor_type && index && index != VKD3D_SET_INDEX_UAV_COUNTER
|
||||
if (device->vk_info.EXT_mutable_descriptor_type
|
||||
&& index != VKD3D_SET_INDEX_MUTABLE && index != VKD3D_SET_INDEX_UAV_COUNTER
|
||||
&& device->vk_descriptor_heap_layouts[index].applicable_heap_type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
|
||||
{
|
||||
device->vk_descriptor_heap_layouts[index].vk_set_layout = VK_NULL_HANDLE;
|
||||
@ -144,7 +145,7 @@ static HRESULT vkd3d_create_vk_descriptor_heap_layout(struct d3d12_device *devic
|
||||
}
|
||||
|
||||
binding.binding = 0;
|
||||
binding.descriptorType = (device->vk_info.EXT_mutable_descriptor_type && !index)
|
||||
binding.descriptorType = (device->vk_info.EXT_mutable_descriptor_type && index == VKD3D_SET_INDEX_MUTABLE)
|
||||
? VK_DESCRIPTOR_TYPE_MUTABLE_EXT : device->vk_descriptor_heap_layouts[index].type;
|
||||
binding.descriptorCount = device->vk_descriptor_heap_layouts[index].count;
|
||||
binding.stageFlags = VK_SHADER_STAGE_ALL;
|
||||
@ -200,14 +201,20 @@ static HRESULT vkd3d_vk_descriptor_heap_layouts_init(struct d3d12_device *device
|
||||
{
|
||||
static const struct vkd3d_vk_descriptor_heap_layout vk_descriptor_heap_layouts[VKD3D_SET_INDEX_COUNT] =
|
||||
{
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, false, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, false, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
{VK_DESCRIPTOR_TYPE_SAMPLER, false, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER},
|
||||
/* UAV counters */
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_UNIFORM_BUFFER] =
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER] =
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_SAMPLED_IMAGE] =
|
||||
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, false, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER] =
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_STORAGE_IMAGE] =
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, false, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
[VKD3D_SET_INDEX_SAMPLER] =
|
||||
{VK_DESCRIPTOR_TYPE_SAMPLER, false, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER},
|
||||
[VKD3D_SET_INDEX_UAV_COUNTER] =
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, true, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV},
|
||||
};
|
||||
const struct vkd3d_device_descriptor_limits *limits = &device->vk_info.descriptor_limits;
|
||||
enum vkd3d_vk_descriptor_set_index set;
|
||||
|
@ -2498,7 +2498,7 @@ static void d3d12_desc_write_vk_heap_null_descriptor(struct d3d12_descriptor_hea
|
||||
enum vkd3d_vk_descriptor_set_index set, end;
|
||||
unsigned int i = writes->count;
|
||||
|
||||
end = device->vk_info.EXT_mutable_descriptor_type ? VKD3D_SET_INDEX_UNIFORM_BUFFER
|
||||
end = device->vk_info.EXT_mutable_descriptor_type ? VKD3D_SET_INDEX_MUTABLE
|
||||
: VKD3D_SET_INDEX_STORAGE_IMAGE;
|
||||
/* Binding a shader with the wrong null descriptor type works in Windows.
|
||||
* To support that here we must write one to all applicable Vulkan sets. */
|
||||
@ -4250,7 +4250,8 @@ static HRESULT d3d12_descriptor_heap_create_descriptor_pool(struct d3d12_descrip
|
||||
if (device->vk_descriptor_heap_layouts[set].applicable_heap_type == desc->Type
|
||||
&& device->vk_descriptor_heap_layouts[set].vk_set_layout)
|
||||
{
|
||||
pool_sizes[pool_desc.poolSizeCount].type = (device->vk_info.EXT_mutable_descriptor_type && !set)
|
||||
pool_sizes[pool_desc.poolSizeCount].type =
|
||||
(device->vk_info.EXT_mutable_descriptor_type && set == VKD3D_SET_INDEX_MUTABLE)
|
||||
? VK_DESCRIPTOR_TYPE_MUTABLE_EXT : device->vk_descriptor_heap_layouts[set].type;
|
||||
pool_sizes[pool_desc.poolSizeCount++].descriptorCount = desc->NumDescriptors;
|
||||
}
|
||||
@ -4280,11 +4281,12 @@ static HRESULT d3d12_descriptor_heap_create_descriptor_set(struct d3d12_descript
|
||||
|
||||
if (!device->vk_descriptor_heap_layouts[set].vk_set_layout)
|
||||
{
|
||||
/* Set 0 uses mutable descriptors, and this set is unused. */
|
||||
if (!descriptor_heap->vk_descriptor_sets[0].vk_set
|
||||
&& FAILED(hr = d3d12_descriptor_heap_create_descriptor_set(descriptor_heap, device, 0)))
|
||||
/* Mutable descriptors are in use, and this set is unused. */
|
||||
if (!descriptor_heap->vk_descriptor_sets[VKD3D_SET_INDEX_MUTABLE].vk_set
|
||||
&& FAILED(hr = d3d12_descriptor_heap_create_descriptor_set(descriptor_heap,
|
||||
device, VKD3D_SET_INDEX_MUTABLE)))
|
||||
return hr;
|
||||
descriptor_set->vk_set = descriptor_heap->vk_descriptor_sets[0].vk_set;
|
||||
descriptor_set->vk_set = descriptor_heap->vk_descriptor_sets[VKD3D_SET_INDEX_MUTABLE].vk_set;
|
||||
descriptor_set->vk_type = device->vk_descriptor_heap_layouts[set].type;
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ static void vkd3d_descriptor_heap_binding_from_descriptor_range(const struct d3d
|
||||
}
|
||||
else
|
||||
{
|
||||
binding->set = 0;
|
||||
binding->set = VKD3D_SET_INDEX_MUTABLE;
|
||||
descriptor_set_size = descriptor_limits->sampled_image_max_descriptors;
|
||||
}
|
||||
}
|
||||
@ -1482,22 +1482,22 @@ static unsigned int d3d12_root_signature_copy_descriptor_set_layouts(const struc
|
||||
VkDescriptorSetLayout *vk_set_layouts)
|
||||
{
|
||||
const struct d3d12_device *device = root_signature->device;
|
||||
VkDescriptorSetLayout mutable_layout, vk_set_layout;
|
||||
enum vkd3d_vk_descriptor_set_index set;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < root_signature->vk_set_count; ++i)
|
||||
vk_set_layouts[i] = root_signature->descriptor_set_layouts[i].vk_layout;
|
||||
|
||||
if (device->use_vk_heaps)
|
||||
{
|
||||
VkDescriptorSetLayout mutable_layout = device->vk_descriptor_heap_layouts[0].vk_set_layout;
|
||||
if (!device->use_vk_heaps)
|
||||
return i;
|
||||
|
||||
for (set = 0; set < ARRAY_SIZE(device->vk_descriptor_heap_layouts); ++set)
|
||||
{
|
||||
VkDescriptorSetLayout 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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
@ -773,6 +773,7 @@ void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_dev
|
||||
enum vkd3d_vk_descriptor_set_index
|
||||
{
|
||||
VKD3D_SET_INDEX_UNIFORM_BUFFER = 0,
|
||||
VKD3D_SET_INDEX_MUTABLE = VKD3D_SET_INDEX_UNIFORM_BUFFER,
|
||||
VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER = 1,
|
||||
VKD3D_SET_INDEX_SAMPLED_IMAGE = 2,
|
||||
VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER = 3,
|
||||
|
Loading…
Reference in New Issue
Block a user