tests: Pass HLSL source to the draw_quad() function.

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:
Zebediah Figura 2022-01-26 19:40:31 -06:00 committed by Alexandre Julliard
parent 33c845ece5
commit 3994cec7b1
3 changed files with 15 additions and 16 deletions

View File

@ -495,10 +495,11 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
break; break;
case STATE_SHADER_PIXEL: case STATE_SHADER_PIXEL:
if (!(context->ps_code = context->ops->compile_shader(context, free(context->ps_source);
shader_source, context->minimum_shader_model))) context->ps_source = shader_source;
return; shader_source = NULL;
shader_source_len = 0; shader_source_len = 0;
shader_source_size = 0;
break; break;
case STATE_SHADER_INVALID_PIXEL: 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")) else if (!strcmp(line, "[pixel shader]\n"))
{ {
state = STATE_SHADER_PIXEL; 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")) 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) free(context->ps_source);
ID3D10Blob_Release(context->ps_code);
for (i = 0; i < context->texture_count; ++i) for (i = 0; i < context->texture_count; ++i)
{ {
if (context->textures[i]) if (context->textures[i])

View File

@ -66,7 +66,7 @@ struct shader_context
{ {
const struct shader_runner_ops *ops; const struct shader_runner_ops *ops;
ID3D10Blob *ps_code; char *ps_source;
enum shader_model minimum_shader_model; enum shader_model minimum_shader_model;
uint32_t *uniforms; uint32_t *uniforms;
@ -81,7 +81,6 @@ struct shader_context
struct shader_runner_ops 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); struct texture *(*create_texture)(struct shader_context *context, const struct texture_params *params);
void (*destroy_texture)(struct shader_context *context, struct texture *texture); void (*destroy_texture)(struct shader_context *context, struct texture *texture);
void (*draw_quad)(struct shader_context *context); void (*draw_quad)(struct shader_context *context);

View File

@ -51,8 +51,7 @@ static struct d3d12_shader_context *d3d12_shader_context(struct shader_context *
return CONTAINING_RECORD(c, struct d3d12_shader_context, c); return CONTAINING_RECORD(c, struct d3d12_shader_context, c);
} }
static ID3D10Blob *d3d12_runner_compile_shader(struct shader_context *c, static ID3D10Blob *compile_shader(const char *source, enum shader_model shader_model)
const char *source, enum shader_model shader_model)
{ {
ID3D10Blob *blob = NULL, *errors = NULL; ID3D10Blob *blob = NULL, *errors = NULL;
HRESULT hr; 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 d3d12_shader_context *context = d3d12_shader_context(c);
struct test_context *test_context = &context->test_context; 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; ID3D12GraphicsCommandList *command_list = test_context->list;
D3D12_ROOT_SIGNATURE_DESC root_signature_desc = {0}; D3D12_ROOT_SIGNATURE_DESC root_signature_desc = {0};
D3D12_ROOT_PARAMETER root_params[3], *root_param; 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; ID3D12Device *device = test_context->device;
static const float clear_color[4]; static const float clear_color[4];
unsigned int uniform_index; unsigned int uniform_index;
D3D12_SHADER_BYTECODE ps;
ID3D12PipelineState *pso; ID3D12PipelineState *pso;
ID3D10Blob *ps_code;
HRESULT hr; HRESULT hr;
size_t i; 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.NumParameters = 0;
root_signature_desc.pParameters = root_params; root_signature_desc.pParameters = root_params;
root_signature_desc.NumStaticSamplers = 0; 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); 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); 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, pso = create_pipeline_state(device, test_context->root_signature,
test_context->render_target_desc.Format, NULL, &ps, NULL); test_context->render_target_desc.Format, NULL, &ps, NULL);
ID3D10Blob_Release(ps_code);
if (!pso) if (!pso)
return; return;
vkd3d_array_reserve((void **)&test_context->pso, &test_context->pso_capacity, 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 = static const struct shader_runner_ops d3d12_runner_ops =
{ {
.compile_shader = d3d12_runner_compile_shader,
.create_texture = d3d12_runner_create_texture, .create_texture = d3d12_runner_create_texture,
.destroy_texture = d3d12_runner_destroy_texture, .destroy_texture = d3d12_runner_destroy_texture,
.draw_quad = d3d12_runner_draw_quad, .draw_quad = d3d12_runner_draw_quad,