libs/vkd3d: Add support for OffsetInDescriptorsFromTableStart.

This commit is contained in:
Józef Kucia 2017-08-31 11:21:34 +02:00
parent 39a2c0e5f1
commit 62bd4e6e63
4 changed files with 16 additions and 9 deletions

View File

@ -2543,6 +2543,13 @@ static void d3d12_command_list_set_descriptor_table(struct d3d12_command_list *l
for (i = 0; i < descriptor_table->range_count; ++i) for (i = 0; i < descriptor_table->range_count; ++i)
{ {
range = &descriptor_table->ranges[i]; range = &descriptor_table->ranges[i];
if (range->offset != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
{
descriptor = (struct d3d12_desc *)(intptr_t)base_descriptor.ptr;
descriptor += range->offset;
}
for (j = 0; j < range->descriptor_count; ++j, ++descriptor) for (j = 0; j < range->descriptor_count; ++j, ++descriptor)
{ {
if (!vk_write_descriptor_set_from_d3d12_desc(current_descriptor_write, if (!vk_write_descriptor_set_from_d3d12_desc(current_descriptor_write,

View File

@ -309,8 +309,6 @@ static bool vk_binding_from_d3d12_descriptor_range(struct VkDescriptorSetLayoutB
FIXME("Unhandled register space %u.\n", descriptor_range->RegisterSpace); FIXME("Unhandled register space %u.\n", descriptor_range->RegisterSpace);
return false; return false;
} }
if (descriptor_range->OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
FIXME("Unhandled offset %#x.\n", descriptor_range->OffsetInDescriptorsFromTableStart);
binding_desc->stageFlags = stage_flags_from_visibility(shader_visibility); binding_desc->stageFlags = stage_flags_from_visibility(shader_visibility);
binding_desc->pImmutableSamplers = NULL; binding_desc->pImmutableSamplers = NULL;
@ -687,8 +685,9 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
++cur_binding; ++cur_binding;
} }
table->ranges[j].binding = vk_binding; table->ranges[j].offset = descriptor_range->OffsetInDescriptorsFromTableStart;
table->ranges[j].descriptor_count = descriptor_range->NumDescriptors; table->ranges[j].descriptor_count = descriptor_range->NumDescriptors;
table->ranges[j].binding = vk_binding;
} }
} }

View File

@ -275,8 +275,9 @@ struct d3d12_query_heap *unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface
struct d3d12_root_descriptor_table_range struct d3d12_root_descriptor_table_range
{ {
uint32_t binding; unsigned int offset;
unsigned int descriptor_count; unsigned int descriptor_count;
uint32_t binding;
}; };
struct d3d12_root_descriptor_table struct d3d12_root_descriptor_table

View File

@ -8222,7 +8222,7 @@ static void test_descriptor_tables(void)
descriptor_range[0].NumDescriptors = 2; descriptor_range[0].NumDescriptors = 2;
descriptor_range[0].BaseShaderRegister = 0; descriptor_range[0].BaseShaderRegister = 0;
descriptor_range[0].RegisterSpace = 0; descriptor_range[0].RegisterSpace = 0;
descriptor_range[0].OffsetInDescriptorsFromTableStart = 0; descriptor_range[0].OffsetInDescriptorsFromTableStart = 1;
root_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; root_parameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
root_parameters[0].DescriptorTable.NumDescriptorRanges = 1; root_parameters[0].DescriptorTable.NumDescriptorRanges = 1;
root_parameters[0].DescriptorTable.pDescriptorRanges = &descriptor_range[0]; root_parameters[0].DescriptorTable.pDescriptorRanges = &descriptor_range[0];
@ -8232,7 +8232,7 @@ static void test_descriptor_tables(void)
descriptor_range[1].NumDescriptors = 1; descriptor_range[1].NumDescriptors = 1;
descriptor_range[1].BaseShaderRegister = 0; descriptor_range[1].BaseShaderRegister = 0;
descriptor_range[1].RegisterSpace = 0; descriptor_range[1].RegisterSpace = 0;
descriptor_range[1].OffsetInDescriptorsFromTableStart = 0; descriptor_range[1].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
root_parameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; root_parameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
root_parameters[1].DescriptorTable.NumDescriptorRanges = 1; root_parameters[1].DescriptorTable.NumDescriptorRanges = 1;
root_parameters[1].DescriptorTable.pDescriptorRanges = &descriptor_range[1]; root_parameters[1].DescriptorTable.pDescriptorRanges = &descriptor_range[1];
@ -8270,7 +8270,7 @@ static void test_descriptor_tables(void)
memset(&heap_desc, 0, sizeof(heap_desc)); memset(&heap_desc, 0, sizeof(heap_desc));
heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
heap_desc.NumDescriptors = 5; heap_desc.NumDescriptors = 6;
heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
hr = ID3D12Device_CreateDescriptorHeap(context.device, &heap_desc, hr = ID3D12Device_CreateDescriptorHeap(context.device, &heap_desc,
&IID_ID3D12DescriptorHeap, (void **)&heap); &IID_ID3D12DescriptorHeap, (void **)&heap);
@ -8301,6 +8301,7 @@ static void test_descriptor_tables(void)
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
cpu_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap); cpu_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap);
cpu_handle.ptr += descriptor_size;
/* t0-t3 */ /* t0-t3 */
for (i = 0; i < ARRAY_SIZE(textures); ++i) for (i = 0; i < ARRAY_SIZE(textures); ++i)
{ {
@ -8326,9 +8327,9 @@ static void test_descriptor_tables(void)
heaps[0] = heap; heaps[1] = sampler_heap; heaps[0] = heap; heaps[1] = sampler_heap;
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, ARRAY_SIZE(heaps), heaps); ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, ARRAY_SIZE(heaps), heaps);
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, gpu_handle); ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, gpu_handle);
gpu_handle.ptr += 2 * descriptor_size;
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 1, ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 1,
ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(sampler_heap)); ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(sampler_heap));
gpu_handle.ptr += 3 * descriptor_size;
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 2, gpu_handle); ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 2, gpu_handle);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
@ -8337,7 +8338,6 @@ static void test_descriptor_tables(void)
transition_resource_state(command_list, context.render_target, transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xb2664c19, 2); check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xb2664c19, 2);
ID3D12Resource_Release(cb); ID3D12Resource_Release(cb);