From af1e9403e732651fe2cedde230ac7010f2f1a649 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 10:53:34 -0700 Subject: mesa: remove redundant _MaxElement computation Eric added some new code to check if offset < obj_size before computing _MaxElement but my original code was still present afterward and it clobbered the _MaxElement value. Not sure if this came from a bad merge or what. --- src/mesa/main/state.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 904ad01205..5e07d1d2f1 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -82,12 +82,6 @@ compute_max_element(struct gl_client_array *array) } else { array->_MaxElement = 0; } - /* Compute the max element we can access in the VBO without going - * out of bounds. - */ - array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size - - (GLsizeiptrARB) array->Ptr + array->StrideB - - array->_ElementSize) / array->StrideB; } else { /* user-space array, no idea how big it is */ -- cgit v1.2.3 From 645e297a0019eb2f7513bd801ffdaac03187f29f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 12:47:51 -0700 Subject: vbo: clamp DrawElements start/end to max possible values Some apps are sloppy with their start/end values. Clamp them to max possible values to prevent problems later. --- src/mesa/vbo/vbo_exec_array.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 2c82f7c9c5..f455382592 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -688,6 +688,16 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, * or we can read/write out of memory in several different places! */ + /* Catch/fix some potential user errors */ + if (type == GL_UNSIGNED_BYTE) { + start = MIN2(start, 0xff); + end = MIN2(end, 0xff); + } + else if (type == GL_UNSIGNED_SHORT) { + start = MIN2(start, 0xffff); + end = MIN2(end, 0xffff); + } + if (end >= ctx->Array.ArrayObj->_MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ warnCount++; -- cgit v1.2.3 From cbecb8fc8e85cfafed7fd8fd0e2dd1143efcf62b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 12:49:44 -0700 Subject: vbo: if 'end' is out of bounds, clamp it If we determine that the 'end' parameter to glDrawElements() is out of bounds, clamp it to the max legal index value. --- src/mesa/vbo/vbo_exec_array.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index f455382592..bd2fccdba1 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -748,6 +748,10 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, */ } #endif + + /* Set 'end' to the max possible legal value */ + assert(ctx->Array.ArrayObj->_MaxElement >= 1); + end = ctx->Array.ArrayObj->_MaxElement - 1; } else if (0) { _mesa_printf("glDraw[Range]Elements{,BaseVertex}" -- cgit v1.2.3 From 68ca19afd7299fa9c686f95d53b7e14df37aba4c Mon Sep 17 00:00:00 2001 From: Erik Wien Date: Tue, 26 Jan 2010 13:19:30 -0700 Subject: mesa: Don't bind DRAW/READ_FRAMEBUFFER separately without FBO blit support If GL_EXT_framebuffer_blit was not supported _mesa_DeleteFramebuffersEXT would raise an error when deleting the currently bound framebuffer. This because it tried to bind the default DRAW- and READ_FRAMEBUFFER separately. This patch binds the default FRAMEBUFFER instead in that case. Encountered in the fbo/fbo-copyteximage piglit test on R600. Patch cleaned up a bit by Brian Paul. --- src/mesa/main/fbobject.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 56e806559f..0e83a4e87f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1350,15 +1350,26 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); /* check if deleting currently bound framebuffer object */ - if (fb == ctx->DrawBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + if (ctx->Extensions.EXT_framebuffer_blit) { + /* separate draw/read binding points */ + if (fb == ctx->DrawBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + } + if (fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + } } - if (fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + else { + /* only one binding point for read/draw buffers */ + if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } } /* remove from hash table immediately, to free the ID */ -- cgit v1.2.3