From 9037005d6034d6bcbeb508e0f783622e2351b957 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 4 Mar 2020 19:24:34 -0500 Subject: [PATCH] glthread: track instance divisor changes Part-of: --- src/mapi/glapi/gen/ARB_instanced_arrays.xml | 6 ++- src/mesa/main/glthread.h | 4 ++ src/mesa/main/glthread_varray.c | 42 +++++++++++++++------ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_instanced_arrays.xml b/src/mapi/glapi/gen/ARB_instanced_arrays.xml index 8ecf7951af8..feeeeabeb1c 100644 --- a/src/mapi/glapi/gen/ARB_instanced_arrays.xml +++ b/src/mapi/glapi/gen/ARB_instanced_arrays.xml @@ -10,12 +10,14 @@ - + - + diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index c1117872dc8..c13ca9e8236 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -64,10 +64,12 @@ struct glthread_vao { GLuint CurrentElementBufferName; GLbitfield Enabled; GLbitfield UserPointerMask; + GLbitfield NonZeroDivisorMask; struct { GLuint ElementSize; GLsizei Stride; + GLuint Divisor; const void *Pointer; } Attrib[VERT_ATTRIB_MAX]; }; @@ -162,6 +164,8 @@ void _mesa_glthread_GenVertexArrays(struct gl_context *ctx, GLsizei n, GLuint *arrays); void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, gl_vert_attrib attrib, bool enable); +void _mesa_glthread_AttribDivisor(struct gl_context *ctx, const GLuint *vaobj, + gl_vert_attrib attrib, GLuint divisor); void _mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib, GLint size, GLenum type, GLsizei stride, const void *pointer); diff --git a/src/mesa/main/glthread_varray.c b/src/mesa/main/glthread_varray.c index 53a973600a6..bcbd229320b 100644 --- a/src/mesa/main/glthread_varray.c +++ b/src/mesa/main/glthread_varray.c @@ -33,7 +33,6 @@ #include "main/dispatch.h" /* TODO: - * - Handle GL_ARB_instanced_arrays (incl. EXT_dsa) * - Handle ARB_vertex_attrib_binding (incl. EXT_dsa and ARB_dsa) */ @@ -131,23 +130,26 @@ _mesa_glthread_GenVertexArrays(struct gl_context *ctx, } } +/* If vaobj is NULL, use the currently-bound VAO. */ +static inline struct glthread_vao * +get_vao(struct gl_context *ctx, const GLuint *vaobj) +{ + if (vaobj) + return lookup_vao(ctx, *vaobj); + + return ctx->GLThread.CurrentVAO; +} + void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, gl_vert_attrib attrib, bool enable) { - struct glthread_state *glthread = &ctx->GLThread; - struct glthread_vao *vao; - if (attrib >= VERT_ATTRIB_MAX) return; - if (vaobj) { - vao = lookup_vao(ctx, *vaobj); - if (!vao) - return; - } else { - vao = glthread->CurrentVAO; - } + struct glthread_vao *vao = get_vao(ctx, vaobj); + if (!vao) + return; if (enable) vao->Enabled |= 1u << attrib; @@ -155,6 +157,24 @@ _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, vao->Enabled &= ~(1u << attrib); } +void _mesa_glthread_AttribDivisor(struct gl_context *ctx, const GLuint *vaobj, + gl_vert_attrib attrib, GLuint divisor) +{ + if (attrib >= VERT_ATTRIB_MAX) + return; + + struct glthread_vao *vao = get_vao(ctx, vaobj); + if (!vao) + return; + + vao->Attrib[attrib].Divisor = divisor; + + if (divisor) + vao->NonZeroDivisorMask |= 1u << attrib; + else + vao->NonZeroDivisorMask &= ~(1u << attrib); +} + static void attrib_pointer(struct glthread_state *glthread, struct glthread_vao *vao, GLuint buffer, gl_vert_attrib attrib, -- 2.30.2