From 84676c378f509fd11d7a0713285e9de5340be4fa Mon Sep 17 00:00:00 2001
From: Francisco Casas <fcasas@codeweavers.com>
Date: Fri, 26 Jul 2024 14:19:27 -0400
Subject: [PATCH 1/4] tests: Add missing double precission require directives.

Otherwise these tests fail on Intel UHD Graphics 770.
---
 tests/hlsl/uav-rwbyteaddressbuffer.shader_test | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/hlsl/uav-rwbyteaddressbuffer.shader_test b/tests/hlsl/uav-rwbyteaddressbuffer.shader_test
index c7b3be2121..9ac3b43ca6 100644
--- a/tests/hlsl/uav-rwbyteaddressbuffer.shader_test
+++ b/tests/hlsl/uav-rwbyteaddressbuffer.shader_test
@@ -24,6 +24,10 @@ if(sm<6) probe uav 1 (1) ri (11)
 if(sm>=6) probe uav 1 (1) r (11.1)
 
 
+[require]
+shader model >= 5.0
+float64
+
 [pixel shader todo]
 RWByteAddressBuffer u : register(u1);
 
@@ -42,6 +46,7 @@ if(sm>=6) probe uav 1 (0) rd (12.2)
 % SM 6 add support for templated Store<>().
 [require]
 shader model >= 6.0
+float64
 
 [pixel shader]
 RWByteAddressBuffer u : register(u1);
-- 
GitLab


From 2efc79bb81de66144a5a90c02d1d873cf0e43382 Mon Sep 17 00:00:00 2001
From: Francisco Casas <fcasas@codeweavers.com>
Date: Mon, 5 Aug 2024 12:58:23 -0400
Subject: [PATCH 2/4] tests: Report tests skipped because of missing
 capabilities.

---
 tests/shader_runner.c | 59 ++++++++++++++++++++++++++++---------------
 tests/test-driver.sh  | 22 +++++++++++++---
 2 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/tests/shader_runner.c b/tests/shader_runner.c
index 8058f1364f..6390f0ab64 100644
--- a/tests/shader_runner.c
+++ b/tests/shader_runner.c
@@ -1563,10 +1563,8 @@ static enum parse_state read_shader_directive(struct shader_runner *runner, enum
     return state;
 }
 
-static bool check_requirements(const struct shader_runner *runner, const struct shader_runner_caps *caps)
+static bool check_capabilities(const struct shader_runner *runner, const struct shader_runner_caps *caps)
 {
-    if (runner->maximum_shader_model < runner->minimum_shader_model)
-        return false;
     if (runner->require_float64 && !caps->float64)
         return false;
     if (runner->require_int64 && !caps->int64)
@@ -1616,6 +1614,13 @@ static void update_line_number_context(const char *testname, unsigned int line_n
     vkd3d_test_push_context("%s:%u", testname, line_number);
 }
 
+enum test_action
+{
+    TEST_ACTION_RUN,
+    TEST_ACTION_SKIP_SHADER_MODEL,
+    TEST_ACTION_SKIP_CAPS,
+};
+
 void run_shader_tests(struct shader_runner *runner, const struct shader_runner_caps *caps,
         const struct shader_runner_ops *ops, void *dxc_compiler)
 {
@@ -1624,9 +1629,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
     struct sampler *current_sampler = NULL;
     enum parse_state state = STATE_NONE;
     unsigned int i, line_number = 0, block_start_line_number = 0;
+    enum test_action test_action = TEST_ACTION_RUN;
     char *shader_source = NULL;
     HRESULT expect_hr = S_OK;
-    bool skip_tests = false;
     char line_buffer[256];
     const char *testname;
     FILE *f;
@@ -1682,8 +1687,10 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                     break;
 
                 case STATE_REQUIRE:
-                    if (!check_requirements(runner, caps))
-                        skip_tests = true;
+                    if (runner->maximum_shader_model < runner->minimum_shader_model)
+                        test_action = TEST_ACTION_SKIP_SHADER_MODEL;
+                    else if (!check_capabilities(runner, caps))
+                        test_action = TEST_ACTION_SKIP_CAPS;
                     break;
 
                 case STATE_RESOURCE:
@@ -1693,21 +1700,21 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                     /* Not every backend supports every resource type
                      * (specifically, D3D9 doesn't support UAVs and
                      * textures with data type other than float). */
-                    if (!skip_tests)
-                    {
+                    if (test_action == TEST_ACTION_RUN)
                         set_resource(runner, &current_resource);
-                    }
                     free(current_resource.data);
                     break;
 
                 case STATE_SHADER_COMPUTE:
                 case STATE_SHADER_COMPUTE_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_COMPUTE_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_CS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->cs_source);
                     runner->cs_source = shader_source;
                     shader_source = NULL;
@@ -1717,12 +1724,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_PIXEL:
                 case STATE_SHADER_PIXEL_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_PIXEL_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_PS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->ps_source);
                     runner->ps_source = shader_source;
                     shader_source = NULL;
