Simplifies the code path for handling array bindings and unbounded ranges.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/command.c | 6 +----- libs/vkd3d/state.c | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 116a8a62..06d7746d 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2674,7 +2674,6 @@ static void d3d12_command_list_update_descriptor_table(struct d3d12_command_list
descriptor_table = root_signature_get_descriptor_table(root_signature, index);
- descriptor = base_descriptor; descriptor_count = 0; current_descriptor_write = descriptor_writes; current_image_info = image_infos; @@ -2682,10 +2681,7 @@ static void d3d12_command_list_update_descriptor_table(struct d3d12_command_list { range = &descriptor_table->ranges[i];
- if (range->offset != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) - { - descriptor = base_descriptor + range->offset; - } + descriptor = base_descriptor + range->offset;
for (j = 0; j < range->descriptor_count; ++j, ++descriptor) { diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index e459c998..d07212f6 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -591,6 +591,8 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo for (i = 0; i < desc->NumParameters; ++i) { const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i]; + unsigned int offset = 0; + if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) continue;
@@ -608,6 +610,24 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo { range = &p->u.DescriptorTable.pDescriptorRanges[j];
+ if (range->OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + offset = range->OffsetInDescriptorsFromTableStart; + + table->ranges[j].offset = offset; + table->ranges[j].descriptor_count = range->NumDescriptors; + table->ranges[j].descriptor_magic = vkd3d_descriptor_magic_from_d3d12(range->RangeType); + table->ranges[j].register_space = range->RegisterSpace; + table->ranges[j].base_register_idx = range->BaseShaderRegister; + + TRACE("Descriptor table range %u.%u, offset %u, type %u, count %d.\n", i, j, + offset, range->RangeType, range->NumDescriptors); + + /* Validation during counting ensures this value is never used if range->NumDescriptors == UINT_MAX. */ + offset += range->NumDescriptors; + } + + for (j = 0; j < range_count; ++j) + { vk_binding = d3d12_root_signature_assign_vk_bindings(root_signature, vkd3d_descriptor_type_from_d3d12_range_type(range->RangeType), range->RegisterSpace, range->BaseShaderRegister, range->NumDescriptors, false, true, @@ -638,12 +658,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo ++cur_binding; }
- table->ranges[j].offset = range->OffsetInDescriptorsFromTableStart; - table->ranges[j].descriptor_count = range->NumDescriptors; table->ranges[j].binding = vk_binding; - table->ranges[j].descriptor_magic = vkd3d_descriptor_magic_from_d3d12(range->RangeType); - table->ranges[j].register_space = range->RegisterSpace; - table->ranges[j].base_register_idx = range->BaseShaderRegister; } }