0
0
mirror of https://gitlab.winehq.org/wine/vkd3d.git synced 2025-01-28 13:05:02 -08:00

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

@ -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)); 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) 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)); 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) #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, static void check_sub_resource_float_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,

@ -413,7 +413,6 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
{ {
unsigned int left, top, right, bottom, ulps; unsigned int left, top, right, bottom, ulps;
struct resource_readback *rb; struct resource_readback *rb;
struct vec4 v;
int ret, len; int ret, len;
RECT rect; 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); 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); 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); runner->ops->release_readback(runner, rb);
} }
else if (match_string(line, "uniform", &line)) else if (match_string(line, "uniform", &line))

@ -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]; 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) 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)); 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) #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, 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) const RECT *rect, const struct vec4 *expected, unsigned int max_diff)