mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
tests: Add support for running shader tests with a custom vertex shader.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
71db328d38
commit
52223250d7
@ -80,6 +80,7 @@ enum parse_state
|
||||
STATE_SAMPLER,
|
||||
STATE_SHADER_INVALID_PIXEL,
|
||||
STATE_SHADER_PIXEL,
|
||||
STATE_SHADER_VERTEX,
|
||||
STATE_TEXTURE,
|
||||
STATE_TEST,
|
||||
};
|
||||
@ -501,6 +502,14 @@ void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const
|
||||
shader_source_size = 0;
|
||||
break;
|
||||
|
||||
case STATE_SHADER_VERTEX:
|
||||
free(runner->vs_source);
|
||||
runner->vs_source = shader_source;
|
||||
shader_source = NULL;
|
||||
shader_source_len = 0;
|
||||
shader_source_size = 0;
|
||||
break;
|
||||
|
||||
case STATE_SHADER_INVALID_PIXEL:
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
@ -639,6 +648,10 @@ void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const
|
||||
{
|
||||
state = STATE_PREPROC_INVALID;
|
||||
}
|
||||
else if (!strcmp(line, "[vertex shader]\n"))
|
||||
{
|
||||
state = STATE_SHADER_VERTEX;
|
||||
}
|
||||
|
||||
vkd3d_test_set_context("Section %.*s, line %u", strlen(line) - 1, line, line_number);
|
||||
}
|
||||
@ -654,6 +667,7 @@ void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const
|
||||
case STATE_PREPROC_INVALID:
|
||||
case STATE_SHADER_INVALID_PIXEL:
|
||||
case STATE_SHADER_PIXEL:
|
||||
case STATE_SHADER_VERTEX:
|
||||
{
|
||||
size_t len = strlen(line);
|
||||
|
||||
@ -682,6 +696,7 @@ void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const
|
||||
}
|
||||
}
|
||||
|
||||
free(runner->vs_source);
|
||||
free(runner->ps_source);
|
||||
for (i = 0; i < runner->texture_count; ++i)
|
||||
{
|
||||
|
@ -72,6 +72,7 @@ struct shader_runner
|
||||
{
|
||||
const struct shader_runner_ops *ops;
|
||||
|
||||
char *vs_source;
|
||||
char *ps_source;
|
||||
enum shader_model minimum_shader_model;
|
||||
|
||||
|
@ -434,7 +434,7 @@ static void d3d11_runner_draw_quad(struct shader_runner *r)
|
||||
|
||||
if (!runner->vs)
|
||||
{
|
||||
ID3D10Blob *vs_code = compile_shader(vs_source, "vs_4_0");
|
||||
ID3D10Blob *vs_code = compile_shader(runner->r.vs_source ? runner->r.vs_source : vs_source, "vs_4_0");
|
||||
|
||||
hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code),
|
||||
ID3D10Blob_GetBufferSize(vs_code), NULL, &runner->vs);
|
||||
|
@ -52,22 +52,23 @@ 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 char *source, enum shader_model shader_model)
|
||||
static ID3D10Blob *compile_shader(const char *source, const char *type, enum shader_model shader_model)
|
||||
{
|
||||
ID3D10Blob *blob = NULL, *errors = NULL;
|
||||
char profile[7];
|
||||
HRESULT hr;
|
||||
|
||||
static const char *const shader_models[] =
|
||||
{
|
||||
[SHADER_MODEL_2_0] = "ps_4_0",
|
||||
[SHADER_MODEL_4_0] = "ps_4_0",
|
||||
[SHADER_MODEL_4_1] = "ps_4_1",
|
||||
[SHADER_MODEL_5_0] = "ps_5_0",
|
||||
[SHADER_MODEL_5_1] = "ps_5_1",
|
||||
[SHADER_MODEL_2_0] = "4_0",
|
||||
[SHADER_MODEL_4_0] = "4_0",
|
||||
[SHADER_MODEL_4_1] = "4_1",
|
||||
[SHADER_MODEL_5_0] = "5_0",
|
||||
[SHADER_MODEL_5_1] = "5_1",
|
||||
};
|
||||
|
||||
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main",
|
||||
shader_models[shader_model], 0, 0, &blob, &errors);
|
||||
sprintf(profile, "%s_%s", type, shader_models[shader_model]);
|
||||
hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", profile, 0, 0, &blob, &errors);
|
||||
ok(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
|
||||
if (errors)
|
||||
{
|
||||
@ -132,17 +133,23 @@ static void d3d12_runner_draw_quad(struct shader_runner *r)
|
||||
ID3D12CommandQueue *queue = test_context->queue;
|
||||
D3D12_STATIC_SAMPLER_DESC static_samplers[1];
|
||||
ID3D12Device *device = test_context->device;
|
||||
ID3D10Blob *vs_code = NULL, *ps_code;
|
||||
static const float clear_color[4];
|
||||
D3D12_SHADER_BYTECODE vs, ps;
|
||||
unsigned int uniform_index;
|
||||
D3D12_SHADER_BYTECODE ps;
|
||||
ID3D12PipelineState *pso;
|
||||
ID3D10Blob *ps_code;
|
||||
HRESULT hr;
|
||||
size_t i;
|
||||
|
||||
if (!(ps_code = compile_shader(runner->r.ps_source, runner->r.minimum_shader_model)))
|
||||
if (!(ps_code = compile_shader(runner->r.ps_source, "ps", runner->r.minimum_shader_model)))
|
||||
return;
|
||||
|
||||
if (runner->r.vs_source && !(vs_code = compile_shader(runner->r.vs_source, "vs", runner->r.minimum_shader_model)))
|
||||
{
|
||||
ID3D10Blob_Release(ps_code);
|
||||
return;
|
||||
}
|
||||
|
||||
root_signature_desc.NumParameters = 0;
|
||||
root_signature_desc.pParameters = root_params;
|
||||
root_signature_desc.NumStaticSamplers = 0;
|
||||
@ -202,10 +209,17 @@ static void d3d12_runner_draw_quad(struct shader_runner *r)
|
||||
hr = create_root_signature(device, &root_signature_desc, &test_context->root_signature);
|
||||
ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
vs.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs_code);
|
||||
vs.BytecodeLength = ID3D10Blob_GetBufferSize(vs_code);
|
||||
}
|
||||
ps.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps_code);
|
||||
ps.BytecodeLength = ID3D10Blob_GetBufferSize(ps_code);
|
||||
pso = create_pipeline_state(device, test_context->root_signature,
|
||||
test_context->render_target_desc.Format, NULL, &ps, NULL);
|
||||
test_context->render_target_desc.Format, vs_code ? &vs : NULL, &ps, NULL);
|
||||
if (vs_code)
|
||||
ID3D10Blob_Release(vs_code);
|
||||
ID3D10Blob_Release(ps_code);
|
||||
if (!pso)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user