glthread: track which vertex array attribs are enabled
authorMarek Olšák <marek.olsak@amd.com>
Wed, 4 Mar 2020 19:49:09 +0000 (14:49 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 21 Mar 2020 03:01:13 +0000 (23:01 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4124>

src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mapi/glapi/gen/EXT_direct_state_access.xml
src/mapi/glapi/gen/gl_API.xml
src/mesa/main/glthread.h
src/mesa/main/glthread_marshal.h
src/mesa/main/glthread_varray.c

index ec7b13609a188b6f76787e4728c0961ab77c6fce..cd0f51c4327b46de7a729b418ab9a12136cb0af7 100644 (file)
       <param name="arrays" type="GLuint *" />
    </function>
 
-   <function name="DisableVertexArrayAttrib" no_error="true">
+   <function name="DisableVertexArrayAttrib" no_error="true"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, VERT_ATTRIB_GENERIC(index), false);">
       <param name="vaobj" type="GLuint" />
       <param name="index" type="GLuint" />
    </function>
 
-   <function name="EnableVertexArrayAttrib" no_error="true">
+   <function name="EnableVertexArrayAttrib" no_error="true"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, VERT_ATTRIB_GENERIC(index), true);">
       <param name="vaobj" type="GLuint" />
       <param name="index" type="GLuint" />
    </function>
index 397c75a37d0352e3f98df5e51ee7fbdd98358516..81310e343f41b80de0b207616592111942e4fcaf 100644 (file)
       <param name="params" type="GLint *" />
    </function>
 
-   <function name="EnableClientStateiEXT">
+   <function name="EnableClientStateiEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, VERT_ATTRIB_TEX(index), true);">
       <param name="array" type="GLenum" />
       <param name="index" type="GLuint" />
    </function>
 
-   <function name="DisableClientStateiEXT">
+   <function name="DisableClientStateiEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, VERT_ATTRIB_TEX(index), false);">
       <param name="array" type="GLenum" />
       <param name="index" type="GLuint" />
    </function>
       <param name="offset" type="GLintptr" />
    </function>
 
-   <function name="EnableVertexArrayEXT">
+   <function name="EnableVertexArrayEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, _mesa_array_to_attrib(ctx, array), true);">
       <param name="vaobj" type="GLuint" />
       <param name="array" type="GLenum" />
    </function>
 
-   <function name="DisableVertexArrayEXT">
+   <function name="DisableVertexArrayEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, _mesa_array_to_attrib(ctx, array), false);">
       <param name="vaobj" type="GLuint" />
       <param name="array" type="GLenum" />
    </function>
 
-   <function name="EnableVertexArrayAttribEXT">
+   <function name="EnableVertexArrayAttribEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, VERT_ATTRIB_GENERIC(index), true);">
       <param name="vaobj" type="GLuint" />
       <param name="index" type="GLuint" />
    </function>
 
-   <function name="DisableVertexArrayAttribEXT">
+   <function name="DisableVertexArrayAttribEXT"
+             marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, &amp;vaobj, VERT_ATTRIB_GENERIC(index), false);">
       <param name="vaobj" type="GLuint" />
       <param name="index" type="GLuint" />
    </function>
index e1ef626228194125a44c4c4f0d68e8a54f75b651..bd5e0f111108068142e2a2bdb0ed8649d137bc7e 100644 (file)
         <glx handcode="true"/>
     </function>
 
-    <function name="DisableClientState" es1="1.0" deprecated="3.1">
+    <function name="DisableClientState" es1="1.0" deprecated="3.1"
+              marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, _mesa_array_to_attrib(ctx, array), false);">
         <param name="array" type="GLenum"/>
         <glx handcode="true"/>
     </function>
         <glx handcode="true"/>
     </function>
 
-    <function name="EnableClientState" es1="1.0" deprecated="3.1">
+    <function name="EnableClientState" es1="1.0" deprecated="3.1"
+              marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, _mesa_array_to_attrib(ctx, array), true);">
         <param name="array" type="GLenum"/>
         <glx handcode="true"/>
     </function>
         <glx rop="197"/>
     </function>
 
-    <function name="ClientActiveTexture" es1="1.0" deprecated="3.1">
+    <function name="ClientActiveTexture" es1="1.0" deprecated="3.1"
+              marshal_call_after="ctx->GLThread.ClientActiveTexture = texture - GL_TEXTURE0;">
         <param name="texture" type="GLenum"/>
         <glx handcode="true"/>
     </function>
         <glx ignore="true"/>
     </function>
 
