glthread: track instance divisor changes
authorMarek Olšák <marek.olsak@amd.com>
Thu, 5 Mar 2020 00:24:34 +0000 (19:24 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Apr 2020 22:01:55 +0000 (22:01 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>

src/mapi/glapi/gen/ARB_instanced_arrays.xml
src/mesa/main/glthread.h
src/mesa/main/glthread_varray.c

index 8ecf7951af81ee72f7a4b193320608d7dcf115e8..feeeeabeb1cd07cd9daf9fe7d32ebfc6b0f59b92 100644 (file)
 
   <enum name="VERTEX_ATTRIB_ARRAY_DIVISOR_ARB" value="0x88FE"/>
 
 
   <enum name="VERTEX_ATTRIB_ARRAY_DIVISOR_ARB" value="0x88FE"/>
 
-  <function name="VertexAttribDivisorARB" alias="VertexAttribDivisor">
+  <function name="VertexAttribDivisorARB" alias="VertexAttribDivisor"
+            marshal_call_after="if (COMPAT) _mesa_glthread_AttribDivisor(ctx, NULL, VERT_ATTRIB_GENERIC(index), divisor);">
     <param name="index" type="GLuint"/>
     <param name="divisor" type="GLuint"/>
   </function>
 
     <param name="index" type="GLuint"/>
     <param name="divisor" type="GLuint"/>
   </function>
 
-  <function name="VertexArrayVertexAttribDivisorEXT">
+  <function name="VertexArrayVertexAttribDivisorEXT"
+            marshal_call_after="if (COMPAT) _mesa_glthread_AttribDivisor(ctx, &amp;vaobj, VERT_ATTRIB_GENERIC(index), divisor);">
        <param name="vaobj" type="GLuint"/>
     <param name="index" type="GLuint"/>
     <param name="divisor" type="GLuint"/>
        <param name="vaobj" type="GLuint"/>
     <param name="index" type="GLuint"/>
     <param name="divisor" type="GLuint"/>
index c1117872dc8aab3ba653f70c40a79a711673467b..c13ca9e823695ce89ea666bbeeb0299d94b42947 100644 (file)
@@ -64,10 +64,12 @@ struct glthread_vao {
    GLuint CurrentElementBufferName;
    GLbitfield Enabled;
    GLbitfield UserPointerMask;
    GLuint CurrentElementBufferName;
    GLbitfield Enabled;
    GLbitfield UserPointerMask;
+   GLbitfield NonZeroDivisorMask;
 
    struct {
       GLuint ElementSize;
       GLsizei Stride;
 
    struct {
       GLuint ElementSize;
       GLsizei Stride;
+      GLuint Divisor;
       const void *Pointer;
    } Attrib[VERT_ATTRIB_MAX];
 };
       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);
                                     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);
 void _mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib,
                                   GLint size, GLenum type, GLsizei stride,
                                   const void *pointer);
index 53a973600a6fd1d4bda5df0be806c568c2dd4403..bcbd229320b2dd9bb448387d63eace56ca4e8793 100644 (file)
@@ -33,7 +33,6 @@
 #include "main/dispatch.h"
 
 /* TODO:
 #include "main/dispatch.h"
 
 /* TODO:
- *   - Handle GL_ARB_instanced_arrays (incl. EXT_dsa)
  *   - Handle ARB_vertex_attrib_binding (incl. EXT_dsa and ARB_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)
 {
 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 (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;
 
    if (enable)
       vao->Enabled |= 1u << attrib;
@@ -155,6 +157,24 @@ _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj,
       vao->Enabled &= ~(1u << attrib);
 }
 
       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,
 static void
 attrib_pointer(struct glthread_state *glthread, struct glthread_vao *vao,
                GLuint buffer, gl_vert_attrib attrib,