From: Marek Olšák Date: Sat, 7 Mar 2020 01:37:57 +0000 (-0500) Subject: mesa: add _mesa_InternalBind{ElementBuffer,VertexBuffers} for glthread X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=70847eb0a95f1e1b0fbd435aa0ef4091ae5bef88;p=mesa.git mesa: add _mesa_InternalBind{ElementBuffer,VertexBuffers} for glthread Uploaded non-VBO user data will be set via these functions. Part-of: --- diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 40118d261b9..db5fdaf6075 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -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. * diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 9a22d4de440..bcafd350e70 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -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); diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index a50b2f87ceb..32c7826a8f2 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -52,6 +52,12 @@ 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; diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index ff743f751c4..81068d00d0b 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -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, diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 0db3fa9083c..48c257993eb 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -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,