From 203b1b537070b43ae840fff35a981f44af5536ab Mon Sep 17 00:00:00 2001 From: Kalyan Kondapally Date: Wed, 7 Oct 2015 20:53:29 -0700 Subject: [PATCH] Accept BGRA_EXT as a valid format for TexImage2D Mesa always advertises support for GL_EXT_texture_format_BGRA8888. This extension adds BGRA_EXT as a valid internal and external format for TexSubImage2D. Also, this extension makes BGRA_EXT format and UNSIGNED_BYTE type a valid combination. This seems to be a recent regression in Mesa as the combinations worked fine previously. Signed-off-by: Kalyan Kondapally --- src/mesa/main/glformats.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index d7cad31..015b3f5 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -2151,12 +2151,13 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) ; /* fallthrough */ } - /* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0). + /* We always advertise support for GL_EXT_texture_format_BGRA8888, which + * allows GL_BGRA as internal and external format. */ if (_mesa_is_gles(ctx)) { switch (internalFormat) { case GL_BGRA: - return GL_RGBA; + return internalFormat; default: ; /* fallthrough */ } @@ -2622,6 +2623,7 @@ _mesa_es3_effective_internal_format_for_format_and_type(GLenum format, case GL_LUMINANCE_ALPHA: case GL_LUMINANCE: case GL_ALPHA: + case GL_BGRA_EXT: return format; } break; @@ -2734,13 +2736,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, if (_mesa_is_enum_format_unsized(internalFormat)) { GLenum effectiveInternalFormat = _mesa_es3_effective_internal_format_for_format_and_type(format, type); - if (effectiveInternalFormat == GL_NONE) return GL_INVALID_OPERATION; GLenum baseInternalFormat = _mesa_base_tex_format(ctx, effectiveInternalFormat); - if (internalFormat != baseInternalFormat) return GL_INVALID_OPERATION; @@ -2748,6 +2748,16 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, } switch (format) { + /* We always support GL_EXT_texture_format_BGRA8888 externsion. */ + case GL_BGRA_EXT: + switch (type) { + case GL_UNSIGNED_BYTE: + break; + default: + return GL_INVALID_OPERATION; + } + break; + case GL_RGBA: switch (type) { case GL_UNSIGNED_BYTE: @@ -3517,3 +3527,4 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type) */ unreachable("Unsupported format"); } + -- 1.9.1