diff options
author | Adam Jackson <ajax@redhat.com> | 2021-01-07 15:47:08 -0500 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2021-01-07 17:39:24 -0500 |
commit | df4a7d67aacd913cdac7b2e0a6d8d67f30d24ba2 (patch) | |
tree | 0238fe30c3b3fc9af89b0e9fded145f194d583a3 | |
parent | ab0d17338f9a8fd1185aa14ca3ebf5a9c7b89acd (diff) |
mesa: Fix array-format-to-format table on big-endian
The table constructor and the table lookup were doing different things
for big-endian. This fixes MesaFormatsTest.FormatFromFormatAndType and
MesaFormatsTest.FormatMatchesFormatAndType failing to round-trip for
GL_RGBA / GL_SHORT, which we're not currently running in CI for s390x,
but which a subsequent commit will enable.
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8353>
-rw-r--r-- | src/mesa/main/formats.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index ffb04084d98..ac00a21306b 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -430,10 +430,9 @@ _mesa_array_format_flip_channels(mesa_array_format format) unreachable("Invalid array format"); } -uint32_t -_mesa_format_to_array_format(mesa_format format) +static uint32_t +_mesa_format_info_to_array_format(const struct mesa_format_info *info) { - const struct mesa_format_info *info = _mesa_get_format_info(format); #if UTIL_ARCH_BIG_ENDIAN if (info->ArrayFormat && info->Layout == MESA_FORMAT_LAYOUT_PACKED) return _mesa_array_format_flip_channels(info->ArrayFormat); @@ -442,6 +441,13 @@ _mesa_format_to_array_format(mesa_format format) return info->ArrayFormat; } +uint32_t +_mesa_format_to_array_format(mesa_format format) +{ + const struct mesa_format_info *info = _mesa_get_format_info(format); + return _mesa_format_info_to_array_format(info); +} + static struct hash_table *format_array_format_table; static once_flag format_array_format_table_exists = ONCE_FLAG_INIT; @@ -483,12 +489,7 @@ format_array_format_table_init(void) if (_mesa_is_format_srgb(f)) continue; -#if UTIL_ARCH_LITTLE_ENDIAN - array_format = info->ArrayFormat; -#else - array_format = _mesa_array_format_flip_channels(info->ArrayFormat); -#endif - + array_format = _mesa_format_info_to_array_format(info); _mesa_hash_table_insert_pre_hashed(format_array_format_table, array_format, (void *)(intptr_t)array_format, |