Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
-- v3: tests: Add some tests for 'technique' token behaviour. tests: Add [effect] section support.
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- tests/shader_runner.c | 43 +++++++++++++++++++++++++++++++++++++++++-- tests/shader_runner.h | 2 ++ 2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 9b9d1d9e4..ec34c4b7d 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -89,6 +89,8 @@ enum parse_state STATE_SHADER_PIXEL_TODO, STATE_SHADER_VERTEX, STATE_SHADER_VERTEX_TODO, + STATE_SHADER_EFFECT, + STATE_SHADER_EFFECT_TODO, STATE_TEST, };
@@ -814,6 +816,7 @@ const char *shader_type_string(enum shader_type type) [SHADER_TYPE_CS] = "cs", [SHADER_TYPE_PS] = "ps", [SHADER_TYPE_VS] = "vs", + [SHADER_TYPE_FX] = "fx", }; assert(type < ARRAY_SIZE(shader_types)); return shader_types[type]; @@ -953,6 +956,14 @@ static void compile_shader(struct shader_runner *runner, IDxcCompiler3 *dxc_comp [SHADER_MODEL_6_0] = "6_0", };
+ static const char *const effect_models[] = + { + [SHADER_MODEL_2_0] = "2_0", + [SHADER_MODEL_4_0] = "4_0", + [SHADER_MODEL_4_1] = "4_1", + [SHADER_MODEL_5_0] = "5_0", + }; + if (use_dxcompiler) { assert(dxc_compiler); @@ -960,7 +971,10 @@ static void compile_shader(struct shader_runner *runner, IDxcCompiler3 *dxc_comp } else { - sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); + if (type == SHADER_TYPE_FX) + sprintf(profile, "%s_%s", shader_type_string(type), effect_models[runner->minimum_shader_model]); + else + sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); } hr = map_unidentified_hrs(hr); @@ -996,8 +1010,10 @@ static enum parse_state read_shader_directive(struct shader_runner *runner, enum state = STATE_SHADER_COMPUTE_TODO; else if (state == STATE_SHADER_PIXEL) state = STATE_SHADER_PIXEL_TODO; - else + else if (state == STATE_SHADER_VERTEX) state = STATE_SHADER_VERTEX_TODO; + else + state = STATE_SHADER_EFFECT_TODO; } else if (match_directive_substring(src, "fail", &src)) { @@ -1130,6 +1146,21 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o shader_source_size = 0; break;
+ case STATE_SHADER_EFFECT: + case STATE_SHADER_EFFECT_TODO: + if (!skip_tests) + { + todo_if (state == STATE_SHADER_EFFECT_TODO) + compile_shader(runner, dxc_compiler, shader_source, shader_source_len, SHADER_TYPE_FX, + expect_hr); + } + free(runner->fx_source); + runner->fx_source = shader_source; + shader_source = NULL; + shader_source_len = 0; + shader_source_size = 0; + break; + case STATE_PREPROC_INVALID: { ID3D10Blob *blob = NULL, *errors = NULL; @@ -1318,6 +1349,12 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o expect_hr = S_OK; state = read_shader_directive(runner, state, line_buffer, line, &expect_hr); } + else if (match_directive_substring(line, "[effect", &line)) + { + state = STATE_SHADER_EFFECT; + expect_hr = S_OK; + state = read_shader_directive(runner, state, line_buffer, line, &expect_hr); + } else if (!strcmp(line, "[input layout]\n")) { state = STATE_INPUT_LAYOUT; @@ -1349,6 +1386,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o case STATE_SHADER_PIXEL_TODO: case STATE_SHADER_VERTEX: case STATE_SHADER_VERTEX_TODO: + case STATE_SHADER_EFFECT: + case STATE_SHADER_EFFECT_TODO: { size_t len = strlen(line);
diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 3efbcf362..bda44a429 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -44,6 +44,7 @@ enum shader_type SHADER_TYPE_CS, SHADER_TYPE_PS, SHADER_TYPE_VS, + SHADER_TYPE_FX, };
const char *shader_type_string(enum shader_type type); @@ -118,6 +119,7 @@ struct shader_runner char *vs_source; char *ps_source; char *cs_source; + char *fx_source; enum shader_model minimum_shader_model; enum shader_model maximum_shader_model;
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- Makefile.am | 3 + tests/hlsl/technique-fx_2.shader_test | 104 ++++++++++++++++++++++++++ tests/hlsl/technique-fx_4.shader_test | 83 ++++++++++++++++++++ tests/hlsl/technique-fx_5.shader_test | 83 ++++++++++++++++++++ 4 files changed, 273 insertions(+) create mode 100644 tests/hlsl/technique-fx_2.shader_test create mode 100644 tests/hlsl/technique-fx_4.shader_test create mode 100644 tests/hlsl/technique-fx_5.shader_test
diff --git a/Makefile.am b/Makefile.am index 8364aaa37..8117936c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -168,6 +168,9 @@ vkd3d_shader_tests = \ tests/hlsl/swizzle-constant-prop.shader_test \ tests/hlsl/swizzle-matrix.shader_test \ tests/hlsl/swizzles.shader_test \ + tests/hlsl/technique-fx_2.shader_test \ + tests/hlsl/technique-fx_4.shader_test \ + tests/hlsl/technique-fx_5.shader_test \ tests/hlsl/ternary.shader_test \ tests/hlsl/texture-load-offset.shader_test \ tests/hlsl/texture-load-typed.shader_test \ diff --git a/tests/hlsl/technique-fx_2.shader_test b/tests/hlsl/technique-fx_2.shader_test new file mode 100644 index 000000000..149506e68 --- /dev/null +++ b/tests/hlsl/technique-fx_2.shader_test @@ -0,0 +1,104 @@ +[require] +shader model < 3.0 + +[pixel shader fail todo] +float4 main() : sv_target +{ + float4 teChnique = {0, 0, 0, 0}; + return teChnique; +} + +[pixel shader fail] +float4 main() : sv_target +{ + float4 technique10 = {0, 0, 0, 0}; + return technique10; +} + +[pixel shader fail todo] +float4 main() : sv_target +{ + float4 technique11 = {0, 0, 0, 0}; + return technique11; +} + +[pixel shader fail] +typedef float4 technique10; + +float4 main() : sv_target +{ + return float4(0, 0, 0, 0); +} + +[pixel shader fail todo] +typedef float4 Technique; + +float4 main() : sv_target +{ + return float4(0, 0, 0, 0); +} + +[pixel shader] +typedef float4 Technique10; +typedef float4 Technique11; + +float4 main() : sv_target +{ + return float4(0, 0, 0, 0); +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique10 = {0, 0, 0, 0}; + float4 teChnique11 = {0, 0, 0, 0}; + return teChnique10 + teChnique11; +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique11 = {0, 0, 0, 0}; + return teChnique11; +} + +[effect todo] +technique +{ +} + +technique10 +{ +} + +% Effects without techniques are not allowed for fx_2_0 +[effect fail] +float4 f; + +% fx_5_0 keyword fails with fx_2_0 profile +[effect fail] +technique +{ +} + +technique11 +{ +} + +[effect fail] +technique +{ +} + +tEchnique10 +{ +} + +[effect fail] +technique +{ +} + +tEchnique11 +{ +} diff --git a/tests/hlsl/technique-fx_4.shader_test b/tests/hlsl/technique-fx_4.shader_test new file mode 100644 index 000000000..dd4fdc271 --- /dev/null +++ b/tests/hlsl/technique-fx_4.shader_test @@ -0,0 +1,83 @@ +[require] +shader model >= 4.0 +shader model < 6.0 + +[pixel shader fail todo] +float4 main() : sv_target +{ + float4 teChnique = {0, 0, 0, 0}; + return teChnique; +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique10 = {0, 0, 0, 0}; + return teChnique10; +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique11 = {0, 0, 0, 0}; + return teChnique11; +} + +[effect todo] +technique +{ +} + +technique10 +{ +} + +% Effects without techniques are allowed for fx_4_0+ +[effect todo] +float4 f; + +% fx_2_0 keyword is allowed with fx_4_0+ profiles +[effect todo] +technique +{ +} + +technique11 +{ +} + +[effect fail] +technique +{ +} + +tEchnique10 +{ +} + +[effect fail] +technique +{ +} + +tEchnique11 +{ +} + +[effect fail] +float4 technique; + +[effect fail] +float4 technIque; + +[effect fail] +float4 technique10; + +[effect fail] +float4 technique11; + +[effect todo] +float4 technIque10; + +[effect todo] +float4 technIque11; diff --git a/tests/hlsl/technique-fx_5.shader_test b/tests/hlsl/technique-fx_5.shader_test new file mode 100644 index 000000000..ae253234d --- /dev/null +++ b/tests/hlsl/technique-fx_5.shader_test @@ -0,0 +1,83 @@ +[require] +shader model >= 5.0 +shader model < 6.0 + +[pixel shader fail todo] +float4 main() : sv_target +{ + float4 teChnique = {0, 0, 0, 0}; + return teChnique; +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique10 = {0, 0, 0, 0}; + return teChnique10; +} + +[pixel shader] +float4 main() : sv_target +{ + float4 teChnique11 = {0, 0, 0, 0}; + return teChnique11; +} + +[effect todo] +technique +{ +} + +technique10 +{ +} + +% Effects without techniques are allowed for fx_5_0 +[effect todo] +float4 f; + +% fx_2_0 keyword is allowed with fx_5_0 profiles +[effect todo] +technique +{ +} + +technique11 +{ +} + +[effect fail] +technique +{ +} + +tEchnique10 +{ +} + +[effect fail] +technique +{ +} + +tEchnique11 +{ +} + +[effect fail] +float4 technique; + +[effect fail] +float4 technIque; + +[effect fail] +float4 technique10; + +[effect fail] +float4 technique11; + +[effect todo] +float4 technIque10; + +[effect todo] +float4 technIque11;
On Wed Oct 18 16:19:19 2023 +0000, Giovanni Mascellani wrote:
Yeah, it's true that dxcompiler is a bit more annoying than we'd like, but it's not too difficult to setup. Since 57280673e51f6b60487e91369bd57213a8243a56 the README has a paragraph on that. You basically need to download the compiler, set `DXCOMPILER_LIBS` when calling `configure` and `LD_LIBRARY_PATH` when running the tests.
I disabled effects tests on SM6+, compiler does not support them, and there is no fx_6 target.
This merge request was approved by Zebediah Figura.
This merge request was approved by Henri Verbeet.
This merge request was approved by Giovanni Mascellani.