mesa/varray: split update_array() into validate_array() and update_array()
[mesa.git] / src / mesa / main / bufferobj.c
index 43dfebf63e6d3698ef99649c7b31f79d75fe9b53..922c7d82fcbd31ee51f182c1e8c0657bb92b0cfb 100644 (file)
@@ -1119,20 +1119,6 @@ _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
 }
 
 
-void
-_mesa_begin_bufferobj_lookups(struct gl_context *ctx)
-{
-   _mesa_HashLockMutex(ctx->Shared->BufferObjects);
-}
-
-
-void
-_mesa_end_bufferobj_lookups(struct gl_context *ctx)
-{
-   _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
-}
-
-
 /**
  * Look up a buffer object for a multi-bind function.
  *
@@ -1147,7 +1133,8 @@ _mesa_end_bufferobj_lookups(struct gl_context *ctx)
  * returns NULL.
  *
  * This function assumes that the caller has already locked the
- * hash table mutex by calling _mesa_begin_bufferobj_lookups().
+ * hash table mutex by calling
+ * _mesa_HashLockMutex(ctx->Shared->BufferObjects).
  */
 struct gl_buffer_object *
 _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx,
@@ -1307,38 +1294,38 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
          }
 
          if (ctx->Array.ArrayBufferObj == bufObj) {
-            _mesa_BindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
+            bind_buffer_object(ctx, &ctx->Array.ArrayBufferObj, 0);
          }
          if (vao->IndexBufferObj == bufObj) {
-            _mesa_BindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
+            bind_buffer_object(ctx, &vao->IndexBufferObj, 0);
          }
 
          /* unbind ARB_draw_indirect binding point */
          if (ctx->DrawIndirectBuffer == bufObj) {
-            _mesa_BindBuffer( GL_DRAW_INDIRECT_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->DrawIndirectBuffer, 0);
          }
 
          /* unbind ARB_indirect_parameters binding point */
          if (ctx->ParameterBuffer == bufObj) {
-            _mesa_BindBuffer(GL_PARAMETER_BUFFER_ARB, 0);
+            bind_buffer_object(ctx, &ctx->ParameterBuffer, 0);
          }
 
          /* unbind ARB_compute_shader binding point */
          if (ctx->DispatchIndirectBuffer == bufObj) {
-            _mesa_BindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0);
+            bind_buffer_object(ctx, &ctx->DispatchIndirectBuffer, 0);
          }
 
          /* unbind ARB_copy_buffer binding points */
          if (ctx->CopyReadBuffer == bufObj) {
-            _mesa_BindBuffer( GL_COPY_READ_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->CopyReadBuffer, 0);
          }
          if (ctx->CopyWriteBuffer == bufObj) {
-            _mesa_BindBuffer( GL_COPY_WRITE_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->CopyWriteBuffer, 0);
          }
 
          /* unbind transform feedback binding points */
          if (ctx->TransformFeedback.CurrentBuffer == bufObj) {
-            _mesa_BindBuffer( GL_TRANSFORM_FEEDBACK_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, 0);
          }
          for (j = 0; j < MAX_FEEDBACK_BUFFERS; j++) {
             if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) {
@@ -1354,7 +1341,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
          }
 
          if (ctx->UniformBuffer == bufObj) {
-            _mesa_BindBuffer( GL_UNIFORM_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->UniformBuffer, 0);
          }
 
          /* unbind SSBO binding points */
@@ -1365,7 +1352,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
          }
 
          if (ctx->ShaderStorageBuffer == bufObj) {
-            _mesa_BindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
+            bind_buffer_object(ctx, &ctx->ShaderStorageBuffer, 0);
          }
 
          /* unbind Atomci Buffer binding points */
