mesa: Don't put sRGB formats in the array format table.
authorEric Anholt <eric@anholt.net>
Fri, 15 Nov 2019 01:41:27 +0000 (17:41 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 15 Nov 2019 20:32:17 +0000 (20:32 +0000)
sRGB vs unorm was the only conflict case being guarded against in this
function.  Before the PIPE_FORMAT conversion, we always listed the
unorm before the sRGB in the enums, but PIPE_FORMAT_A8B8G8R8_SRGB
happens to be before _UNORM.  We always want the unorm result here.

Fixes: 807a800d8c3e ("mesa: Redefine MESA_FORMAT_* in terms of PIPE_FORMAT_*.")
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/formats.c

index 5b420bf59dec11dff8fd2f3bc423f006fef6e2a1..370859d37ca1595357495dd0340dc30f4cf9fa3a 100644 (file)
@@ -477,20 +477,18 @@ format_array_format_table_init(void)
       if (!info || !info->ArrayFormat)
          continue;
 
+      /* All sRGB formats should have an equivalent UNORM format, and that's
+       * the one we want in the table.
+       */
+      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
 
-      /* This can happen and does for some of the BGR formats.  Let's take
-       * the first one in the list.
-       */
-      if (_mesa_hash_table_search_pre_hashed(format_array_format_table,
-                                             array_format,
-                                             (void *)(intptr_t)array_format))
-         continue;
-
       _mesa_hash_table_insert_pre_hashed(format_array_format_table,
                                          array_format,
                                          (void *)(intptr_t)array_format,