mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
tests/shader_runner: Avoid creating devices for backends that won't execute.
My main motivation to this is avoiding generating a lot of useless log lines from other executors when I'm interested in just one of them, but I can imagine this also somewhat improving efficiency.
This commit is contained in:
parent
0b273ea88c
commit
fc4316f664
Notes:
Henri Verbeet
2025-03-17 15:28:49 +01:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1416
@ -2066,6 +2066,41 @@ enum test_action
|
||||
TEST_ACTION_SKIP_EXECUTION,
|
||||
};
|
||||
|
||||
bool test_skipping_execution(const char *executor, const char *compiler,
|
||||
enum shader_model minimum_shader_model, enum shader_model maximum_shader_model)
|
||||
{
|
||||
if (shader_test_options.executor_filter
|
||||
&& strcmp(shader_test_options.executor_filter, executor))
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because of the executor filter.\n",
|
||||
compiler, executor);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (shader_test_options.compiler_filter
|
||||
&& strcmp(shader_test_options.compiler_filter, compiler))
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because of the compiler filter.\n",
|
||||
compiler, executor);
|
||||
return true;
|
||||
}
|
||||
|
||||
minimum_shader_model = max(minimum_shader_model, shader_test_options.minimum_shader_model);
|
||||
maximum_shader_model = min(maximum_shader_model, shader_test_options.maximum_shader_model);
|
||||
|
||||
if (minimum_shader_model > maximum_shader_model)
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because the shader model range is empty.\n",
|
||||
compiler, executor);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void run_shader_tests(struct shader_runner *runner, const struct shader_runner_caps *caps,
|
||||
const struct shader_runner_ops *ops, void *dxc_compiler)
|
||||
{
|
||||
@ -2082,35 +2117,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
|
||||
const char *testname;
|
||||
FILE *f;
|
||||
|
||||
if (shader_test_options.executor_filter
|
||||
&& strcmp(shader_test_options.executor_filter, caps->runner))
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because of the executor filter\n",
|
||||
caps->compiler, caps->runner);
|
||||
return;
|
||||
}
|
||||
|
||||
if (shader_test_options.compiler_filter
|
||||
&& strcmp(shader_test_options.compiler_filter, caps->compiler))
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because of the executor filter\n",
|
||||
caps->compiler, caps->runner);
|
||||
return;
|
||||
}
|
||||
|
||||
minimum_shader_model = max(caps->minimum_shader_model, shader_test_options.minimum_shader_model);
|
||||
maximum_shader_model = min(caps->maximum_shader_model, shader_test_options.maximum_shader_model);
|
||||
|
||||
if (minimum_shader_model > maximum_shader_model)
|
||||
{
|
||||
trace("Skipping compiling shaders with %s and executing with %s "
|
||||
"because the shader model range is empty\n",
|
||||
caps->compiler, caps->runner);
|
||||
return;
|
||||
}
|
||||
|
||||
trace("Compiling SM%s-SM%s shaders with %s and executing with %s.\n",
|
||||
model_strings[minimum_shader_model], model_strings[maximum_shader_model],
|
||||
caps->compiler, caps->runner);
|
||||
@ -2612,6 +2621,10 @@ static void run_compile_tests(void *dxc_compiler)
|
||||
for (unsigned int i = 0; i < DXGI_FORMAT_COUNT; ++i)
|
||||
caps.format_caps[i] = ~0u;
|
||||
|
||||
if (test_skipping_execution(caps.runner, caps.compiler,
|
||||
caps.minimum_shader_model, caps.maximum_shader_model))
|
||||
return;
|
||||
|
||||
run_shader_tests(&runner, &caps, NULL, dxc_compiler);
|
||||
}
|
||||
|
||||
|
@ -288,6 +288,8 @@ ID3D10Blob *compile_hlsl(const struct shader_runner *runner, enum shader_type ty
|
||||
struct sampler *shader_runner_get_sampler(struct shader_runner *runner, unsigned int slot);
|
||||
struct resource *shader_runner_get_resource(struct shader_runner *runner, enum resource_type type, unsigned int slot);
|
||||
|
||||
bool test_skipping_execution(const char *executor, const char *compiler,
|
||||
enum shader_model minimum_shader_model, enum shader_model maximum_shader_model);
|
||||
void run_shader_tests(struct shader_runner *runner, const struct shader_runner_caps *caps,
|
||||
const struct shader_runner_ops *ops, void *dxc_compiler);
|
||||
|
||||
|
@ -1043,6 +1043,10 @@ void run_shader_tests_d3d11(void)
|
||||
struct d3d11_shader_runner runner;
|
||||
HMODULE dxgi_module, d3d11_module;
|
||||
|
||||
if (test_skipping_execution("d3d11.dll",
|
||||
HLSL_COMPILER, SHADER_MODEL_4_0, SHADER_MODEL_5_0))
|
||||
return;
|
||||
|
||||
d3d11_module = LoadLibraryA("d3d11.dll");
|
||||
dxgi_module = LoadLibraryA("dxgi.dll");
|
||||
if (d3d11_module && dxgi_module)
|
||||
|
@ -1129,11 +1129,24 @@ static void run_shader_tests_for_model_range(void *dxc_compiler,
|
||||
|
||||
void run_shader_tests_d3d12(void *dxc_compiler)
|
||||
{
|
||||
#ifdef VKD3D_CROSSTEST
|
||||
const char *executor = "d3d12.dll";
|
||||
#else
|
||||
const char *executor = "vkd3d";
|
||||
#endif
|
||||
|
||||
bool skip_sm4 = test_skipping_execution(executor, HLSL_COMPILER, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
|
||||
bool skip_sm6 = test_skipping_execution(executor, "dxcompiler", SHADER_MODEL_6_0, SHADER_MODEL_6_2);
|
||||
|
||||
if (skip_sm4 && skip_sm6)
|
||||
return;
|
||||
|
||||
enable_d3d12_debug_layer();
|
||||
init_adapter_info();
|
||||
|
||||
run_shader_tests_for_model_range(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
|
||||
if (!skip_sm4)
|
||||
run_shader_tests_for_model_range(NULL, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
|
||||
|
||||
if (dxc_compiler)
|
||||
if (dxc_compiler && !skip_sm6)
|
||||
run_shader_tests_for_model_range(dxc_compiler, SHADER_MODEL_6_0, SHADER_MODEL_6_2);
|
||||
}
|
||||
|
@ -645,6 +645,10 @@ void run_shader_tests_d3d9(void)
|
||||
struct d3d9_shader_runner runner;
|
||||
HMODULE d3d9_module;
|
||||
|
||||
if (test_skipping_execution("d3d9.dll",
|
||||
HLSL_COMPILER, SHADER_MODEL_2_0, SHADER_MODEL_3_0))
|
||||
return;
|
||||
|
||||
if (!(d3d9_module = LoadLibraryA("d3d9.dll")))
|
||||
return;
|
||||
|
||||
|
@ -1459,6 +1459,10 @@ static void run_tests(enum shading_language language)
|
||||
{
|
||||
struct gl_runner runner;
|
||||
|
||||
if (test_skipping_execution(language == SPIR_V ? "OpenGL/SPIR-V" : "OpenGL/GLSL",
|
||||
HLSL_COMPILER, SHADER_MODEL_4_0, SHADER_MODEL_5_1))
|
||||
return;
|
||||
|
||||
if (!gl_runner_init(&runner, language))
|
||||
return;
|
||||
run_shader_tests(&runner.r, &runner.caps, &gl_runner_ops, NULL);
|
||||
|
@ -739,6 +739,9 @@ void run_shader_tests_metal(void)
|
||||
{
|
||||
struct metal_runner runner;
|
||||
|
||||
if (test_skipping_execution("Metal", HLSL_COMPILER, SHADER_MODEL_4_0, SHADER_MODEL_5_0))
|
||||
return;
|
||||
|
||||
if (!metal_runner_init(&runner))
|
||||
return;
|
||||
run_shader_tests(&runner.r, &runner.caps, &metal_runner_ops, NULL);
|
||||
|
@ -1856,20 +1856,31 @@ out_destroy_context:
|
||||
void run_shader_tests_vulkan(void)
|
||||
{
|
||||
struct vulkan_shader_runner runner = {0};
|
||||
bool skip_sm2 = test_skipping_execution("Vulkan", HLSL_COMPILER, SHADER_MODEL_2_0, SHADER_MODEL_3_0);
|
||||
bool skip_sm4 = test_skipping_execution("Vulkan", HLSL_COMPILER, SHADER_MODEL_4_0, SHADER_MODEL_5_1);
|
||||
|
||||
if (skip_sm2 && skip_sm4)
|
||||
return;
|
||||
|
||||
if (!init_vulkan_runner(&runner))
|
||||
return;
|
||||
|
||||
runner.caps.minimum_shader_model = SHADER_MODEL_2_0;
|
||||
runner.caps.maximum_shader_model = SHADER_MODEL_3_0;
|
||||
run_shader_tests(&runner.r, &runner.caps, &vulkan_runner_ops, NULL);
|
||||
if (!skip_sm2)
|
||||
{
|
||||
runner.caps.minimum_shader_model = SHADER_MODEL_2_0;
|
||||
runner.caps.maximum_shader_model = SHADER_MODEL_3_0;
|
||||
run_shader_tests(&runner.r, &runner.caps, &vulkan_runner_ops, NULL);
|
||||
}
|
||||
|
||||
/* Fog requires remapping, which is only correct for sm1. */
|
||||
runner.caps.shader_caps[SHADER_CAP_FOG] = false;
|
||||
if (!skip_sm4)
|
||||
{
|
||||
/* Fog requires remapping, which is only correct for sm1. */
|
||||
runner.caps.shader_caps[SHADER_CAP_FOG] = false;
|
||||
|
||||
runner.caps.minimum_shader_model = SHADER_MODEL_4_0;
|
||||
runner.caps.maximum_shader_model = SHADER_MODEL_5_1;
|
||||
run_shader_tests(&runner.r, &runner.caps, &vulkan_runner_ops, NULL);
|
||||
runner.caps.minimum_shader_model = SHADER_MODEL_4_0;
|
||||
runner.caps.maximum_shader_model = SHADER_MODEL_5_1;
|
||||
run_shader_tests(&runner.r, &runner.caps, &vulkan_runner_ops, NULL);
|
||||
}
|
||||
|
||||
vulkan_test_context_destroy(&runner.context);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user