glthread: initialize VAOs properly

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
This commit is contained in:
Marek Olšák 2020-03-21 02:24:28 -04:00 committed by Marge Bot
parent 47cf310a67
commit 09f94632e0
3 changed files with 33 additions and 0 deletions

View File

@ -89,6 +89,8 @@ _mesa_glthread_init(struct gl_context *ctx)
util_queue_destroy(&glthread->queue);
return;
}
_mesa_glthread_reset_vao(&glthread->DefaultVAO);
glthread->CurrentVAO = &glthread->DefaultVAO;
ctx->MarshalExec = _mesa_create_marshal_table(ctx);

View File

@ -161,6 +161,7 @@ void _mesa_glthread_upload(struct gl_context *ctx, const void *data,
GLsizeiptr size, unsigned *out_offset,
struct gl_buffer_object **out_buffer,
uint8_t **out_ptr);
void _mesa_glthread_reset_vao(struct glthread_vao *vao);
void _mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target,
GLuint buffer);

View File

@ -37,6 +37,35 @@
* - Handle ARB_vertex_attrib_binding (incl. EXT_dsa and ARB_dsa)
*/
void
_mesa_glthread_reset_vao(struct glthread_vao *vao)
{
static unsigned default_elem_size[VERT_ATTRIB_MAX] = {
[VERT_ATTRIB_NORMAL] = 12,
[VERT_ATTRIB_COLOR1] = 12,
[VERT_ATTRIB_FOG] = 4,
[VERT_ATTRIB_COLOR_INDEX] = 4,
[VERT_ATTRIB_EDGEFLAG] = 1,
[VERT_ATTRIB_POINT_SIZE] = 4,
};
vao->CurrentElementBufferName = 0;
vao->Enabled = 0;
vao->UserPointerMask = 0;
vao->NonZeroDivisorMask = 0;
for (unsigned i = 0; i < ARRAY_SIZE(vao->Attrib); i++) {
unsigned elem_size = default_elem_size[i];
if (!elem_size)
elem_size = 16;
vao->Attrib[i].ElementSize = elem_size;
vao->Attrib[i].Stride = elem_size;
vao->Attrib[i].Divisor = 0;
vao->Attrib[i].Pointer = NULL;
}
}
static struct glthread_vao *
lookup_vao(struct gl_context *ctx, GLuint id)
{
@ -127,6 +156,7 @@ _mesa_glthread_GenVertexArrays(struct gl_context *ctx,
continue; /* Is that all we can do? */
vao->Name = id;
_mesa_glthread_reset_vao(vao);
_mesa_HashInsertLocked(glthread->VAOs, id, vao);
}
}