glthread: initialize VAOs properly
authorMarek Olšák <marek.olsak@amd.com>
Sat, 21 Mar 2020 06:24:28 +0000 (02:24 -0400)
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/mesa/main/glthread.c
src/mesa/main/glthread.h
src/mesa/main/glthread_varray.c

index 8769f8b40336c2d1e4201831e5daba15f7acd09d..ac86081b679b869d1a945ba39fb79b76aae9f551 100644 (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);
index 2c6e59adac9c4208e2d56f058dba17205a2d2f42..f979e5931d4389bf5890326395495dc96b96f6d7 100644 (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);
index 2aa4a6d65fbc3124fd4084457a7ce4a6c7e545f0..ac83c7a93cd773c18a90327a8b21e68f28fe79a1 100644 (file)
  *   - 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);
    }
 }