From 31ea11fb0eeffc2d46ccb43f4d490fa8d2af62db Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 18 Dec 2024 23:31:01 +0100 Subject: [PATCH] tests/shader_runner: Ignore the "backcompat" option for shader model 5.1+. --- tests/hlsl/sampler-state.shader_test | 4 +++- tests/hlsl/sampler.shader_test | 2 +- tests/shader_runner.c | 25 ++++++++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/hlsl/sampler-state.shader_test b/tests/hlsl/sampler-state.shader_test index 3aa5df44..46552a7d 100644 --- a/tests/hlsl/sampler-state.shader_test +++ b/tests/hlsl/sampler-state.shader_test @@ -135,7 +135,7 @@ float4 main(): sv_target } -[pixel shader fail(sm>=5.1) todo(sm>=5.1)] +[pixel shader fail(sm>=6)] // default value initializers make it more permissive but if types don't match // then the whole initializer is discarded. float4 f = { @@ -206,6 +206,8 @@ float4 main(): sv_target [require] shader model >= 5.0 +% Segfaults with 5.1 on d3dcompiler_47 10.0.19041.868 +shader model < 5.1 options: backcompat [pixel shader fail(sm>=5.1) todo(sm>=5.1)] diff --git a/tests/hlsl/sampler.shader_test b/tests/hlsl/sampler.shader_test index 710b2c3e..2638b326 100644 --- a/tests/hlsl/sampler.shader_test +++ b/tests/hlsl/sampler.shader_test @@ -75,7 +75,7 @@ size (2d, 3, 3) 0.0 1.0 0.0 1.0 1.0 1.0 0.0 1.0 2.0 1.0 0.0 1.0 0.0 2.0 0.0 1.0 1.0 2.0 0.0 1.0 2.0 2.0 0.0 1.0 -[pixel shader fail(sm>=6)] +[pixel shader fail(sm>=5.1) todo(sm>=5.1)] sampler s; float4 f; diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 1e73cb55..8bbbdfab 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1612,6 +1612,7 @@ static HRESULT dxc_compiler_compile_shader(void *dxc_compiler, enum shader_type ID3D10Blob *compile_hlsl(const struct shader_runner *runner, enum shader_type type) { const char *source = runner->shader_source[type]; + unsigned int options = runner->compile_options; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -1627,16 +1628,22 @@ ID3D10Blob *compile_hlsl(const struct shader_runner *runner, enum shader_type ty [SHADER_MODEL_6_0] = "6_0", }; + /* Behaviour is inconsistent between different versions of + * d3dcompiler_47.dll. Version 10.0.17134.12 seems to reject + * D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY for 5.1 profiles, while + * version 10.0.10150.0 apparently doesn't. */ + if (runner->minimum_shader_model >= SHADER_MODEL_5_1) + options &= ~D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; + if (runner->minimum_shader_model >= SHADER_MODEL_6_0) { assert(runner->dxc_compiler); - hr = dxc_compiler_compile_shader(runner->dxc_compiler, type, runner->compile_options, source, &blob); + hr = dxc_compiler_compile_shader(runner->dxc_compiler, type, options, source, &blob); } else { sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->minimum_shader_model]); - hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", - profile, runner->compile_options, 0, &blob, &errors); + hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, options, 0, &blob, &errors); } if (hr != S_OK) { @@ -1656,6 +1663,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, size_t len, enum shader_type type, enum shader_model model) { bool use_dxcompiler = (model >= SHADER_MODEL_6_0); + unsigned int options = runner->compile_options; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -1686,10 +1694,17 @@ static void compile_shader(struct shader_runner *runner, const char *source, if (model < SHADER_MODEL_5_0 && (type == SHADER_TYPE_HS || type == SHADER_TYPE_DS)) return; + /* Behaviour is inconsistent between different versions of + * d3dcompiler_47.dll. Version 10.0.17134.12 seems to reject + * D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY for 5.1 profiles, while + * version 10.0.10150.0 apparently doesn't. */ + if (model >= SHADER_MODEL_5_1) + options &= ~D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; + if (use_dxcompiler) { assert(runner->dxc_compiler); - hr = dxc_compiler_compile_shader(runner->dxc_compiler, type, runner->compile_options, source, &blob); + hr = dxc_compiler_compile_shader(runner->dxc_compiler, type, options, source, &blob); } else { @@ -1697,7 +1712,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, sprintf(profile, "%s_%s", shader_type_string(type), effect_models[model]); else sprintf(profile, "%s_%s", shader_type_string(type), shader_models[model]); - hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); + hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, options, 0, &blob, &errors); } hr = map_special_hrs(hr); todo_if (runner->hlsl_todo[model])