vkd3d: Avoid copying empty ranges in d3d12_device_CopyDescriptors().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-04-02 12:15:52 +02:00 committed by Alexandre Julliard
parent 4408816e24
commit 91e88a820e
3 changed files with 50 additions and 24 deletions

View File

@ -2306,29 +2306,27 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptors(ID3D12Device *iface,
} }
dst_range_idx = dst_idx = 0; dst_range_idx = dst_idx = 0;
dst = d3d12_desc_from_cpu_handle(dst_descriptor_range_offsets[0]); src_range_idx = src_idx = 0;
dst_range_size = dst_descriptor_range_sizes ? dst_descriptor_range_sizes[0] : 1; while (dst_range_idx < dst_descriptor_range_count && src_range_idx < src_descriptor_range_count)
for (src_range_idx = 0; src_range_idx < src_descriptor_range_count; ++src_range_idx)
{ {
src = d3d12_desc_from_cpu_handle(src_descriptor_range_offsets[src_range_idx]); dst_range_size = dst_descriptor_range_sizes ? dst_descriptor_range_sizes[dst_range_idx] : 1;
src_range_size = src_descriptor_range_sizes ? src_descriptor_range_sizes[src_range_idx] : 1; src_range_size = src_descriptor_range_sizes ? src_descriptor_range_sizes[src_range_idx] : 1;
for (src_idx = 0; src_idx < src_range_size; ++src_idx)
dst = d3d12_desc_from_cpu_handle(dst_descriptor_range_offsets[dst_range_idx]);
src = d3d12_desc_from_cpu_handle(src_descriptor_range_offsets[src_range_idx]);
while (dst_idx < dst_range_size && src_idx < src_range_size)
d3d12_desc_copy(&dst[dst_idx++], &src[src_idx++], device);
if (dst_idx >= dst_range_size)
{ {
if (dst_idx >= dst_range_size) ++dst_range_idx;
{ dst_idx = 0;
dst_idx = 0; }
++dst_range_idx; if (src_idx >= src_range_size)
{
if (dst_range_idx >= dst_descriptor_range_count) ++src_range_idx;
return; src_idx = 0;
dst = d3d12_desc_from_cpu_handle(dst_descriptor_range_offsets[dst_range_idx]);
dst_range_size = dst_descriptor_range_sizes ? dst_descriptor_range_sizes[dst_range_idx] : 1;
}
d3d12_desc_copy(dst++, src++, device);
++dst_idx;
} }
} }
} }

View File

@ -1600,6 +1600,8 @@ static void d3d12_desc_destroy(struct d3d12_desc *descriptor,
void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src, void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src,
struct d3d12_device *device) struct d3d12_device *device)
{ {
assert(dst != src);
d3d12_desc_destroy(dst, device); d3d12_desc_destroy(dst, device);
*dst = *src; *dst = *src;

View File

@ -15168,12 +15168,16 @@ static void test_copy_descriptors(void)
dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 9); dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 9);
dst_range_sizes[0] = 4; dst_range_sizes[0] = 4;
dst_handles[1] = get_cpu_descriptor_handle(&context, heap, 13); dst_handles[1] = get_cpu_descriptor_handle(&context, heap, 9);
dst_range_sizes[1] = 3; dst_range_sizes[1] = 0;
dst_handles[2] = get_cpu_descriptor_handle(&context, heap, 13);
dst_range_sizes[2] = 3;
dst_handles[3] = get_cpu_descriptor_handle(&context, heap, 13);
dst_range_sizes[3] = 0;
src_handles[0] = get_cpu_descriptor_handle(&context, cpu_heap, 10); src_handles[0] = get_cpu_descriptor_handle(&context, cpu_heap, 10);
src_range_sizes[0] = 7; src_range_sizes[0] = 8;
/* t0-t6 */ /* t0-t6 */
ID3D12Device_CopyDescriptors(device, 2, dst_handles, dst_range_sizes, ID3D12Device_CopyDescriptors(device, 4, dst_handles, dst_range_sizes,
1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); 1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
/* copy 1 uninitialized descriptor (19) */ /* copy 1 uninitialized descriptor (19) */
@ -15195,6 +15199,28 @@ static void test_copy_descriptors(void)
get_cpu_descriptor_handle(&context, cpu_heap, 22), get_cpu_descriptor_handle(&context, cpu_heap, 22),
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
/* range sizes equal to 0 */
dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 19);
dst_range_sizes[0] = 0;
dst_handles[1] = get_cpu_descriptor_handle(&context, heap, 19);
dst_range_sizes[1] = 0;
src_handles[0] = get_cpu_descriptor_handle(&context, cpu_heap, 0);
src_range_sizes[0] = 1;
src_handles[1] = get_cpu_descriptor_handle(&context, cpu_heap, 0);
src_range_sizes[1] = 4;
ID3D12Device_CopyDescriptors(device, 2, dst_handles, dst_range_sizes,
2, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 19);
dst_range_sizes[0] = 4;
dst_handles[1] = get_cpu_descriptor_handle(&context, heap, 19);
dst_range_sizes[1] = 4;
src_handles[0] = get_cpu_descriptor_handle(&context, cpu_heap, 0);
src_range_sizes[0] = 0;
src_handles[1] = get_cpu_descriptor_handle(&context, cpu_heap, 0);
src_range_sizes[1] = 0;
ID3D12Device_CopyDescriptors(device, 2, dst_handles, dst_range_sizes,
2, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, context.root_signature); ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, context.root_signature);
heaps[0] = sampler_heap; heaps[1] = heap; heaps[0] = sampler_heap; heaps[1] = heap;
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, ARRAY_SIZE(heaps), heaps); ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, ARRAY_SIZE(heaps), heaps);