diff options
author | Brian Paul <[email protected]> | 2005-10-08 14:41:17 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-10-08 14:41:17 +0000 |
commit | 474f28e57ca750ca39d7f684904a3c0e69a03f62 (patch) | |
tree | aa9d5d1c9c37bf9a457ed0e77f89eabda631efda /src/mesa | |
parent | 81a22ef53953d950052c7bd5a282e96107a25f24 (diff) |
Fix some issues with state updates and renderbuffers. Querying GL_RED_BITS,
etc. after calling glRenderBufferStorageEXT gave undefined results.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/fbobject.c | 36 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.c | 42 | ||||
-rw-r--r-- | src/mesa/main/get.c | 10 | ||||
-rw-r--r-- | src/mesa/main/get_gen.py | 4 |
4 files changed, 64 insertions, 28 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 6fc7c8ab631..f5ae4518beb 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -527,7 +527,6 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -535,6 +534,8 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (renderbuffer) { newRb = lookup_renderbuffer(ctx, renderbuffer); if (newRb == &DummyRenderbuffer) { @@ -578,6 +579,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); for (i = 0; i < n; i++) { if (renderbuffers[i] > 0) { @@ -700,7 +702,6 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (target != GL_RENDERBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glRenderbufferStorageEXT(target)"); @@ -731,6 +732,8 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + /* Now allocate the storage */ ASSERT(rb->AllocStorage); if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { @@ -776,6 +779,8 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + switch (pname) { case GL_RENDERBUFFER_WIDTH_EXT: *params = ctx->CurrentRenderbuffer->Width; @@ -870,13 +875,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (target != GL_FRAMEBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (framebuffer) { /* Binding a user-created framebuffer object */ newFb = lookup_framebuffer(ctx, framebuffer); @@ -927,6 +933,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); for (i = 0; i < n; i++) { if (framebuffers[i] > 0) { @@ -1008,6 +1015,8 @@ _mesa_CheckFramebufferStatusEXT(GLenum target) return GL_FRAMEBUFFER_COMPLETE_EXT; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); return ctx->DrawBuffer->_Status; } @@ -1070,7 +1079,6 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */ if (error_check_framebuffer_texture(ctx, 1, target, attachment, textarget, texture, level)) @@ -1085,6 +1093,8 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (texture) { texObj = (struct gl_texture_object *) _mesa_HashLookup(ctx->Shared->TexObjects, texture); @@ -1104,8 +1114,6 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, texObj = NULL; } ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0); - - _mesa_update_framebuffer_visual(ctx->DrawBuffer); } @@ -1118,7 +1126,6 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */ if (error_check_framebuffer_texture(ctx, 2, target, attachment, textarget, texture, level)) @@ -1135,6 +1142,8 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (texture) { texObj = (struct gl_texture_object *) _mesa_HashLookup(ctx->Shared->TexObjects, texture); @@ -1158,7 +1167,6 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, texObj = NULL; } ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0); - _mesa_update_framebuffer_visual(ctx->DrawBuffer); } @@ -1172,7 +1180,6 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */ if (error_check_framebuffer_texture(ctx, 3, target, attachment, textarget, texture, level)) @@ -1187,6 +1194,8 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (texture) { const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); texObj = (struct gl_texture_object *) @@ -1213,7 +1222,6 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, } ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, zoffset); - _mesa_update_framebuffer_visual(ctx->DrawBuffer); } @@ -1227,7 +1235,6 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); if (target != GL_FRAMEBUFFER_EXT) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1267,10 +1274,10 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, rb = NULL; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + assert(ctx->Driver.FramebufferRenderbuffer); ctx->Driver.FramebufferRenderbuffer(ctx, att, rb); - - _mesa_update_framebuffer_visual(ctx->DrawBuffer); } @@ -1302,6 +1309,8 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, return; } + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + switch (pname) { case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: *params = att->Type; @@ -1361,6 +1370,7 @@ _mesa_GenerateMipmapEXT(GLenum target) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); switch (target) { case GL_TEXTURE_1D: diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index f6322bf4d1c..479f7625684 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -328,23 +328,33 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx) void _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) { + GLuint i; + assert(fb->Name != 0); _mesa_bzero(&fb->Visual, sizeof(fb->Visual)); - fb->Visual.rgbMode = GL_TRUE; - - if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) { - fb->Visual.redBits - = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->RedBits; - fb->Visual.greenBits - = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->GreenBits; - fb->Visual.blueBits - = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->BlueBits; - fb->Visual.alphaBits - = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->AlphaBits; - fb->Visual.rgbBits - = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits; - fb->Visual.floatMode = GL_FALSE; + fb->Visual.rgbMode = GL_TRUE; /* assume this */ + + /* find first RGB or CI renderbuffer */ + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer) { + const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) { + fb->Visual.redBits = rb->RedBits; + fb->Visual.greenBits = rb->GreenBits; + fb->Visual.blueBits = rb->BlueBits; + fb->Visual.alphaBits = rb->AlphaBits; + fb->Visual.rgbBits = fb->Visual.redBits + + fb->Visual.greenBits + fb->Visual.blueBits; + fb->Visual.floatMode = GL_FALSE; + break; + } + else if (rb->_BaseFormat == GL_COLOR_INDEX) { + fb->Visual.indexBits = rb->IndexBits; + fb->Visual.rgbMode = GL_FALSE; + break; + } + } } if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { @@ -380,8 +390,10 @@ _mesa_update_framebuffer(GLcontext *ctx) GLuint output; /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) + if (fb->Name != 0) { _mesa_test_framebuffer_completeness(ctx, fb); + _mesa_update_framebuffer_visual(fb); + } /* * Update the list of color drawing renderbuffer pointers. diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 96ee29f6f5a..633d8e8617d 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -11,6 +11,7 @@ #include "get.h" #include "macros.h" #include "mtypes.h" +#include "state.h" #include "texcompress.h" @@ -85,6 +86,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) if (!params) return; + if (ctx->NewState) + _mesa_update_state(ctx); + if (ctx->Driver.GetBooleanv && ctx->Driver.GetBooleanv(ctx, pname, params)) return; @@ -1912,6 +1916,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) if (!params) return; + if (ctx->NewState) + _mesa_update_state(ctx); + if (ctx->Driver.GetFloatv && ctx->Driver.GetFloatv(ctx, pname, params)) return; @@ -3739,6 +3746,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) if (!params) return; + if (ctx->NewState) + _mesa_update_state(ctx); + if (ctx->Driver.GetIntegerv && ctx->Driver.GetIntegerv(ctx, pname, params)) return; diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index aff4a0c922c..a722ac23f71 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1025,6 +1025,9 @@ def EmitGetFunction(stateVars, returnType): print " if (!params)" print " return;" print "" + print " if (ctx->NewState)" + print " _mesa_update_state(ctx);" + print "" print " if (ctx->Driver.%s &&" % function print " ctx->Driver.%s(ctx, pname, params))" % function print " return;" @@ -1075,6 +1078,7 @@ def EmitHeader(): #include "get.h" #include "macros.h" #include "mtypes.h" +#include "state.h" #include "texcompress.h" |