tests: Rename struct shader_context to struct shader_runner.

This is a bit clearer, and avoids colliding with other things named "context",
e.g. struct test_context, or d3d11 device contexts.

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-03-19 12:35:31 -05:00 committed by Alexandre Julliard
parent ead5cc3113
commit 5841e79102
4 changed files with 71 additions and 71 deletions

View File

@ -99,7 +99,7 @@ static bool match_string(const char *line, const char *token, const char **const
return true; return true;
} }
static void parse_require_directive(struct shader_context *context, const char *line) static void parse_require_directive(struct shader_runner *runner, const char *line)
{ {
if (match_string(line, "shader model >=", &line)) if (match_string(line, "shader model >=", &line))
{ {
@ -117,7 +117,7 @@ static void parse_require_directive(struct shader_context *context, const char *
{ {
if (match_string(line, model_strings[i], &line)) if (match_string(line, model_strings[i], &line))
{ {
context->minimum_shader_model = i; runner->minimum_shader_model = i;
return; return;
} }
} }
@ -277,19 +277,19 @@ static void parse_texture_directive(struct texture_params *texture, const char *
} }
} }
static void set_uniforms(struct shader_context *context, size_t offset, size_t count, const void *uniforms) static void set_uniforms(struct shader_runner *runner, size_t offset, size_t count, const void *uniforms)
{ {
context->uniform_count = align(max(context->uniform_count, offset + count), 4); runner->uniform_count = align(max(runner->uniform_count, offset + count), 4);
vkd3d_array_reserve((void **)&context->uniforms, &context->uniform_capacity, vkd3d_array_reserve((void **)&runner->uniforms, &runner->uniform_capacity,
context->uniform_count, sizeof(*context->uniforms)); runner->uniform_count, sizeof(*runner->uniforms));
memcpy(context->uniforms + offset, uniforms, count * sizeof(*context->uniforms)); memcpy(runner->uniforms + offset, uniforms, count * sizeof(*runner->uniforms));
} }
static void parse_test_directive(struct shader_context *context, const char *line) static void parse_test_directive(struct shader_runner *runner, const char *line)
{ {
if (match_string(line, "draw quad", &line)) if (match_string(line, "draw quad", &line))
{ {
context->ops->draw_quad(context); runner->ops->draw_quad(runner);
} }
else if (match_string(line, "probe all rgba", &line)) else if (match_string(line, "probe all rgba", &line))
{ {
@ -304,7 +304,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (ret < 5) if (ret < 5)
ulps = 0; ulps = 0;
context->ops->probe_vec4(context, &rect, &v, ulps); runner->ops->probe_vec4(runner, &rect, &v, ulps);
} }
else if (match_string(line, "probe rect rgba", &line)) else if (match_string(line, "probe rect rgba", &line))
{ {
@ -324,7 +324,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
rect.right = x + w; rect.right = x + w;
rect.top = y; rect.top = y;
rect.bottom = y + h; rect.bottom = y + h;
context->ops->probe_vec4(context, &rect, &v, ulps); runner->ops->probe_vec4(runner, &rect, &v, ulps);
} }
else if (match_string(line, "probe rgba", &line)) else if (match_string(line, "probe rgba", &line))
{ {
@ -343,7 +343,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
rect.right = x + 1; rect.right = x + 1;
rect.top = y; rect.top = y;
rect.bottom = y + 1; rect.bottom = y + 1;
context->ops->probe_vec4(context, &rect, &v, ulps); runner->ops->probe_vec4(runner, &rect, &v, ulps);
} }
else if (match_string(line, "uniform", &line)) else if (match_string(line, "uniform", &line))
{ {
@ -359,7 +359,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (sscanf(line, "%f %f %f %f", &v.x, &v.y, &v.z, &v.w) < 4) if (sscanf(line, "%f %f %f %f", &v.x, &v.y, &v.z, &v.w) < 4)
fatal_error("Malformed float4 constant '%s'.\n", line); fatal_error("Malformed float4 constant '%s'.\n", line);
set_uniforms(context, offset, 4, &v); set_uniforms(runner, offset, 4, &v);
} }
else if (match_string(line, "float", &line)) else if (match_string(line, "float", &line))
{ {
@ -367,7 +367,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (sscanf(line, "%f", &f) < 1) if (sscanf(line, "%f", &f) < 1)
fatal_error("Malformed float constant '%s'.\n", line); fatal_error("Malformed float constant '%s'.\n", line);
set_uniforms(context, offset, 1, &f); set_uniforms(runner, offset, 1, &f);
} }
else if (match_string(line, "int4", &line)) else if (match_string(line, "int4", &line))
{ {
@ -375,7 +375,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (sscanf(line, "%d %d %d %d", &v[0], &v[1], &v[2], &v[3]) < 4) if (sscanf(line, "%d %d %d %d", &v[0], &v[1], &v[2], &v[3]) < 4)
fatal_error("Malformed int4 constant '%s'.\n", line); fatal_error("Malformed int4 constant '%s'.\n", line);
set_uniforms(context, offset, 4, v); set_uniforms(runner, offset, 4, v);
} }
else if (match_string(line, "int", &line)) else if (match_string(line, "int", &line))
{ {
@ -383,7 +383,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (sscanf(line, "%i", &i) < 1) if (sscanf(line, "%i", &i) < 1)
fatal_error("Malformed int constant '%s'.\n", line); fatal_error("Malformed int constant '%s'.\n", line);
set_uniforms(context, offset, 1, &i); set_uniforms(runner, offset, 1, &i);
} }
else if (match_string(line, "uint", &line)) else if (match_string(line, "uint", &line))
{ {
@ -391,7 +391,7 @@ static void parse_test_directive(struct shader_context *context, const char *lin
if (sscanf(line, "%u", &u) < 1) if (sscanf(line, "%u", &u) < 1)
fatal_error("Malformed uint constant '%s'.\n", line); fatal_error("Malformed uint constant '%s'.\n", line);
set_uniforms(context, offset, 1, &u); set_uniforms(runner, offset, 1, &u);
} }
} }
else else
@ -400,14 +400,14 @@ static void parse_test_directive(struct shader_context *context, const char *lin
} }
} }
static struct sampler *get_sampler(struct shader_context *context, unsigned int slot) static struct sampler *get_sampler(struct shader_runner *runner, unsigned int slot)
{ {
struct sampler *sampler; struct sampler *sampler;
size_t i; size_t i;
for (i = 0; i < context->sampler_count; ++i) for (i = 0; i < runner->sampler_count; ++i)
{ {
sampler = &context->samplers[i]; sampler = &runner->samplers[i];
if (sampler->slot == slot) if (sampler->slot == slot)
return sampler; return sampler;
@ -416,25 +416,25 @@ static struct sampler *get_sampler(struct shader_context *context, unsigned int
return NULL; return NULL;
} }
static void set_texture(struct shader_context *context, struct texture *texture) static void set_texture(struct shader_runner *runner, struct texture *texture)
{ {
size_t i; size_t i;
for (i = 0; i < context->texture_count; ++i) for (i = 0; i < runner->texture_count; ++i)
{ {
if (context->textures[i]->slot == texture->slot) if (runner->textures[i]->slot == texture->slot)
{ {
context->ops->destroy_texture(context, context->textures[i]); runner->ops->destroy_texture(runner, runner->textures[i]);
context->textures[i] = texture; runner->textures[i] = texture;
return; return;
} }
} }
context->textures = realloc(context->textures, (context->texture_count + 1) * sizeof(*context->textures)); runner->textures = realloc(runner->textures, (runner->texture_count + 1) * sizeof(*runner->textures));
context->textures[context->texture_count++] = texture; runner->textures[runner->texture_count++] = texture;
} }
void run_shader_tests(struct shader_context *context, int argc, char **argv, const struct shader_runner_ops *ops) void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const struct shader_runner_ops *ops)
{ {
size_t shader_source_size = 0, shader_source_len = 0; size_t shader_source_size = 0, shader_source_len = 0;
struct sampler *current_sampler = NULL; struct sampler *current_sampler = NULL;
@ -446,7 +446,7 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
char line[256]; char line[256];
FILE *f; FILE *f;
context->minimum_shader_model = SHADER_MODEL_2_0; runner->minimum_shader_model = SHADER_MODEL_2_0;
for (i = 1; i < argc; ++i) for (i = 1; i < argc; ++i)
{ {
@ -469,8 +469,8 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
return; return;
} }
memset(context, 0, sizeof(*context)); memset(runner, 0, sizeof(*runner));
context->ops = ops; runner->ops = ops;
for (;;) for (;;)
{ {
@ -489,13 +489,13 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
break; break;
case STATE_TEXTURE: case STATE_TEXTURE:
set_texture(context, context->ops->create_texture(context, &current_texture)); set_texture(runner, runner->ops->create_texture(runner, &current_texture));
free(current_texture.data); free(current_texture.data);
break; break;
case STATE_SHADER_PIXEL: case STATE_SHADER_PIXEL:
free(context->ps_source); free(runner->ps_source);
context->ps_source = shader_source; runner->ps_source = shader_source;
shader_source = NULL; shader_source = NULL;
shader_source_len = 0; shader_source_len = 0;
shader_source_size = 0; shader_source_size = 0;
@ -599,15 +599,15 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
{ {
state = STATE_SAMPLER; state = STATE_SAMPLER;
if ((current_sampler = get_sampler(context, index))) if ((current_sampler = get_sampler(runner, index)))
{ {
memset(current_sampler, 0, sizeof(*current_sampler)); memset(current_sampler, 0, sizeof(*current_sampler));
} }
else else
{ {
context->samplers = realloc(context->samplers, runner->samplers = realloc(runner->samplers,
++context->sampler_count * sizeof(*context->samplers)); ++runner->sampler_count * sizeof(*runner->samplers));
current_sampler = &context->samplers[context->sampler_count - 1]; current_sampler = &runner->samplers[runner->sampler_count - 1];
memset(current_sampler, 0, sizeof(*current_sampler)); memset(current_sampler, 0, sizeof(*current_sampler));
} }
current_sampler->slot = index; current_sampler->slot = index;
@ -664,7 +664,7 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
} }
case STATE_REQUIRE: case STATE_REQUIRE:
parse_require_directive(context, line); parse_require_directive(runner, line);
break; break;
case STATE_SAMPLER: case STATE_SAMPLER:
@ -676,19 +676,19 @@ void run_shader_tests(struct shader_context *context, int argc, char **argv, con
break; break;
case STATE_TEST: case STATE_TEST:
parse_test_directive(context, line); parse_test_directive(runner, line);
break; break;
} }
} }
} }
free(context->ps_source); free(runner->ps_source);
for (i = 0; i < context->texture_count; ++i) for (i = 0; i < runner->texture_count; ++i)
{ {
if (context->textures[i]) if (runner->textures[i])
context->ops->destroy_texture(context, context->textures[i]); runner->ops->destroy_texture(runner, runner->textures[i]);
} }
free(context->textures); free(runner->textures);
fclose(f); fclose(f);

View File

@ -65,7 +65,7 @@ struct texture
unsigned int slot; unsigned int slot;
}; };
struct shader_context struct shader_runner
{ {
const struct shader_runner_ops *ops; const struct shader_runner_ops *ops;
@ -84,15 +84,15 @@ struct shader_context
struct shader_runner_ops struct shader_runner_ops
{ {
struct texture *(*create_texture)(struct shader_context *context, const struct texture_params *params); struct texture *(*create_texture)(struct shader_runner *runner, const struct texture_params *params);
void (*destroy_texture)(struct shader_context *context, struct texture *texture); void (*destroy_texture)(struct shader_runner *runner, struct texture *texture);
void (*draw_quad)(struct shader_context *context); void (*draw_quad)(struct shader_runner *runner);
void (*probe_vec4)(struct shader_context *context, const RECT *rect, const struct vec4 *v, unsigned int ulps); void (*probe_vec4)(struct shader_runner *runner, const RECT *rect, const struct vec4 *v, unsigned int ulps);
}; };
void fatal_error(const char *format, ...) VKD3D_NORETURN VKD3D_PRINTF_FUNC(1, 2); void fatal_error(const char *format, ...) VKD3D_NORETURN VKD3D_PRINTF_FUNC(1, 2);
void run_shader_tests(struct shader_context *context, int argc, char **argv, const struct shader_runner_ops *ops); void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const struct shader_runner_ops *ops);
#ifdef _WIN32 #ifdef _WIN32
void run_shader_tests_d3d11(int argc, char **argv); void run_shader_tests_d3d11(int argc, char **argv);

View File

@ -53,7 +53,7 @@ static struct d3d11_texture *d3d11_texture(struct texture *t)
struct d3d11_shader_context struct d3d11_shader_context
{ {
struct shader_context c; struct shader_runner c;
ID3D11Device *device; ID3D11Device *device;
HWND window; HWND window;
@ -65,9 +65,9 @@ struct d3d11_shader_context
ID3D11VertexShader *vs; ID3D11VertexShader *vs;
}; };
static struct d3d11_shader_context *d3d11_shader_context(struct shader_context *c) static struct d3d11_shader_context *d3d11_shader_context(struct shader_runner *r)
{ {
return CONTAINING_RECORD(c, struct d3d11_shader_context, c); return CONTAINING_RECORD(r, struct d3d11_shader_context, c);
} }
static bool enable_debug_layer; static bool enable_debug_layer;
@ -359,9 +359,9 @@ static ID3D11Buffer *create_buffer(ID3D11Device *device, unsigned int bind_flags
return buffer; return buffer;
} }
static struct texture *d3d11_runner_create_texture(struct shader_context *c, const struct texture_params *params) static struct texture *d3d11_runner_create_texture(struct shader_runner *r, const struct texture_params *params)
{ {
struct d3d11_shader_context *context = d3d11_shader_context(c); struct d3d11_shader_context *context = d3d11_shader_context(r);
ID3D11Device *device = context->device; ID3D11Device *device = context->device;
D3D11_SUBRESOURCE_DATA resource_data; D3D11_SUBRESOURCE_DATA resource_data;
D3D11_TEXTURE2D_DESC desc = {0}; D3D11_TEXTURE2D_DESC desc = {0};
@ -394,7 +394,7 @@ static struct texture *d3d11_runner_create_texture(struct shader_context *c, con
return &texture->t; return &texture->t;
} }
static void d3d11_runner_destroy_texture(struct shader_context *c, struct texture *t) static void d3d11_runner_destroy_texture(struct shader_runner *r, struct texture *t)
{ {
struct d3d11_texture *texture = d3d11_texture(t); struct d3d11_texture *texture = d3d11_texture(t);
@ -403,7 +403,7 @@ static void d3d11_runner_destroy_texture(struct shader_context *c, struct textur
free(texture); free(texture);
} }
static void d3d11_runner_draw_quad(struct shader_context *c) static void d3d11_runner_draw_quad(struct shader_runner *r)
{ {
static const char vs_source[] = static const char vs_source[] =
"void main(uint id : SV_VertexID, out float4 position : SV_Position)\n" "void main(uint id : SV_VertexID, out float4 position : SV_Position)\n"
@ -412,7 +412,7 @@ static void d3d11_runner_draw_quad(struct shader_context *c)
" position = float4(coords * float2(2, -2) + float2(-1, 1), 0, 1);\n" " position = float4(coords * float2(2, -2) + float2(-1, 1), 0, 1);\n"
"}"; "}";
struct d3d11_shader_context *context = d3d11_shader_context(c); struct d3d11_shader_context *context = d3d11_shader_context(r);
ID3D11Device *device = context->device; ID3D11Device *device = context->device;
ID3D11Buffer *cb = NULL; ID3D11Buffer *cb = NULL;
ID3D11PixelShader *ps; ID3D11PixelShader *ps;
@ -561,9 +561,9 @@ static void check_readback_data_vec4(struct resource_readback *rb,
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
} }
static void d3d11_runner_probe_vec4(struct shader_context *c, const RECT *rect, const struct vec4 *v, unsigned int ulps) static void d3d11_runner_probe_vec4(struct shader_runner *r, const RECT *rect, const struct vec4 *v, unsigned int ulps)
{ {
struct d3d11_shader_context *context = d3d11_shader_context(c); struct d3d11_shader_context *context = d3d11_shader_context(r);
struct resource_readback rb; struct resource_readback rb;
init_readback(context, &rb); init_readback(context, &rb);

View File

@ -40,16 +40,16 @@ static struct d3d12_texture *d3d12_texture(struct texture *t)
struct d3d12_shader_context struct d3d12_shader_context
{ {
struct shader_context c; struct shader_runner c;
struct test_context test_context; struct test_context test_context;
ID3D12DescriptorHeap *heap; ID3D12DescriptorHeap *heap;
}; };
static struct d3d12_shader_context *d3d12_shader_context(struct shader_context *c) static struct d3d12_shader_context *d3d12_shader_context(struct shader_runner *r)
{ {
return CONTAINING_RECORD(c, struct d3d12_shader_context, c); return CONTAINING_RECORD(r, struct d3d12_shader_context, c);
} }
static ID3D10Blob *compile_shader(const char *source, enum shader_model shader_model) static ID3D10Blob *compile_shader(const char *source, enum shader_model shader_model)
@ -80,9 +80,9 @@ static ID3D10Blob *compile_shader(const char *source, enum shader_model shader_m
#define MAX_RESOURCE_DESCRIPTORS 256 #define MAX_RESOURCE_DESCRIPTORS 256
static struct texture *d3d12_runner_create_texture(struct shader_context *c, const struct texture_params *params) static struct texture *d3d12_runner_create_texture(struct shader_runner *r, const struct texture_params *params)
{ {
struct d3d12_shader_context *context = d3d12_shader_context(c); struct d3d12_shader_context *context = d3d12_shader_context(r);
struct test_context *test_context = &context->test_context; struct test_context *test_context = &context->test_context;
ID3D12Device *device = test_context->device; ID3D12Device *device = test_context->device;
D3D12_SUBRESOURCE_DATA resource_data; D3D12_SUBRESOURCE_DATA resource_data;
@ -113,7 +113,7 @@ static struct texture *d3d12_runner_create_texture(struct shader_context *c, con
return &texture->t; return &texture->t;
} }
static void d3d12_runner_destroy_texture(struct shader_context *c, struct texture *t) static void d3d12_runner_destroy_texture(struct shader_runner *r, struct texture *t)
{ {
struct d3d12_texture *texture = d3d12_texture(t); struct d3d12_texture *texture = d3d12_texture(t);
@ -121,9 +121,9 @@ static void d3d12_runner_destroy_texture(struct shader_context *c, struct textur
free(texture); free(texture);
} }
static void d3d12_runner_draw_quad(struct shader_context *c) static void d3d12_runner_draw_quad(struct shader_runner *r)
{ {
struct d3d12_shader_context *context = d3d12_shader_context(c); struct d3d12_shader_context *context = d3d12_shader_context(r);
struct test_context *test_context = &context->test_context; struct test_context *test_context = &context->test_context;
ID3D12GraphicsCommandList *command_list = test_context->list; ID3D12GraphicsCommandList *command_list = test_context->list;
@ -243,10 +243,10 @@ static void d3d12_runner_draw_quad(struct shader_context *c)
reset_command_list(command_list, test_context->allocator); reset_command_list(command_list, test_context->allocator);
} }
static void d3d12_runner_probe_vec4(struct shader_context *c, static void d3d12_runner_probe_vec4(struct shader_runner *r,
const RECT *rect, const struct vec4 *v, unsigned int ulps) const RECT *rect, const struct vec4 *v, unsigned int ulps)
{ {
struct d3d12_shader_context *context = d3d12_shader_context(c); struct d3d12_shader_context *context = d3d12_shader_context(r);
struct test_context *test_context = &context->test_context; struct test_context *test_context = &context->test_context;
struct resource_readback rb; struct resource_readback rb;