@@ -1732,12 +1741,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_VERTEX:
                 case STATE_SHADER_VERTEX_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_VERTEX_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_VS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->vs_source);
                     runner->vs_source = shader_source;
                     shader_source = NULL;
@@ -1747,12 +1758,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_EFFECT:
                 case STATE_SHADER_EFFECT_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_EFFECT_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_FX,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->fx_source);
                     runner->fx_source = shader_source;
                     shader_source = NULL;
@@ -1762,12 +1775,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_HULL:
                 case STATE_SHADER_HULL_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_HULL_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_HS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->hs_source);
                     runner->hs_source = shader_source;
                     shader_source = NULL;
@@ -1777,12 +1792,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_DOMAIN:
                 case STATE_SHADER_DOMAIN_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_DOMAIN_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_DS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->ds_source);
                     runner->ds_source = shader_source;
                     shader_source = NULL;
@@ -1792,12 +1809,14 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
 
                 case STATE_SHADER_GEOMETRY:
                 case STATE_SHADER_GEOMETRY_TODO:
-                    if (!skip_tests)
+                    if (test_action == TEST_ACTION_RUN)
                     {
                         todo_if (state == STATE_SHADER_GEOMETRY_TODO)
                         compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_GS,
                                 expect_hr);
                     }
+                    if (test_action == TEST_ACTION_SKIP_CAPS)
+                        vkd3d_test_skip(line_number, "Missing capabilities.\n");
                     free(runner->gs_source);
                     runner->gs_source = shader_source;
                     shader_source = NULL;
@@ -1810,7 +1829,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                     ID3D10Blob *blob = NULL, *errors = NULL;
                     HRESULT hr;
 
-                    if (skip_tests)
+                    if (test_action != TEST_ACTION_RUN)
                         break;
 
                     hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors);
@@ -1836,7 +1855,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                     HRESULT hr;
                     char *text;
 
-                    if (skip_tests)
+                    if (test_action != TEST_ACTION_RUN)
                         break;
 
                     hr = D3DPreprocess(shader_source, strlen(shader_source), NULL, NULL, NULL, &blob, &errors);
@@ -1891,7 +1910,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                 runner->require_rov = false;
                 runner->require_wave_ops = false;
                 runner->compile_options = 0;
-                skip_tests = false;
+                test_action = TEST_ACTION_RUN;
             }
             else if (match_directive_substring(line, "[pixel shader", &line))
             {
@@ -2086,7 +2105,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
                 case STATE_TEST:
                     /* Compilation which fails with dxcompiler is not 'todo', therefore the tests are
                      * not 'todo' either. They cannot run, so skip them entirely. */
-                    if (!runner->failed_resource_count && !skip_tests && SUCCEEDED(expect_hr))
+                    if (!runner->failed_resource_count && test_action == TEST_ACTION_RUN && SUCCEEDED(expect_hr))
                         parse_test_directive(runner, line);
                     break;
             }
diff --git a/tests/test-driver.sh b/tests/test-driver.sh
index b7104a3445..2499bd40cd 100755
--- a/tests/test-driver.sh
+++ b/tests/test-driver.sh
@@ -1,7 +1,7 @@
 #! /bin/sh
 # test-driver - basic testsuite driver script. Modified for vkd3d tests.
 
-scriptversion=2022-02-20.01; # UTC
+scriptversion=2024-08-05.01; # UTC
 
 # This is a modified version of the test_driver script provided by
 # auto-tools, whose licence is as follows:
@@ -173,6 +173,10 @@ BEGIN {
     print "<fade>" $4 "<reset>" "[XP]"
 }
 
+/: Test skipped:/ {
+    print "<fade>" $4 "<reset>" "[SK]"
+}
+
 /: Assertion .* failed\./ {
     print "#    [AF] <fade>" $0 "<reset>"
 }
@@ -198,10 +202,14 @@ fi
 # Count number of [XF] tags.
 xfcount=$(echo "$details" | awk '/\[XF\]/{count++} END{printf "%d", count}')
 
