Zebediah Figura : tests: Import HLSL conditional tests from Wine.
Alexandre Julliard
julliard at winehq.org
Thu Oct 1 15:50:16 CDT 2020
Module: vkd3d
Branch: master
Commit: b64b3040612b3ba314900398710996d1c198a391
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=b64b3040612b3ba314900398710996d1c198a391
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Wed Sep 30 21:01:21 2020 -0500
tests: Import HLSL conditional tests from Wine.
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/conditional.shader_test | 13 +++++++++++
tests/d3d12_test_utils.h | 51 ++++++++++++++++++++++++++-----------------
tests/shader_runner_d3d12.c | 25 +++++++++++++++++++++
3 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/tests/conditional.shader_test b/tests/conditional.shader_test
new file mode 100644
index 0000000..70718f1
--- /dev/null
+++ b/tests/conditional.shader_test
@@ -0,0 +1,13 @@
+[pixel shader]
+float4 main(float4 pos : SV_POSITION) : SV_TARGET
+{
+ if(pos.x > 200.0)
+ return float4(0.1, 0.2, 0.3, 0.4);
+ else
+ return float4(0.9, 0.8, 0.7, 0.6);
+}
+
+[test]
+draw quad
+probe rect rgba (0, 0, 200, 480) (0.9, 0.8, 0.7, 0.6)
+probe rect rgba (200, 0, 440, 480) (0.1, 0.2, 0.3, 0.4)
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index ece4896..a1e039d 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -585,6 +585,36 @@ static void check_readback_data_uint_(unsigned int line, struct resource_readbac
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 void check_readback_data_vec4_(unsigned int line, struct resource_readback *rb,
+ const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
+{
+ RECT r = {0, 0, rb->width, rb->height};
+ unsigned int x = 0, y = 0;
+ struct vec4 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_vec4(rb, x, y);
+ if (!compare_vec4(&got, expected, max_diff))
+ {
+ all_match = false;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
+ got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
+}
+
#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,
@@ -603,29 +633,10 @@ static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *t
const struct vec4 *expected, unsigned int max_diff)
{
struct resource_readback rb;
- unsigned int x = 0, y;
- bool all_match = true;
- struct vec4 got = {0};
get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
- for (y = 0; y < rb.height; ++y)
- {
- for (x = 0; x < rb.width; ++x)
- {
- got = *get_readback_vec4(&rb, x, y);
- if (!compare_vec4(&got, expected, max_diff))
- {
- all_match = false;
- break;
- }
- }
- if (!all_match)
- break;
- }
+ check_readback_data_vec4_(line, &rb, NULL, expected, max_diff);
release_resource_readback(&rb);
-
- ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
- got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
}
#define create_default_buffer(a, b, c, d) create_default_buffer_(__LINE__, a, b, c, d)
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
index f323a54..e429d38 100644
--- a/tests/shader_runner_d3d12.c
+++ b/tests/shader_runner_d3d12.c
@@ -167,6 +167,29 @@ static void parse_test_directive(struct shader_context *context, const char *lin
check_sub_resource_vec4(context->c.render_target, 0, context->c.queue, context->c.list, &v, ulps);
reset_command_list(context->c.list, context->c.allocator);
}
+ else if (match_string(line, "probe rect rgba", &line))
+ {
+ unsigned int x, y, w, h, ulps;
+ struct resource_readback rb;
+ struct vec4 v;
+ RECT rect;
+ int ret;
+
+ ret = sscanf(line, "( %u , %u , %u , %u ) ( %f , %f , %f , %f )", &x, &y, &w, &h, &v.x, &v.y, &v.z, &v.w);
+ if (ret < 8)
+ goto err;
+ if (ret < 9)
+ ulps = 0;
+
+ get_texture_readback_with_command_list(context->c.render_target, 0, &rb, context->c.queue, context->c.list);
+ rect.left = x;
+ rect.right = x + w;
+ rect.top = y;
+ rect.bottom = y + h;
+ check_readback_data_vec4(&rb, &rect, &v, ulps);
+ release_resource_readback(&rb);
+ reset_command_list(context->c.list, context->c.allocator);
+ }
else if (match_string(line, "uniform", &line))
{
unsigned int offset;
@@ -204,6 +227,8 @@ START_TEST(shader_runner_d3d12)
{
static const struct test_context_desc desc =
{
+ .rt_width = 640,
+ .rt_height = 480,
.no_root_signature = true,
.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT,
};
More information about the wine-cvs
mailing list