Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ tests/hlsl-struct-assignment.shader_test | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/hlsl-struct-assignment.shader_test
diff --git a/Makefile.am b/Makefile.am index 415e6862..f3a5967d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ vkd3d_shader_tests = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ + tests/hlsl-struct-assignment.shader_test \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ @@ -195,6 +196,7 @@ XFAIL_TESTS = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ + tests/hlsl-struct-assignment.shader_test \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ diff --git a/tests/hlsl-struct-assignment.shader_test b/tests/hlsl-struct-assignment.shader_test new file mode 100644 index 00000000..ea55b9ad --- /dev/null +++ b/tests/hlsl-struct-assignment.shader_test @@ -0,0 +1,23 @@ +[pixel shader] +struct apple +{ + struct + { + float4 a; + } m; + float4 b; +}; + +float4 main() : sv_target +{ + struct apple q, r, s; + + q.m.a = float4(0.1, 0.2, 0.3, 0.4); + q.b = float4(0.5, 0.1, 0.4, 0.5); + s = r = q; + return s.m.a + s.b; +} + +[test] +draw quad +probe all rgba (0.6, 0.3, 0.7, 0.9) 1
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ tests/hlsl-struct-varying.shader_test | 29 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/hlsl-struct-varying.shader_test
diff --git a/Makefile.am b/Makefile.am index f3a5967d..ce0d193c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,7 @@ vkd3d_shader_tests = \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-struct-assignment.shader_test \ + tests/hlsl-struct-varying.shader_test \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ @@ -197,6 +198,7 @@ XFAIL_TESTS = \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-struct-assignment.shader_test \ + tests/hlsl-struct-varying.shader_test \ tests/hlsl-vector-indexing.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ diff --git a/tests/hlsl-struct-varying.shader_test b/tests/hlsl-struct-varying.shader_test new file mode 100644 index 00000000..b623a998 --- /dev/null +++ b/tests/hlsl-struct-varying.shader_test @@ -0,0 +1,29 @@ +[pixel shader] +struct input +{ + struct + { + float4 pos : sv_position; + } m; +}; + +struct output +{ + struct + { + float4 color : sv_target; + } m; +}; + +struct output main(struct input i) +{ + struct output o; + o.m.color = i.m.pos; + return o; +} + +[test] +draw quad +probe rgba (0, 1) (0.5, 1.5, 0.0, 1.0) +probe rgba (1, 0) (1.5, 0.5, 0.0, 1.0) +probe rgba (3, 5) (3.5, 5.5, 0.0, 1.0)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ tests/hlsl-static-initializer.shader_test | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/hlsl-static-initializer.shader_test
diff --git a/Makefile.am b/Makefile.am index ce0d193c..15be1371 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ vkd3d_shader_tests = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ + tests/hlsl-static-initializer.shader_test \ tests/hlsl-struct-assignment.shader_test \ tests/hlsl-struct-varying.shader_test \ tests/hlsl-vector-indexing.shader_test \ @@ -197,6 +198,7 @@ XFAIL_TESTS = \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ + tests/hlsl-static-initializer.shader_test \ tests/hlsl-struct-assignment.shader_test \ tests/hlsl-struct-varying.shader_test \ tests/hlsl-vector-indexing.shader_test \ diff --git a/tests/hlsl-static-initializer.shader_test b/tests/hlsl-static-initializer.shader_test new file mode 100644 index 00000000..9b9d000f --- /dev/null +++ b/tests/hlsl-static-initializer.shader_test @@ -0,0 +1,15 @@ +[pixel shader] +float myfunc() +{ + return 0.6; +} +static float a = myfunc() + 0.2; +static float b; +float4 main() : sv_target +{ + return float4(a, b, 0, 0); +} + +[test] +draw quad +probe all rgba (0.8, 0.0, 0.0, 0.0)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 + tests/hlsl-invalid.shader_test | 117 +++++++++++++++++++++++++++++++++ tests/shader_runner_d3d12.c | 47 +++++++++++-- 3 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 tests/hlsl-invalid.shader_test
diff --git a/Makefile.am b/Makefile.am index 15be1371..93289a23 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ vkd3d_shader_tests = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-comma.shader_test \ + tests/hlsl-invalid.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ @@ -194,6 +195,7 @@ XFAIL_TESTS = \ tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-comma.shader_test \ + tests/hlsl-invalid.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ diff --git a/tests/hlsl-invalid.shader_test b/tests/hlsl-invalid.shader_test new file mode 100644 index 00000000..16e75d0a --- /dev/null +++ b/tests/hlsl-invalid.shader_test @@ -0,0 +1,117 @@ +[pixel shader fail] +float4 main() : sv_target +{ + return y; +} + +[pixel shader fail] +float4 main() : sv_target +{ + float4 x = float4(0, 0, 0, 0); + x.xzzx = float4(1, 2, 3, 4); + return x; +} + +[pixel shader fail] +float4 main(float2 pos : TEXCOORD0) : sv_target +{ + float4 x = pos; + return x; +} + +[pixel shader fail] +float4 563r(float2 45s : TEXCOORD0) : sv_target +{ + float4 x = 45s; + return float4(x.x, x.y, 0, 0); +} + +[pixel shader fail] +float4 main() : sv_target +{ + struct { int b,c; } x = {0}; + return x; +} + +[pixel shader fail] +float4 main() : sv_target +{ + struct {} x = {}; + return x; +} + +[pixel shader fail] +float4 main(float2 pos : TEXCOORD0) : sv_target +{ + return; +} + +[pixel shader fail] +void main(float2 pos : TEXCOORD0) +{ + return pos; +} + +[pixel shader fail] +float4 main(float2 pos : TEXCOORD0) : sv_target +{ + return pos; +} + +[pixel shader fail] +float4 main() : sv_target +{ + float a[0]; + return 0; +} + +[pixel shader fail] +float4 main() : sv_target +{ + float a[65537]; + return 0; +} + +[pixel shader fail] +float4 main() : sv_target +{ + int x; + float a[(x = 2)]; + return 0; +} + +[pixel shader fail] +uniform float4 main() : sv_target +{ + return 0; +} + +[pixel shader fail] +typedef row_major float4x4 matrix_t; +typedef column_major matrix_t matrix2_t; + +float4 main() : sv_target +{ + return 0; +} + +[pixel shader fail] +float4 main() +{ + return 0; +} + +[pixel shader fail] +float4 main(out float4 o : sv_target) +{ + o = 1; + return 0; +} + +[pixel shader fail] +struct {float4 a;}; + +float4 main() : sv_target +{ + return 0; +} diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 0e9694a4..df7076ce 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -102,6 +102,7 @@ static ID3D10Blob *compile_shader(const char *source, const char *target) enum parse_state { STATE_NONE, + STATE_SHADER_INVALID_PIXEL, STATE_SHADER_PIXEL, STATE_TEST, }; @@ -269,10 +270,10 @@ START_TEST(shader_runner_d3d12) }; size_t shader_source_size = 0, shader_source_len = 0; enum parse_state state = STATE_NONE; + unsigned int i, line_number = 0; struct shader_context context; const char *filename = NULL; char *shader_source = NULL; - unsigned int i; char line[256]; FILE *f;
@@ -304,12 +305,13 @@ START_TEST(shader_runner_d3d12) memset(&context, 0, sizeof(context)); init_test_context(&context.c, &desc);
- while (fgets(line, sizeof(line), f)) + for (;;) { - if (line[0] == '\n') - continue; + char *ret = fgets(line, sizeof(line), f);
- if (line[0] == '[') + ++line_number; + + if (!ret || line[0] == '[') { switch (state) { @@ -322,14 +324,43 @@ START_TEST(shader_runner_d3d12) return; shader_source_len = 0; break; + + case STATE_SHADER_INVALID_PIXEL: + { + ID3D10Blob *blob = NULL, *errors = NULL; + HRESULT hr; + + hr = D3DCompile(shader_source, strlen(shader_source), NULL, + NULL, NULL, "main", "ps_4_0", 0, 0, &blob, &errors); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!blob, "Expected no compiled shader blob.\n"); + ok(!!errors, "Expected non-NULL error blob.\n"); + + if (vkd3d_test_state.debug_level) + trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); + ID3D10Blob_Release(errors); + + shader_source_len = 0; + break; + } } + } + + if (!ret) + break;
+ if (line[0] == '[') + { if (!strcmp(line, "[pixel shader]\n")) state = STATE_SHADER_PIXEL; + else if (!strcmp(line, "[pixel shader fail]\n")) + state = STATE_SHADER_INVALID_PIXEL; else if (!strcmp(line, "[test]\n")) state = STATE_TEST; + + vkd3d_test_set_context("Section %.*s, line %u", strlen(line) - 1, line, line_number); } - else + else if (line[0] != '\n') { switch (state) { @@ -338,6 +369,7 @@ START_TEST(shader_runner_d3d12) fprintf(stderr, "Ignoring line '%s' in %s.\n", line, argv[1]); break;
+ case STATE_SHADER_INVALID_PIXEL: case STATE_SHADER_PIXEL: { size_t len = strlen(line); @@ -356,7 +388,8 @@ START_TEST(shader_runner_d3d12) } }
- ID3D10Blob_Release(context.ps_code); + if (context.ps_code) + ID3D10Blob_Release(context.ps_code); destroy_test_context(&context.c);
fclose(f);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com