tests/shader-runner: Support testing for integer pixel data.

Modified by Conor McCarthy to use read_uint() and read_uint4().
This commit is contained in:
Evan Tang 2023-10-13 16:27:44 -05:00 committed by Alexandre Julliard
parent 6dea3d08b1
commit 13ac795061
Notes: Alexandre Julliard 2024-02-01 23:07:09 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/589
4 changed files with 133 additions and 64 deletions

View File

@ -249,11 +249,6 @@ 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 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_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 *resource,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,

View File

@ -74,14 +74,6 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y,
vp->MaxDepth = max_depth;
}
static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff)
{
return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
&& compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
&& compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
&& compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
}
static D3D12_SHADER_BYTECODE shader_bytecode(const DWORD *code, size_t size)
{
D3D12_SHADER_BYTECODE shader_bytecode = { code, size };
@ -526,12 +518,6 @@ static void get_resource_readback_with_command_list(ID3D12Resource *resource, un
RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE);
}
static unsigned int get_readback_uint(struct resource_readback *rb,
unsigned int x, unsigned int y, unsigned int z)
{
return *(unsigned int *)get_readback_data(rb, x, y, z, sizeof(unsigned int));
}
static void release_resource_readback(struct d3d12_resource_readback *rb)
{
D3D12_RANGE range = {0, 0};
@ -539,40 +525,6 @@ static void release_resource_readback(struct d3d12_resource_readback *rb)
ID3D12Resource_Release(rb->resource);
}
#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__LINE__, a, b, c, d)
static void check_readback_data_uint_(unsigned int line, struct resource_readback *rb,
const D3D12_BOX *box, unsigned int expected, unsigned int max_diff)
{
D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth};
unsigned int x = 0, y = 0, z;
bool all_match = true;
unsigned int got = 0;
if (box)
b = *box;
for (z = b.front; z < b.back; ++z)
{
for (y = b.top; y < b.bottom; ++y)
{
for (x = b.left; x < b.right; ++x)
{
got = get_readback_uint(rb, x, y, z);
if (!compare_color(got, expected, max_diff))
{
all_match = false;
break;
}
}
if (!all_match)
break;
}
if (!all_match)
break;
}
ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z);
}
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f)
static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,

View File

