From 3e8b5a9fc31a41235adb2c55b74ff11a04c45e52 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 11 Apr 2022 12:18:30 -0500 Subject: [PATCH] tests: Store samplers in a fixed-size array. We will need to allocate some structures in the Vulkan backend; this is easier if we don't need to worry about allocating them dynamically. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- tests/shader_runner.c | 15 ++++++--------- tests/shader_runner.h | 3 ++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 2bdc6bd1..bf3bc0d8 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -725,17 +725,14 @@ void run_shader_tests(struct shader_runner *runner, int argc, char **argv, const { state = STATE_SAMPLER; - if ((current_sampler = get_sampler(runner, index))) + if (!(current_sampler = get_sampler(runner, index))) { - memset(current_sampler, 0, sizeof(*current_sampler)); - } - else - { - runner->samplers = realloc(runner->samplers, - ++runner->sampler_count * sizeof(*runner->samplers)); - current_sampler = &runner->samplers[runner->sampler_count - 1]; - memset(current_sampler, 0, sizeof(*current_sampler)); + if (runner->sampler_count == MAX_SAMPLERS) + fatal_error("Too many samplers declared.\n"); + + current_sampler = &runner->samplers[runner->sampler_count++]; } + memset(current_sampler, 0, sizeof(*current_sampler)); current_sampler->slot = index; current_sampler->filter = D3D12_FILTER_MIN_MAG_MIP_POINT; current_sampler->u_address = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 3bfbf48d..5d08206f 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -88,6 +88,7 @@ struct input_element }; #define MAX_RESOURCES 32 +#define MAX_SAMPLERS 32 struct shader_runner { @@ -103,7 +104,7 @@ struct shader_runner struct resource *resources[MAX_RESOURCES]; size_t resource_count; - struct sampler *samplers; + struct sampler samplers[MAX_SAMPLERS]; size_t sampler_count; struct input_element *input_elements;