From: Evan Tang etang@codeweavers.com
--- tests/d3d12.c | 5 --- tests/d3d12_test_utils.h | 48 ----------------------- tests/shader_runner.c | 27 ++++++++++++- tests/utils.h | 82 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 54 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index c2a6ca92e..a007d281b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -254,11 +254,6 @@ 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 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_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 *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index 2c7b10f45..d65bf636e 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -74,14 +74,6 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y, vp->MaxDepth = max_depth; }
-static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff) -{ - return compare_uint(c1 & 0xff, c2 & 0xff, max_diff) - && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff) - && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff) - && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff); -} - static D3D12_SHADER_BYTECODE shader_bytecode(const DWORD *code, size_t size) { D3D12_SHADER_BYTECODE shader_bytecode = { code, size }; @@ -509,12 +501,6 @@ static void get_resource_readback_with_command_list(ID3D12Resource *resource, un assert_that(hr == S_OK, "Failed to map readback buffer, hr %#x.\n", hr); }
-static unsigned int get_readback_uint(struct resource_readback *rb, - unsigned int x, unsigned int y, unsigned int z) -{ - return *(unsigned int *)get_readback_data(rb, x, y, z, sizeof(unsigned int)); -} - static void release_resource_readback(struct d3d12_resource_readback *rb) { D3D12_RANGE range = {0, 0}; @@ -522,40 +508,6 @@ static void release_resource_readback(struct d3d12_resource_readback *rb) ID3D12Resource_Release(rb->resource); }
-#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__LINE__, a, b, c, d) -static void check_readback_data_uint_(unsigned int line, struct resource_readback *rb, - const D3D12_BOX *box, unsigned int expected, unsigned int max_diff) -{ - D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth}; - unsigned int x = 0, y = 0, z; - bool all_match = true; - unsigned int got = 0; - - if (box) - b = *box; - - for (z = b.front; z < b.back; ++z) - { - for (y = b.top; y < b.bottom; ++y) - { - for (x = b.left; x < b.right; ++x) - { - got = get_readback_uint(rb, x, y, z); - if (!compare_color(got, expected, max_diff)) - { - all_match = false; - break; - } - } - if (!all_match) - break; - } - if (!all_match) - break; - } - ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z); -} - #define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f) static inline void check_sub_resource_uint_(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 f6948b765..99f4b5c10 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -671,7 +671,16 @@ 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)) + if (match_string(line, "rgbaui", &line)) + { + struct uvec4 v; + + ret = sscanf(line, "( %i , %i , %i , %i )", &v.x, &v.y, &v.z, &v.w); + if (ret < 4) + fatal_error("Malformed probe arguments '%s'.\n", line); + todo_if(runner->is_todo) check_readback_data_uvec4(rb, &rect, &v); + } + else if (match_string(line, "rgba", &line)) { struct vec4 v;
@@ -682,6 +691,22 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) ulps = 0; todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps); } + else if (match_string(line, "rui", &line)) + { + unsigned int expect; + D3D12_BOX box; + + box.left = rect.left; + box.right = rect.right; + box.top = rect.top; + box.bottom = rect.bottom; + box.front = 0; + box.back = 1; + ret = sscanf(line, "( %i )", &expect); + if (ret < 1) + fatal_error("Malformed probe arguments '%s'.\n", line); + todo_if(runner->is_todo) check_readback_data_uint(rb, &box, expect, 0); + } else if (match_string(line, "r", &line)) { float expect; diff --git a/tests/utils.h b/tests/utils.h index 670941905..66e01c33d 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -89,6 +89,14 @@ static bool compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) return diff <= max_diff; }
+static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff) +{ + return compare_uint(c1 & 0xff, c2 & 0xff, max_diff) + && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff) + && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff) + && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff); +} + static bool compare_float(float f, float g, unsigned int ulps) { int x, y; @@ -144,11 +152,21 @@ static float get_readback_float(const struct resource_readback *rb, unsigned int return *(float *)get_readback_data(rb, x, y, 0, sizeof(float)); }
+static unsigned int get_readback_uint(const struct resource_readback *rb, unsigned int x, unsigned int y, unsigned int z) +{ + return *(unsigned int*)get_readback_data(rb, x, y, z, sizeof(unsigned int)); +} + 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)); }
+static const struct uvec4 *get_readback_uvec4(const 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 inline void check_readback_data_float_(unsigned int line, const struct resource_readback *rb, const RECT *rect, float expected, unsigned int max_diff) @@ -178,6 +196,40 @@ static inline void check_readback_data_float_(unsigned int line, const struct re ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y); }
+#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__LINE__, a, b, c, d) +static inline void check_readback_data_uint_(unsigned int line, struct resource_readback *rb, + const D3D12_BOX *box, unsigned int expected, unsigned int max_diff) +{ + D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth}; + unsigned int x = 0, y = 0, z; + bool all_match = true; + unsigned int got = 0; + + if (box) + b = *box; + + for (z = b.front; z < b.back; ++z) + { + for (y = b.top; y < b.bottom; ++y) + { + for (x = b.left; x < b.right; ++x) + { + got = get_readback_uint(rb, x, y, z); + if (!compare_color(got, expected, max_diff)) + { + all_match = false; + break; + } + } + if (!all_match) + break; + } + if (!all_match) + break; + } + ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z); +} + #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) @@ -208,6 +260,36 @@ static inline void check_readback_data_vec4_(unsigned int line, const struct res got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); }
+#define check_readback_data_uvec4(a, b, c) check_readback_data_uvec4_(__LINE__, a, b, c) +static inline void check_readback_data_uvec4_(unsigned int line, const struct resource_readback *rb, + const RECT *rect, const struct uvec4 *expected) +{ + RECT r = {0, 0, rb->width, rb->height}; + unsigned int x = 0, y = 0; + struct uvec4 got = {0}; + bool all_match = true; + + if (rect) + r = *rect; + + for (y = r.top; y < r.bottom; ++y) + { + for (x = r.left; x < r.right; ++x) + { + got = *get_readback_uvec4(rb, x, y); + if (!compare_uvec4(&got, expected)) + { + all_match = false; + break; + } + } + if (!all_match) + break; + } + ok_(line)(all_match, "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n", + got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); +} + struct test_options { bool use_warp_device;