@ -229,6 +229,17 @@ static bool match_directive_substring(const char *line, const char *token, const
return match_string_generic(line, token, rest, true, false, 0);
}
static const char *close_parentheses(const char *line)
{
while (isspace(*line))
++line;
if (*line != ')')
fatal_error("Malformed probe arguments '%s'.\n", line);
return line;
}
static void parse_require_directive(struct shader_runner *runner, const char *line)
{
bool less_than = false;
@ -564,7 +575,7 @@ static void read_int(const char **line, int *i)
*line = rest;
}
static void read_uint(const char **line, unsigned int *u)
static void read_uint(const char **line, unsigned int *u, bool is_uniform)
{
char *rest;
unsigned long val;
@ -572,14 +583,14 @@ static void read_uint(const char **line, unsigned int *u)
errno = 0;
val = strtoul(*line, &rest, 0);
if (errno != 0 || (*rest != '\0' && !isspace((unsigned char)*rest)))
if (errno != 0 || (is_uniform && *rest != '\0' && !isspace((unsigned char)*rest)))
fatal_error("Malformed uint constant '%s'.\n", *line);
*u = val;
if (*u != val)
fatal_error("Out of range uint constant '%.*s'.\n", (int)(rest - *line), *line);
*line = rest;
*line = rest + (!is_uniform && *rest == ',');
}
static void read_int4(const char **line, struct ivec4 *v)
@ -590,12 +601,12 @@ static void read_int4(const char **line, struct ivec4 *v)
read_int(line, &v->w);
}
static void read_uint4(const char **line, struct uvec4 *v)
static void read_uint4(const char **line, struct uvec4 *v, bool is_uniform)
{
read_uint(line, &v->x);
read_uint(line, &v->y);
read_uint(line, &v->z);
read_uint(line, &v->w);
read_uint(line, &v->x, is_uniform);
read_uint(line, &v->y, is_uniform);
read_uint(line, &v->z, is_uniform);
read_uint(line, &v->w, is_uniform);
}
static void read_int64(const char **line, int64_t *i)
@ -825,7 +836,18 @@ 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))
if (match_string(line, "rgbaui", &line))
{
struct uvec4 v;
if (*line != '(')
fatal_error("Malformed probe arguments '%s'.\n", line);
++line;
read_uint4(&line, &v, false);
line = close_parentheses(line);
todo_if(runner->is_todo) check_readback_data_uvec4(rb, &rect, &v);
}
else if (match_string(line, "rgba", &line))
{
struct vec4 v;
@ -836,6 +858,24 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
ulps = 0;
todo_if(runner->is_todo) check_readback_data_vec4(rb, &rect, &v, ulps);
}
else if (match_string(line, "rui", &line))
{
unsigned int expect;
D3D12_BOX box;
box.left = rect.left;
box.right = rect.right;
box.top = rect.top;
box.bottom = rect.bottom;
box.front = 0;
box.back = 1;
if (*line != '(')
fatal_error("Malformed probe arguments '%s'.\n", line);
++line;
read_uint(&line, &expect, false);
line = close_parentheses(line);
todo_if(runner->is_todo) check_readback_data_uint(rb, &box, expect, 0);
}
else if (match_string(line, "r", &line))
{
float expect;
@ -897,7 +937,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
{
struct uvec4 v;
read_uint4(&line, &v);
read_uint4(&line, &v, true);
set_uniforms(runner, offset, 4, &v);
}
else if (match_string(line, "int", &line))
@ -911,7 +951,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
{
unsigned int u;
read_uint(&line, &u);
read_uint(&line, &u, true);
set_uniforms(runner, offset, 1, &u);
}
else if (match_string(line, "int64_t2", &line))

View File

@ -104,6 +104,14 @@ static bool compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
return diff <= max_diff;
}
static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff)
{
return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
&& compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
&& compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
&& compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
}
static bool compare_float(float f, float g, unsigned int ulps)
{
int x, y;
@ -159,11 +167,21 @@ static float get_readback_float(const struct resource_readback *rb, unsigned int
return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
}
static unsigned int get_readback_uint(const struct resource_readback *rb, unsigned int x, unsigned int y, unsigned int z)
{
return *(unsigned int*)get_readback_data(rb, x, y, z, sizeof(unsigned int));
}
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));
}
static const struct uvec4 *get_readback_uvec4(const 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 inline void check_readback_data_float_(unsigned int line, const struct resource_readback *rb,
const RECT *rect, float expected, unsigned int max_diff)
@ -193,6 +211,40 @@ static inline void check_readback_data_float_(unsigned int line, const struct re
ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y);
}
#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__LINE__, a, b, c, d)
static inline void check_readback_data_uint_(unsigned int line, struct resource_readback *rb,
const D3D12_BOX *box, unsigned int expected, unsigned int max_diff)
{
D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth};
unsigned int x = 0, y = 0, z;
bool all_match = true;
unsigned int got = 0;
if (box)
b = *box;
for (z = b.front; z < b.back; ++z)
{
for (y = b.top; y < b.bottom; ++y)
{
for (x = b.left; x < b.right; ++x)
{
got = get_readback_uint(rb, x, y, z);
if (!compare_color(got, expected, max_diff))
{
all_match = false;
break;
}
}
if (!all_match)
break;
}
if (!all_match)
break;
}
ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z);
}
#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)
@ -223,6 +275,36 @@ static inline void check_readback_data_vec4_(unsigned int line, const struct res
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
}
#define check_readback_data_uvec4(a, b, c) check_readback_data_uvec4_(__LINE__, a, b, c)
static inline void check_readback_data_uvec4_(unsigned int line, const struct resource_readback *rb,
const RECT *rect, const struct uvec4 *expected)
{
RECT r = {0, 0, rb->width, rb->height};
unsigned int x = 0, y = 0;
struct uvec4 got = {0};
bool all_match = true;
if (rect)
r = *rect;
for (y = r.top; y < r.bottom; ++y)
{
for (x = r.left; x < r.right; ++x)
{
got = *get_readback_uvec4(rb, x, y);
if (!compare_uvec4(&got, expected))
{
all_match = false;
break;
}
}
if (!all_match)
break;
}
ok_(line)(all_match, "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n",
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
}
struct test_options
{
bool use_warp_device;