diff options
author | Christian König <[email protected]> | 2010-10-28 20:24:56 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2010-10-28 20:24:56 +0200 |
commit | 41ed47d6b8fb6c032e2907ef2e49e414c26f35c1 (patch) | |
tree | 8cf267ee3ac5d8b530dd70a28a0d568344aa8304 /src/mesa/main/fbobject.c | |
parent | 97a7cf230a70c64fff300931ae7c00aa00449c97 (diff) | |
parent | 5479fa34d9acebd55f68c23a278cf382d0e84248 (diff) |
Merge branch 'master' of ssh://git.freedesktop.org/git/mesa/mesa into pipe-video
Conflicts:
src/gallium/include/pipe/p_format.h
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 95 |
1 files changed, 66 insertions, 29 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f28846c4c99..7c3357043fa 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -95,7 +95,7 @@ delete_dummy_framebuffer(struct gl_framebuffer *fb) void -_mesa_init_fbobjects(GLcontext *ctx) +_mesa_init_fbobjects(struct gl_context *ctx) { _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); @@ -115,7 +115,7 @@ _mesa_get_incomplete_framebuffer(void) * Helper routine for getting a gl_renderbuffer. */ struct gl_renderbuffer * -_mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id) +_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) { struct gl_renderbuffer *rb; @@ -132,7 +132,7 @@ _mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id) * Helper routine for getting a gl_framebuffer. */ struct gl_framebuffer * -_mesa_lookup_framebuffer(GLcontext *ctx, GLuint id) +_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) { struct gl_framebuffer *fb; @@ -166,7 +166,7 @@ invalidate_framebuffer(struct gl_framebuffer *fb) * the depth buffer attachment point. */ struct gl_renderbuffer_attachment * -_mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, +_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment) { GLuint i; @@ -216,7 +216,7 @@ _mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, * window-system framebuffer (not user-created framebuffer objects). */ static struct gl_renderbuffer_attachment * -_mesa_get_fb0_attachment(GLcontext *ctx, struct gl_framebuffer *fb, +_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, GLenum attachment) { assert(fb->Name == 0); @@ -255,7 +255,8 @@ _mesa_get_fb0_attachment(GLcontext *ctx, struct gl_framebuffer *fb, * point. Update reference counts, etc. */ void -_mesa_remove_attachment(GLcontext *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); @@ -281,7 +282,7 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att) * The previous binding, if any, will be removed first. */ void -_mesa_set_texture_attachment(GLcontext *ctx, +_mesa_set_texture_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att, struct gl_texture_object *texObj, @@ -322,7 +323,7 @@ _mesa_set_texture_attachment(GLcontext *ctx, * The previous binding, if any, will be removed first. */ void -_mesa_set_renderbuffer_attachment(GLcontext *ctx, +_mesa_set_renderbuffer_attachment(struct gl_context *ctx, struct gl_renderbuffer_attachment *att, struct gl_renderbuffer *rb) { @@ -340,7 +341,8 @@ _mesa_set_renderbuffer_attachment(GLcontext *ctx, * Attach a renderbuffer object to a framebuffer object. */ void -_mesa_framebuffer_renderbuffer(GLcontext *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; + } +} /** @@ -406,7 +446,7 @@ fbo_incomplete(const char *msg, int index) * if GL_STENCIL, this is a stencil component attachment point. */ static void -test_attachment_completeness(const GLcontext *ctx, GLenum format, +test_attachment_completeness(const struct gl_context *ctx, GLenum format, struct gl_renderbuffer_attachment *att) { assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); @@ -448,14 +488,7 @@ test_attachment_completeness(const GLcontext *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 GLcontext *ctx, GLenum format, * framebuffer is complete. */ void -_mesa_test_framebuffer_completeness(GLcontext *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(GLcontext *ctx, struct gl_framebuffer *fb) 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(GLcontext *ctx, struct gl_framebuffer *fb) 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(GLcontext *ctx, struct gl_framebuffer *fb) 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(GLcontext *ctx, struct gl_framebuffer *fb) 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) { @@ -833,7 +870,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) * The spec calls for unbinding. */ static void -detach_renderbuffer(GLcontext *ctx, +detach_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { @@ -934,7 +971,7 @@ _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) * we'll also return GL_RED and GL_RG. */ GLenum -_mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat) +_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) { switch (internalFormat) { case GL_ALPHA: @@ -1287,7 +1324,7 @@ _mesa_IsFramebufferEXT(GLuint framebuffer) * attachments. */ static void -check_begin_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) +check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint i; ASSERT(ctx->Driver.RenderTexture); @@ -1312,7 +1349,7 @@ check_begin_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) * notify the device driver that the texture image may have changed. */ static void -check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) +check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) { if (fb->Name == 0) return; /* can't render to texture with winsys framebuffers */ @@ -1606,7 +1643,7 @@ _mesa_CheckFramebufferStatusEXT(GLenum target) * Common code called by glFramebufferTexture1D/2D/3DEXT(). */ static void -framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target, +framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) { |