Allows use of todo with check_buffer_uint().
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index c9e75e08..f782ef1f 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -317,14 +317,14 @@ static void get_buffer_readback_with_command_list(ID3D12Resource *buffer, DXGI_F HRESULT hr;
hr = ID3D12Resource_GetDevice(buffer, &IID_ID3D12Device, (void **)&device); - ok(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); + assert_that(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr);
resource_desc = ID3D12Resource_GetDesc(buffer); - assert(resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER); + assert_that(resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER, "Resource %p is not a buffer.\n", buffer); resource_desc.Flags = D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
hr = ID3D12Resource_GetHeapProperties(buffer, &heap_properties, NULL); - ok(SUCCEEDED(hr), "Failed to get heap properties.\n"); + assert_that(SUCCEEDED(hr), "Failed to get heap properties.\n"); if (heap_properties.Type == D3D12_HEAP_TYPE_READBACK) { rb_buffer = buffer; @@ -338,7 +338,7 @@ static void get_buffer_readback_with_command_list(ID3D12Resource *buffer, DXGI_F }
hr = ID3D12GraphicsCommandList_Close(command_list); - ok(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + assert_that(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr);
exec_command_list(queue, command_list); wait_queue_idle(device, queue); @@ -354,7 +354,7 @@ static void get_buffer_readback_with_command_list(ID3D12Resource *buffer, DXGI_F read_range.Begin = 0; read_range.End = resource_desc.Width; hr = ID3D12Resource_Map(rb_buffer, 0, &read_range, &rb->data); - ok(SUCCEEDED(hr), "Failed to map readback buffer, hr %#x.\n", hr); + assert_that(SUCCEEDED(hr), "Failed to map readback buffer, hr %#x.\n", hr); }
static uint8_t get_readback_uint8(struct resource_readback *rb, unsigned int x, unsigned int y)
It's technically correct in warning about overwriting the entire vec4 from the address of .x, if a bit overzealous. It's probably a good warning to keep enabled.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index f782ef1f..e7e6da29 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4460,7 +4460,7 @@ static void test_clear_depth_stencil_view(void) static void test_clear_render_target_view(void) { static const unsigned int array_expected_colors[] = {0xff00ff00, 0xff0000ff, 0xffff0000}; - static const struct vec4 array_colors[] = + static const float array_colors[][4] = { {0.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 0.0f, 0.0f, 1.0f}, @@ -4644,7 +4644,7 @@ static void test_clear_render_target_view(void)
ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, &array_colors[i].x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, array_colors[i], 0, NULL); }
transition_resource_state(command_list, resource, @@ -4675,7 +4675,7 @@ static void test_clear_render_target_view(void)
ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, &array_colors[i].x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, array_colors[i], 0, NULL); }
transition_resource_state(command_list, resource, @@ -5591,7 +5591,7 @@ static void test_unknown_rtv_format(void) create_render_target(&context, &desc, &render_targets[1], &rtvs[2]);
for (i = 0; i < ARRAY_SIZE(rtvs); ++i) - ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtvs[i], &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtvs[i], (const float *)&white, 0, NULL);
/* NULL RTV */ memset(&rtv_desc, 0, sizeof(rtv_desc)); @@ -13989,7 +13989,7 @@ static void test_gather(void) {0.3f, 1.3f, 1.2f, 0.2f}, {1.3f, 2.3f, 2.2f, 1.2f}, {2.3f, 3.3f, 3.2f, 2.2f}, {3.3f, 3.3f, 3.2f, 3.2f}, {0.3f, 1.3f, 1.3f, 0.3f}, {1.3f, 2.3f, 2.3f, 1.3f}, {2.3f, 3.3f, 3.3f, 2.3f}, {3.3f, 3.3f, 3.3f, 3.3f}, }; - static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f}; + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; static const D3D12_SUBRESOURCE_DATA resource_data = {&texture_data, sizeof(texture_data) / 4};
memset(&desc, 0, sizeof(desc)); @@ -14026,7 +14026,7 @@ static void test_gather(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14064,7 +14064,7 @@ static void test_gather(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4_offset, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14102,7 +14102,7 @@ static void test_gather(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4_green, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14140,7 +14140,7 @@ static void test_gather(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4_po, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14176,7 +14176,7 @@ static void test_gather(void) constants.offset_x = 0; constants.offset_y = 0;
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14310,7 +14310,7 @@ static void test_gather_c(void) {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, }; - static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f}; + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; static const D3D12_SUBRESOURCE_DATA resource_data = {&texture_data, sizeof(texture_data) / 4}; static const D3D12_STATIC_SAMPLER_DESC sampler_desc = { @@ -14366,7 +14366,7 @@ static void test_gather_c(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4_c, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14404,7 +14404,7 @@ static void test_gather_c(void) context.pipeline_state = create_pipeline_state(context.device, context.root_signature, desc.rt_format, NULL, &ps_gather4_po_c, NULL);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -14440,7 +14440,7 @@ static void test_gather_c(void) constants.offset_x = 0; constants.offset_y = 0;
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, &white.x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); @@ -15136,7 +15136,7 @@ static void test_multisample_array_texture(void) }; static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; - static const struct vec4 colors[] = + static const float colors[][4] = { {1.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, @@ -15242,7 +15242,7 @@ static void test_multisample_array_texture(void) rtv_desc.Texture2DMSArray.ArraySize = 1; ID3D12Device_CreateRenderTargetView(device, texture, &rtv_desc, cpu_handle);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, cpu_handle, &colors[i].x, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, cpu_handle, colors[i], 0, NULL); }
transition_resource_state(command_list, texture,
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index e7e6da29..66b28c4f 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -34963,7 +34963,7 @@ static void test_unbounded_resource_arrays(void) upload_buffer_data(constant_buffers[i], 0, sizeof(cb_data), &cb_data, queue, command_list); reset_command_list(command_list, context.allocator); transition_resource_state(command_list, constant_buffers[i], - D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
cbv_desc.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(constant_buffers[i]); cbv_desc.SizeInBytes = align(sizeof(cb_data), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- v2: Use check_buffer_uint() and check_readback_data_uint(). Supersedes 213798. --- tests/d3d12.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 66b28c4f..eac95f69 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -7588,6 +7588,193 @@ static void test_bundle_state_inheritance(void) destroy_test_context(&context); }
+static void test_compute_bundle(void) +{ + ID3D12Resource *cb, *sr_buffer, *root_buffer, *heap_buffer; + ID3D12GraphicsCommandList *command_list, *bundle; + D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc; + ID3D12DescriptorHeap *descriptor_heap; + D3D12_DESCRIPTOR_HEAP_DESC heap_desc; + struct bundle_context bundle_context; + D3D12_BOX box = {0, 0, 0, 1, 1, 1}; + struct test_context_desc desc; + struct test_context context; + struct resource_readback rb; + ID3D12CommandQueue *queue; + ID3D12Device *device; + unsigned int i; + HRESULT hr; + + static const D3D12_DESCRIPTOR_RANGE descriptor_ranges[] = + { + {D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 1, 0, 0}, + }; + + static const D3D12_ROOT_PARAMETER root_parameters[] = + { + {D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + .DescriptorTable = {ARRAY_SIZE(descriptor_ranges), descriptor_ranges}}, + {D3D12_ROOT_PARAMETER_TYPE_CBV, .Descriptor = {0, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_SRV, .Descriptor = {0, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_UAV, .Descriptor = {0, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, .Constants = {1, 0, 3}}, + }; + + static const D3D12_ROOT_SIGNATURE_DESC root_signature_desc = + { + .NumParameters = ARRAY_SIZE(root_parameters), + .pParameters = root_parameters, + }; + + static const DWORD cs_code[] = + { +#if 0 + cbuffer cb0 : register(b0) + { + uint c0; + } + cbuffer cb1 : register(b1) + { + uint3 c1; + } + + ByteAddressBuffer t0 : register(t0); + + RWByteAddressBuffer u0 : register(u0); + RWByteAddressBuffer u1 : register(u1); + + [numthreads(1, 1, 1)] + void main() + { + u0.Store(0, 0xcafef00d); /* Test root UAV. */ + u1.Store(0 * 4, 0xc0ffee); /* Test heap UAV. */ + u1.Store(1 * 4, c0); /* Test CBV. */ + u1.Store(2 * 4, t0.Load(0)); /* Test SRV. */ + u1.Store(3 * 4, c1.x); /* Test setting one root constant. */ + u1.Store(4 * 4, c1.y); /* Test setting multiple root constants. */ + u1.Store(5 * 4, c1.z); /* " */ + } +#endif + 0x43425844, 0xc9916567, 0xbc1d4d84, 0xd66efd25, 0x3095566c, 0x00000001, 0x00000180, 0x00000003, + 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x0000012c, 0x00050050, 0x0000004b, 0x0100086a, + 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000059, 0x00208e46, 0x00000001, 0x00000001, + 0x030000a1, 0x00107000, 0x00000000, 0x0300009d, 0x0011e000, 0x00000000, 0x0300009d, 0x0011e000, + 0x00000001, 0x02000068, 0x00000001, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x070000a6, + 0x0011e012, 0x00000000, 0x00004001, 0x00000000, 0x00004001, 0xcafef00d, 0x890000a5, 0x800002c2, + 0x00199983, 0x00100042, 0x00000000, 0x00004001, 0x00000000, 0x00107006, 0x00000000, 0x05000036, + 0x00100012, 0x00000000, 0x00004001, 0x00c0ffee, 0x06000036, 0x00100022, 0x00000000, 0x0020800a, + 0x00000000, 0x00000000, 0x06000036, 0x00100082, 0x00000000, 0x0020800a, 0x00000001, 0x00000000, + 0x070000a6, 0x0011e0f2, 0x00000001, 0x00004001, 0x00000000, 0x00100e46, 0x00000000, 0x080000a6, + 0x0011e032, 0x00000001, 0x00004001, 0x00000010, 0x00208596, 0x00000001, 0x00000000, 0x0100003e, + }; + static const uint32_t cb_constant = 0x11111111; + static const uint32_t sr_data = 0x22222222; + static const uint32_t root_constants[] = {0x33333333, 0x44444444, 0x55555555}; + + memset(&desc, 0, sizeof(desc)); + desc.no_root_signature = true; + desc.no_render_target = true; + if (!init_test_context(&context, &desc)) + return; + device = context.device; + command_list = context.list; + queue = context.queue; + init_bundle_context(device, &bundle_context); + bundle = bundle_context.list; + + hr = create_root_signature(device, &root_signature_desc, &context.root_signature); + ok(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + + context.pipeline_state = create_compute_pipeline_state(device, context.root_signature, + shader_bytecode(cs_code, sizeof(cs_code))); + + cb = create_upload_buffer(device, sizeof(cb_constant), &cb_constant); + sr_buffer = create_upload_buffer(device, sizeof(sr_data), &sr_data); + root_buffer = create_default_buffer(device, 1 * sizeof(uint32_t), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + heap_buffer = create_default_buffer(device, 6 * sizeof(uint32_t), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + heap_desc.NumDescriptors = 1; + heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + heap_desc.NodeMask = 0; + hr = ID3D12Device_CreateDescriptorHeap(device, &heap_desc, + &IID_ID3D12DescriptorHeap, (void **)&descriptor_heap); + ok(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); + + uav_desc.Format = DXGI_FORMAT_R32_TYPELESS; + uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + uav_desc.Buffer.FirstElement = 0; + uav_desc.Buffer.NumElements = 6; + uav_desc.Buffer.StructureByteStride = 0; + uav_desc.Buffer.CounterOffsetInBytes = 0; + uav_desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW; + ID3D12Device_CreateUnorderedAccessView(device, heap_buffer, NULL, &uav_desc, + ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(descriptor_heap)); + + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &descriptor_heap); + ID3D12GraphicsCommandList_SetComputeRootSignature(bundle, context.root_signature); + /* Setting descriptor heaps in a bundle is valid if the heaps match those + * set in the executing command list. */ + ID3D12GraphicsCommandList_SetDescriptorHeaps(bundle, 1, &descriptor_heap); + ID3D12GraphicsCommandList_SetPipelineState(bundle, context.pipeline_state); + ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(bundle, 0, + ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(descriptor_heap)); + ID3D12GraphicsCommandList_SetComputeRootConstantBufferView(bundle, + 1, ID3D12Resource_GetGPUVirtualAddress(cb)); + ID3D12GraphicsCommandList_SetComputeRootShaderResourceView(bundle, + 2, ID3D12Resource_GetGPUVirtualAddress(sr_buffer)); + ID3D12GraphicsCommandList_SetComputeRootUnorderedAccessView(bundle, + 3, ID3D12Resource_GetGPUVirtualAddress(root_buffer)); + ID3D12GraphicsCommandList_SetComputeRoot32BitConstant(bundle, 4, root_constants[0], 0); + ID3D12GraphicsCommandList_SetComputeRoot32BitConstants(bundle, 4, 2, &root_constants[1], 1); + + ID3D12GraphicsCommandList_Dispatch(bundle, 1, 1, 1); + ID3D12GraphicsCommandList_Close(bundle); + ID3D12GraphicsCommandList_ExecuteBundle(command_list, bundle); + + transition_sub_resource_state(command_list, root_buffer, 0, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + transition_sub_resource_state(command_list, heap_buffer, 0, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + + /* Root UAV was set. */ + todo + check_buffer_uint(root_buffer, queue, command_list, 0xcafef00d, 0); + reset_command_list(command_list, context.allocator); + + get_buffer_readback_with_command_list(heap_buffer, uav_desc.Format, &rb, queue, command_list); + /* Heap UAV was set. */ + todo + check_readback_data_uint(&rb, &box, 0xc0ffee, 0); + /* Root CBV was set. */ + ++box.left; ++box.right; + todo + check_readback_data_uint(&rb, &box, cb_constant, 0); + /* Root SRV was set. */ + ++box.left; ++box.right; + todo + check_readback_data_uint(&rb, &box, sr_data, 0); + /* Root constants were set. */ + for (i = 0; i < ARRAY_SIZE(root_constants); ++i) + { + ++box.left; ++box.right; + todo + check_readback_data_uint(&rb, &box, root_constants[i], 0); + } + release_resource_readback(&rb); + + ID3D12Resource_Release(cb); + ID3D12Resource_Release(root_buffer); + ID3D12Resource_Release(heap_buffer); + ID3D12Resource_Release(sr_buffer); + ID3D12DescriptorHeap_Release(descriptor_heap); + destroy_bundle_context(&bundle_context); + destroy_test_context(&context); +} + static void test_shader_instructions(void) { struct named_shader @@ -35242,6 +35429,7 @@ START_TEST(d3d12) run_test(test_map_resource); run_test(test_map_placed_resources); run_test(test_bundle_state_inheritance); + run_test(test_compute_bundle); run_test(test_shader_instructions); run_test(test_compute_shader_instructions); run_test(test_discard_instruction);
September 9, 2021 2:47 PM, "Conor McCarthy" cmccarthy@codeweavers.com wrote:
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com
v2: Use check_buffer_uint() and check_readback_data_uint(). Supersedes 213798.
Patch 1 in this series is identical to 213797 and it should be applied first.
Not tested: OMSetBlendFactor(), OMSetStencilRef(), and methods not implemented on the vkd3d command list object.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- v2: Use check_sub_resource_uint(). Supersedes 213799. --- tests/d3d12.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index eac95f69..744346e8 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -7775,6 +7775,249 @@ static void test_compute_bundle(void) destroy_test_context(&context); }
+static void test_graphics_bundle(void) +{ + ID3D12Resource *cb, *sr_buffer, *root_buffer, *heap_buffer, *vb, *ib; + ID3D12GraphicsCommandList *command_list, *bundle; + D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc; + ID3D12DescriptorHeap *descriptor_heap; + D3D12_DESCRIPTOR_HEAP_DESC heap_desc; + D3D12_INPUT_LAYOUT_DESC input_layout; + struct bundle_context bundle_context; + struct test_context_desc desc; + D3D12_VERTEX_BUFFER_VIEW vbv; + struct test_context context; + D3D12_INDEX_BUFFER_VIEW ibv; + ID3D12CommandQueue *queue; + ID3D12Device *device; + HRESULT hr; + + static const D3D12_DESCRIPTOR_RANGE descriptor_ranges[] = + { + {D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 2, 0, 0}, + }; + + static const D3D12_ROOT_PARAMETER root_parameters[] = + { + {D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + .DescriptorTable = {ARRAY_SIZE(descriptor_ranges), descriptor_ranges}}, + {D3D12_ROOT_PARAMETER_TYPE_CBV, .Descriptor = {0, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_SRV, .Descriptor = {0, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_UAV, .Descriptor = {1, 0}}, + {D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, .Constants = {1, 0, 3}}, + }; + + static const D3D12_ROOT_SIGNATURE_DESC root_signature_desc = + { + .NumParameters = ARRAY_SIZE(root_parameters), + .pParameters = root_parameters, + .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, + }; + + static const DWORD vs_code[] = + { +#if 0 + void main(float4 in_position : POSITION, out float4 out_position : SV_POSITION) + { + out_position = in_position; + } +#endif + 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040, + 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)}; + static const DWORD ps_code[] = + { +#if 0 + cbuffer cb0 : register(b0) + { + uint c0; + } + cbuffer cb1 : register(b1) + { + uint3 c1; + } + + ByteAddressBuffer t0 : register(t0); + + RWByteAddressBuffer u1 : register(u1); + RWByteAddressBuffer u2 : register(u2); + + void main(out float4 target : SV_Target0) + { + target = float4(1.0f, 1.0f, 1.0f, 1.0f); + if (c0 != 0x11111111) /* Test CBV. */ + target.x = 0.0f; + if (t0.Load(0) != 0x22222222) /* Test SRV. */ + target.x = 0.0f; + if (u1.Load(0) != 0xcafef00d) /* Test root UAV. */ + target.x = 0.0f; + if (u2.Load(0) != 0xc0ffee) /* Test heap UAV. */ + target.y = 0.0f; + if (c1.x != 0x33333333) /* Test setting one root constant. */ + target.z = 0.0f; + if (c1.z != 0x55555555) /* Test setting multiple root constants. */ + target.w = 0.0f; + } +#endif + 0x43425844, 0x01abdf56, 0xb7ffa3e4, 0x356ba2d5, 0xdc1e8864, 0x00000001, 0x000002a8, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000230, 0x00000050, 0x0000008c, + 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000059, 0x00208e46, 0x00000001, + 0x00000001, 0x030000a1, 0x00107000, 0x00000000, 0x0300009d, 0x0011e000, 0x00000001, 0x0300009d, + 0x0011e000, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x890000a5, + 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x00107006, 0x00000000, + 0x07000027, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x22222222, 0x08000027, + 0x00100022, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x11111111, 0x0700003c, + 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000, 0x890000a5, 0x800002c2, + 0x00199983, 0x00100022, 0x00000000, 0x00004001, 0x00000000, 0x0011e006, 0x00000001, 0x07000027, + 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0xcafef00d, 0x0700003c, 0x00100012, + 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x09000037, 0x00102012, 0x00000000, + 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004001, 0x3f800000, 0x890000a5, 0x800002c2, + 0x00199983, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x0011e006, 0x00000002, 0x07000027, + 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00c0ffee, 0x09000037, 0x00102022, + 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x00004001, 0x3f800000, 0x0b000027, + 0x00100032, 0x00000000, 0x00208086, 0x00000001, 0x00000000, 0x00004002, 0x33333333, 0x55555555, + 0x00000000, 0x00000000, 0x0f000037, 0x001020c2, 0x00000000, 0x00100406, 0x00000000, 0x00004002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, + 0x3f800000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + + static const D3D12_INPUT_ELEMENT_DESC layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + }; + static const struct vec4 vertices[] = + { + {-1.0f, 1.0f, 0.00f, 1.00f}, + {-1.0f, 1.0f, 0.00f, 1.00f}, + { 3.0f, 1.0f, 0.00f, 1.00f}, + {-1.0f, -3.0f, 0.00f, 1.00f}, + }; + static const uint16_t indices[] = {0, 0, 1, 2}; + + static const float grey[] = {0.5f, 0.5f, 0.5f, 0.5f}; + static const uint32_t root_ua_data = 0xcafef00d; + static const uint32_t heap_ua_data = 0xc0ffee; + static const uint32_t cb_constant = 0x11111111; + static const uint32_t sr_data = 0x22222222; + static const uint32_t root_constants[] = {0x33333333, 0x44444444, 0x55555555}; + + memset(&desc, 0, sizeof(desc)); + desc.no_root_signature = true; + desc.no_pipeline = true; + if (!init_test_context(&context, &desc)) + return; + device = context.device; + command_list = context.list; + queue = context.queue; + init_bundle_context(device, &bundle_context); + bundle = bundle_context.list; + + hr = create_root_signature(device, &root_signature_desc, &context.root_signature); + ok(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + + input_layout.pInputElementDescs = layout_desc; + input_layout.NumElements = ARRAY_SIZE(layout_desc); + context.pipeline_state = create_pipeline_state(device, + context.root_signature, context.render_target_desc.Format, &vs, &ps, &input_layout); + + cb = create_upload_buffer(device, sizeof(cb_constant), &cb_constant); + sr_buffer = create_upload_buffer(device, sizeof(sr_data), &sr_data); + + root_buffer = create_default_buffer(device, sizeof(root_ua_data), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST); + upload_buffer_data(root_buffer, 0, sizeof(root_ua_data), &root_ua_data, queue, command_list); + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, root_buffer, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + heap_buffer = create_default_buffer(device, sizeof(heap_ua_data), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST); + upload_buffer_data(heap_buffer, 0, sizeof(heap_ua_data), &heap_ua_data, queue, command_list); + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, heap_buffer, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + heap_desc.NumDescriptors = 1; + heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + heap_desc.NodeMask = 0; + hr = ID3D12Device_CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, (void **)&descriptor_heap); + ok(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); + + uav_desc.Format = DXGI_FORMAT_R32_TYPELESS; + uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + uav_desc.Buffer.FirstElement = 0; + uav_desc.Buffer.NumElements = 1; + uav_desc.Buffer.StructureByteStride = 0; + uav_desc.Buffer.CounterOffsetInBytes = 0; + uav_desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW; + ID3D12Device_CreateUnorderedAccessView(device, heap_buffer, NULL, &uav_desc, + ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(descriptor_heap)); + + vb = create_upload_buffer(context.device, sizeof(vertices), vertices); + vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb); + vbv.StrideInBytes = sizeof(*vertices); + vbv.SizeInBytes = sizeof(vertices); + + ib = create_upload_buffer(device, sizeof(indices), indices); + ibv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(ib); + ibv.SizeInBytes = sizeof(indices); + ibv.Format = DXGI_FORMAT_R16_UINT; + + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, grey, 0, NULL); + + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &descriptor_heap); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(bundle, context.root_signature); + /* Setting descriptor heaps in a bundle is valid if the heaps match those + * set in the executing command list. */ + ID3D12GraphicsCommandList_SetDescriptorHeaps(bundle, 1, &descriptor_heap); + ID3D12GraphicsCommandList_SetPipelineState(bundle, context.pipeline_state); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(bundle, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_IASetVertexBuffers(bundle, 0, 1, &vbv); + ID3D12GraphicsCommandList_IASetIndexBuffer(bundle, &ibv); + ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(bundle, 0, + ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(descriptor_heap)); + ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(bundle, + 1, ID3D12Resource_GetGPUVirtualAddress(cb)); + ID3D12GraphicsCommandList_SetGraphicsRootShaderResourceView(bundle, + 2, ID3D12Resource_GetGPUVirtualAddress(sr_buffer)); + ID3D12GraphicsCommandList_SetGraphicsRootUnorderedAccessView(bundle, + 3, ID3D12Resource_GetGPUVirtualAddress(root_buffer)); + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstant(bundle, 4, root_constants[0], 0); + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(bundle, 4, 2, &root_constants[1], 1); + ID3D12GraphicsCommandList_DrawIndexedInstanced(bundle, 3, 1, 1, 1, 0); + ID3D12GraphicsCommandList_Close(bundle); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + ID3D12GraphicsCommandList_ExecuteBundle(command_list, bundle); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + todo + check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xffffffff, 0); + + ID3D12Resource_Release(cb); + ID3D12Resource_Release(root_buffer); + ID3D12Resource_Release(heap_buffer); + ID3D12Resource_Release(sr_buffer); + ID3D12Resource_Release(vb); + ID3D12Resource_Release(ib); + ID3D12DescriptorHeap_Release(descriptor_heap); + destroy_bundle_context(&bundle_context); + destroy_test_context(&context); +} + static void test_shader_instructions(void) { struct named_shader @@ -35430,6 +35673,7 @@ START_TEST(d3d12) run_test(test_map_placed_resources); run_test(test_bundle_state_inheritance); run_test(test_compute_bundle); + run_test(test_graphics_bundle); run_test(test_shader_instructions); run_test(test_compute_shader_instructions); run_test(test_discard_instruction);