From bfaab9700d5960dd4923cafae78831ea9a06b41a Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Fri, 13 Sep 2024 00:23:06 +1000 Subject: [PATCH] vkd3d: Lay out virtual descriptor heap buffer and image bindings consecutively instead of interleaving them. Slightly simplifies descriptor write addressing, and makes layouts essentially the same as array layouts, differing only in the binding details, and therefore easier to understand. This also simplifies the addition of storage buffer bindings, which can all be added onto the end. --- libs/vkd3d/command.c | 6 ++---- libs/vkd3d/state.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index eab0436b..4a8ca2f7 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2795,7 +2795,7 @@ static bool vk_write_descriptor_set_from_d3d12_desc(VkWriteDescriptorSet *vk_des /* We use separate bindings for buffer and texture SRVs/UAVs. * See d3d12_root_signature_init(). For unbounded ranges the * descriptors exist in two consecutive sets, otherwise they occur - * in pairs in one set. */ + * as consecutive ranges within a set. */ if (range->descriptor_count == UINT_MAX) { if (vk_descriptor_type != VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER @@ -2807,11 +2807,9 @@ static bool vk_write_descriptor_set_from_d3d12_desc(VkWriteDescriptorSet *vk_des } else { - if (!use_array) - vk_descriptor_write->dstBinding = vk_binding + 2 * index; if (vk_descriptor_type != VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER && vk_descriptor_type != VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER) - ++vk_descriptor_write->dstBinding; + vk_descriptor_write->dstBinding += use_array ? 1 : range->descriptor_count; } if (vk_descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index e961fcf7..8e5ec70a 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -930,10 +930,16 @@ static HRESULT d3d12_root_signature_init_descriptor_table_binding(struct d3d12_r register_space, range->base_register_idx + i, is_buffer, shader_visibility, vk_binding_array_count, context, NULL, NULL))) return hr; + } - if (descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_SRV && descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) - continue; + if (descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_SRV && descriptor_type != VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) + { + context->unbounded_offset = UINT_MAX; + return S_OK; + } + for (i = 0; i < bindings_per_range; ++i) + { if (FAILED(hr = d3d12_root_signature_append_vk_binding(root_signature, descriptor_type, register_space, range->base_register_idx + i, false, shader_visibility, vk_binding_array_count, context, NULL, NULL)))