-    <function name="DisableVertexAttribArray" es2="2.0" no_error="true">
+    <function name="DisableVertexAttribArray" es2="2.0" no_error="true"
+              marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, VERT_ATTRIB_GENERIC(index), false);">
         <param name="index" type="GLuint"/>
         <glx ignore="true"/>
         <glx handcode="true"/>
     </function>
 
-    <function name="EnableVertexAttribArray" es2="2.0" no_error="true">
+    <function name="EnableVertexAttribArray" es2="2.0" no_error="true"
+              marshal_call_after="if (COMPAT) _mesa_glthread_ClientState(ctx, NULL, VERT_ATTRIB_GENERIC(index), true);">
         <param name="index" type="GLuint"/>
         <glx ignore="true"/>
         <glx handcode="true"/>
index 5491e1994c1f068e536bd6b2b0f05b29165c3abc..2dff33d9deb95f3523feb7837019abb4ccae3fdf 100644 (file)
@@ -47,6 +47,7 @@
 #include <stdbool.h>
 #include "util/u_queue.h"
 #include "GL/gl.h"
+#include "compiler/shader_enums.h"
 
 struct gl_context;
 struct _mesa_HashTable;
@@ -55,6 +56,7 @@ struct glthread_vao {
    GLuint Name;
    bool HasUserPointer;
    GLuint CurrentElementBufferName;
+   GLbitfield Enabled;
 };
 
 /** A single batch of commands queued up for execution. */
@@ -103,6 +105,7 @@ struct glthread_state
    struct glthread_vao *CurrentVAO;
    struct glthread_vao *LastLookedUpVAO;
    struct glthread_vao DefaultVAO;
+   int ClientActiveTexture;
 
    /** Currently-bound buffer object IDs. */
    GLuint CurrentArrayBufferName;
@@ -128,6 +131,8 @@ void _mesa_glthread_DeleteVertexArrays(struct gl_context *ctx,
                                        GLsizei n, const GLuint *ids);
 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_AttribPointer(struct gl_context *ctx);
 
 #endif /* _GLTHREAD_H*/
index 2e5001b1af7e06d4fe0bafecf26890d79c01c2c1..116d79f436673fb1aa6528a29fb9422102bd685f 100644 (file)
@@ -372,4 +372,33 @@ _mesa_semaphore_enum_to_count(GLenum pname)
    }
 }
 
+static inline gl_vert_attrib
+_mesa_array_to_attrib(struct gl_context *ctx, GLenum array)
+{
+   switch (array) {
+   case GL_VERTEX_ARRAY:
+      return VERT_ATTRIB_POS;
+   case GL_NORMAL_ARRAY:
+      return VERT_ATTRIB_NORMAL;
+   case GL_COLOR_ARRAY:
+      return VERT_ATTRIB_COLOR0;
+   case GL_INDEX_ARRAY:
+      return VERT_ATTRIB_COLOR_INDEX;
+   case GL_TEXTURE_COORD_ARRAY:
+      return VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture);
+   case GL_EDGE_FLAG_ARRAY:
+      return VERT_ATTRIB_EDGEFLAG;
+   case GL_FOG_COORDINATE_ARRAY:
+      return VERT_ATTRIB_FOG;
+   case GL_SECONDARY_COLOR_ARRAY:
+      return VERT_ATTRIB_COLOR1;
+   case GL_POINT_SIZE_ARRAY_OES:
+      return VERT_ATTRIB_POINT_SIZE;
+   default:
+      if (array >= GL_TEXTURE0 && array <= GL_TEXTURE7)
+         return VERT_ATTRIB_TEX(array - GL_TEXTURE0);
+      return VERT_ATTRIB_MAX;
+   }
+}
+
 #endif /* MARSHAL_H */
index 8049a9d2ff1f6a59d1b547eaa398f7a0742d5dc0..9e45aa287554be2201be067b3052747df92e4311 100644 (file)
@@ -133,6 +133,30 @@ _mesa_glthread_GenVertexArrays(struct gl_context *ctx,
    }
 }
 
+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;
+   }
+
+   if (enable)
+      vao->Enabled |= 1u << attrib;
+   else
+      vao->Enabled &= ~(1u << attrib);
+}
+
 void
 _mesa_glthread_AttribPointer(struct gl_context *ctx)
 {