d3d11/tests: Add test for staging buffers.

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 2018-09-06 22:01:59 +02:00 committed by Alexandre Julliard
parent 3cd28caf17
commit 8abb76f4b1
1 changed files with 67 additions and 0 deletions

View File

@ -28102,6 +28102,72 @@ static void test_depth_clip(void)
release_test_context(&test_context);
}
static void test_staging_buffers(void)
{
struct d3d11_test_context test_context;
ID3D11Buffer *dst_buffer, *src_buffer;
D3D11_SUBRESOURCE_DATA resource_data;
D3D11_BUFFER_DESC buffer_desc;
ID3D11DeviceContext *context;
struct resource_readback rb;
float data[16], value;
ID3D11Device *device;
unsigned int i;
HRESULT hr;
if (!init_test_context(&test_context, NULL))
return;
device = test_context.device;
context = test_context.immediate_context;
buffer_desc.ByteWidth = sizeof(data);
buffer_desc.Usage = D3D11_USAGE_STAGING;
buffer_desc.BindFlags = 0;
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
buffer_desc.MiscFlags = 0;
buffer_desc.StructureByteStride = 0;
for (i = 0; i < ARRAY_SIZE(data); ++i)
data[i] = i;
resource_data.pSysMem = data;
resource_data.SysMemPitch = 0;
resource_data.SysMemSlicePitch = 0;
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, &resource_data, &src_buffer);
ok(hr == S_OK, "Failed to create buffer, hr %#x.\n", hr);
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
buffer_desc.CPUAccessFlags = 0;
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &dst_buffer);
ok(hr == S_OK, "Failed to create buffer, hr %#x.\n", hr);
ID3D11DeviceContext_CopyResource(context, (ID3D11Resource *)dst_buffer, (ID3D11Resource *)src_buffer);
get_buffer_readback(dst_buffer, &rb);
for (i = 0; i < ARRAY_SIZE(data); ++i)
{
value = get_readback_float(&rb, i, 0);
ok(value == data[i], "Got unexpected value %.8e at %u.\n", value, i);
}
release_resource_readback(&rb);
for (i = 0; i < ARRAY_SIZE(data); ++i)
data[i] = 2 * i;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)src_buffer, 0, NULL, data, 0, 0);
ID3D11DeviceContext_CopyResource(context, (ID3D11Resource *)dst_buffer, (ID3D11Resource *)src_buffer);
get_buffer_readback(dst_buffer, &rb);
for (i = 0; i < ARRAY_SIZE(data); ++i)
{
value = get_readback_float(&rb, i, 0);
ok(value == i, "Got unexpected value %.8e at %u.\n", value, i);
}
release_resource_readback(&rb);
ID3D11Buffer_Release(dst_buffer);
ID3D11Buffer_Release(src_buffer);
release_test_context(&test_context);
}
START_TEST(d3d11)
{
unsigned int argc, i;
@ -28249,6 +28315,7 @@ START_TEST(d3d11)
queue_test(test_sample_shading);
queue_test(test_sample_mask);
queue_test(test_depth_clip);
queue_test(test_staging_buffers);
run_queued_tests();
}