=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d10core/tests: Add a test for CopySubresourceRegion() with 1D textures.

Alexandre Julliard julliard at winehq.org
Mon Aug 20 13:26:11 CDT 2018


Module: wine
Branch: master
Commit: 958c93104e4a6bd08aa7d97ae5931ff0422fe17d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=958c93104e4a6bd08aa7d97ae5931ff0422fe17d

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Mon Aug 20 13:09:27 2018 +0200

d3d10core/tests: Add a test for CopySubresourceRegion() with 1D textures.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d10core/tests/device.c | 87 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 8c95ee3..569c8ee 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -9241,6 +9241,92 @@ static void test_copy_subresource_region(void)
     release_test_context(&test_context);
 }
 
+static void test_copy_subresource_region_1d(void)
+{
+    struct d3d10core_test_context test_context;
+    D3D10_SUBRESOURCE_DATA resource_data[4];
+    D3D10_TEXTURE1D_DESC texture1d_desc;
+    D3D10_TEXTURE2D_DESC texture2d_desc;
+    struct resource_readback rb;
+    ID3D10Texture1D *texture1d;
+    ID3D10Texture2D *texture2d;
+    ID3D10Device *device;
+    unsigned int i, j;
+    D3D10_BOX box;
+    DWORD color;
+    HRESULT hr;
+
+    static const DWORD bitmap_data[] =
+    {
+        0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
+        0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
+        0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
+        0xffffffff, 0xff000000, 0xff000000, 0xff000000,
+    };
+
+    if (!init_test_context(&test_context))
+        return;
+    device = test_context.device;
+
+    texture1d_desc.Width = 4;
+    texture1d_desc.MipLevels = 1;
+    texture1d_desc.ArraySize = 4;
+    texture1d_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    texture1d_desc.Usage = D3D10_USAGE_DEFAULT;
+    texture1d_desc.BindFlags = 0;
+    texture1d_desc.CPUAccessFlags = 0;
+    texture1d_desc.MiscFlags = 0;
+
+    for (i = 0; i < ARRAY_SIZE(resource_data); ++i)
+    {
+        resource_data[i].pSysMem = &bitmap_data[4 * i];
+        resource_data[i].SysMemPitch = texture1d_desc.Width * sizeof(bitmap_data);
+        resource_data[i].SysMemSlicePitch = 0;
+    }
+
+    hr = ID3D10Device_CreateTexture1D(device, &texture1d_desc, resource_data, &texture1d);
+    ok(hr == S_OK, "Failed to create 1d texture, hr %#x.\n", hr);
+
+    texture2d_desc.Width = 4;
+    texture2d_desc.Height = 4;
+    texture2d_desc.MipLevels = 1;
+    texture2d_desc.ArraySize = 1;
+    texture2d_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    texture2d_desc.SampleDesc.Count = 1;
+    texture2d_desc.SampleDesc.Quality = 0;
+    texture2d_desc.Usage = D3D10_USAGE_DEFAULT;
+    texture2d_desc.BindFlags = 0;
+    texture2d_desc.CPUAccessFlags = 0;
+    texture2d_desc.MiscFlags = 0;
+
+    hr = ID3D10Device_CreateTexture2D(device, &texture2d_desc, NULL, &texture2d);
+    ok(hr == S_OK, "Failed to create 2d texture, hr %#x.\n", hr);
+
+    set_box(&box, 0, 0, 0, 4, 1, 1);
+    for (i = 0; i < ARRAY_SIZE(resource_data); ++i)
+    {
+        ID3D10Device_CopySubresourceRegion(device, (ID3D10Resource *)texture2d, 0,
+                0, i, 0, (ID3D10Resource *)texture1d, i, &box);
+    }
+
+    get_texture_readback(texture2d, 0, &rb);
+    for (i = 0; i < 4; ++i)
+    {
+        for (j = 0; j < 4; ++j)
+        {
+            color = get_readback_color(&rb, j, i);
+            ok(compare_color(color, bitmap_data[j + i * 4], 1),
+                    "Got color 0x%08x at (%u, %u), expected 0x%08x.\n",
+                    color, j, i, bitmap_data[j + i * 4]);
+        }
+    }
+    release_resource_readback(&rb);
+
+    ID3D10Texture1D_Release(texture1d);
+    ID3D10Texture2D_Release(texture2d);
+    release_test_context(&test_context);
+}
+
 #define check_buffer_cpu_access(a, b, c, d) check_buffer_cpu_access_(__LINE__, a, b, c, d)
 static void check_buffer_cpu_access_(unsigned int line, ID3D10Buffer *buffer,
         D3D10_USAGE usage, UINT bind_flags, UINT cpu_access)
@@ -17112,6 +17198,7 @@ START_TEST(device)
     test_fragment_coords();
     test_update_subresource();
     test_copy_subresource_region();
+    test_copy_subresource_region_1d();
     test_resource_access();
     test_check_multisample_quality_levels();
     test_cb_relative_addressing();




More information about the wine-cvs mailing list