Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- tests/d3d12.c | 131 +++++++++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 50 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index a7647e0..6d2040d 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -30180,6 +30180,29 @@ static void test_vertex_shader_stream_output(void) destroy_test_context(&context); }
+static void write_subresource_test_data(unsigned int *dst_buffer) +{ + unsigned int x, y, z; + unsigned int *ptr; + + for (z = 0; z < 64; ++z) + { + for (y = 0; y < 100; ++y) + { + for (x = 0; x < 128; ++x) + { + ptr = &dst_buffer[z * 128 * 100 + y * 128 + x]; + if (x < 2 && y< 2 && z < 2) /* Region 1 */ + *ptr = (z + 1) << 16 | (y + 1) << 8 | (x + 1); + else if (2 <= x && x < 11 && 2 <= y && y < 13 && 2 <= z && z < 17) /* Region 2 */ + *ptr = (z + 2) << 16 | (y + 2) << 8 | (x + 2); + else + *ptr = 0xdeadbeef; + } + } + } +} + static void test_read_write_subresource(void) { D3D12_TEXTURE_COPY_LOCATION src_location, dst_location; @@ -30201,9 +30224,9 @@ static void test_read_write_subresource(void) unsigned int row_pitch; unsigned int x, y, z; ID3D12Device *device; - unsigned int *ptr; D3D12_BOX box; HRESULT hr; + int i;
memset(&desc, 0, sizeof(desc)); desc.no_render_target = true; @@ -30271,71 +30294,79 @@ static void test_read_write_subresource(void) hr = ID3D12Resource_ReadFromSubresource(src_texture, dst_buffer, row_pitch, slice_pitch, 0, &box); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- for (z = 0; z < 64; ++z) + for (i = 0; i < 2; ++i) { - for (y = 0; y < 100; ++y) - { - for (x = 0; x < 128; ++x) - { - ptr = &dst_buffer[z * 128 * 100 + y * 128 + x]; - if (x < 2 && y< 2 && z < 2) /* Region 1 */ - *ptr = (z + 1) << 16 | (y + 1) << 8 | (x + 1); - else if (2 <= x && x < 11 && 2 <= y && y < 13 && 2 <= z && z < 17) /* Region 2 */ - *ptr = (z + 2) << 16 | (y + 2) << 8 | (x + 2); - else - *ptr = 0xdeadbeef; - } - } - } + vkd3d_test_set_context("Test %u", i);
- /* Write region 1 */ - set_box(&box, 0, 0, 0, 2, 2, 2); - hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, dst_buffer, row_pitch, slice_pitch); - todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + write_subresource_test_data(dst_buffer);
- /* Write region 2 */ - set_box(&box, 2, 2, 2, 11, 13, 17); - hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2], - row_pitch, slice_pitch); - todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + if (!i) + { + /* Write region 1 */ + set_box(&box, 0, 0, 0, 2, 2, 2); + hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, dst_buffer, row_pitch, slice_pitch); + todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- memset(dst_buffer, 0, buffer_size); + /* Write region 2 */ + set_box(&box, 2, 2, 2, 11, 13, 17); + hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2], + row_pitch, slice_pitch); + todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + } + else + { + /* Upload the test data */ + transition_resource_state(command_list, src_texture, + D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_COPY_DEST); + texture_data.pData = dst_buffer; + texture_data.RowPitch = row_pitch; + texture_data.SlicePitch = slice_pitch; + upload_texture_data(src_texture, &texture_data, 1, queue, command_list); + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, src_texture, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COMMON); + }
- /* Read region 1 */ - set_box(&box, 0, 0, 0, 2, 2, 2); - hr = ID3D12Resource_ReadFromSubresource(src_texture, dst_buffer, row_pitch, slice_pitch, 0, &box); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + memset(dst_buffer, 0, buffer_size);
- /* Read region 2 */ - set_box(&box, 2, 2, 2, 11, 13, 17); - hr = ID3D12Resource_ReadFromSubresource(src_texture, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2], row_pitch, - slice_pitch, 0, &box); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + /* Read region 1 */ + set_box(&box, 0, 0, 0, 2, 2, 2); + hr = ID3D12Resource_ReadFromSubresource(src_texture, dst_buffer, row_pitch, slice_pitch, 0, &box); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- for (z = 0; z < 64; ++z) - { - for (y = 0; y < 100; ++y) + /* Read region 2 */ + set_box(&box, 2, 2, 2, 11, 13, 17); + hr = ID3D12Resource_ReadFromSubresource(src_texture, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2], row_pitch, + slice_pitch, 0, &box); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + for (z = 0; z < 64; ++z) { - for (x = 0; x < 128; ++x) + for (y = 0; y < 100; ++y) { - if (x < 2 && y < 2 && z < 2) /* Region 1 */ - expected = (z + 1) << 16 | (y + 1) << 8 | (x + 1); - else if (2 <= x && x < 11 && 2 <= y && y < 13 && 2 <= z && z < 17) /* Region 2 */ - expected = (z + 2) << 16 | (y + 2) << 8 | (x + 2); - else /* Untouched */ - expected = 0; - - got = dst_buffer[z * 128 * 100 + y * 128 + x]; + for (x = 0; x < 128; ++x) + { + if (x < 2 && y < 2 && z < 2) /* Region 1 */ + expected = (z + 1) << 16 | (y + 1) << 8 | (x + 1); + else if (2 <= x && x < 11 && 2 <= y && y < 13 && 2 <= z && z < 17) /* Region 2 */ + expected = (z + 2) << 16 | (y + 2) << 8 | (x + 2); + else /* Untouched */ + expected = 0; + + got = dst_buffer[z * 128 * 100 + y * 128 + x]; + if (got != expected) + break; + } if (got != expected) break; } if (got != expected) break; } - if (got != expected) - break; + todo_if(!i) + ok(got == expected, "Got unexpected value 0x%08x at (%u, %u, %u), expected 0x%08x.\n", got, x, y, z, expected); } - todo ok(got == expected, "Got unexpected value 0x%08x at (%u, %u, %u), expected 0x%08x.\n", got, x, y, z, expected); + vkd3d_test_set_context(NULL);
/* Test layout is the same */ dst_texture = create_default_texture3d(device, 128, 100, 64, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0,