tests: Add more tests for ReadFromSubresource().

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:
Conor McCarthy 2019-08-07 15:58:25 +02:00 committed by Alexandre Julliard
parent d5a8fbe9f5
commit f2753dd618

View File

@ -30390,6 +30390,7 @@ static void test_vertex_shader_stream_output(void)
static void test_read_write_subresource(void) static void test_read_write_subresource(void)
{ {
D3D12_TEXTURE_COPY_LOCATION src_location, dst_location; D3D12_TEXTURE_COPY_LOCATION src_location, dst_location;
uint32_t *dst_buffer, *zero_buffer, *ptr;
ID3D12GraphicsCommandList *command_list; ID3D12GraphicsCommandList *command_list;
D3D12_HEAP_PROPERTIES heap_properties; D3D12_HEAP_PROPERTIES heap_properties;
D3D12_SUBRESOURCE_DATA texture_data; D3D12_SUBRESOURCE_DATA texture_data;
@ -30399,16 +30400,14 @@ static void test_read_write_subresource(void)
struct resource_readback rb; struct resource_readback rb;
ID3D12Resource *src_texture; ID3D12Resource *src_texture;
ID3D12Resource *dst_texture; ID3D12Resource *dst_texture;
unsigned int got, expected;
ID3D12CommandQueue *queue; ID3D12CommandQueue *queue;
ID3D12Resource *rb_buffer; ID3D12Resource *rb_buffer;
unsigned int *dst_buffer;
unsigned int buffer_size; unsigned int buffer_size;
unsigned int slice_pitch; unsigned int slice_pitch;
unsigned int x, y, z, i;
unsigned int row_pitch; unsigned int row_pitch;
unsigned int x, y, z; uint32_t got, expected;
ID3D12Device *device; ID3D12Device *device;
unsigned int *ptr;
D3D12_BOX box; D3D12_BOX box;
HRESULT hr; HRESULT hr;
@ -30428,6 +30427,9 @@ static void test_read_write_subresource(void)
rb_buffer = create_readback_buffer(device, buffer_size); rb_buffer = create_readback_buffer(device, buffer_size);
dst_buffer = malloc(buffer_size); dst_buffer = malloc(buffer_size);
ok(dst_buffer, "Failed to allocate memory.\n"); ok(dst_buffer, "Failed to allocate memory.\n");
zero_buffer = malloc(buffer_size);
ok(zero_buffer, "Failed to allocate memory.\n");
memset(zero_buffer, 0, buffer_size);
set_box(&box, 0, 0, 0, 1, 1, 1); set_box(&box, 0, 0, 0, 1, 1, 1);
hr = ID3D12Resource_WriteToSubresource(rb_buffer, 0, &box, dst_buffer, row_pitch, slice_pitch); hr = ID3D12Resource_WriteToSubresource(rb_buffer, 0, &box, dst_buffer, row_pitch, slice_pitch);
@ -30479,6 +30481,10 @@ static void test_read_write_subresource(void)
hr = ID3D12Resource_ReadFromSubresource(src_texture, dst_buffer, row_pitch, slice_pitch, 0, &box); hr = ID3D12Resource_ReadFromSubresource(src_texture, dst_buffer, row_pitch, slice_pitch, 0, &box);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 2; ++i)
{
vkd3d_test_set_context("Test %u", i);
for (z = 0; z < 64; ++z) for (z = 0; z < 64; ++z)
{ {
for (y = 0; y < 100; ++y) for (y = 0; y < 100; ++y)
@ -30496,6 +30502,11 @@ static void test_read_write_subresource(void)
} }
} }
if (i)
{
hr = ID3D12Resource_WriteToSubresource(src_texture, 0, NULL, zero_buffer, row_pitch, slice_pitch);
todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
/* Write region 1 */ /* Write region 1 */
set_box(&box, 0, 0, 0, 2, 2, 2); set_box(&box, 0, 0, 0, 2, 2, 2);
hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, dst_buffer, row_pitch, slice_pitch); hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, dst_buffer, row_pitch, slice_pitch);
@ -30506,6 +30517,20 @@ static void test_read_write_subresource(void)
hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2], hr = ID3D12Resource_WriteToSubresource(src_texture, 0, &box, &dst_buffer[2 * 128 * 100 + 2 * 128 + 2],
row_pitch, slice_pitch); row_pitch, slice_pitch);
todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); 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);
}
memset(dst_buffer, 0, buffer_size); memset(dst_buffer, 0, buffer_size);
@ -30545,7 +30570,10 @@ static void test_read_write_subresource(void)
if (got != expected) if (got != expected)
break; break;
} }
todo ok(got == expected, "Got unexpected value 0x%08x at (%u, %u, %u), expected 0x%08x.\n", got, x, y, z, expected); todo_if(is_nvidia_device(device))
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 */ /* Test layout is the same */
dst_texture = create_default_texture3d(device, 128, 100, 64, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, dst_texture = create_default_texture3d(device, 128, 100, 64, 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0,
@ -30601,6 +30629,7 @@ static void test_read_write_subresource(void)
done: done:
free(dst_buffer); free(dst_buffer);
free(zero_buffer);
destroy_test_context(&context); destroy_test_context(&context);
} }