Fix some issues with state updates and renderbuffers. Querying GL_RED_BITS,
etc. after calling glRenderBufferStorageEXT gave undefined results.
This commit is contained in:
@@ -527,7 +527,6 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
|
||||||
|
|
||||||
if (target != GL_RENDERBUFFER_EXT) {
|
if (target != GL_RENDERBUFFER_EXT) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||||
@@ -535,6 +534,8 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
if (renderbuffer) {
|
if (renderbuffer) {
|
||||||
newRb = lookup_renderbuffer(ctx, renderbuffer);
|
newRb = lookup_renderbuffer(ctx, renderbuffer);
|
||||||
if (newRb == &DummyRenderbuffer) {
|
if (newRb == &DummyRenderbuffer) {
|
||||||
@@ -578,6 +579,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (renderbuffers[i] > 0) {
|
if (renderbuffers[i] > 0) {
|
||||||
@@ -700,7 +702,6 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
|
||||||
|
|
||||||
if (target != GL_RENDERBUFFER_EXT) {
|
if (target != GL_RENDERBUFFER_EXT) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glRenderbufferStorageEXT(target)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glRenderbufferStorageEXT(target)");
|
||||||
@@ -731,6 +732,8 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
/* Now allocate the storage */
|
/* Now allocate the storage */
|
||||||
ASSERT(rb->AllocStorage);
|
ASSERT(rb->AllocStorage);
|
||||||
if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
|
if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
|
||||||
@@ -776,6 +779,8 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_RENDERBUFFER_WIDTH_EXT:
|
case GL_RENDERBUFFER_WIDTH_EXT:
|
||||||
*params = ctx->CurrentRenderbuffer->Width;
|
*params = ctx->CurrentRenderbuffer->Width;
|
||||||
@@ -870,13 +875,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
|
||||||
|
|
||||||
if (target != GL_FRAMEBUFFER_EXT) {
|
if (target != GL_FRAMEBUFFER_EXT) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
if (framebuffer) {
|
if (framebuffer) {
|
||||||
/* Binding a user-created framebuffer object */
|
/* Binding a user-created framebuffer object */
|
||||||
newFb = lookup_framebuffer(ctx, framebuffer);
|
newFb = lookup_framebuffer(ctx, framebuffer);
|
||||||
@@ -927,6 +933,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (framebuffers[i] > 0) {
|
if (framebuffers[i] > 0) {
|
||||||
@@ -1008,6 +1015,8 @@ _mesa_CheckFramebufferStatusEXT(GLenum target)
|
|||||||
return GL_FRAMEBUFFER_COMPLETE_EXT;
|
return GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
_mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer);
|
_mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer);
|
||||||
return ctx->DrawBuffer->_Status;
|
return ctx->DrawBuffer->_Status;
|
||||||
}
|
}
|
||||||
@@ -1070,7 +1079,6 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
|
|
||||||
|
|
||||||
if (error_check_framebuffer_texture(ctx, 1, target, attachment,
|
if (error_check_framebuffer_texture(ctx, 1, target, attachment,
|
||||||
textarget, texture, level))
|
textarget, texture, level))
|
||||||
@@ -1085,6 +1093,8 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
if (texture) {
|
if (texture) {
|
||||||
texObj = (struct gl_texture_object *)
|
texObj = (struct gl_texture_object *)
|
||||||
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
|
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
|
||||||
@@ -1104,8 +1114,6 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
|
|||||||
texObj = NULL;
|
texObj = NULL;
|
||||||
}
|
}
|
||||||
ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
|
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);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
|
|
||||||
|
|
||||||
if (error_check_framebuffer_texture(ctx, 2, target, attachment,
|
if (error_check_framebuffer_texture(ctx, 2, target, attachment,
|
||||||
textarget, texture, level))
|
textarget, texture, level))
|
||||||
@@ -1135,6 +1142,8 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
if (texture) {
|
if (texture) {
|
||||||
texObj = (struct gl_texture_object *)
|
texObj = (struct gl_texture_object *)
|
||||||
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
|
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
|
||||||
@@ -1158,7 +1167,6 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
|
|||||||
texObj = NULL;
|
texObj = NULL;
|
||||||
}
|
}
|
||||||
ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
|
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);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
|
|
||||||
|
|
||||||
if (error_check_framebuffer_texture(ctx, 3, target, attachment,
|
if (error_check_framebuffer_texture(ctx, 3, target, attachment,
|
||||||
textarget, texture, level))
|
textarget, texture, level))
|
||||||
@@ -1187,6 +1194,8 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
if (texture) {
|
if (texture) {
|
||||||
const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
|
const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
|
||||||
texObj = (struct gl_texture_object *)
|
texObj = (struct gl_texture_object *)
|
||||||
@@ -1213,7 +1222,6 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
|
|||||||
}
|
}
|
||||||
ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget,
|
ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget,
|
||||||
level, zoffset);
|
level, zoffset);
|
||||||
_mesa_update_framebuffer_visual(ctx->DrawBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1227,7 +1235,6 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
|
||||||
|
|
||||||
if (target != GL_FRAMEBUFFER_EXT) {
|
if (target != GL_FRAMEBUFFER_EXT) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||||
@@ -1267,10 +1274,10 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
|
|||||||
rb = NULL;
|
rb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
assert(ctx->Driver.FramebufferRenderbuffer);
|
assert(ctx->Driver.FramebufferRenderbuffer);
|
||||||
ctx->Driver.FramebufferRenderbuffer(ctx, att, rb);
|
ctx->Driver.FramebufferRenderbuffer(ctx, att, rb);
|
||||||
|
|
||||||
_mesa_update_framebuffer_visual(ctx->DrawBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1302,6 +1309,8 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
|
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
|
||||||
*params = att->Type;
|
*params = att->Type;
|
||||||
@@ -1361,6 +1370,7 @@ _mesa_GenerateMipmapEXT(GLenum target)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
|
||||||
|
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_TEXTURE_1D:
|
case GL_TEXTURE_1D:
|
||||||
|
@@ -328,23 +328,33 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx)
|
|||||||
void
|
void
|
||||||
_mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
|
_mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
|
||||||
{
|
{
|
||||||
|
GLuint i;
|
||||||
|
|
||||||
assert(fb->Name != 0);
|
assert(fb->Name != 0);
|
||||||
|
|
||||||
_mesa_bzero(&fb->Visual, sizeof(fb->Visual));
|
_mesa_bzero(&fb->Visual, sizeof(fb->Visual));
|
||||||
fb->Visual.rgbMode = GL_TRUE;
|
fb->Visual.rgbMode = GL_TRUE; /* assume this */
|
||||||
|
|
||||||
if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
|
/* find first RGB or CI renderbuffer */
|
||||||
fb->Visual.redBits
|
for (i = 0; i < BUFFER_COUNT; i++) {
|
||||||
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->RedBits;
|
if (fb->Attachment[i].Renderbuffer) {
|
||||||
fb->Visual.greenBits
|
const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
|
||||||
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->GreenBits;
|
if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) {
|
||||||
fb->Visual.blueBits
|
fb->Visual.redBits = rb->RedBits;
|
||||||
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->BlueBits;
|
fb->Visual.greenBits = rb->GreenBits;
|
||||||
fb->Visual.alphaBits
|
fb->Visual.blueBits = rb->BlueBits;
|
||||||
= fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->AlphaBits;
|
fb->Visual.alphaBits = rb->AlphaBits;
|
||||||
fb->Visual.rgbBits
|
fb->Visual.rgbBits = fb->Visual.redBits
|
||||||
= fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits;
|
+ fb->Visual.greenBits + fb->Visual.blueBits;
|
||||||
fb->Visual.floatMode = GL_FALSE;
|
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) {
|
if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
|
||||||
@@ -380,8 +390,10 @@ _mesa_update_framebuffer(GLcontext *ctx)
|
|||||||
GLuint output;
|
GLuint output;
|
||||||
|
|
||||||
/* Completeness only matters for user-created framebuffers */
|
/* Completeness only matters for user-created framebuffers */
|
||||||
if (fb->Name != 0)
|
if (fb->Name != 0) {
|
||||||
_mesa_test_framebuffer_completeness(ctx, fb);
|
_mesa_test_framebuffer_completeness(ctx, fb);
|
||||||
|
_mesa_update_framebuffer_visual(fb);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the list of color drawing renderbuffer pointers.
|
* Update the list of color drawing renderbuffer pointers.
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include "get.h"
|
#include "get.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
|
#include "state.h"
|
||||||
#include "texcompress.h"
|
#include "texcompress.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -85,6 +86,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
|||||||
if (!params)
|
if (!params)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ctx->NewState)
|
||||||
|
_mesa_update_state(ctx);
|
||||||
|
|
||||||
if (ctx->Driver.GetBooleanv &&
|
if (ctx->Driver.GetBooleanv &&
|
||||||
ctx->Driver.GetBooleanv(ctx, pname, params))
|
ctx->Driver.GetBooleanv(ctx, pname, params))
|
||||||
return;
|
return;
|
||||||
@@ -1912,6 +1916,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
|||||||
if (!params)
|
if (!params)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ctx->NewState)
|
||||||
|
_mesa_update_state(ctx);
|
||||||
|
|
||||||
if (ctx->Driver.GetFloatv &&
|
if (ctx->Driver.GetFloatv &&
|
||||||
ctx->Driver.GetFloatv(ctx, pname, params))
|
ctx->Driver.GetFloatv(ctx, pname, params))
|
||||||
return;
|
return;
|
||||||
@@ -3739,6 +3746,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
|||||||
if (!params)
|
if (!params)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ctx->NewState)
|
||||||
|
_mesa_update_state(ctx);
|
||||||
|
|
||||||
if (ctx->Driver.GetIntegerv &&
|
if (ctx->Driver.GetIntegerv &&
|
||||||
ctx->Driver.GetIntegerv(ctx, pname, params))
|
ctx->Driver.GetIntegerv(ctx, pname, params))
|
||||||
return;
|
return;
|
||||||
|
@@ -1025,6 +1025,9 @@ def EmitGetFunction(stateVars, returnType):
|
|||||||
print " if (!params)"
|
print " if (!params)"
|
||||||
print " return;"
|
print " return;"
|
||||||
print ""
|
print ""
|
||||||
|
print " if (ctx->NewState)"
|
||||||
|
print " _mesa_update_state(ctx);"
|
||||||
|
print ""
|
||||||
print " if (ctx->Driver.%s &&" % function
|
print " if (ctx->Driver.%s &&" % function
|
||||||
print " ctx->Driver.%s(ctx, pname, params))" % function
|
print " ctx->Driver.%s(ctx, pname, params))" % function
|
||||||
print " return;"
|
print " return;"
|
||||||
@@ -1075,6 +1078,7 @@ def EmitHeader():
|
|||||||
#include "get.h"
|
#include "get.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
|
#include "state.h"
|
||||||
#include "texcompress.h"
|
#include "texcompress.h"
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user