On 09/29/2011 03:43 AM, Yuanhan Liu wrote:
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?

Buffer objects are reference counted so the glDeleteBuffersARB() call wouldn't really delete the buffer since it should be referenced by something saved by glPushClientAttrib().

Looking at attrib.c, we're fudging the reference counts but it's not handling the case of deleting the buffer object between glPushClientAttrib() and the Pop() because while we're decrementing the refcounts in Pop(), we're not freeing the arrays if the refcount hits zero.

I'm attaching the beginnings of a patch to do the reference counting properly. Maybe you can take this and do the rest?

I'm also attaching a simple piglit test. It passes with NVIDIA's driver but fails with Mesa.

-Brian

Attachment: attrib.c.patch
Description: application/pgp-keys

#include "piglit-util.h"

int piglit_width = 600, piglit_height = 200;
int piglit_window_mode = GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE;


enum piglit_result
piglit_display(void)
{
	GLuint bufname[2];
	GLint val1, val2;

	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();

	glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &val1);
	glGetIntegerv(GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, &val2);

	/*printf("val1 %d  val2 %d\n", val1, val2);*/

	if (val1 == 0 && val2 == 0)
		return PIGLIT_PASS;
	else
		return PIGLIT_FAIL;
}


void
piglit_init(int argc, char **argv)
{
	/* nop */
}
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to