mesa: Use the common logic for "is this baseformat a color format?"

When figuring out whether a renderbuffer should be used to set the
visual bits of an FBO, we were missing important baseformats like
GL_RED, GL_RG, and GL_LUMINANCE.
This commit is contained in:
Eric Anholt
2011-01-02 17:58:07 -08:00
parent beac6ee62a
commit 059cca92a8
4 changed files with 16 additions and 12 deletions

View File

@@ -402,8 +402,8 @@ fbo_incomplete(const char *msg, int index)
/** /**
* Is the given base format a legal format for a color renderbuffer? * Is the given base format a legal format for a color renderbuffer?
*/ */
static GLboolean GLboolean
is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) _mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat)
{ {
switch (baseFormat) { switch (baseFormat) {
case GL_RGB: case GL_RGB:
@@ -488,7 +488,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
baseFormat = _mesa_get_format_base_format(texImage->TexFormat); baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
if (format == GL_COLOR) { if (format == GL_COLOR) {
if (!is_legal_color_format(ctx, baseFormat)) { if (!_mesa_is_legal_color_format(ctx, baseFormat)) {
att_incomplete("bad format"); att_incomplete("bad format");
att->Complete = GL_FALSE; att->Complete = GL_FALSE;
return; return;
@@ -542,7 +542,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
return; return;
} }
if (format == GL_COLOR) { if (format == GL_COLOR) {
if (!is_legal_color_format(ctx, baseFormat)) { if (!_mesa_is_legal_color_format(ctx, baseFormat)) {
att_incomplete("bad renderbuffer color format"); att_incomplete("bad renderbuffer color format");
att->Complete = GL_FALSE; att->Complete = GL_FALSE;
return; return;
@@ -668,7 +668,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
f = texImg->_BaseFormat; f = texImg->_BaseFormat;
mesaFormat = texImg->TexFormat; mesaFormat = texImg->TexFormat;
numImages++; numImages++;
if (!is_legal_color_format(ctx, f) && if (!_mesa_is_legal_color_format(ctx, f) &&
!is_legal_depth_format(ctx, f)) { !is_legal_depth_format(ctx, f)) {
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
fbo_incomplete("texture attachment incomplete", -1); fbo_incomplete("texture attachment incomplete", -1);
@@ -792,7 +792,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->Height = minHeight; fb->Height = minHeight;
/* finally, update the visual info for the framebuffer */ /* finally, update the visual info for the framebuffer */
_mesa_update_framebuffer_visual(fb); _mesa_update_framebuffer_visual(ctx, fb);
} }
} }
@@ -1939,7 +1939,7 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
/* Some subsequent GL commands may depend on the framebuffer's visual /* Some subsequent GL commands may depend on the framebuffer's visual
* after the binding is updated. Update visual info now. * after the binding is updated. Update visual info now.
*/ */
_mesa_update_framebuffer_visual(fb); _mesa_update_framebuffer_visual(ctx, fb);
} }

View File

@@ -71,6 +71,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb
extern void extern void
_mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb); _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb);
extern GLboolean
_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat);
extern GLenum extern GLenum
_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat); _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat);

View File

@@ -522,7 +522,8 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx)
* integer Z values. * integer Z values.
*/ */
void void
_mesa_update_framebuffer_visual(struct gl_framebuffer *fb) _mesa_update_framebuffer_visual(struct gl_context *ctx,
struct gl_framebuffer *fb)
{ {
GLuint i; GLuint i;
@@ -543,8 +544,7 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
const gl_format fmt = rb->Format; const gl_format fmt = rb->Format;
if (baseFormat == GL_RGBA || baseFormat == GL_RGB || if (_mesa_is_legal_color_format(ctx, baseFormat)) {
baseFormat == GL_ALPHA) {
fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS);

View File

@@ -70,7 +70,8 @@ extern void
_mesa_update_draw_buffer_bounds(struct gl_context *ctx); _mesa_update_draw_buffer_bounds(struct gl_context *ctx);
extern void extern void
_mesa_update_framebuffer_visual(struct gl_framebuffer *fb); _mesa_update_framebuffer_visual(struct gl_context *ctx,
struct gl_framebuffer *fb);
extern void extern void
_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, _mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,