#include "state.h"
#include "teximage.h"
#include "texobj.h"
+#include "texparam.h"
/** Set this to 1 to help debug FBO incompleteness problems */
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;
- }
}
}
-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 ||
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) {
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;
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) {
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);
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;
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;