[Mesa-dev] [PATCH v2 14/18] mesa: Fix EXT_texture_sRGB functionality leaks

Nanley Chery nanleychery at gmail.com
Fri Oct 30 14:19:31 PDT 2015


From: Nanley Chery <nanley.g.chery at intel.com>

Stop leaks into GLES contexts in _mesa_base_tex_format() and
lookup_view_class().

Stop allowing compressed sRGB formats as valid formats in GLES3
contexts. These formats are only exposed to contexts advertising
EXT_texture_sRGB.

v2. Remove references to pre-1.2 desktop GL contexts.
    Remove note about how the GLES3 bug was found.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/mesa/main/glformats.c   | 16 ++++++++++++----
 src/mesa/main/textureview.c |  2 +-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index f37b5da..9134d7d 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1310,8 +1310,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
           */
          return ctx->Extensions.ANGLE_texture_compression_dxt;
       } else {
-         return _mesa_is_desktop_gl(ctx)
-            && ctx->Extensions.EXT_texture_sRGB
+         return _mesa_has_EXT_texture_sRGB(ctx)
             && _mesa_has_EXT_texture_compression_s3tc(ctx);
       }
    case MESA_FORMAT_LAYOUT_FXT1:
@@ -2354,14 +2353,23 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
       }
    }
 
-   if (ctx->Extensions.EXT_texture_sRGB) {
+   if (_mesa_has_EXT_texture_sRGB(ctx) ||
+       _mesa_is_gles3(ctx)) {
       switch (internalFormat) {
       case GL_SRGB_EXT:
       case GL_SRGB8_EXT:
-      case GL_COMPRESSED_SRGB_EXT:
          return GL_RGB;
       case GL_SRGB_ALPHA_EXT:
       case GL_SRGB8_ALPHA8_EXT:
+         return GL_RGBA;
+      default:
+         ; /* fallthrough */
+      }
+   }
+   if (_mesa_has_EXT_texture_sRGB(ctx)) {
+      switch (internalFormat) {
+      case GL_COMPRESSED_SRGB_EXT:
+         return GL_RGB;
       case GL_COMPRESSED_SRGB_ALPHA_EXT:
          return GL_RGBA;
       case GL_SLUMINANCE_ALPHA_EXT:
diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 1ac46d6..c5b0175 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -177,7 +177,7 @@ lookup_view_class(const struct gl_context *ctx, GLenum internalformat)
    }
 
    if (_mesa_has_EXT_texture_compression_s3tc(ctx) &&
-       ctx->Extensions.EXT_texture_sRGB) {
+       _mesa_has_EXT_texture_sRGB(ctx)) {
       for (i = 0; i < ARRAY_SIZE(s3tc_compatible_internal_formats); i++) {
          if (s3tc_compatible_internal_formats[i].internal_format
              == internalformat)
-- 
2.6.2



More information about the mesa-dev mailing list