[PATCH vkd3d 7/8] tests: Mark driver-specific test failures as bugs.

Józef Kucia joseph.kucia at gmail.com
Mon Mar 4 06:15:20 CST 2019


From: Józef Kucia <jkucia at codeweavers.com>

Allows running all tests cleanly on Intel and Nvidia.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 include/private/vkd3d_test.h | 57 +++++++++++++++++++++++++++++-------
 tests/d3d12.c                | 35 ++++++++++++++++------
 tests/d3d12_crosstest.h      | 38 ++++++++++++++++++++++--
 3 files changed, 109 insertions(+), 21 deletions(-)

diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h
index ccc5350a2acb..d7593e2649ff 100644
--- a/include/private/vkd3d_test.h
+++ b/include/private/vkd3d_test.h
@@ -57,7 +57,7 @@ static void vkd3d_test_end_todo(void);
         unsigned int vkd3d_line = line; \
         VKD3D_TEST_TODO
 
-# define VKD3D_TEST_TODO(args...) \
+#define VKD3D_TEST_TODO(args...) \
         vkd3d_test_todo(vkd3d_line, args); } while (0)
 
 #define skip_(line) \
@@ -79,6 +79,9 @@ static void vkd3d_test_end_todo(void);
 #define todo_if(is_todo) \
     for (vkd3d_test_start_todo(is_todo); vkd3d_test_loop_todo(); vkd3d_test_end_todo())
 
+#define bug_if(is_bug) \
+    for (vkd3d_test_start_bug(is_bug); vkd3d_test_loop_bug(); vkd3d_test_end_bug())
+
 #define todo todo_if(true)
 
 static struct
@@ -88,12 +91,16 @@ static struct
     LONG skip_count;
     LONG todo_count;
     LONG todo_success_count;
+    LONG bug_count;
 
     unsigned int debug_level;
 
     unsigned int todo_level;
     bool todo_do_loop;
 
+    unsigned int bug_level;
+    bool bug_do_loop;
+
     char context[1024];
 } vkd3d_test_state;
 
@@ -113,33 +120,44 @@ static void
 vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list args)
 {
     bool is_todo = vkd3d_test_state.todo_level && !vkd3d_test_platform_is_windows();
+    bool is_bug = vkd3d_test_state.bug_level && !vkd3d_test_platform_is_windows();
 
-    if (is_todo)
+    if (is_bug)
+    {
+        InterlockedIncrement(&vkd3d_test_state.bug_count);
+        if (is_todo)
+            result = !result;
+        if (result)
+            printf("%s:%d%s: Fixed bug: ", vkd3d_test_name, line, vkd3d_test_state.context);
+        else
+            printf("%s:%d%s: Bug: ", vkd3d_test_name, line, vkd3d_test_state.context);
+        vprintf(fmt, args);
+    }
+    else if (is_todo)
     {
         if (result)
         {
-            printf("%s:%d%s: Todo succeeded: ", vkd3d_test_name, line, vkd3d_test_state.context);
-            vprintf(fmt, args);
             InterlockedIncrement(&vkd3d_test_state.todo_success_count);
+            printf("%s:%d%s: Todo succeeded: ", vkd3d_test_name, line, vkd3d_test_state.context);
         }
         else
         {
-            printf("%s:%d%s: Todo: ", vkd3d_test_name, line, vkd3d_test_state.context);
-            vprintf(fmt, args);
             InterlockedIncrement(&vkd3d_test_state.todo_count);
+            printf("%s:%d%s: Todo: ", vkd3d_test_name, line, vkd3d_test_state.context);
         }
+        vprintf(fmt, args);
     }
     else if (result)
     {
+        InterlockedIncrement(&vkd3d_test_state.success_count);
         if (vkd3d_test_state.debug_level > 1)
             printf("%s:%d%s: Test succeeded.\n", vkd3d_test_name, line, vkd3d_test_state.context);
-        InterlockedIncrement(&vkd3d_test_state.success_count);
     }
     else
     {
+        InterlockedIncrement(&vkd3d_test_state.failure_count);
         printf("%s:%d%s: Test failed: ", vkd3d_test_name, line, vkd3d_test_state.context);
         vprintf(fmt, args);
-        InterlockedIncrement(&vkd3d_test_state.failure_count);
     }
 }
 
@@ -217,7 +235,7 @@ int main(int argc, char **argv)
 
     vkd3d_test_main(argc, argv);
 
-    printf("%s: %lu tests executed (%lu failures, %lu skipped, %lu todo).\n",
+    printf("%s: %lu tests executed (%lu failures, %lu skipped, %lu todo, %lu bugs).\n",
             vkd3d_test_name,
             (unsigned long)(vkd3d_test_state.success_count
             + vkd3d_test_state.failure_count + vkd3d_test_state.todo_count
@@ -225,7 +243,8 @@ int main(int argc, char **argv)
             (unsigned long)(vkd3d_test_state.failure_count
             + vkd3d_test_state.todo_success_count),
             (unsigned long)vkd3d_test_state.skip_count,
-            (unsigned long)vkd3d_test_state.todo_count);
+            (unsigned long)vkd3d_test_state.todo_count,
+            (unsigned long)vkd3d_test_state.bug_count);
 
     if (test_platform)
         free(test_platform);
@@ -306,6 +325,24 @@ static inline void vkd3d_test_end_todo(void)
     vkd3d_test_state.todo_level >>= 1;
 }
 
