From 269747dbf3ee32bf23e6d1ab388d2a058ca90f9f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 25 Aug 2023 15:05:51 +0200 Subject: [PATCH] tests: Enable compiler backwards compatibility mode only for shaders that require it. Signed-off-by: Nikolay Sivov --- tests/hlsl/combined-samplers.shader_test | 2 ++ tests/hlsl/texture-ordering.shader_test | 3 +++ tests/shader_runner.c | 4 ++-- tests/shader_runner_d3d11.c | 3 +-- tests/shader_runner_d3d12.c | 3 +-- tests/shader_runner_vulkan.c | 4 ++++ 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/hlsl/combined-samplers.shader_test b/tests/hlsl/combined-samplers.shader_test index 16db3129..57644c26 100644 --- a/tests/hlsl/combined-samplers.shader_test +++ b/tests/hlsl/combined-samplers.shader_test @@ -34,6 +34,8 @@ size (1, 1) size (1, 1) 4.0 4.0 4.0 1.0 +[require] +options: backcompat [pixel shader] sampler sam; diff --git a/tests/hlsl/texture-ordering.shader_test b/tests/hlsl/texture-ordering.shader_test index eb3d5c90..2291ddf8 100644 --- a/tests/hlsl/texture-ordering.shader_test +++ b/tests/hlsl/texture-ordering.shader_test @@ -83,6 +83,9 @@ size (1, 1) % The "allocation size" for textures affects the starting register id for the next resource in the % table, and may be larger than the "bind count". +[require] +options: backcompat + [pixel shader] // Name Type Format Dim HLSL Bind Count // ------------------------------ ---------- ------- ----------- -------------- ------ diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 126cf6ab..05edf5da 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -148,6 +148,7 @@ static void parse_require_directive(struct shader_runner *runner, const char *li { 0, "none" }, { D3DCOMPILE_PACK_MATRIX_ROW_MAJOR, "row-major" }, { D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR, "column-major" }, + { D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY, "backcompat" }, }; runner->compile_options = 0; @@ -773,7 +774,6 @@ static HRESULT map_unidentified_hrs(HRESULT hr) static void compile_shader(struct shader_runner *runner, const char *source, size_t len, const char *type, HRESULT expect) { - UINT flags = runner->compile_options | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -789,7 +789,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz }; sprintf(profile, "%s_%s", type, shader_models[runner->minimum_shader_model]); - hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, flags, 0, &blob, &errors); + hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, runner->compile_options, 0, &blob, &errors); hr = map_unidentified_hrs(hr); ok(hr == expect, "Got unexpected hr %#x.\n", hr); if (hr == S_OK) diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 788d8af4..25b585b1 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -74,7 +74,6 @@ static struct d3d11_shader_runner *d3d11_shader_runner(struct shader_runner *r) static ID3D10Blob *compile_shader(const struct d3d11_shader_runner *runner, const char *source, const char *type) { - UINT flags = runner->r.compile_options | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -90,7 +89,7 @@ static ID3D10Blob *compile_shader(const struct d3d11_shader_runner *runner, cons }; sprintf(profile, "%s_%s", type, shader_models[runner->r.minimum_shader_model]); - hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, flags, 0, &blob, &errors); + hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, runner->r.compile_options, 0, &blob, &errors); ok(hr == S_OK, "Failed to compile shader, hr %#lx.\n", hr); if (errors) { diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index bdd47087..d620f1e2 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -58,7 +58,6 @@ static struct d3d12_shader_runner *d3d12_shader_runner(struct shader_runner *r) static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, const char *source, const char *type) { - UINT flags = runner->r.compile_options | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; ID3D10Blob *blob = NULL, *errors = NULL; char profile[7]; HRESULT hr; @@ -74,7 +73,7 @@ static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, cons }; sprintf(profile, "%s_%s", type, shader_models[runner->r.minimum_shader_model]); - hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, flags, 0, &blob, &errors); + hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, runner->r.compile_options, 0, &blob, &errors); ok(FAILED(hr) == !blob, "Got unexpected hr %#x, blob %p.\n", hr, blob); if (errors) { diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 716b922c..a8e59eef 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -430,6 +430,10 @@ static bool compile_shader(const struct vulkan_shader_runner *runner, const char compile_options &= ~(D3DCOMPILE_PACK_MATRIX_ROW_MAJOR | D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR); } + /* FIXME: ignore compatibility flag for now */ + if (compile_options & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY) + compile_options &= ~D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; + if (compile_options) fatal_error("Unsupported compiler options %#x.\n", compile_options); }