Module: vkd3d Branch: master Commit: 130e7bdf0f94269a42ea3ab5d78be2c6215b35b5 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/130e7bdf0f94269a42ea3ab5d78be2...
Author: Conor McCarthy cmccarthy@codeweavers.com Date: Fri Nov 10 14:48:23 2023 +1000
tests/shader-runner: Add tests for 64-bit casts.
---
Makefile.am | 1 + tests/d3d12.c | 5 --- tests/hlsl/cast-64-bit.shader_test | 57 +++++++++++++++++++++++++++++++++ tests/shader_runner.c | 64 ++++++++++++++++++++++++++++++++++++++ tests/utils.h | 15 +++++++++ 5 files changed, 137 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am index a5c5fe62..2666194a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,7 @@ vkd3d_shader_tests = \ tests/hlsl/bitwise.shader_test \ tests/hlsl/bool-cast.shader_test \ tests/hlsl/bool-semantics.shader_test \ + tests/hlsl/cast-64-bit.shader_test \ tests/hlsl/cast-broadcast.shader_test \ tests/hlsl/cast-componentwise-compatible.shader_test \ tests/hlsl/cast-componentwise-equal.shader_test \ diff --git a/tests/d3d12.c b/tests/d3d12.c index 649d86ec..aa6b880f 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -42,11 +42,6 @@ static ID3D10Blob *compile_shader(const char *source, size_t len, const char *pr return bytecode; }
-struct dvec2 -{ - double x, y; -}; - static bool compare_uint8(uint8_t a, uint8_t b, unsigned int max_diff) { return abs(a - b) <= max_diff; diff --git a/tests/hlsl/cast-64-bit.shader_test b/tests/hlsl/cast-64-bit.shader_test new file mode 100644 index 00000000..813cce10 --- /dev/null +++ b/tests/hlsl/cast-64-bit.shader_test @@ -0,0 +1,57 @@ +[require] +shader model >= 5.0 + +[pixel shader todo] +uniform double2 d; +uniform float2 f; + +float4 main() : sv_target +{ + double2 n = d / f; + return float4(d.x, d.y, n.x, n.y); +} + +[test] +uniform 0 double2 -4.5 8.5 +uniform 4 float4 -2.25 4.25 0.0 0.0 +todo(sm<6) draw quad +probe all rgba (-4.5, 8.5, 2.0, 2.0) + + +[require] +shader model >= 6.0 + +[pixel shader] +uniform uint64_t2 l; +uniform uint2 u; + +float4 main() : sv_target +{ + uint64_t2 n = l / u; + uint4 result = uint4(l.x, l.y, n.x, n.y); + return result; +} + +[test] +uniform 0 uint64_t2 0x500000001 0x100000002 +uniform 4 uint4 10 4 0 0 +todo draw quad +todo probe all rgba (1.0, 2.0, 2147483648.0, 1073741824.0) + + +[pixel shader] +uniform int64_t2 l; +uniform int2 i; + +float4 main() : sv_target +{ + int64_t2 n = l / i; + int4 result = int4(l.x, l.y, n.x, n.y); + return result; +} + +[test] +uniform 0 int64_t2 -21474836481 0x100000002 +uniform 4 int4 -20 8 0 0 +todo draw quad +todo probe all rgba (-1.0, 2.0, 1073741824.0, 536870912.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 7e595814..e9fa32c4 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -491,6 +491,48 @@ static void read_uint4(const char **line, struct uvec4 *v) read_uint(line, &v->w); }
+static void read_int64(const char **line, int64_t *i) +{ + char *rest; + int64_t val; + + errno = 0; + val = strtoll(*line, &rest, 0); + + if (errno != 0 || (*rest != '\0' && !isspace((unsigned char)*rest))) + fatal_error("Malformed int64 constant '%s'.\n", *line); + + *i = val; + *line = rest; +} + +static void read_uint64(const char **line, uint64_t *u) +{ + char *rest; + uint64_t val; + + errno = 0; + val = strtoull(*line, &rest, 0); + + if (errno != 0 || (*rest != '\0' && !isspace((unsigned char)*rest))) + fatal_error("Malformed uint64 constant '%s'.\n", *line); + + *u = val; + *line = rest; +} + +static void read_int64_t2(const char **line, struct i64vec2 *v) +{ + read_int64(line, &v->x); + read_int64(line, &v->y); +} + +static void read_uint64_t2(const char **line, struct u64vec2 *v) +{ + read_uint64(line, &v->x); + read_uint64(line, &v->y); +} + static void parse_test_directive(struct shader_runner *runner, const char *line) { char *rest; @@ -726,6 +768,14 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) fatal_error("Malformed float constant '%s'.\n", line); set_uniforms(runner, offset, 1, &f); } + else if (match_string(line, "double2", &line)) + { + struct dvec2 v; + + if (sscanf(line, "%lf %lf", &v.x, &v.y) < 2) + fatal_error("Malformed double2 constant '%s'.\n", line); + set_uniforms(runner, offset, 4, &v); + } else if (match_string(line, "int4", &line)) { struct ivec4 v; @@ -754,6 +804,20 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) read_uint(&line, &u); set_uniforms(runner, offset, 1, &u); } + else if (match_string(line, "int64_t2", &line)) + { + struct i64vec2 v; + + read_int64_t2(&line, &v); + set_uniforms(runner, offset, 4, &v); + } + else if (match_string(line, "uint64_t2", &line)) + { + struct u64vec2 v; + + read_uint64_t2(&line, &v); + set_uniforms(runner, offset, 4, &v); + } else { fatal_error("Unknown uniform type '%s'.\n", line); diff --git a/tests/utils.h b/tests/utils.h index 67094190..e8bbacc3 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -35,6 +35,11 @@ struct vec4 float x, y, z, w; };
+struct dvec2 +{ + double x, y; +}; + struct ivec4 { int x, y, z, w; @@ -45,6 +50,16 @@ struct uvec4 unsigned int x, y, z, w; };
+struct i64vec2 +{ + int64_t x, y; +}; + +struct u64vec2 +{ + uint64_t x, y; +}; + struct resource_readback { uint64_t width;