+static inline void vkd3d_test_start_bug(bool is_bug)
+{
+    vkd3d_test_state.bug_level = (vkd3d_test_state.bug_level << 1) | is_bug;
+    vkd3d_test_state.bug_do_loop = true;
+}
+
+static inline int vkd3d_test_loop_bug(void)
+{
+    bool do_loop = vkd3d_test_state.bug_do_loop;
+    vkd3d_test_state.bug_do_loop = false;
+    return do_loop;
+}
+
+static inline void vkd3d_test_end_bug(void)
+{
+    vkd3d_test_state.bug_level >>= 1;
+}
+
 static inline void vkd3d_test_set_context(const char *fmt, ...)
 {
     va_list args;
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 5393072f203a..ac58565a45fa 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -5569,6 +5569,7 @@ static void test_draw_uav_only(void)
     D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;
     D3D12_ROOT_PARAMETER root_parameter;
     struct test_context_desc desc;
+    struct resource_readback rb;
     struct test_context context;
     ID3D12CommandQueue *queue;
     ID3D12Resource *resource;
@@ -5650,7 +5651,10 @@ static void test_draw_uav_only(void)
 
     transition_resource_state(command_list, resource,
             D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
-    check_sub_resource_uint(resource, 0, queue, command_list, 500, 0);
+    get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list);
+    bug_if(is_radv_device(context.device))
+    check_readback_data_uint(&rb, NULL, 500, 0);
+    release_resource_readback(&rb);
 
     ID3D12DescriptorHeap_Release(cpu_descriptor_heap);
     ID3D12DescriptorHeap_Release(descriptor_heap);
@@ -7865,6 +7869,7 @@ static void test_shader_instructions(void)
             struct ivec4 i;
         } output;
         bool skip_on_warp;
