[Mesa-dev] [RFC 15/21] mesa: Fix EXT_texture_sRGB functionality leaks
Nanley Chery
nanleychery at gmail.com
Mon Oct 19 15:44:53 PDT 2015
From: Nanley Chery <nanley.g.chery at intel.com>
Stop leaks into the following contexts:
* GLES in _mesa_base_tex_format() and lookup_view_class().
* Pre-1.1 GL legacy contexts in all uses.
Stop allowing compressed sRGB formats as valid formats in GLES3
contexts. I realized this was happening when CTS failures occured after
fixing the extension functionality leak with the helper function.
The extension spec lists 1.1 as required for OpenGL, so update the
extension table accordingly.
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
src/mesa/main/extensions_table.h | 2 +-
src/mesa/main/glformats.c | 16 ++++++++++++----
src/mesa/main/textureview.c | 2 +-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 3729d22..cf6eed7 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -202,7 +202,7 @@ EXT(EXT_texture , dummy_true
EXT(EXT_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2004)
EXT(EXT_texture_shared_exponent , EXT_texture_shared_exponent , GLL, GLC, x , x , 2004)
EXT(EXT_texture_snorm , EXT_texture_snorm , GLL, GLC, x , x , 2009)
-EXT(EXT_texture_sRGB , EXT_texture_sRGB , GLL, GLC, x , x , 2004)
+EXT(EXT_texture_sRGB , EXT_texture_sRGB , 11, GLC, x , x , 2004)
EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode , GLL, GLC, x , x , 2006)
EXT(EXT_texture_swizzle , EXT_texture_swizzle , GLL, GLC, x , x , 2008)
EXT(EXT_texture_type_2_10_10_10_REV , dummy_true , x , x , x , ES2, 2008)
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.1
More information about the mesa-dev
mailing list