[Mesa-dev] [PATCH 1/2] mesa: support internalFormat=GL_BGRA in TexImage2D
Benjamin Franzke
benjaminfranzke at googlemail.com
Mon Jan 17 14:44:44 PST 2011
internalFormat=GL_BGRA is only allowed with gles1/2
and GL_EXT_texture_format_BGRA8888 enabled.
---
src/mesa/main/texformat.c | 4 ++++
src/mesa/main/teximage.c | 9 +++++++++
src/mesa/main/texparam.c | 7 +++++--
src/mesa/main/texstate.c | 1 +
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 146b2b3..3fb4530 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -94,6 +94,10 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444);
break;
+ case GL_BGRA:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
+ break;
+
/* deep RGBA formats */
case GL_RGB10_A2:
RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB2101010);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 47d5093..7ee62b0 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -183,6 +183,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
; /* fallthrough */
}
+ if (ctx->Extensions.EXT_texture_format_BGRA8888) {
+ switch (internalFormat) {
+ case GL_BGRA_EXT:
+ return GL_BGRA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
if (ctx->Extensions.EXT_paletted_texture) {
switch (internalFormat) {
case GL_COLOR_INDEX:
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index d2b8b5c..190a14d 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -885,7 +885,9 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
}
/* FALLTHROUGH */
case GL_TEXTURE_BLUE_SIZE:
- if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)
+ if (img->_BaseFormat == GL_RGB ||
+ img->_BaseFormat == GL_RGBA ||
+ img->_BaseFormat == GL_BGRA)
*params = _mesa_get_format_bits(texFormat, pname);
else
*params = 0;
@@ -893,7 +895,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
case GL_TEXTURE_ALPHA_SIZE:
if (img->_BaseFormat == GL_ALPHA ||
img->_BaseFormat == GL_LUMINANCE_ALPHA ||
- img->_BaseFormat == GL_RGBA)
+ img->_BaseFormat == GL_RGBA ||
+ img->_BaseFormat == GL_BGRA)
*params = _mesa_get_format_bits(texFormat, pname);
else
*params = 0;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index f4d7718..e8315a1 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -176,6 +176,7 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state,
case GL_LUMINANCE_ALPHA:
case GL_INTENSITY:
case GL_RGBA:
+ case GL_BGRA:
break;
case GL_LUMINANCE:
--
1.7.3.4
More information about the mesa-dev
mailing list