=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: tests: Add more tests for texture allocation info.

Alexandre Julliard julliard at winehq.org
Tue Jan 22 14:43:48 CST 2019


Module: vkd3d
Branch: master
Commit: 49a02a41f3fb690902f7814b766260bd78ca8cc9
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=49a02a41f3fb690902f7814b766260bd78ca8cc9

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Fri Jan 18 10:25:51 2019 +0100

tests: Add more tests for texture allocation info.

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>

---

 tests/d3d12.c            | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/d3d12_test_utils.h |  1 +
 2 files changed, 62 insertions(+)

diff --git a/tests/d3d12.c b/tests/d3d12.c
index bccface..06543e9 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -22025,6 +22025,7 @@ static void test_resource_allocation_info(void)
     ID3D12Device *device;
     unsigned int i, j;
     ULONG refcount;
+    UINT64 size;
 
     static const unsigned int alignments[] =
     {
@@ -22046,6 +22047,22 @@ static void test_resource_allocation_info(void)
         D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
         D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT + 1,
     };
+    static const struct
+    {
+        unsigned int width;
+        unsigned int height;
+        unsigned int array_size;
+        DXGI_FORMAT format;
+    }
+    texture_tests[] =
+    {
+        { 4,  4, 1, DXGI_FORMAT_R8_UINT},
+        { 8,  8, 1, DXGI_FORMAT_R8G8B8A8_UNORM},
+        {16, 16, 1, DXGI_FORMAT_R8G8B8A8_UNORM},
+        {16, 16, 6, DXGI_FORMAT_R8G8B8A8_UNORM},
+
+        {1024, 1024, 1, DXGI_FORMAT_R8G8B8A8_UNORM},
+    };
 
     if (!(device = create_device()))
     {
@@ -22086,6 +22103,50 @@ static void test_resource_allocation_info(void)
         }
     }
 
+    desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
+    desc.MipLevels = 1;
+    desc.SampleDesc.Count = 1;
+    desc.SampleDesc.Quality = 0;
+    desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
+    desc.Flags = 0;
+
+    for (i = 0; i < ARRAY_SIZE(texture_tests); ++i)
+    {
+        desc.Width = texture_tests[i].width;
+        desc.Height = texture_tests[i].height;
+        desc.DepthOrArraySize = texture_tests[i].array_size;
+        desc.Format = texture_tests[i].format;
+
+        desc.Alignment = 0;
+        info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc);
+        ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+                "Got unexpected alignment %"PRIu64".\n", info.Alignment);
+        check_alignment(info.SizeInBytes, info.Alignment);
+
+        desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+        info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc);
+        ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+                "Got unexpected alignment %"PRIu64".\n", info.Alignment);
+        check_alignment(info.SizeInBytes, info.Alignment);
+
+        desc.Alignment = D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT;
+        info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc);
+        ok(info.Alignment >= D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT,
+                "Got unexpected alignment %"PRIu64".\n", info.Alignment);
+        size = desc.Width * desc.Height * desc.DepthOrArraySize * format_size(desc.Format);
+        if (size <= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
+        {
+            check_alignment(info.SizeInBytes, info.Alignment);
+        }
+        else
+        {
+            ok(info.SizeInBytes == ~(UINT64)0,
+                    "Got unexpected size %"PRIu64".\n", info.SizeInBytes);
+            ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+                    "Got unexpected alignment %"PRIu64".\n", info.Alignment);
+        }
+    }
+
     refcount = ID3D12Device_Release(device);
     ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
 }
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index d4265fc..6ccbc64 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -227,6 +227,7 @@ static unsigned int format_size(DXGI_FORMAT format)
     {
         case DXGI_FORMAT_UNKNOWN:
         case DXGI_FORMAT_A8_UNORM:
+        case DXGI_FORMAT_R8_UINT:
             return 1;
         case DXGI_FORMAT_R32G32B32A32_FLOAT:
         case DXGI_FORMAT_R32G32B32A32_UINT:




More information about the wine-cvs mailing list