diff options
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 3dc78f2bf5..7c3357043f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -255,7 +255,8 @@ _mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, * point. Update reference counts, etc. */ void -_mesa_remove_attachment(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) +_mesa_remove_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att) { if (att->Type == GL_TEXTURE) { ASSERT(att->Texture); @@ -340,7 +341,8 @@ _mesa_set_renderbuffer_attachment(struct gl_context *ctx, * Attach a renderbuffer object to a framebuffer object. */ void -_mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, +_mesa_framebuffer_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, GLenum attachment, struct gl_renderbuffer *rb) { struct gl_renderbuffer_attachment *att; @@ -397,6 +399,44 @@ fbo_incomplete(const char *msg, int index) } +/** + * Is the given base format a legal format for a color renderbuffer? + */ +static GLboolean +is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_RGB: + case GL_RGBA: + return GL_TRUE; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + return ctx->Extensions.ARB_framebuffer_object; + case GL_RED: + case GL_RG: + return ctx->Extensions.ARB_texture_rg; + default: + return GL_FALSE; + } +} + + +/** + * Is the given base format a legal format for a depth/stencil renderbuffer? + */ +static GLboolean +is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} /** @@ -448,14 +488,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, baseFormat = _mesa_get_format_base_format(texImage->TexFormat); if (format == GL_COLOR) { - if (baseFormat != GL_RGB && - baseFormat != GL_RGBA && - (!ctx->Extensions.ARB_framebuffer_object || - baseFormat != GL_ALPHA) && - (!ctx->Extensions.ARB_texture_rg || - baseFormat != GL_RED) && - (!ctx->Extensions.ARB_texture_rg || - baseFormat != GL_RG)) { + if (!is_legal_color_format(ctx, baseFormat)) { att_incomplete("bad format"); att->Complete = GL_FALSE; return; @@ -563,7 +596,8 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, * framebuffer is complete. */ 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) { GLuint numImages; GLenum intFormat = GL_NONE; /* color buffers' internal format */ @@ -586,6 +620,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffe for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { struct gl_renderbuffer_attachment *att; GLenum f; + gl_format mesaFormat; /* * XXX for ARB_fbo, only check color buffers that are named by @@ -632,12 +667,10 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffe minHeight = MIN2(minHeight, texImg->Height); maxHeight = MAX2(maxHeight, texImg->Height); f = texImg->_BaseFormat; + mesaFormat = texImg->TexFormat; numImages++; - if (f != GL_RGB && f != GL_RGBA && f != GL_DEPTH_COMPONENT - && f != GL_DEPTH_STENCIL_EXT - && (!ctx->Extensions.ARB_framebuffer_object || f != GL_ALPHA) - && (!ctx->Extensions.ARB_texture_rg || f != GL_RED) - && (!ctx->Extensions.ARB_texture_rg || f != GL_RG)) { + if (!is_legal_color_format(ctx, f) && + !is_legal_depth_format(ctx, f)) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fbo_incomplete("texture attachment incomplete", -1); return; @@ -649,6 +682,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffe minHeight = MIN2(minHeight, att->Renderbuffer->Height); maxHeight = MAX2(minHeight, att->Renderbuffer->Height); f = att->Renderbuffer->InternalFormat; + mesaFormat = att->Renderbuffer->Format; numImages++; } else { @@ -661,6 +695,9 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffe numSamples = att->Renderbuffer->NumSamples; } + /* check if integer color */ + fb->_IntegerColor = _mesa_is_format_integer_color(mesaFormat); + /* Error-check width, height, format, samples */ if (numImages == 1) { |