Mesa (master): st: Choose a 2101010 format for GL_RGB/GL_RGBA with a 2_10_10_10 type.

Eric Anholt anholt at kemper.freedesktop.org
Thu Apr 26 18:30:42 UTC 2018


Module: Mesa
Branch: master
Commit: 8adf813f83b9f54e3c9958cc7c7a485e62222e2e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8adf813f83b9f54e3c9958cc7c7a485e62222e2e

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Apr 25 11:40:40 2018 -0700

st: Choose a 2101010 format for GL_RGB/GL_RGBA with a 2_10_10_10 type.

GLES's GL_EXT_texture_type_2_10_10_10_REV allows uploading this type to an
unsized internalformat, and it should be non-color-renderable.
fbobject.c's implementation of the check for color-renderable is checks
that the texture has a 2101010 mesa format, so make sure that we have
chosen a 2101010 format so that check can do what it meant to.

Fixes KHR-GLES3.packed_pixels.pbo_rectangle.rgb on vc5.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/state_tracker/st_format.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 3db3c7e967..418f534202 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -2138,6 +2138,19 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
       goto success;
    }
 
+   /* For an unsized GL_RGB but a 2_10_10_10 type, try to pick one of the
+    * 2_10_10_10 formats.  This is important for
+    * GL_EXT_texture_type_2_10_10_10_EXT support, which says that these
+    * formats are not color-renderable.  Mesa's check for making those
+    * non-color-renderable is based on our chosen format being 2101010.
+    */
+   if (type == GL_UNSIGNED_INT_2_10_10_10_REV) {
+      if (internalFormat == GL_RGB)
+         internalFormat = GL_RGB10;
+      else if (internalFormat == GL_RGBA)
+         internalFormat = GL_RGB10_A2;
+   }
+
    /* search table for internalFormat */
    for (i = 0; i < ARRAY_SIZE(format_map); i++) {
       const struct format_mapping *mapping = &format_map[i];




More information about the mesa-commit mailing list