mesa: Add support for the GL_UNIFORM_BUFFER general binding point.
authorEric Anholt <eric@anholt.net>
Mon, 18 Jun 2012 18:17:04 +0000 (11:17 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 21 Jun 2012 17:57:54 +0000 (10:57 -0700)
Fixes piglit ARB_uniform_buffer_object/buffer-targets.

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

index 332af3d36d77c78d7e36ef3593bf371165ac93fc..b646baa41a147c8913f318b6a28c03f8c74015e0 100644 (file)
@@ -92,6 +92,11 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
          return &ctx->Texture.BufferObject;
       }
       break;
+   case GL_UNIFORM_BUFFER:
+      if (ctx->Extensions.ARB_uniform_buffer_object) {
+         return &ctx->UniformBuffer;
+      }
+      break;
    default:
       return NULL;
    }
@@ -840,6 +845,10 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
             }
          }
 
+         if (ctx->UniformBuffer == bufObj) {
+            _mesa_BindBufferARB( GL_UNIFORM_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 );
index 4ac3689ae4affb012a669e7fe3651c2ad91fb7b9..9e9ddcbcc4339f60278f075a47d461ad5b15334b 100644 (file)
@@ -1351,6 +1351,8 @@ static const struct value_desc values[] = {
    { GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, CONTEXT_INT(Const.UniformBufferOffsetAlignment),
      extra_ARB_uniform_buffer_object },
 
+   { GL_UNIFORM_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_uniform_buffer_object },
+
 #endif /* FEATURE_GL */
 };
 
@@ -1801,6 +1803,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
          v->value_int = samp ? samp->Name : 0;
       }
       break;
+   /* GL_ARB_uniform_buffer_object */
+   case GL_UNIFORM_BUFFER_BINDING:
+      v->value_int = ctx->UniformBuffer->Name;
+      break;
    }   
 }
 
index 53e52807d95d0d3d5bd8a839f33c112cbfeba91b..cf6d9c16c05f9ddd255535d3b60cae51fd3e7c35 100644 (file)
@@ -3430,6 +3430,13 @@ struct gl_context
 
    struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
    struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
+
+   /**
+    * Current GL_ARB_uniform_buffer_object binding referenced by
+    * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
+    */
+   struct gl_buffer_object *UniformBuffer;
+
    /*@}*/
 
    struct gl_meta_state *Meta;  /**< for "meta" operations */