[PATCH v2 5/5] d3d10core/tests: Test partial updates of 3D textures.
Jan Sikorski
jsikorski at codeweavers.com
Wed Mar 17 07:50:59 CDT 2021
Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
---
dlls/d3d10core/tests/d3d10core.c | 125 +++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c
index 09279f5fc62..a26523c4852 100644
--- a/dlls/d3d10core/tests/d3d10core.c
+++ b/dlls/d3d10core/tests/d3d10core.c
@@ -148,6 +148,12 @@ static void set_box(D3D10_BOX *box, UINT left, UINT top, UINT front, UINT right,
box->back = back;
}
+static BOOL is_inside_box(D3D10_BOX *box, UINT x, UINT y, UINT z)
+{
+ return x >= box->left && x < box->right && y >= box->top && y < box->bottom
+ && z >= box->front && z < box->back;
+}
+
static ULONG get_refcount(void *iface)
{
IUnknown *unknown = iface;
@@ -9723,6 +9729,124 @@ static void test_update_subresource(void)
release_test_context(&test_context);
}
+static void test_update_subresource_3d(void)
+{
+ unsigned int x, y, z, left, right, top, bottom, front, back, i;
+ struct d3d10core_test_context test_context;
+ D3D10_TEXTURE3D_DESC texture_desc;
+ struct resource_readback rb;
+ ID3D10Texture3D *texture;
+ D3D10_BOX box, clear_box;
+ ID3D10Device *device;
+ HRESULT hr;
+
+ static const DWORD color_data[] =
+ {
+ 0x01020304, 0x05060708, 0x090a0b0c, 0x0d0e0f10, 0x11121314, 0x15161718, 0x191a1b1c, 0x1d1e1f20,
+ 0x21222324, 0x25262728, 0x292a2b2c, 0x2d2e2f30, 0x31323334, 0x35363738, 0x393a3b3c, 0x3d3e3f40,
+ 0x41424344, 0x45464748, 0x494a4b4c, 0x4d4e4f50, 0x51525354, 0x55565758, 0x595a5b5c, 0x5d5e5f60,
+ 0x61626364, 0x65666768, 0x696a6b6c, 0x6d6e6f70, 0x71727374, 0x75767778, 0x797a7b7c, 0x7d7e7f80,
+ 0x81828384, 0x85868788, 0x898a8b8c, 0x8d8e8f90, 0x91929394, 0x95969798, 0x999a9b9c, 0x9d9e9fa0,
+ };
+
+ static const DWORD black_data[ARRAY_SIZE(color_data)] = {0};
+
+ static const struct
+ {
+ DXGI_FORMAT format;
+ unsigned int slice_pitch;
+ unsigned int row_pitch;
+ unsigned int block_width;
+ unsigned int block_height;
+ unsigned int bytes_per_block;
+ BOOL todo;
+ }
+ tests[] =
+ {
+ { DXGI_FORMAT_R8G8B8A8_UNORM, 2 * 2 * 4, 2 * 4, 1, 1, 4 },
+ { DXGI_FORMAT_R8G8B8A8_UNORM, 2 * 2 * 4 + 4, 2 * 4, 1, 1, 4 },
+ { DXGI_FORMAT_R8G8B8A8_UNORM, 2 * 2 * 4, 2 * 4 + 4, 1, 1, 4 },
+
+ { DXGI_FORMAT_BC1_UNORM, 2 * 2 * 8, 2 * 8, 4, 4, 8, TRUE },
+ };
+
+ if (!init_test_context(&test_context))
+ return;
+
+ device = test_context.device;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ unsigned int block_width = tests[i].block_width;
+ unsigned int block_height = tests[i].block_height;
+ unsigned int slice_pitch = tests[i].slice_pitch;
+ unsigned int row_pitch = tests[i].row_pitch;
+ unsigned int dim_limit = tests[i].todo ? 1 : 2;
+
+ texture_desc.Width = 2 * block_width;
+ texture_desc.Height = 2 * block_height;
+ texture_desc.Depth = 2;
+ texture_desc.MipLevels = 1;
+ texture_desc.Format = tests[i].format;
+ texture_desc.Usage = D3D10_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+
+ set_box(&clear_box, 0, 0, 0, texture_desc.Width, texture_desc.Height, 2);
+
+ hr = ID3D10Device_CreateTexture3D(device, &texture_desc, NULL, &texture);
+ if (FAILED(hr))
+ {
+ skip("Test %u: Failed to create texture, hr %#x.\n", i, hr);
+ continue;
+ }
+
+ for (left = 0; left < dim_limit; ++left)
+ for (right = left + 1; right <= dim_limit; ++right)
+ for (top = 0; top < dim_limit; ++top)
+ for (bottom = top + 1; bottom <= dim_limit; ++bottom)
+ for (front = 0; front < dim_limit; ++front)
+ for (back = front + 1; back <= dim_limit; ++back)
+ {
+ const BYTE *data = (const BYTE *)color_data + tests[i].bytes_per_block * left
+ + row_pitch * top + slice_pitch * front;
+
+ ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture, 0,
+ &clear_box, black_data, 0, 0);
+ set_box(&box, block_width * left, block_height * top, front,
+ block_width * right, block_height * bottom, back);
+ ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture, 0,
+ &box, data, row_pitch, slice_pitch);
+
+ get_texture3d_readback(texture, 0, &rb);
+
+ for (z = 0; z < dim_limit; ++z)
+ for (y = 0; y < dim_limit; ++y)
+ for (x = 0; x < dim_limit; ++x)
+ {
+ const BYTE *expected = (const BYTE *)black_data;
+ data = get_readback_data(&rb, x, y, z, tests[i].bytes_per_block);
+ if (is_inside_box(&box, block_width * x, block_height * y, z))
+ expected = (const BYTE *)color_data + tests[i].bytes_per_block * x
+ + row_pitch * y + slice_pitch * z;
+
+ todo_wine_if(tests[i].todo)
+ ok(!memcmp(data, expected, tests[i].bytes_per_block), "Test %u: box (%u,%u,%u)-(%u,%u,%u), "
+ "invalid block at %u %u %u, got 0x%08x, expected 0x%08x.\n", i, left, top, front,
+ right, bottom, back, x, y, z, *(DWORD *)data, *(DWORD *)expected);
+ }
+
+ release_resource_readback(&rb);
+ }
+
+ ID3D10Texture3D_Release(texture);
+ }
+
+ release_test_context(&test_context);
+}
+
+
static void test_copy_subresource_region(void)
{
struct d3d10core_test_context test_context;
@@ -18905,6 +19029,7 @@ START_TEST(d3d10core)
queue_test(test_fragment_coords);
queue_test(test_initial_texture_data);
queue_test(test_update_subresource);
+ queue_test(test_update_subresource_3d);
queue_test(test_copy_subresource_region);
queue_test(test_copy_subresource_region_1d);
queue_test(test_resource_access);
--
2.30.1
More information about the wine-devel
mailing list