@@ -1376,28 +1363,28 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
          }
 
          if (ctx->AtomicBuffer == bufObj) {
-            _mesa_BindBuffer( GL_ATOMIC_COUNTER_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->AtomicBuffer, 0);
          }
 
          /* unbind any pixel pack/unpack pointers bound to this buffer */
          if (ctx->Pack.BufferObj == bufObj) {
-            _mesa_BindBuffer( GL_PIXEL_PACK_BUFFER_EXT, 0 );
+            bind_buffer_object(ctx, &ctx->Pack.BufferObj, 0);
          }
          if (ctx->Unpack.BufferObj == bufObj) {
-            _mesa_BindBuffer( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
+            bind_buffer_object(ctx, &ctx->Unpack.BufferObj, 0);
          }
 
          if (ctx->Texture.BufferObject == bufObj) {
-            _mesa_BindBuffer( GL_TEXTURE_BUFFER, 0 );
+            bind_buffer_object(ctx, &ctx->Texture.BufferObject, 0);
          }
 
          if (ctx->ExternalVirtualMemoryBuffer == bufObj) {
-            _mesa_BindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
+            bind_buffer_object(ctx, &ctx->ExternalVirtualMemoryBuffer, 0);
          }
 
          /* unbind query buffer binding point */
          if (ctx->QueryBuffer == bufObj) {
-            _mesa_BindBuffer(GL_QUERY_BUFFER, 0);
+            bind_buffer_object(ctx, &ctx->QueryBuffer, 0);
          }
 
          /* The ID is immediately freed for re-use */
@@ -3253,7 +3240,7 @@ bind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count,
     *       parameters are valid and no other error occurs."
     */
 
-   _mesa_begin_bufferobj_lookups(ctx);
+   _mesa_HashLockMutex(ctx->Shared->BufferObjects);
 
    for (i = 0; i < count; i++) {
       struct gl_uniform_buffer_binding *binding =
@@ -3313,7 +3300,7 @@ bind_uniform_buffers(struct gl_context *ctx, GLuint first, GLsizei count,
       }
    }
 
-   _mesa_end_bufferobj_lookups(ctx);
+   _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
 }
 
 static void
@@ -3365,7 +3352,7 @@ bind_shader_storage_buffers(struct gl_context *ctx, GLuint first,
     *       parameters are valid and no other error occurs."
     */
 
-   _mesa_begin_bufferobj_lookups(ctx);
+   _mesa_HashLockMutex(ctx->Shared->BufferObjects);
 
    for (i = 0; i < count; i++) {
       struct gl_shader_storage_buffer_binding *binding =
@@ -3425,7 +3412,7 @@ bind_shader_storage_buffers(struct gl_context *ctx, GLuint first,
       }
    }
 
-   _mesa_end_bufferobj_lookups(ctx);
+   _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
 }
 
 static bool
@@ -3544,7 +3531,7 @@ bind_xfb_buffers(struct gl_context *ctx,
     *       parameters are valid and no other error occurs."
     */
 
-   _mesa_begin_bufferobj_lookups(ctx);
+   _mesa_HashLockMutex(ctx->Shared->BufferObjects);
 
    for (i = 0; i < count; i++) {
       const GLuint index = first + i;
@@ -3610,7 +3597,7 @@ bind_xfb_buffers(struct gl_context *ctx,
                                               offset, size);
    }
 
-   _mesa_end_bufferobj_lookups(ctx);
+   _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
 }
 
 static bool
@@ -3707,7 +3694,7 @@ bind_atomic_buffers(struct gl_context *ctx,
     *       parameters are valid and no other error occurs."
     */
 
-   _mesa_begin_bufferobj_lookups(ctx);
+   _mesa_HashLockMutex(ctx->Shared->BufferObjects);
 
    for (i = 0; i < count; i++) {
       struct gl_atomic_buffer_binding *binding =
@@ -3760,7 +3747,7 @@ bind_atomic_buffers(struct gl_context *ctx,
          set_atomic_buffer_binding(ctx, binding, bufObj, offset, size);
    }
 
-   _mesa_end_bufferobj_lookups(ctx);
+   _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
 }
 
 void GLAPIENTRY