+        bool skip_on_mesa;
     }
     tests[] =
     {
@@ -7904,25 +7909,26 @@ static void test_shader_instructions(void)
         {&ps_if, {{0.0f}}, {{1.0f, 0.0f, 0.0f, 1.0f}}},
         {&ps_if, {{1.0f}}, {{0.0f, 1.0f, 0.0f, 1.0f}}},
 
+        /* FIXME: Ordered/unordered comparisons are broken on Mesa. */
         {&ps_if_return, {{0.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}},
-        {&ps_if_return, {{ NAN, 0.0f, 0.0f, 0.0f}}, {{1.0f, 0.0f, 0.0f, 0.0f}}},
+        {&ps_if_return, {{ NAN, 0.0f, 0.0f, 0.0f}}, {{1.0f, 0.0f, 0.0f, 0.0f}}, false, true},
         {&ps_if_return, {{3.0f, 0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 0.0f, 0.0f, 0.0f}}, {{1.0f, 0.0f, 0.0f, 0.0f}}},
-        {&ps_if_return, {{4.0f,  NAN, 0.0f, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
+        {&ps_if_return, {{4.0f,  NAN, 0.0f, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}, false, true},
         {&ps_if_return, {{4.0f, 3.0f, 0.0f, 0.0f}}, {{1.0f, 0.0f, 0.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
-        {&ps_if_return, {{4.0f, 4.0f,  NAN, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
+        {&ps_if_return, {{4.0f, 4.0f,  NAN, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}, false, true},
         {&ps_if_return, {{4.0f, 4.0f, 3.0f, 0.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 4.0f, 0.0f}}, {{1.0f, 1.0f, 0.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 5.0f, 0.0f}}, {{1.0f, 1.0f, 0.0f, 0.0f}}},
-        {&ps_if_return, {{4.0f, 4.0f, 0.0f,  NAN}}, {{1.0f, 1.0f, 1.0f, 1.0f}}},
+        {&ps_if_return, {{4.0f, 4.0f, 0.0f,  NAN}}, {{1.0f, 1.0f, 1.0f, 1.0f}}, false, true},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 1.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 2.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 3.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 4.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
         {&ps_if_return, {{4.0f, 4.0f, 0.0f, 5.0f}}, {{1.0f, 1.0f, 1.0f, 1.0f}}},
         {&ps_if_return, {{5.0f, 4.0f, 0.0f, 5.0f}}, {{1.0f, 1.0f, 1.0f, 0.0f}}},
-        {&ps_if_return, {{ NAN,  NAN,  NAN,  NAN}}, {{1.0f, 1.0f, 1.0f, 1.0f}}},
+        {&ps_if_return, {{ NAN,  NAN,  NAN,  NAN}}, {{1.0f, 1.0f, 1.0f, 1.0f}}, false, true},
 
         {&ps_nested_if, {{0.0f, 0.0f, 0.0f}}, {{0.0f, 0.0f, 0.0f, 1.0f}}},
         {&ps_nested_if, {{0.0f, 0.0f, 1.0f}}, {{1.0f, 0.0f, 0.0f, 1.0f}}},
@@ -8628,6 +8634,12 @@ static void test_shader_instructions(void)
             continue;
         }
 
+        if (tests[i].skip_on_mesa && is_mesa_device(context.device))
+        {
+            skip("Skipping shader '%s' test on Mesa.\n", tests[i].ps->name);
+            continue;
+        }
+
         if (current_ps != tests[i].ps)
         {
             if (context.pipeline_state)
@@ -16214,7 +16226,7 @@ static void test_depth_stencil_sampling(void)
             destroy_depth_stencil(&ds);
             continue;
         }
-        if (is_amd_device(device))
+        if (is_amd_windows_device(device))
         {
             skip("Reads from depth/stencil shader resource views return stale values on some AMD drivers.\n");
             destroy_depth_stencil(&ds);
@@ -18511,6 +18523,7 @@ static void test_atomic_instructions(void)
     ID3D12CommandQueue *queue;
     ID3D12Device *device;
     unsigned int i, j;
+    bool is_todo;
     HRESULT hr;
 
     static const DWORD ps_atomics_code[] =
@@ -18721,8 +18734,11 @@ static void test_atomic_instructions(void)
             unsigned int value = get_readback_uint(&rb, j, 0, 0);
             unsigned int expected = test->expected_result[j];
 
-            todo_if(test->i.x < 0
-                    && (!strcmp(instructions[j], "atomic_imax") || !strcmp(instructions[j], "atomic_imin")))
+            is_todo = test->i.x < 0
+                    && (!strcmp(instructions[j], "atomic_imax") || !strcmp(instructions[j], "atomic_imin"));
+
+            bug_if(is_todo && is_nvidia_device(device))
+            todo_if(is_todo)
             ok(value == expected, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
                     "with inputs (%u, %u), (%d), %#x (%d).\n",
                     i, value, value, expected, expected, instructions[j],
@@ -18741,6 +18757,7 @@ static void test_atomic_instructions(void)
             unsigned int value = get_readback_uint(&rb, j, 0, 0);
             unsigned int expected = test->expected_result[j];
 
+            bug_if(test->i.x < 0 && todo_instruction && is_nvidia_device(device))
             todo_if(test->i.x < 0 && todo_instruction)
             ok(value == expected, "Test %u: Got %#x (%d), expected %#x (%d) for '%s' "
                     "with inputs (%u, %u), (%d), %#x (%d).\n",
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h
index d0019dc85042..be6076a45950 100644
--- a/tests/d3d12_crosstest.h
+++ b/tests/d3d12_crosstest.h
@@ -296,7 +296,7 @@ static void init_adapter_info(void)
     IDXGIAdapter_Release(dxgi_adapter);
 }
 
-static inline bool is_amd_device(ID3D12Device *device)
+static inline bool is_amd_windows_device(ID3D12Device *device)
 {
     DXGI_ADAPTER_DESC desc = {0};
     IDXGIFactory4 *factory;
@@ -324,8 +324,24 @@ static inline bool is_amd_device(ID3D12Device *device)
 
     return desc.VendorId == 0x1002;
 }
+
+static inline bool is_mesa_device(ID3D12Device *device)
+{
+    return false;
+}
+
+static inline bool is_nvidia_device(ID3D12Device *device)
+{
+    return false;
+}
+
+static inline bool is_radv_device(ID3D12Device *device)
+{
+    return false;
+}
 #else
 static bool have_VK_KHR_driver_properties;
+static VkDriverIdKHR vk_driver_id;
 
 static HRESULT create_vkd3d_instance(struct vkd3d_instance **instance)
 {
@@ -484,16 +500,34 @@ static void init_adapter_info(void)
 
     trace("Driver name: %s, driver info: %s.\n", driver_properties.driverName, driver_properties.driverInfo);
 
+    vk_driver_id = driver_properties.driverID;
+
     ID3D12Device_Release(device);
 
 done:
     vkd3d_instance_decref(instance);
 }
 
-static inline bool is_amd_device(ID3D12Device *device)
+static inline bool is_amd_windows_device(ID3D12Device *device)
 {
     return false;
 }
+
+static inline bool is_mesa_device(ID3D12Device *device)
+{
+    return vk_driver_id == VK_DRIVER_ID_MESA_RADV_KHR
+            || vk_driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR;
+}
+
+static inline bool is_nvidia_device(ID3D12Device *device)
+{
+    return vk_driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR;
+}
+
+static inline bool is_radv_device(ID3D12Device *device)
+{
+    return vk_driver_id == VK_DRIVER_ID_MESA_RADV_KHR;
+}
 #endif
 
 static ID3D12Device *create_device(void)
-- 
2.19.2




More information about the wine-devel mailing list