Mesa (master): glthread: initialize VAOs properly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 30 22:24:58 UTC 2020


Module: Mesa
Branch: master
Commit: 09f94632e033805bee57a963ca15df131e7c7f7c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=09f94632e033805bee57a963ca15df131e7c7f7c

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sat Mar 21 02:24:28 2020 -0400

glthread: initialize VAOs properly

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>

---

 src/mesa/main/glthread.c        |  2 ++
 src/mesa/main/glthread.h        |  1 +
 src/mesa/main/glthread_varray.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 8769f8b4033..ac86081b679 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -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);
diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h
index 2c6e59adac9..f979e5931d4 100644
--- a/src/mesa/main/glthread.h
+++ b/src/mesa/main/glthread.h
@@ -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);
diff --git a/src/mesa/main/glthread_varray.c b/src/mesa/main/glthread_varray.c
index 2aa4a6d65fb..ac83c7a93cd 100644
--- a/src/mesa/main/glthread_varray.c
+++ b/src/mesa/main/glthread_varray.c
@@ -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);
    }
 }



More information about the mesa-commit mailing list