From: Zebediah Figura Subject: [PATCH vkd3d v3 6/8] tests: Pass HLSL source to the draw_quad() function. Message-Id: <20220127014033.55195-6-zfigura@codeweavers.com> Date: Wed, 26 Jan 2022 19:40:31 -0600 In-Reply-To: <20220127014033.55195-1-zfigura@codeweavers.com> References: <20220127014033.55195-1-zfigura@codeweavers.com> Signed-off-by: Zebediah Figura --- tests/shader_runner.c | 14 +++++--------- tests/shader_runner.h | 3 +-- tests/shader_runner_d3d12.c | 14 +++++++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index aabae5ae0..12fdad308 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -495,10 +495,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, context->minimum_shader_model))) - 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: @@ -590,10 +591,6 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con else 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")) { @@ -686,8 +683,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 2e6d3606f..6865d4d05 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -66,7 +66,7 @@ struct shader_context { const struct shader_runner_ops *ops; - ID3D10Blob *ps_code; + char *ps_source; enum shader_model minimum_shader_model; uint32_t *uniforms; @@ -81,7 +81,6 @@ struct shader_context struct shader_runner_ops { - ID3D10Blob *(*compile_shader)(struct shader_context *context, const char *source, enum shader_model minimum_shader_model); 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 f79c53be4..3b415ec76 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -51,8 +51,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, enum shader_model shader_model) +static ID3D10Blob *compile_shader(const char *source, enum shader_model shader_model) { ID3D10Blob *blob = NULL, *errors = NULL; HRESULT hr; @@ -118,8 +117,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; @@ -128,10 +125,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, context->c.minimum_shader_model))) + return; + root_signature_desc.NumParameters = 0; root_signature_desc.pParameters = root_params; root_signature_desc.NumStaticSamplers = 0; @@ -191,8 +193,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, @@ -245,7 +250,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, -- 2.34.1