mesa: add _mesa_InternalBind{ElementBuffer,VertexBuffers} for glthread
authorMarek Olšák <marek.olsak@amd.com>
Sat, 7 Mar 2020 01:37:57 +0000 (20:37 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Apr 2020 22:01:55 +0000 (22:01 +0000)
Uploaded non-VBO user data will be set via these functions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>

src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/glthread.h
src/mesa/main/varray.c
src/mesa/main/varray.h

index 40118d261b933c40cb0b71e774f6b68e6c2ec3e1..db5fdaf6075e99cb617d08ccac42a3e616436883 100644 (file)
@@ -1228,6 +1228,19 @@ _mesa_BindBuffer(GLenum target, GLuint buffer)
    bind_buffer_object(ctx, bindTarget, buffer);
 }
 
+void
+_mesa_InternalBindElementBuffer(struct gl_context *ctx,
+                                struct gl_buffer_object *buf)
+{
+   struct gl_buffer_object **bindTarget =
+      get_buffer_target(ctx, GL_ELEMENT_ARRAY_BUFFER);
+
+   /* Move the buffer reference from the parameter to the bind point. */
+   _mesa_reference_buffer_object(ctx, bindTarget, NULL);
+   if (buf)
+      *bindTarget = buf;
+}
+
 /**
  * Binds a buffer object to a binding point.
  *
index 9a22d4de4406e690891c29d96f98b2f799d12a75..bcafd350e70a7f8d60e76a9cd5375243fba31608 100644 (file)
@@ -151,6 +151,10 @@ _mesa_BindBuffer_no_error(GLenum target, GLuint buffer);
 void GLAPIENTRY
 _mesa_BindBuffer(GLenum target, GLuint buffer);
 
+void
+_mesa_InternalBindElementBuffer(struct gl_context *ctx,
+                                struct gl_buffer_object *buf);
+
 void GLAPIENTRY
 _mesa_DeleteBuffers_no_error(GLsizei n, const GLuint * buffer);
 
index a50b2f87ceb4e3d97021e6b02386106591e1345e..32c7826a8f2b734c3a3e74915eb2fd3a91dbe1f1 100644 (file)
 struct gl_context;
 struct _mesa_HashTable;
 
+struct glthread_attrib_binding {
+   struct gl_buffer_object *buffer; /**< where non-VBO data was uploaded */
+   int offset;                      /**< offset to uploaded non-VBO data */
+   const void *original_pointer;    /**< restore this pointer after the draw */
+};
+
 struct glthread_vao {
    GLuint Name;
    GLuint CurrentElementBufferName;
index ff743f751c40c28aa637886360bb87eedb1ce60c..81068d00d0b91545bc03d655c1ce269a852813cd 100644 (file)
@@ -3259,6 +3259,39 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
 }
 
 
+void
+_mesa_InternalBindVertexBuffers(struct gl_context *ctx,
+                                const struct glthread_attrib_binding *attribs,
+                                GLbitfield attrib_mask,
+                                GLboolean restore_pointers)
+{
+   struct gl_vertex_array_object *vao = ctx->Array.VAO;
+   unsigned param_index = 0;
+
+   if (restore_pointers) {
+      while (attrib_mask) {
+         unsigned i = u_bit_scan(&attrib_mask);
+
+         _mesa_bind_vertex_buffer(ctx, vao, i, NULL,
+                                  (GLintptr)attribs[param_index].original_pointer,
+                                  vao->BufferBinding[i].Stride, false, false);
+         param_index++;
+      }
+      return;
+   }
+
+   while (attrib_mask) {
+      unsigned i = u_bit_scan(&attrib_mask);
+      struct gl_buffer_object *buf = attribs[param_index].buffer;
+
+      /* The buffer reference is passed to _mesa_bind_vertex_buffer. */
+      _mesa_bind_vertex_buffer(ctx, vao, i, buf, attribs[param_index].offset,
+                               vao->BufferBinding[i].Stride, true, true);
+      param_index++;
+   }
+}
+
+
 void GLAPIENTRY
 _mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj, GLuint first,
                                         GLsizei count, const GLuint *buffers,
index 0db3fa9083c0601b5acc494ef372b399166efbce..48c257993eb74799a59ea66b708fb5cf2d643445 100644 (file)
@@ -377,6 +377,12 @@ extern void GLAPIENTRY
 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
                         const GLintptr *offsets, const GLsizei *strides);
 
+void
+_mesa_InternalBindVertexBuffers(struct gl_context *ctx,
+                                const struct glthread_attrib_binding *attribs,
+                                GLbitfield attrib_mask,
+                                GLboolean restore_pointers);
+
 void GLAPIENTRY
 _mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj, GLuint first,
                                         GLsizei count, const GLuint *buffers,