Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- Needs to go on top of the final shader non-uniform patch for the tests to work. --- libs/vkd3d/state.c | 29 +++++++++++++++++++++++------ libs/vkd3d/vkd3d_private.h | 1 + tests/d3d12.c | 1 - 3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 78b0c717..123761f2 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->binding_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 binding_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->binding_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 = binding_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 binding_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, + binding_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, + binding_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->binding_offsets = vkd3d_calloc(root_signature->binding_count, + sizeof(*root_signature->binding_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_binding_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,14 @@ 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->binding_offsets) + { + target_info.next = &offset_info; + offset_info.type = VKD3D_SHADER_STRUCTURE_TYPE_BINDING_OFFSET_INFO; + offset_info.next = NULL; + offset_info.binding_offsets = root_signature->binding_offsets; + } + 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 f8474caa..46e4a485 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 *binding_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 cc06b137..27393eec 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) 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);