[PATCH vkd3d v3 1/5] tests: Test ClearRenderTargetView() with R8G8B8A8_{SINT, UINT} formats.

Józef Kucia joseph.kucia at gmail.com
Fri Jul 19 11:28:04 CDT 2019


From: Jactry Zeng <jzeng at codeweavers.com>

Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

Version 3: Use 1 table.

---
 tests/d3d12.c            | 84 ++++++++++++++++++++++++++++++----------
 tests/d3d12_test_utils.h |  4 +-
 2 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/tests/d3d12.c b/tests/d3d12.c
index bd055fb5d444..c37821f03f2e 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -4283,6 +4283,21 @@ static void test_clear_depth_stencil_view(void)
     destroy_test_context(&context);
 }
 
+#define test_clear_rtv_r8g8b8a8_2d(a, b, c, d, e, f) test_clear_rtv_r8g8b8a8_2d_(__LINE__, a, b, c, d, e, f)
+static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_context *context,
+        ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
+        const float *color, uint32_t expected, unsigned int max_diff)
+{
+    ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL);
+    transition_resource_state(context->list, resource,
+            D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+    check_sub_resource_uint_(line, resource, 0, context->queue, context->list, expected, max_diff);
+
+    reset_command_list(context->list, context->allocator);
+    transition_resource_state(context->list, resource,
+            D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+}
+
 static void test_clear_render_target_view(void)
 {
     static const unsigned int array_expected_colors[] = {0xff00ff00, 0xff0000ff, 0xffff0000};
@@ -4292,6 +4307,7 @@ static void test_clear_render_target_view(void)
         {1.0f, 0.0f, 0.0f, 1.0f},
         {0.0f, 0.0f, 1.0f, 1.0f},
     };
+    static const float negative_value[] = {1.0f, -1.0f, -0.5f, -2.0f};
     static const float color[] = {0.1f, 0.5f, 0.3f, 0.75f};
     static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};
     ID3D12GraphicsCommandList *command_list;
@@ -4311,6 +4327,19 @@ static void test_clear_render_target_view(void)
     unsigned int i;
     D3D12_BOX box;
     HRESULT hr;
+    static const struct
+    {
+        const float *color;
+        uint32_t unorm_result;
+        uint32_t uint_result;
+        uint32_t sint_result;
+    }
+    test_r8g8b8a8[] =
+    {
+        {green,          0xff00ff00, 0x01000100, 0x01000100},
+        {color,          0xbf4c7f19, 0x00000000, 0x00000000},
+        {negative_value, 0x00000000, 0x00000001, 0xfe00ff01},
+    };
 
     STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
 
@@ -4358,34 +4387,48 @@ static void test_clear_render_target_view(void)
     rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
     rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
     ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+    for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8); ++i)
+    {
+        if (!test_r8g8b8a8[i].unorm_result)
+            continue;
 
-    ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, green, 0, NULL);
-    transition_resource_state(command_list, resource,
-            D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
-    check_sub_resource_uint(resource, 0, queue, command_list, 0xff00ff00, 0);
-
-    reset_command_list(command_list, context.allocator);
-    transition_resource_state(command_list, resource,
-            D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
-
-    ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL);
-    transition_resource_state(command_list, resource,
-            D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
-    check_sub_resource_uint(resource, 0, queue, command_list, 0xbf4c7f19, 2);
+        vkd3d_test_set_context("Test %u", i);
+        test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle,
+                test_r8g8b8a8[i].color, test_r8g8b8a8[i].unorm_result, 2);
+    }
+    vkd3d_test_set_context(NULL);
 
     /* sRGB view */
-    reset_command_list(command_list, context.allocator);
-    transition_resource_state(command_list, resource,
-            D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
     rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
     ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+    test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, color, 0xbf95bc59, 2);
 
-    ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL);
-    transition_resource_state(command_list, resource,
-            D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
-    check_sub_resource_uint(resource, 0, queue, command_list, 0xbf95bc59, 2);
+    /* DXGI_FORMAT_R8G8B8A8_UINT view */
+    rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT;
+    ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+    for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8); ++i)
+    {
+        vkd3d_test_set_context("Test %u", i);
+        todo test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle,
+                test_r8g8b8a8[i].color, test_r8g8b8a8[i].uint_result, 0);
+    }
+    vkd3d_test_set_context(NULL);
+
+    /* DXGI_FORMAT_R8G8B8A8_SINT view */
+    rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_SINT;
+    ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+    for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8); ++i)
+    {
+        vkd3d_test_set_context("Test %u", i);
+        todo test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle,
+                test_r8g8b8a8[i].color, test_r8g8b8a8[i].sint_result, 0);
+    }
+    vkd3d_test_set_context(NULL);
 
     /* 2D array texture */
+    hr = ID3D12GraphicsCommandList_Close(command_list);
+    ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
+    reset_command_list(command_list, context.allocator);
     ID3D12Resource_Release(resource);
     resource_desc.DepthOrArraySize = ARRAY_SIZE(array_colors);
     hr = ID3D12Device_CreateCommittedResource(device,
@@ -4394,7 +4437,6 @@ static void test_clear_render_target_view(void)
             &IID_ID3D12Resource, (void **)&resource);
     ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
 
-    reset_command_list(command_list, context.allocator);
     for (i = 0; i < ARRAY_SIZE(array_colors); ++i)
     {
         memset(&rtv_desc, 0, sizeof(rtv_desc));
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index 027a1fd68e97..da272da98d6b 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -88,9 +88,9 @@ static inline void reset_command_list_(unsigned int line,
     HRESULT hr;
 
     hr = ID3D12CommandAllocator_Reset(allocator);
-    ok_(line)(SUCCEEDED(hr), "Failed to reset command allocator, hr %#x.\n", hr);
+    assert_that_(line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
     hr = ID3D12GraphicsCommandList_Reset(list, allocator, NULL);
-    ok_(line)(SUCCEEDED(hr), "Failed to reset command list, hr %#x.\n", hr);
+    assert_that_(line)(hr == S_OK, "Failed to reset command list, hr %#x.\n", hr);
 }
 
 #define queue_signal(a, b, c) queue_signal_(__LINE__, a, b, c)
-- 
2.21.0




More information about the wine-devel mailing list