[Mesa-dev] [RFC][PATCH] vbo: do not restore all the arrayobj stuff if the bufobj is deleted
Yuanhan Liu
yuanhan.liu at linux.intel.com
Thu Sep 29 02:43:51 PDT 2011
I hope I can find something from OpenGL spec to support this. Badly, I
didn't make it with a simply searching.
Basically, it's an issue that should we restore all the arrayobj stuff
if the bufobj is deleted? Say, in a following case:
glGenBuffersARB(2, bufname);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, bufname[1]);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, bufname[0]);
glVertexPointer(2, GL_INT, 0, NULL);
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
glDeleteBuffersARB(1, bufname); /* This would delete bufname[0] */
glPopClientAttrib();
Then what's the expected value of the following two queries:
glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &val1);
glGetIntegerv(GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, &val2);
The old code would make val1 and val2 both to be bufname[0]. Well, this
patch keep the val1 but let the val2 to be 0.
I know this patch is ugly, but I'd heard about your comments?
Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
src/mesa/main/attrib.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 2f391c5..d5559fd 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1461,6 +1461,8 @@ _mesa_PopClientAttrib(void)
case GL_CLIENT_VERTEX_ARRAY_BIT: {
struct gl_array_attrib * data =
(struct gl_array_attrib *) node->data;
+ int bufobj_deleted =
+ _mesa_lookup_bufferobj(ctx, data->ArrayBufferObj->Name) == NULL;
adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1);
@@ -1479,8 +1481,11 @@ _mesa_PopClientAttrib(void)
data->ElementArrayBufferObj->Name);
#endif
- memcpy( ctx->Array.ArrayObj, data->ArrayObj,
- sizeof( struct gl_array_object ) );
+ /* if the object is deleted, don't restore all the arrayobj stuff */
+ if (!bufobj_deleted) {
+ memcpy( ctx->Array.ArrayObj, data->ArrayObj,
+ sizeof( struct gl_array_object ) );
+ }
FREE( data->ArrayObj );
--
1.7.4.4
More information about the mesa-dev
mailing list