mesa: Unbind ARB_copy_buffer and transform feedback buffers on delete.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 4 Jun 2012 05:34:32 +0000 (22:34 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 5 Jun 2012 21:41:33 +0000 (14:41 -0700)
According to the GL 3.1 spec, section 2.9 ("Buffer Objects"):
"If a buffer object is deleted while it is bound, all bindings to that
 object in the current context (i.e. in the thread that called
 DeleteBuffers) are reset to zero."

The code already checked for a number of cases, but neglected these
newer binding points.

+21 oglconforms.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/bufferobj.c

index ae7bac14dbdb6b191bbbde8056b78d59af29f330..fe7db2a678bf7a655de00ff78b5b1a4d433ac200 100644 (file)
@@ -821,6 +821,19 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
             _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
          }
 
+         /* unbind ARB_copy_buffer binding points */
+         if (ctx->CopyReadBuffer == bufObj) {
+            _mesa_BindBufferARB( GL_COPY_READ_BUFFER, 0 );
+         }
+         if (ctx->CopyWriteBuffer == bufObj) {
+            _mesa_BindBufferARB( GL_COPY_WRITE_BUFFER, 0 );
+         }
+
+         /* unbind transform feedback binding point */
+         if (ctx->TransformFeedback.CurrentBuffer == bufObj) {
+            _mesa_BindBufferARB( GL_TRANSFORM_FEEDBACK_BUFFER, 0 );
+         }
+
          /* unbind any pixel pack/unpack pointers bound to this buffer */
          if (ctx->Pack.BufferObj == bufObj) {
             _mesa_BindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, 0 );