aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texparam.c')
-rw-r--r--mesalib/src/mesa/main/texparam.c96
1 files changed, 11 insertions, 85 deletions
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 0081c3b52..f4ec63388 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -35,6 +35,7 @@
#include "main/context.h"
#include "main/enums.h"
#include "main/formats.h"
+#include "main/image.h"
#include "main/macros.h"
#include "main/mfeatures.h"
#include "main/mtypes.h"
@@ -884,72 +885,6 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
}
-static GLboolean
-base_format_has_channel(GLenum base_format, GLenum pname)
-{
- switch (pname) {
- case GL_TEXTURE_RED_SIZE:
- case GL_TEXTURE_RED_TYPE:
- if (base_format == GL_RED ||
- base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_GREEN_SIZE:
- case GL_TEXTURE_GREEN_TYPE:
- if (base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_BLUE_SIZE:
- case GL_TEXTURE_BLUE_TYPE:
- if (base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_ALPHA_SIZE:
- case GL_TEXTURE_ALPHA_TYPE:
- if (base_format == GL_RGBA ||
- base_format == GL_ALPHA ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_LUMINANCE_SIZE:
- case GL_TEXTURE_LUMINANCE_TYPE:
- if (base_format == GL_LUMINANCE ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_INTENSITY_SIZE:
- case GL_TEXTURE_INTENSITY_TYPE:
- if (base_format == GL_INTENSITY) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_DEPTH_SIZE:
- case GL_TEXTURE_DEPTH_TYPE:
- if (base_format == GL_DEPTH_STENCIL ||
- base_format == GL_DEPTH_COMPONENT) {
- return GL_TRUE;
- }
- return GL_FALSE;
- default:
- _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
- __FUNCTION__, pname);
- return GL_FALSE;
- }
-
- return GL_FALSE;
-}
-
-
void GLAPIENTRY
_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
GLenum pname, GLfloat *params )
@@ -1048,34 +983,25 @@ _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;
break;
case GL_TEXTURE_INTENSITY_SIZE:
- if (img->_BaseFormat != GL_INTENSITY)
- *params = 0;
- else {
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) {
*params = _mesa_get_format_bits(texFormat, pname);
if (*params == 0) {
- /* intensity probably stored as rgb texture */
- *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
- _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
+ /* intensity or luminance is probably stored as RGB[A] */
+ *params = MIN2(_mesa_get_format_bits(texFormat,
+ GL_TEXTURE_RED_SIZE),
+ _mesa_get_format_bits(texFormat,
+ GL_TEXTURE_GREEN_SIZE));
}
}
- break;
- case GL_TEXTURE_LUMINANCE_SIZE:
- if (img->_BaseFormat != GL_LUMINANCE &&
- img->_BaseFormat != GL_LUMINANCE_ALPHA)
- *params = 0;
else {
- *params = _mesa_get_format_bits(texFormat, pname);
- if (*params == 0) {
- /* luminance probably stored as rgb texture */
- *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
- _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
- }
+ *params = 0;
}
break;
case GL_TEXTURE_DEPTH_SIZE_ARB:
@@ -1122,7 +1048,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;