Giovanni Mascellani : tests/shader_runner: Allow probing a single component.

Alexandre Julliard julliard at winehq.org
Tue May 31 15:45:43 CDT 2022


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

Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date:   Tue May 17 15:45:42 2022 +0200

tests/shader_runner: Allow probing a single component.

Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tests/d3d12.c         | 34 ----------------------------------
 tests/shader_runner.c | 35 ++++++++++++++++++++++++++---------
 tests/utils.h         | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 43 deletions(-)

diff --git a/tests/d3d12.c b/tests/d3d12.c
index 3c4a91e2..ec5cfb20 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -278,45 +278,11 @@ static uint64_t get_readback_uint64(struct resource_readback *rb, unsigned int x
     return *(uint64_t *)get_readback_data(rb, x, y, 0, sizeof(uint64_t));
 }
 
-static float get_readback_float(struct resource_readback *rb, unsigned int x, unsigned int y)
-{
-    return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
-}
-
 static const struct uvec4 *get_readback_uvec4(struct resource_readback *rb, unsigned int x, unsigned int y)
 {
     return get_readback_data(rb, x, y, 0, sizeof(struct uvec4));
 }
 
-#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__LINE__, a, b, c, d)
-static void check_readback_data_float_(unsigned int line, struct resource_readback *rb,
-        const RECT *rect, float expected, unsigned int max_diff)
-{
-    RECT r = {0, 0, rb->width, rb->height};
-    unsigned int x = 0, y;
-    bool all_match = true;
-    float got = 0;
-
-    if (rect)
-        r = *rect;
-
-    for (y = r.top; y < r.bottom; ++y)
-    {
-        for (x = r.left; x < r.right; ++x)
-        {
-            got = get_readback_float(rb, x, y);
-            if (!compare_float(got, expected, max_diff))
-            {
-                all_match = false;
-                break;
-            }
-        }
-        if (!all_match)
-            break;
-    }
-    ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y);
-}
-
 #define check_sub_resource_float(a, b, c, d, e, f) check_sub_resource_float_(__LINE__, a, b, c, d, e, f)
 static void check_sub_resource_float_(unsigned int line, ID3D12Resource *texture,
         unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
diff --git a/tests/shader_runner.c b/tests/shader_runner.c
index 143d0c72..05e2a8a4 100644
--- a/tests/shader_runner.c
+++ b/tests/shader_runner.c
@@ -413,7 +413,6 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
     {
         unsigned int left, top, right, bottom, ulps;
         struct resource_readback *rb;
-        struct vec4 v;
         int ret, len;
         RECT rect;
 
@@ -439,17 +438,35 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
             fatal_error("Malformed probe arguments '%s'.\n", line);
         }
 
-        if (!match_string(line, "rgba", &line))
-            fatal_error("Malformed probe arguments '%s'.\n", line);
+        rb = runner->ops->get_rt_readback(runner);
+
+        if (match_string(line, "rgba", &line))
+        {
+            struct vec4 v;
 
-        ret = sscanf(line, "( %f , %f , %f , %f ) %u", &v.x, &v.y, &v.z, &v.w, &ulps);
-        if (ret < 4)
+            ret = sscanf(line, "( %f , %f , %f , %f ) %u", &v.x, &v.y, &v.z, &v.w, &ulps);
+            if (ret < 4)
+                fatal_error("Malformed probe arguments '%s'.\n", line);
+            if (ret < 5)
+                ulps = 0;
+            todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps);
+        }
+        else if (match_string(line, "r", &line))
+        {
+            float expect;
+
+            ret = sscanf(line, "( %f ) %u", &expect, &ulps);
+            if (ret < 1)
+                fatal_error("Malformed probe arguments '%s'.\n", line);
+            if (ret < 2)
+                ulps = 0;
+            todo_if(runner->is_todo) check_readback_data_float(rb, &rect, expect, ulps);
+        }
+        else
+        {
             fatal_error("Malformed probe arguments '%s'.\n", line);
-        if (ret < 5)
-            ulps = 0;
+        }
 
-        rb = runner->ops->get_rt_readback(runner);
-        todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps);
         runner->ops->release_readback(runner, rb);
     }
     else if (match_string(line, "uniform", &line))
diff --git a/tests/utils.h b/tests/utils.h
index c7d6d772..82f0fc35 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -120,11 +120,45 @@ static void *get_readback_data(const struct resource_readback *rb,
     return &((uint8_t *)rb->data)[slice_pitch * z + rb->row_pitch * y + x * element_size];
 }
 
+static float get_readback_float(const struct resource_readback *rb, unsigned int x, unsigned int y)
+{
+    return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
+}
+
 static const struct vec4 *get_readback_vec4(const struct resource_readback *rb, unsigned int x, unsigned int y)
 {
     return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
 }
 
+#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__LINE__, a, b, c, d)
+static inline void check_readback_data_float_(unsigned int line, const struct resource_readback *rb,
+        const RECT *rect, float expected, unsigned int max_diff)
+{
+    RECT r = {0, 0, rb->width, rb->height};
+    unsigned int x = 0, y;
+    bool all_match = true;
+    float got = 0;
+
+    if (rect)
+        r = *rect;
+
+    for (y = r.top; y < r.bottom; ++y)
+    {
+        for (x = r.left; x < r.right; ++x)
+        {
+            got = get_readback_float(rb, x, y);
+            if (!compare_float(got, expected, max_diff))
+            {
+                all_match = false;
+                break;
+            }
+        }
+        if (!all_match)
+            break;
+    }
+    ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y);
+}
+
 #define check_readback_data_vec4(a, b, c, d) check_readback_data_vec4_(__LINE__, a, b, c, d)
 static inline void check_readback_data_vec4_(unsigned int line, const struct resource_readback *rb,
         const RECT *rect, const struct vec4 *expected, unsigned int max_diff)




More information about the wine-cvs mailing list