mesa: add _mesa_InternalBind{ElementBuffer,VertexBuffers} for glthread

Uploaded non-VBO user data will be set via these functions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
This commit is contained in:
Marek Olšák
2020-03-06 20:37:57 -05:00
committed by Marge Bot
parent a82889e537
commit 70847eb0a9
5 changed files with 62 additions and 0 deletions

View 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.
*

View 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);

View File

@@ -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;

View 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,

View 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,