From f0b6e9a729d14740fc607c1148032d688f3c5c2c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 23 Nov 2011 15:33:45 -0700 Subject: [PATCH] mesa: use _mesa_base_format_has_channel() in fbobject.c queries Reviewed-by: Eric Anholt --- src/mesa/main/fbobject.c | 45 ++++------------------------------------ src/mesa/main/texparam.c | 25 ++++++++++++++++++---- src/mesa/main/texparam.h | 3 +++ 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f63a8e7bec3..2b4c70afbf7 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -46,6 +46,7 @@ #include "state.h" #include "teximage.h" #include "texobj.h" +#include "texparam.h" /** Set this to 1 to help debug FBO incompleteness problems */ @@ -1477,48 +1478,10 @@ _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) static GLint get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) { - switch (pname) { - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA || - baseFormat == GL_RG || baseFormat == GL_RED) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA || baseFormat == GL_RG) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA || - baseFormat == GL_LUMINANCE_ALPHA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - default: + if (_mesa_base_format_has_channel(baseFormat, pname)) + return _mesa_get_format_bits(format, pname); + else return 0; - } } diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 0081c3b5295..4c30a36f412 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -884,12 +884,14 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) } -static GLboolean -base_format_has_channel(GLenum base_format, GLenum pname) +GLboolean +_mesa_base_format_has_channel(GLenum base_format, GLenum pname) { switch (pname) { case GL_TEXTURE_RED_SIZE: case GL_TEXTURE_RED_TYPE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: if (base_format == GL_RED || base_format == GL_RG || base_format == GL_RGB || @@ -899,6 +901,8 @@ base_format_has_channel(GLenum base_format, GLenum pname) return GL_FALSE; case GL_TEXTURE_GREEN_SIZE: case GL_TEXTURE_GREEN_TYPE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: if (base_format == GL_RG || base_format == GL_RGB || base_format == GL_RGBA) { @@ -907,6 +911,8 @@ base_format_has_channel(GLenum base_format, GLenum pname) return GL_FALSE; case GL_TEXTURE_BLUE_SIZE: case GL_TEXTURE_BLUE_TYPE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: if (base_format == GL_RGB || base_format == GL_RGBA) { return GL_TRUE; @@ -914,6 +920,8 @@ base_format_has_channel(GLenum base_format, GLenum pname) return GL_FALSE; case GL_TEXTURE_ALPHA_SIZE: case GL_TEXTURE_ALPHA_TYPE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: if (base_format == GL_RGBA || base_format == GL_ALPHA || base_format == GL_LUMINANCE_ALPHA) { @@ -935,11 +943,20 @@ base_format_has_channel(GLenum base_format, GLenum pname) return GL_FALSE; case GL_TEXTURE_DEPTH_SIZE: case GL_TEXTURE_DEPTH_TYPE: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: if (base_format == GL_DEPTH_STENCIL || base_format == GL_DEPTH_COMPONENT) { return GL_TRUE; } return GL_FALSE; + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (base_format == GL_DEPTH_STENCIL || + base_format == GL_STENCIL_INDEX) { + return GL_TRUE; + } + return GL_FALSE; default: _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n", __FUNCTION__, pname); @@ -1048,7 +1065,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, case GL_TEXTURE_GREEN_SIZE: case GL_TEXTURE_BLUE_SIZE: case GL_TEXTURE_ALPHA_SIZE: - if (base_format_has_channel(img->_BaseFormat, pname)) + if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; @@ -1122,7 +1139,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, case GL_TEXTURE_DEPTH_TYPE_ARB: if (!ctx->Extensions.ARB_texture_float) goto invalid_pname; - if (base_format_has_channel(img->_BaseFormat, pname)) + if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) *params = _mesa_get_format_datatype(texFormat); else *params = GL_NONE; diff --git a/src/mesa/main/texparam.h b/src/mesa/main/texparam.h index 19b4116c0b6..6c6b7fa671e 100644 --- a/src/mesa/main/texparam.h +++ b/src/mesa/main/texparam.h @@ -30,6 +30,9 @@ #include "main/glheader.h" +extern GLboolean +_mesa_base_format_has_channel(GLenum base_format, GLenum pname); + extern void GLAPIENTRY _mesa_GetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ); -- 2.30.2