tests/shader_runner: Allow probing a single component.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
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:
Giovanni Mascellani 2022-05-17 15:45:42 +02:00 committed by Alexandre Julliard
parent 4a9d675c49
commit 6ff6cb4ed2
3 changed files with 62 additions and 45 deletions

View File

@ -278,45 +278,11 @@ static uint64_t get_readback_uint64(struct resource_readback *rb, unsigned int x
return *(uint64_t *)get_readback_data(rb, x, y, 0, sizeof(uint64_t));
}
static float get_readback_float(struct resource_readback *rb, unsigned int x, unsigned int y)
{
return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
}
static const struct uvec4 *get_readback_uvec4(struct resource_readback *rb, unsigned int x, unsigned int y)
{
return get_readback_data(rb, x, y, 0, sizeof(struct uvec4));
}
#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__LINE__, a, b, c, d)
static void check_readback_data_float_(unsigned int line, struct resource_readback *rb,
const RECT *rect, float expected, unsigned int max_diff)
{
RECT r = {0, 0, rb->width, rb->height};
unsigned int x = 0, y;
bool all_match = true;
float got = 0;
if (rect)
r = *rect;
for (y = r.top; y < r.bottom; ++y)
{
for (x = r.left; x < r.right; ++x)
{
got = get_readback_float(rb, x, y);
if (!compare_float(got, expected, max_diff))
{
all_match = false;
break;
}
}
if (!all_match)
break;
}
ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y);
}
#define check_sub_resource_float(a, b, c, d, e, f) check_sub_resource_float_(__LINE__, a, b, c, d, e, f)
static void check_sub_resource_float_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,

View File

@ -413,7 +413,6 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
{
unsigned int left, top, right, bottom, ulps;
struct resource_readback *rb;
struct vec4 v;
int ret, len;
RECT rect;
@ -439,17 +438,35 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
fatal_error("Malformed probe arguments '%s'.\n", line);
}
if (!match_string(line, "rgba", &line))
fatal_error("Malformed probe arguments '%s'.\n", line);
ret = sscanf(line, "( %f , %f , %f , %f ) %u", &v.x, &v.y, &v.z, &v.w, &ulps);
if (ret < 4)
fatal_error("Malformed probe arguments '%s'.\n", line);
if (ret < 5)
ulps = 0;
rb = runner->ops->get_rt_readback(runner);
todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps);
if (match_string(line, "rgba", &line))
{
struct vec4 v;
ret = sscanf(line, "( %f , %f , %f , %f ) %u", &v.x, &v.y, &v.z, &v.w, &ulps);
if (ret < 4)
fatal_error("Malformed probe arguments '%s'.\n", line);
if (ret < 5)
ulps = 0;
todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps);
}
else if (match_string(line, "r", &line))
{
float expect;
ret = sscanf(line, "( %f ) %u", &expect, &ulps);
if (ret < 1)
fatal_error("Malformed probe arguments '%s'.\n", line);
if (ret < 2)
ulps = 0;
todo_if(runner->is_todo) check_readback_data_float(rb, &rect, expect, ulps);
}
else
{
fatal_error("Malformed probe arguments '%s'.\n", line);
}
runner->ops->release_readback(runner, rb);
}
else if (match_string(line, "uniform", &line))

View File

@ -120,11 +120,45 @@ static void *get_readback_data(const struct resource_readback *rb,
return &((uint8_t *)rb->data)[slice_pitch * z + rb->row_pitch * y + x * element_size];
}
static float get_readback_float(const struct resource_readback *rb, unsigned int x, unsigned int y)
{
return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
}
static const struct vec4 *get_readback_vec4(const struct resource_readback *rb, unsigned int x, unsigned int y)
{
return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
}
#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__LINE__, a, b, c, d)
static inline void check_readback_data_float_(unsigned int line, const struct resource_readback *rb,
const RECT *rect, float expected, unsigned int max_diff)
{
RECT r = {0, 0, rb->width, rb->height};
unsigned int x = 0, y;
bool all_match = true;
float got = 0;
if (rect)
r = *rect;
for (y = r.top; y < r.bottom; ++y)
{
for (x = r.left; x < r.right; ++x)
{
got = get_readback_float(rb, x, y);
if (!compare_float(got, expected, max_diff))
{
all_match = false;
break;
}
}
if (!all_match)
break;
}
ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y);
}
#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec4_(__LINE__, a, b, c, d)
static inline void check_readback_data_vec4_(unsigned int line, const struct resource_readback *rb,
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)