st: fix st_choose_matching_format to ignore intensity
authorChris Forbes <chrisf@ijw.co.nz>
Fri, 28 Mar 2014 23:02:54 +0000 (12:02 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Mon, 31 Mar 2014 22:56:18 +0000 (11:56 +1300)
_mesa_format_matches_format_and_type() returns true for
GL_RED/GL_RED_INTEGER (with an appropriate type) into an intensity
mesa_format.

We want the `red`-based format instead, regardless of the order we find
them in our walk of the mesa formats list.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_format.c

index cd6b466815c60c8ec40d5e2fcd19ac537b3c2e8c..38d4ccfea072d1993135006835ba942c9461e553 100644 (file)
@@ -1750,6 +1750,12 @@ st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
       if (_mesa_get_format_color_encoding(mesa_format) == GL_SRGB) {
          continue;
       }
+      if (_mesa_get_format_bits(mesa_format, GL_TEXTURE_INTENSITY_SIZE) > 0) {
+         /* If `format` is GL_RED/GL_RED_INTEGER, then we might match some
+          * intensity formats, which we don't want.
+          */
+         continue;
+      }
 
       if (_mesa_format_matches_format_and_type(mesa_format, format, type,
                                                swapBytes)) {