+# Count number of [SK] tags.
+skcount=$(echo "$details" | awk '/\[SK\]/{count++} END{printf "%d", count}')
+
 details=$(echo "$details" |\
     sed "s/\[F\]/$color_bright_red[F]$color_reset/g" |\
     sed "s/\[XF\]/$color_yellow[XF]$color_reset/g" |\
     sed "s/\[XP\]/$color_dark_red[XP]$color_reset/g" |\
+    sed "s/\[SK\]/$color_blue[SK]$color_reset/g" |\
     sed "s/\[AF\]/$color_bright_purple[AF]$color_reset/g" |\
     sed "s/\[SIGABRT\]/$color_bright_purple[SIGABRT]$color_reset/g" |\
     sed "s/\[SIGSEGV\]/$color_bright_purple[SIGSEGV]$color_reset/g" |\
@@ -211,9 +219,15 @@ details=$(echo "$details" |\
     tr '#' '\n' |\
     awk 'NF != 1' )
 
-# If the test passes but has [XF], we will omit details but report number of [XF]
-if [ "$res" = "PASS" ] && [ "$xfcount" -gt 0 ]; then
-  details="$color_yellow($xfcount XF)$color_reset"
+# If the test passes, we will omit details but report number of [XF] and [SK]
+if [ "$res" = "PASS" ]; then
+  details=""
+  if [ "$xfcount" -gt 0 ]; then
+    details="$details $color_yellow($xfcount XF)$color_reset"
+  fi
+  if [ "$skcount" -gt 0 ]; then
+    details="$details $color_blue($skcount SK)$color_reset"
+  fi
 fi
 
 # Report outcome to console.
-- 
GitLab


From 9dec7403d9aaf129169a98cd14623c2f2ba775a5 Mon Sep 17 00:00:00 2001
From: Francisco Casas <fcasas@codeweavers.com>
Date: Thu, 1 Aug 2024 17:51:11 -0400
Subject: [PATCH 3/4] tests/shader-runner: Add missing trace for wave_ops caps.

---
 tests/shader_runner.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/shader_runner.c b/tests/shader_runner.c
index 6390f0ab64..d785e3554f 100644
--- a/tests/shader_runner.c
+++ b/tests/shader_runner.c
@@ -1644,6 +1644,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
     trace("   float64: %u.\n", caps->float64);
     trace("     int64: %u.\n", caps->int64);
     trace("       rov: %u.\n", caps->rov);
+    trace("  wave_ops: %u.\n", caps->wave_ops);
 
     if (!test_options.filename)
         fatal_error("No filename specified.\n");
-- 
GitLab


From 51abec8c992c70bd30e7ea5d46fcfde81255795c Mon Sep 17 00:00:00 2001
From: Francisco Casas <fcasas@codeweavers.com>
Date: Tue, 6 Aug 2024 17:43:28 -0400
Subject: [PATCH 4/4] tests: Introduce VKD3D_TEST_DETAILED for the test driver.

Useful to know which tests on which backends were skipped.
---
 README               | 4 ++++
 tests/test-driver.sh | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/README b/README
index f6ded1cdbc..0db8a30dd4 100644
--- a/README
+++ b/README
@@ -78,6 +78,10 @@ commas or semicolons.
  * VKD3D_TEST_DEBUG - enables additional debug messages in tests. Set to 0, 1
    or 2.
 
+ * VKD3D_TEST_DETAILED - enables printing detailed output when running the test
+   suite, reporting specific shader_test lines that trigger XFAIL and SKIP even
+   on tests that overall PASS. Set to 0, or 1.
+
  * VKD3D_TEST_FILTER - a filter string. Only the tests whose names matches the
    filter string will be run, e.g. VKD3D_TEST_FILTER=clear_render_target.
    Useful for debugging or developing new tests.
diff --git a/tests/test-driver.sh b/tests/test-driver.sh
index 2499bd40cd..22371d3ac6 100755
--- a/tests/test-driver.sh
+++ b/tests/test-driver.sh
@@ -219,8 +219,11 @@ details=$(echo "$details" |\
     tr '#' '\n' |\
     awk 'NF != 1' )
 
+# Set VKD3D_TEST_DETAILED to 0 if unset.
+VKD3D_TEST_DETAILED=${VKD3D_TEST_DETAILED:-0}
+
 # If the test passes, we will omit details but report number of [XF] and [SK]
-if [ "$res" = "PASS" ]; then
+if [ "$res" = "PASS" ] && [ "$VKD3D_TEST_DETAILED" != "1" ]; then
   details=""
   if [ "$xfcount" -gt 0 ]; then
     details="$details $color_yellow($xfcount XF)$color_reset"
-- 
GitLab