mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
tests/shader-runner: Replace immediate shader type strings with an enum.
This commit is contained in:
parent
0ef0735999
commit
d211160b89
Notes:
Alexandre Julliard
2023-10-11 22:53:48 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/346
@ -790,7 +790,20 @@ static HRESULT map_unidentified_hrs(HRESULT hr)
|
||||
return hr;
|
||||
}
|
||||
|
||||
static void compile_shader(struct shader_runner *runner, const char *source, size_t len, const char *type, HRESULT expect)
|
||||
const char *shader_type_string(enum shader_type type)
|
||||
{
|
||||
static const char *const shader_types[] =
|
||||
{
|
||||
[SHADER_TYPE_CS] = "cs",
|
||||
[SHADER_TYPE_PS] = "ps",
|
||||
[SHADER_TYPE_VS] = "vs",
|
||||
};
|
||||
assert(type < ARRAY_SIZE(shader_types));
|
||||
return shader_types[type];
|
||||
}
|
||||
|
||||
static void compile_shader(struct shader_runner *runner, const char *source, size_t len, enum shader_type type,
|
||||
HRESULT expect)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
char profile[7];
|
||||
@ -806,7 +819,7 @@ static void compile_shader(struct shader_runner *runner, const char *source, siz
|
||||
[SHADER_MODEL_5_1] = "5_1",
|
||||
};
|
||||
|
||||
sprintf(profile, "%s_%s", type, shader_models[runner->minimum_shader_model]);
|
||||
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);
|
||||
ok(hr == expect, "Got unexpected hr %#x.\n", hr);
|
||||
@ -918,7 +931,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
|
||||
if (!skip_tests)
|
||||
{
|
||||
todo_if (state == STATE_SHADER_COMPUTE_TODO)
|
||||
compile_shader(runner, shader_source, shader_source_len, "cs", expect_hr);
|
||||
compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_CS, expect_hr);
|
||||
}
|
||||
free(runner->cs_source);
|
||||
runner->cs_source = shader_source;
|
||||
@ -932,7 +945,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
|
||||
if (!skip_tests)
|
||||
{
|
||||
todo_if (state == STATE_SHADER_PIXEL_TODO)
|
||||
compile_shader(runner, shader_source, shader_source_len, "ps", expect_hr);
|
||||
compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_PS, expect_hr);
|
||||
}
|
||||
free(runner->ps_source);
|
||||
runner->ps_source = shader_source;
|
||||
@ -946,7 +959,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
|
||||
if (!skip_tests)
|
||||
{
|
||||
todo_if (state == STATE_SHADER_VERTEX_TODO)
|
||||
compile_shader(runner, shader_source, shader_source_len, "vs", expect_hr);
|
||||
compile_shader(runner, shader_source, shader_source_len, SHADER_TYPE_VS, expect_hr);
|
||||
}
|
||||
free(runner->vs_source);
|
||||
runner->vs_source = shader_source;
|
||||
|
@ -38,6 +38,15 @@ enum shader_model
|
||||
SHADER_MODEL_5_1,
|
||||
};
|
||||
|
||||
enum shader_type
|
||||
{
|
||||
SHADER_TYPE_CS,
|
||||
SHADER_TYPE_PS,
|
||||
SHADER_TYPE_VS,
|
||||
};
|
||||
|
||||
const char *shader_type_string(enum shader_type type);
|
||||
|
||||
enum texture_data_type
|
||||
{
|
||||
TEXTURE_DATA_FLOAT,
|
||||
|
@ -56,7 +56,7 @@ static struct d3d12_shader_runner *d3d12_shader_runner(struct shader_runner *r)
|
||||
return CONTAINING_RECORD(r, struct d3d12_shader_runner, r);
|
||||
}
|
||||
|
||||
static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, const char *source, const char *type)
|
||||
static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, const char *source, enum shader_type type)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
char profile[7];
|
||||
@ -72,7 +72,7 @@ static ID3D10Blob *compile_shader(const struct d3d12_shader_runner *runner, cons
|
||||
[SHADER_MODEL_5_1] = "5_1",
|
||||
};
|
||||
|
||||
sprintf(profile, "%s_%s", type, shader_models[runner->r.minimum_shader_model]);
|
||||
sprintf(profile, "%s_%s", shader_type_string(type), shader_models[runner->r.minimum_shader_model]);
|
||||
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)
|
||||
@ -310,7 +310,7 @@ static bool d3d12_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
|
||||
HRESULT hr;
|
||||
size_t i;
|
||||
|
||||
cs_code = compile_shader(runner, runner->r.cs_source, "cs");
|
||||
cs_code = compile_shader(runner, runner->r.cs_source, SHADER_TYPE_CS);
|
||||
todo_if (runner->r.is_todo) ok(cs_code, "Failed to compile shader.\n");
|
||||
if (!cs_code)
|
||||
return false;
|
||||
@ -385,8 +385,8 @@ static bool d3d12_runner_draw(struct shader_runner *r,
|
||||
HRESULT hr;
|
||||
size_t i;
|
||||
|
||||
ps_code = compile_shader(runner, runner->r.ps_source, "ps");
|
||||
vs_code = compile_shader(runner, runner->r.vs_source, "vs");
|
||||
ps_code = compile_shader(runner, runner->r.ps_source, SHADER_TYPE_PS);
|
||||
vs_code = compile_shader(runner, runner->r.vs_source, SHADER_TYPE_VS);
|
||||
todo_if (runner->r.is_todo) ok(ps_code && vs_code, "Failed to compile shaders.\n");
|
||||
|
||||
if (!ps_code || !vs_code)
|
||||
|
Loading…
Reference in New Issue
Block a user