tests/shader_runner: Use format names if available in trace_format_cap().

This commit is contained in:
Henri Verbeet
2025-09-30 22:26:53 +02:00
parent 9de229925d
commit 62fa65066f
Notes: Henri Verbeet 2025-10-13 19:32:34 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1782

View File

@@ -401,16 +401,14 @@ static const char *close_parentheses(const char *line)
return line; return line;
} }
static DXGI_FORMAT parse_format(const char *line, unsigned int *texel_size, bool *is_shadow, const char **rest) static const struct format_info
{
static const struct
{ {
const char *string; const char *string;
unsigned int texel_size; unsigned int texel_size;
DXGI_FORMAT format; DXGI_FORMAT format;
bool is_shadow; bool is_shadow;
} }
formats[] = format_info[] =
{ {
{"r32g32b32a32-float", 16, DXGI_FORMAT_R32G32B32A32_FLOAT}, {"r32g32b32a32-float", 16, DXGI_FORMAT_R32G32B32A32_FLOAT},
{"r32g32b32a32-sint", 16, DXGI_FORMAT_R32G32B32A32_SINT}, {"r32g32b32a32-sint", 16, DXGI_FORMAT_R32G32B32A32_SINT},
@@ -425,17 +423,35 @@ static DXGI_FORMAT parse_format(const char *line, unsigned int *texel_size, bool
{"r32-typeless", 4, DXGI_FORMAT_R32_TYPELESS}, {"r32-typeless", 4, DXGI_FORMAT_R32_TYPELESS},
{"unknown", 0, DXGI_FORMAT_UNKNOWN}, {"unknown", 0, DXGI_FORMAT_UNKNOWN},
}; };
static const char *get_format_name(DXGI_FORMAT f)
{
const struct format_info *info;
size_t i;
for (i = 0; i < ARRAY_SIZE(format_info); ++i)
{
info = &format_info[i];
if (info->format == f && !info->is_shadow)
return info->string;
}
return NULL;
}
static DXGI_FORMAT parse_format(const char *line, unsigned int *texel_size, bool *is_shadow, const char **rest)
{
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(formats); ++i) for (i = 0; i < ARRAY_SIZE(format_info); ++i)
{ {
if (match_string(line, formats[i].string, rest)) if (match_string(line, format_info[i].string, rest))
{ {
if (texel_size) if (texel_size)
*texel_size = formats[i].texel_size; *texel_size = format_info[i].texel_size;
if (is_shadow) if (is_shadow)
*is_shadow = formats[i].is_shadow; *is_shadow = format_info[i].is_shadow;
return formats[i].format; return format_info[i].format;
} }
} }
@@ -2201,6 +2217,7 @@ static void trace_format_cap(const struct shader_runner_caps *caps, enum format_
{ {
bool show_none = true; bool show_none = true;
char buffer[80], *p; char buffer[80], *p;
const char *name;
size_t rem; size_t rem;
int rc; int rc;
@@ -2214,6 +2231,9 @@ static void trace_format_cap(const struct shader_runner_caps *caps, enum format_
{ {
if (caps->format_caps[i] & cap) if (caps->format_caps[i] & cap)
{ {
if ((name = get_format_name(i)))
rc = snprintf(p, rem, " %s", name);
else
rc = snprintf(p, rem, " 0x%x", i); rc = snprintf(p, rem, " 0x%x", i);
if (!(rc >= 0 && (size_t)rc < rem)) if (!(rc >= 0 && (size_t)rc < rem))
{ {