Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/state.c | 30 ++++++++++++++++++++++++------ libs/vkd3d/vkd3d_private.h | 1 + tests/d3d12.c | 1 - 3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 8c514bd4..b4476f9e 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -91,6 +91,7 @@ static void d3d12_root_signature_cleanup(struct d3d12_root_signature *root_signa
if (root_signature->descriptor_mapping) vkd3d_free(root_signature->descriptor_mapping); + vkd3d_free(root_signature->descriptor_offsets); if (root_signature->root_constants) vkd3d_free(root_signature->root_constants);
@@ -700,10 +701,11 @@ static HRESULT d3d12_root_signature_init_descriptor_array_binding(struct d3d12_r }
static void d3d12_root_signature_map_vk_unbounded_binding(struct d3d12_root_signature *root_signature, - const struct d3d12_root_descriptor_table_range *range, bool buffer_descriptor, + const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset, bool buffer_descriptor, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context) { - struct vkd3d_shader_resource_binding *mapping = &root_signature->descriptor_mapping[context->descriptor_index++]; + struct vkd3d_shader_resource_binding *mapping = &root_signature->descriptor_mapping[context->descriptor_index]; + unsigned int *offset = &root_signature->descriptor_offsets[context->descriptor_index++];
mapping->type = range->type; mapping->register_space = range->register_space; @@ -714,18 +716,21 @@ static void d3d12_root_signature_map_vk_unbounded_binding(struct d3d12_root_sign || range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) && !buffer_descriptor); mapping->binding.binding = range->binding; mapping->binding.count = range->vk_binding_count; + *offset = descriptor_offset; }
static void d3d12_root_signature_map_descriptor_unbounded_binding(struct d3d12_root_signature *root_signature, - const struct d3d12_root_descriptor_table_range *range, + const struct d3d12_root_descriptor_table_range *range, unsigned int descriptor_offset, enum vkd3d_shader_visibility shader_visibility, struct vkd3d_descriptor_set_context *context) { bool is_buffer = range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_CBV;
if (range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_SRV || range->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV) - d3d12_root_signature_map_vk_unbounded_binding(root_signature, range, true, shader_visibility, context); + d3d12_root_signature_map_vk_unbounded_binding(root_signature, range, + descriptor_offset, true, shader_visibility, context);
- d3d12_root_signature_map_vk_unbounded_binding(root_signature, range, is_buffer, shader_visibility, context); + d3d12_root_signature_map_vk_unbounded_binding(root_signature, range, + descriptor_offset, is_buffer, shader_visibility, context); }
static int compare_register_range(const void *a, const void *b) @@ -869,7 +874,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo range->binding = base_range->binding; range->vk_binding_count = base_range->vk_binding_count - rel_offset; d3d12_root_signature_map_descriptor_unbounded_binding(root_signature, range, - shader_visibility, context); + rel_offset, shader_visibility, context); continue; } else if (range->descriptor_count == UINT_MAX) @@ -1152,6 +1157,9 @@ static HRESULT d3d12_root_signature_init(struct d3d12_root_signature *root_signa if (!(root_signature->descriptor_mapping = vkd3d_calloc(root_signature->binding_count, sizeof(*root_signature->descriptor_mapping)))) goto fail; + if (!(root_signature->descriptor_offsets = vkd3d_calloc(root_signature->binding_count, + sizeof(*root_signature->descriptor_offsets)))) + goto fail; root_signature->root_constant_count = info.root_constant_count; if (!(root_signature->root_constants = vkd3d_calloc(root_signature->root_constant_count, sizeof(*root_signature->root_constants)))) @@ -1865,6 +1873,7 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; struct vkd3d_shader_scan_descriptor_info shader_info; struct vkd3d_shader_interface_info shader_interface; + struct vkd3d_shader_descriptor_offset_info offset_info; const struct d3d12_root_signature *root_signature; struct vkd3d_shader_spirv_target_info target_info; VkPipelineLayout vk_pipeline_layout; @@ -1904,6 +1913,15 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st target_info.extensions = device->vk_info.shader_extensions; target_info.extension_count = device->vk_info.shader_extension_count;
+ if (root_signature->descriptor_offsets) + { + offset_info.type = VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO; + offset_info.next = NULL; + offset_info.descriptor_offsets = root_signature->descriptor_offsets; + offset_info.uav_counter_offsets = NULL; + vkd3d_prepend_struct(&target_info, &offset_info); + } + shader_interface.type = VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO; shader_interface.next = &target_info; shader_interface.bindings = root_signature->descriptor_mapping; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index d5fb0753..f6980957 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -736,6 +736,7 @@ struct d3d12_root_signature
unsigned int binding_count; struct vkd3d_shader_resource_binding *descriptor_mapping; + unsigned int *descriptor_offsets;
unsigned int root_constant_count; struct vkd3d_shader_push_constant_buffer *root_constants; diff --git a/tests/d3d12.c b/tests/d3d12.c index 38fab13c..86b17cea 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -34999,7 +34999,6 @@ static void test_unbounded_resource_arrays(void) D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); get_buffer_readback_with_command_list(output_buffers[i], DXGI_FORMAT_R32_UINT, &rb, queue, command_list); /* Buffers at index >= 64 are aliased. */ - todo_if(i != 74 && i > 63) check_readback_data_uint(&rb, NULL, (i < 64 ? 63 - i : 127 - i) ^ 0x35, 0); release_resource_readback(&rb); reset_command_list(command_list, context.allocator);