From df4a7d67aacd913cdac7b2e0a6d8d67f30d24ba2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 Jan 2021 15:47:08 -0500 Subject: 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 Part-of: --- src/mesa/main/formats.c | 19 ++++++++++--------- 1 file 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, -- cgit v1.2.3