Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- tests/shader_runner.c | 13 +++++-------- tests/shader_runner.h | 3 +-- tests/shader_runner_d3d12.c | 13 +++++++++---- 3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index c1684b8fb..701a7e8b0 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -458,9 +458,11 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con break;
case STATE_SHADER_PIXEL: - if (!(context->ps_code = context->ops->compile_shader(context, shader_source))) - return; + free(context->ps_source); + context->ps_source = shader_source; + shader_source = NULL; shader_source_len = 0; + shader_source_size = 0; break;
case STATE_SHADER_INVALID_PIXEL: @@ -548,10 +550,6 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con if (!strcmp(line, "[pixel shader]\n")) { state = STATE_SHADER_PIXEL; - - if (context->ps_code) - ID3D10Blob_Release(context->ps_code); - context->ps_code = NULL; } else if (!strcmp(line, "[pixel shader fail]\n")) { @@ -640,8 +638,7 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con } }
- if (context->ps_code) - ID3D10Blob_Release(context->ps_code); + free(context->ps_source); for (i = 0; i < context->texture_count; ++i) { if (context->textures[i]) diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 543b648a7..c2337e9be 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -60,7 +60,7 @@ struct shader_context { const struct shader_runner_ops *ops;
- ID3D10Blob *ps_code; + char *ps_source;
uint32_t *uniforms; size_t uniform_count; @@ -74,7 +74,6 @@ struct shader_context
struct shader_runner_ops { - ID3D10Blob *(*compile_shader)(struct shader_context *context, const char *source); struct texture *(*create_texture)(struct shader_context *context, const struct texture_params *params); void (*destroy_texture)(struct shader_context *context, struct texture *texture); void (*draw_quad)(struct shader_context *context); diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index e124f8aa0..9a0276861 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -50,7 +50,7 @@ static struct d3d12_shader_context *d3d12_shader_context(struct shader_context * return CONTAINING_RECORD(c, struct d3d12_shader_context, c); }
-static ID3D10Blob *d3d12_runner_compile_shader(struct shader_context *c, const char *source) +static ID3D10Blob *compile_shader(const char *source) { ID3D10Blob *blob = NULL, *errors = NULL; HRESULT hr; @@ -107,8 +107,6 @@ static void d3d12_runner_draw_quad(struct shader_context *c) struct d3d12_shader_context *context = d3d12_shader_context(c); struct test_context *test_context = &context->test_context;
- D3D12_SHADER_BYTECODE ps - = {ID3D10Blob_GetBufferPointer(context->c.ps_code), ID3D10Blob_GetBufferSize(context->c.ps_code)}; ID3D12GraphicsCommandList *command_list = test_context->list; D3D12_ROOT_SIGNATURE_DESC root_signature_desc = {0}; D3D12_ROOT_PARAMETER root_params[3], *root_param; @@ -117,10 +115,15 @@ static void d3d12_runner_draw_quad(struct shader_context *c) ID3D12Device *device = test_context->device; static const float clear_color[4]; unsigned int uniform_index; + D3D12_SHADER_BYTECODE ps; ID3D12PipelineState *pso; + ID3D10Blob *ps_code; HRESULT hr; size_t i;
+ if (!(ps_code = compile_shader(context->c.ps_source))) + return; + root_signature_desc.NumParameters = 0; root_signature_desc.pParameters = root_params; root_signature_desc.NumStaticSamplers = 0; @@ -180,8 +183,11 @@ static void d3d12_runner_draw_quad(struct shader_context *c) 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);
+ 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); + ID3D10Blob_Release(ps_code); if (!pso) return; vkd3d_array_reserve((void **)&test_context->pso, &test_context->pso_capacity, @@ -234,7 +240,6 @@ static void d3d12_runner_probe_vec4(struct shader_context *c,
static const struct shader_runner_ops d3d12_runner_ops = { - .compile_shader = d3d12_runner_compile_shader, .create_texture = d3d12_runner_create_texture, .destroy_texture = d3d12_runner_destroy_texture, .draw_quad = d3d12_runner_draw_quad,