From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- tests/d3d12.c | 124 ++++++++++++++++++------------------ tests/d3d12_test_utils.h | 94 +++++++++++++++------------ tests/hlsl_d3d12.c | 6 +- tests/shader_runner_d3d12.c | 31 ++++++++- 4 files changed, 146 insertions(+), 109 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 23e1e97c..307e57f1 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -271,13 +271,13 @@ static const struct uvec4 *get_readback_uvec4(struct resource_readback *rb, unsi }
#define check_sub_resource_float(a, b, c, d, e, f) check_sub_resource_float_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_float_(unsigned int line, ID3D12Resource *texture, +static void check_sub_resource_float_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, float expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_float_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } @@ -312,13 +312,13 @@ static void check_readback_data_uint8_(unsigned int line, struct resource_readba }
#define check_sub_resource_uint8(a, b, c, d, e, f) check_sub_resource_uint8_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint8_(unsigned int line, ID3D12Resource *texture, +static void check_sub_resource_uint8_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint8_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_uint8_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } @@ -353,13 +353,13 @@ static void check_readback_data_uint16_(unsigned int line, struct resource_readb }
#define check_sub_resource_uint16(a, b, c, d, e, f) check_sub_resource_uint16_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *texture, +static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint16_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_uint16_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } @@ -394,19 +394,19 @@ static void check_readback_data_uint64_(unsigned int line, struct resource_readb }
#define check_sub_resource_uint64(a, b, c, d, e, f) check_sub_resource_uint64_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *texture, +static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint64_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_uint64_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); }
#define check_sub_resource_uvec4(a, b, c, d, e) check_sub_resource_uvec4_(__LINE__, a, b, c, d, e) -static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *texture, +static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, const struct uvec4 *expected_value) { @@ -415,7 +415,7 @@ static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *texture unsigned int x = 0, y; bool all_match = true;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -4762,7 +4762,7 @@ static void test_clear_render_target_view(void) ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, green, 0, NULL); transition_resource_state(command_list, resource, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 32, 32, 2); check_readback_data_uint(&rb.rb, &box, 0xbf4c7f19, 1); set_box(&box, 0, 0, 2, 32, 32, 4); @@ -4781,7 +4781,7 @@ static void test_clear_render_target_view(void) ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, green, 0, NULL); transition_resource_state(command_list, resource, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, 0, &rb, queue, command_list); set_box(&box, 0, 0, 4, 32, 32, 30); check_readback_data_uint(&rb.rb, &box, 0xbf4c7f19, 1); set_box(&box, 0, 0, 30, 32, 32, 32); @@ -5221,7 +5221,7 @@ static void test_clear_unordered_access_view_image(void)
for (layer = 0; layer < tests[i].image_layers / image_depth; ++layer) { - get_texture_readback_with_command_list(texture, + get_resource_readback_with_command_list(texture, tests[i].mip_level + (layer * tests[i].image_mips), &rb, queue, command_list);
@@ -6092,7 +6092,7 @@ static void test_append_aligned_element(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); color = get_readback_uint(&rb.rb, 80, 16, 0); ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); color = get_readback_uint(&rb.rb, 240, 16, 0); @@ -6370,7 +6370,7 @@ static void test_fragment_coords(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); all_match = true; for (y = 0; y < rb.rb.height; ++y) { @@ -6532,7 +6532,7 @@ static void test_fractional_viewports(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -6611,7 +6611,7 @@ static void test_scissor(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); color = get_readback_uint(&rb.rb, 320, 60, 0); ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); color = get_readback_uint(&rb.rb, 80, 240, 0); @@ -6848,7 +6848,7 @@ static void test_draw_depth_only(void) } transition_resource_state(command_list, ds.texture, D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(ds.texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(ds.texture, 0, &rb, queue, command_list); for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) @@ -7498,7 +7498,7 @@ static void test_bundle_state_inheritance(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -7535,7 +7535,7 @@ static void test_bundle_state_inheritance(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -13505,7 +13505,7 @@ static void test_sample_instructions(void)
x_step = desc.rt_width / tests[i].texture->width; y_step = desc.rt_height / tests[i].texture->height; - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < tests[i].texture->height; ++y) { for (x = 0; x < tests[i].texture->width; ++x) @@ -13957,7 +13957,7 @@ static void test_gather(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -13995,7 +13995,7 @@ static void test_gather(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14033,7 +14033,7 @@ static void test_gather(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14071,7 +14071,7 @@ static void test_gather(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14107,7 +14107,7 @@ static void test_gather(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14297,7 +14297,7 @@ static void test_gather_c(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14335,7 +14335,7 @@ static void test_gather_c(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14371,7 +14371,7 @@ static void test_gather_c(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < rb.rb.height; ++y) { for (x = 0; x < rb.rb.width; ++x) @@ -14804,7 +14804,7 @@ static void test_sample_c_lz(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); /* Avoid testing values affected by seamless cube map filtering. */ set_rect(&rect, 100, 100, 540, 380); check_readback_data_float(&rb.rb, &rect, tests[i].expected, 2); @@ -14856,7 +14856,7 @@ static void test_sample_c_lz(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); /* Avoid testing values affected by seamless cube map filtering. */ set_rect(&rect, 100, 100, 540, 380); check_readback_data_float(&rb.rb, &rect, tests[i].expected, 2); @@ -16704,7 +16704,7 @@ static void test_update_descriptor_tables(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 16, 32, 1); check_readback_data_uint(&rb.rb, &box, 0xff00407f, 1); set_box(&box, 16, 0, 0, 32, 32, 1); @@ -16837,7 +16837,7 @@ static void test_update_descriptor_heap_after_closing_command_list(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); value = get_readback_uint(&rb.rb, 0, 0, 0); todo_if(binding_tier < D3D12_RESOURCE_BINDING_TIER_3) ok(value == 0xff00ff00, "Got unexpected value %#x.\n", value); @@ -18329,7 +18329,7 @@ static void test_copy_descriptors_range_sizes(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (i = 0; i < desc.rt_width; ++i) { set_box(&box, i, 0, 0, i + 1, desc.rt_height, 1); @@ -22170,7 +22170,7 @@ static void test_uav_load(void) transition_sub_resource_state(command_list, rt_texture, 0, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(rt_texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(rt_texture, 0, &rb, queue, command_list); for (y = 0; y < 4; ++y) { for (x = 0; x < 4; ++x) @@ -22520,7 +22520,7 @@ static void test_cs_uav_store(void)
transition_sub_resource_state(command_list, resource, 0, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, 0, &rb, queue, command_list); set_rect(&rect, 0, 0, 16, 32); check_readback_data_float(&rb.rb, &rect, 0.5f, 2); set_rect(&rect, 0, 32, rb.rb.width, rb.rb.height); @@ -22550,7 +22550,7 @@ static void test_cs_uav_store(void)
transition_sub_resource_state(command_list, resource, 0, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, 0, &rb, queue, command_list); set_rect(&rect, 0, 0, 60, 60); check_readback_data_float(&rb.rb, &rect, 0.6f, 2); set_rect(&rect, 0, 60, rb.rb.width, rb.rb.height); @@ -23720,7 +23720,7 @@ static void test_buffer_srv(void) transition_sub_resource_state(command_list, context.render_target, 0, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (y = 0; y < 4; ++y) { for (x = 0; x < 4; ++x) @@ -24598,7 +24598,7 @@ static void test_execute_indirect(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 32, 8, 1); check_readback_data_uint(&rb.rb, &box, 0xffffff00, 0); set_box(&box, 24, 8, 0, 32, 32, 1); @@ -25184,14 +25184,14 @@ static void test_instance_id(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); for (j = 0; j < ARRAY_SIZE(expected_results); ++j) check_readback_data_uint(&rb.rb, &expected_results[j].box, tests[i].expected_colors[j], 1); release_resource_readback(&rb); reset_command_list(command_list, context.allocator); transition_resource_state(command_list, render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(render_target, 0, &rb, queue, command_list); for (j = 0; j < ARRAY_SIZE(expected_results); ++j) check_readback_data_uint(&rb.rb, &expected_results[j].box, expected_results[j].instance_id, 0); release_resource_readback(&rb); @@ -25618,7 +25618,7 @@ static void test_copy_texture(void)
transition_resource_state(command_list, dst_texture, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); for (y = 0; y < 4; ++y) { for (x = 0; x < 4; ++x) @@ -25988,7 +25988,7 @@ static void test_copy_buffer_texture(void) D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
got = expected = 0; - get_texture_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); for (z = 0; z < 64; ++z) { for (y = 0; y < 100; ++y) @@ -26020,7 +26020,7 @@ static void test_copy_buffer_texture(void)
reset_command_list(command_list, context.allocator); got = expected = 0; - get_texture_readback_with_command_list(dst_texture, 1, &rb, queue, command_list); + get_resource_readback_with_command_list(dst_texture, 1, &rb, queue, command_list); for (z = 0; z < 32; ++z) { for (y = 0; y < 50; ++y) @@ -26163,7 +26163,7 @@ static void test_copy_block_compressed_texture(void) transition_resource_state(command_list, dst_buffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(texture, 0, &rb, queue, command_list); for (y = 0; y < 8 / format_block_height(DXGI_FORMAT_BC2_UNORM); ++y) { for (x = 0; x < 8 / format_block_width(DXGI_FORMAT_BC2_UNORM); ++x) @@ -26195,7 +26195,7 @@ static void test_copy_block_compressed_texture(void) got.x, got.y, got.z, got.w, x, y, expected.x, expected.y, expected.z, expected.w);
reset_command_list(command_list, context.allocator); - get_texture_readback_with_command_list(texture, 2, &rb, queue, command_list); + get_resource_readback_with_command_list(texture, 2, &rb, queue, command_list); block_id = 1; expected.x = block_id << 8 | 0; expected.y = block_id << 8 | 1; @@ -26208,7 +26208,7 @@ static void test_copy_block_compressed_texture(void) got.x, got.y, got.z, got.w, expected.x, expected.y, expected.z, expected.w);
reset_command_list(command_list, context.allocator); - get_texture_readback_with_command_list(texture, 3, &rb, queue, command_list); + get_resource_readback_with_command_list(texture, 3, &rb, queue, command_list); block_id = 2; expected.x = block_id << 8 | 0; expected.y = block_id << 8 | 1; @@ -27175,7 +27175,7 @@ static void test_geometry_shader(void) transition_resource_state(command_list, texture, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); color = get_readback_uint(&rb.rb, 320, 190, 0); ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); color = get_readback_uint(&rb.rb, 255, 240, 0); @@ -27189,7 +27189,7 @@ static void test_geometry_shader(void) release_resource_readback(&rb);
reset_command_list(command_list, context.allocator); - get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(texture, 0, &rb, queue, command_list); color = get_readback_uint(&rb.rb, 320, 190, 0); ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); color = get_readback_uint(&rb.rb, 255, 240, 0); @@ -30216,7 +30216,7 @@ static void check_clip_distance(struct test_context *context, ID3D12PipelineStat ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0); transition_resource_state(command_list, context->render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context->render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context->render_target, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 320, 480, 1); check_readback_data_uint(&rb.rb, &box, 0xff00ff00, 1); set_box(&box, 320, 0, 0, 320, 480, 1); @@ -30249,7 +30249,7 @@ static void check_clip_distance(struct test_context *context, ID3D12PipelineStat ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0); transition_resource_state(command_list, context->render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context->render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context->render_target, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 640, 240, 1); check_readback_data_uint(&rb.rb, &box, 0xff00ff00, 0); set_box(&box, 0, 240, 0, 640, 240, 1); @@ -30890,7 +30890,7 @@ static void test_clip_distance(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, 320, 240, 1); check_readback_data_uint(&rb.rb, &box, 0xff00ff00, 1); set_box(&box, 0, 240, 0, 320, 480, 1); @@ -31149,7 +31149,7 @@ static void test_combined_clip_and_cull_distances(void) } else { - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); color = get_readback_uint(&rb.rb, 160, 240, 0); ok(color == expected_color[0], "Got unexpected color 0x%08x.\n", color); color = get_readback_uint(&rb.rb, 480, 240, 0); @@ -31435,7 +31435,7 @@ static void test_64kb_texture_alignment(void) reset_command_list(command_list, context.allocator); transition_resource_state(command_list, textures[1], D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(textures[1], 0, &rb, queue, command_list); + get_resource_readback_with_command_list(textures[1], 0, &rb, queue, command_list); set_box(&box, 0, 0, 0, resource_desc.Width, resource_desc.Height, 1); check_readback_data_uint(&rb.rb, &box, 0xcafef00d, 0); release_resource_readback(&rb); @@ -31448,7 +31448,7 @@ static void test_64kb_texture_alignment(void)
/* If the heap could not be used, the texture is not aliased. */ reset_command_list(command_list, context.allocator); - get_texture_readback_with_command_list(textures[1], 0, &rb, queue, command_list); + get_resource_readback_with_command_list(textures[1], 0, &rb, queue, command_list); check_readback_data_uint(&rb.rb, &box, 0xdeadbeef, 0); release_resource_readback(&rb);
@@ -32533,7 +32533,7 @@ static void test_shader_sample_position(void) transition_resource_state(command_list, readback_texture, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(readback_texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(readback_texture, 0, &rb, queue, command_list); for (i = 0; i < resource_desc.SampleDesc.Count; ++i) { const struct vec4 *position = get_readback_vec4(&rb.rb, i, 0); @@ -32885,7 +32885,7 @@ static void test_primitive_restart(void)
transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); if (tests[i].full_quad) { todo_if(tests[i].is_todo) @@ -33250,7 +33250,7 @@ static void test_read_write_subresource(void)
transition_resource_state(command_list, dst_texture, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(dst_texture, 0, &rb, queue, command_list); for (z = 0; z < 64; ++z) { for (y = 0; y < 100; ++y) @@ -34062,7 +34062,7 @@ static void test_conditional_rendering(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); bug_if(is_radv_device(context.device)) todo check_readback_data_uint(&rb.rb, NULL, 0xffffffff, 0); release_resource_readback(&rb); @@ -34115,7 +34115,7 @@ static void test_conditional_rendering(void) transition_resource_state(command_list, context.render_target, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); todo check_readback_data_uint(&rb.rb, NULL, 0xffffffff, 0); release_resource_readback(&rb); reset_command_list(command_list, context.allocator); @@ -34232,7 +34232,7 @@ static void test_conditional_rendering(void) transition_resource_state(command_list, texture_copy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(texture_copy, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(texture_copy, 0, &rb, queue, command_list); todo check_readback_data_uint(&rb.rb, NULL, r8g8b8a8_data[1], 0); release_resource_readback(&rb);
@@ -34297,7 +34297,7 @@ static void test_conditional_rendering(void) transition_resource_state(command_list, texture_copy, D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_texture_readback_with_command_list(texture_copy, 0, &rb, queue, command_list); + get_resource_readback_with_command_list(texture_copy, 0, &rb, queue, command_list); bug_if(is_radv_device(context.device)) todo check_readback_data_uint(&rb.rb, NULL, r8g8b8a8_data[1], 0); release_resource_readback(&rb); diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index b6a99d43..be759f5d 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -417,10 +417,9 @@ struct d3d12_resource_readback ID3D12Resource *resource; };
-static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsigned int sub_resource, +static void get_resource_readback_with_command_list(ID3D12Resource *resource, unsigned int sub_resource, struct d3d12_resource_readback *rb, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list) { - D3D12_TEXTURE_COPY_LOCATION dst_location, src_location; D3D12_HEAP_PROPERTIES heap_properties; D3D12_RESOURCE_DESC resource_desc; ID3D12Resource *src_resource; @@ -430,12 +429,10 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi uint64_t buffer_size; HRESULT hr;
- hr = ID3D12Resource_GetDevice(texture, &IID_ID3D12Device, (void **)&device); + hr = ID3D12Resource_GetDevice(resource, &IID_ID3D12Device, (void **)&device); assert_that(hr == S_OK, "Failed to get device, hr %#x.\n", hr);
- resource_desc = ID3D12Resource_GetDesc(texture); - assert_that(resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER, - "Resource %p is not texture.\n", texture); + resource_desc = ID3D12Resource_GetDesc(resource);
miplevel = sub_resource % resource_desc.MipLevels; rb->rb.width = max(1, resource_desc.Width >> miplevel); @@ -444,10 +441,13 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi rb->rb.height = align(rb->rb.height, format_block_height(resource_desc.Format)); rb->rb.depth = resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? max(1, resource_desc.DepthOrArraySize >> miplevel) : 1; - rb->rb.row_pitch = align(rb->rb.width * format_size(resource_desc.Format), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); + rb->rb.row_pitch = rb->rb.width * format_size(resource_desc.Format); + if (resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) + rb->rb.row_pitch = align(rb->rb.row_pitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); rb->rb.data = NULL;
- if (resource_desc.SampleDesc.Count > 1) + src_resource = resource; + if (resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && resource_desc.SampleDesc.Count > 1) { memset(&heap_properties, 0, sizeof(heap_properties)); heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT; @@ -462,34 +462,39 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi assert_that(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
ID3D12GraphicsCommandList_ResolveSubresource(command_list, - src_resource, 0, texture, sub_resource, resource_desc.Format); + src_resource, 0, resource, sub_resource, resource_desc.Format); transition_resource_state(command_list, src_resource, D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
sub_resource = 0; } - else - { - src_resource = texture; - }
buffer_size = rb->rb.row_pitch * rb->rb.height * rb->rb.depth; rb->resource = create_readback_buffer(device, buffer_size);
- dst_location.pResource = rb->resource; - dst_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - dst_location.PlacedFootprint.Offset = 0; - dst_location.PlacedFootprint.Footprint.Format = resource_desc.Format; - dst_location.PlacedFootprint.Footprint.Width = rb->rb.width; - dst_location.PlacedFootprint.Footprint.Height = rb->rb.height; - dst_location.PlacedFootprint.Footprint.Depth = rb->rb.depth; - dst_location.PlacedFootprint.Footprint.RowPitch = rb->rb.row_pitch; - - src_location.pResource = src_resource; - src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - src_location.SubresourceIndex = sub_resource; - - ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, 0, 0, 0, &src_location, NULL); + if (resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) + { + ID3D12GraphicsCommandList_CopyResource(command_list, rb->resource, resource); + } + else + { + D3D12_TEXTURE_COPY_LOCATION dst_location, src_location; + + dst_location.pResource = rb->resource; + dst_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + dst_location.PlacedFootprint.Offset = 0; + dst_location.PlacedFootprint.Footprint.Format = resource_desc.Format; + dst_location.PlacedFootprint.Footprint.Width = rb->rb.width; + dst_location.PlacedFootprint.Footprint.Height = rb->rb.height; + dst_location.PlacedFootprint.Footprint.Depth = rb->rb.depth; + dst_location.PlacedFootprint.Footprint.RowPitch = rb->rb.row_pitch; + + src_location.pResource = src_resource; + src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + src_location.SubresourceIndex = sub_resource; + + ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, 0, 0, 0, &src_location, NULL); + } hr = ID3D12GraphicsCommandList_Close(command_list); assert_that(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
@@ -497,7 +502,7 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi wait_queue_idle(device, queue); ID3D12Device_Release(device);
- if (src_resource != texture) + if (src_resource != resource) ID3D12Resource_Release(src_resource);
read_range.Begin = 0; @@ -554,25 +559,25 @@ static void check_readback_data_uint_(unsigned int line, struct resource_readbac }
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f) -static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture, +static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, unsigned int expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_uint_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); }
#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f) -static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture, +static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, const struct vec4 *expected, unsigned int max_diff) { struct d3d12_resource_readback rb;
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); + get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); check_readback_data_vec4_(line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } @@ -696,18 +701,25 @@ static inline void upload_texture_data_(unsigned int line, ID3D12Resource *textu } ID3D12Resource_Unmap(upload_buffer, 0, NULL);
- for (i = 0; i < sub_resource_count; ++i) + if (resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { - dst_location.pResource = texture; - dst_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - dst_location.SubresourceIndex = i; + ID3D12GraphicsCommandList_CopyResource(command_list, texture, upload_buffer); + } + else + { + for (i = 0; i < sub_resource_count; ++i) + { + dst_location.pResource = texture; + dst_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + dst_location.SubresourceIndex = i;
- src_location.pResource = upload_buffer; - src_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - src_location.PlacedFootprint = layouts[i]; + src_location.pResource = upload_buffer; + src_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + src_location.PlacedFootprint = layouts[i];
- ID3D12GraphicsCommandList_CopyTextureRegion(command_list, - &dst_location, 0, 0, 0, &src_location, NULL); + ID3D12GraphicsCommandList_CopyTextureRegion(command_list, + &dst_location, 0, 0, 0, &src_location, NULL); + } }
hr = ID3D12GraphicsCommandList_Close(command_list); diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 16624024..85a1548f 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -502,7 +502,7 @@ static void test_thread_id(void)
transition_resource_state(command_list, textures[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(textures[0], 0, &rb, context.queue, command_list); + get_resource_readback_with_command_list(textures[0], 0, &rb, context.queue, command_list); for (x = 0; x < 16; ++x) { for (y = 0; y < 8; ++y) @@ -525,7 +525,7 @@ static void test_thread_id(void)
transition_resource_state(command_list, textures[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(textures[1], 0, &rb, context.queue, command_list); + get_resource_readback_with_command_list(textures[1], 0, &rb, context.queue, command_list); for (x = 0; x < 16; ++x) { for (y = 0; y < 8; ++y) @@ -548,7 +548,7 @@ static void test_thread_id(void)
transition_resource_state(command_list, textures[2], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(textures[2], 0, &rb, context.queue, command_list); + get_resource_readback_with_command_list(textures[2], 0, &rb, context.queue, command_list); for (x = 0; x < 16; ++x) { for (y = 0; y < 8; ++y) diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 7d9d1cd2..1a0d30fa 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -145,7 +145,6 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co break;
case RESOURCE_TYPE_UAV: - case RESOURCE_TYPE_BUFFER_UAV: if (!runner->heap) runner->heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS); @@ -161,6 +160,30 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co NULL, NULL, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES)); break;
+ case RESOURCE_TYPE_BUFFER_UAV: + { + D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc = { 0 }; + + if (!runner->heap) + runner->heap = create_gpu_descriptor_heap(device, + D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS); + + resource->resource = create_default_buffer(device, params->width * params->height * 4 * sizeof(float), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST); + upload_texture_data(resource->resource, resource_data, + params->level_count, test_context->queue, test_context->list); + reset_command_list(test_context->list, test_context->allocator); + transition_resource_state(test_context->list, resource->resource, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + + uav_desc.Format = params->format; + uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + uav_desc.Buffer.NumElements = params->width * params->height; + + ID3D12Device_CreateUnorderedAccessView(device, resource->resource, + NULL, &uav_desc, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES)); + break; + } case RESOURCE_TYPE_VERTEX_BUFFER: resource->resource = create_upload_buffer(device, params->data_size, params->data); break; @@ -224,7 +247,7 @@ static ID3D12RootSignature *d3d12_runner_create_root_signature(struct d3d12_shad root_param->DescriptorTable.pDescriptorRanges = range; root_param->ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
- if (resource->r.type == RESOURCE_TYPE_UAV) + if (resource->r.type == RESOURCE_TYPE_UAV || resource->r.type == RESOURCE_TYPE_BUFFER_UAV) range->RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; else range->RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; @@ -432,6 +455,8 @@ static bool d3d12_runner_draw(struct shader_runner *r, if (runner->r.uniform_count) ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, uniform_index, runner->r.uniform_count, runner->r.uniforms, 0); + if (runner->heap) + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &runner->heap); for (i = 0; i < runner->r.resource_count; ++i) { struct d3d12_resource *resource = d3d12_resource(runner->r.resources[i]); @@ -498,7 +523,7 @@ static struct resource_readback *d3d12_runner_get_resource_readback(struct shade
transition_resource_state(test_context->list, resource->resource, state, D3D12_RESOURCE_STATE_COPY_SOURCE); - get_texture_readback_with_command_list(resource->resource, 0, rb, + get_resource_readback_with_command_list(resource->resource, 0, rb, test_context->queue, test_context->list); reset_command_list(test_context->list, test_context->allocator); transition_resource_state(test_context->list, resource->resource,