Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/command.c | 6 +----- libs/vkd3d/state.c | 27 ++++++++++++++++++++++----- 2 file changed, 23 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 18340a07..4bc6bdec 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -879,6 +879,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;
@@ -894,6 +896,26 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
context->table_index = i;
+ for (j = 0; j < range_count; ++j) + { + 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) { range = &p->u.DescriptorTable.pDescriptorRanges[j]; @@ -928,12 +950,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; } }