glthread: fix interpreting vertex size == GL_BGRA for vertex attribs
authorMarek Olšák <marek.olsak@amd.com>
Wed, 27 Jan 2021 23:40:16 +0000 (18:40 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 02:28:42 +0000 (02:28 +0000)
Fixes: c9c9f57b022 - glthread: track pointers and strides for Pointer & EXT_dsa attrib functions
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4116

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8753>

src/mesa/main/glthread_varray.c

index 4250cf0..f4f2bde 100644 (file)
@@ -332,6 +332,15 @@ void _mesa_glthread_AttribDivisor(struct gl_context *ctx, const GLuint *vaobj,
       vao->NonZeroDivisorMask &= ~(1u << attrib);
 }
 
+static unsigned
+element_size(GLint size, GLenum type)
+{
+   if (size == GL_BGRA)
+      size = 4;
+
+   return _mesa_bytes_per_vertex_attrib(size, type);
+}
+
 static void
 attrib_pointer(struct glthread_state *glthread, struct glthread_vao *vao,
                GLuint buffer, gl_vert_attrib attrib,
@@ -341,7 +350,7 @@ attrib_pointer(struct glthread_state *glthread, struct glthread_vao *vao,
    if (attrib >= VERT_ATTRIB_MAX)
       return;
 
-   unsigned elem_size = _mesa_bytes_per_vertex_attrib(size, type);
+   unsigned elem_size = element_size(size, type);
 
    vao->Attrib[attrib].ElementSize = elem_size;
    vao->Attrib[attrib].Stride = stride ? stride : elem_size;
@@ -393,7 +402,7 @@ attrib_format(struct glthread_state *glthread, struct glthread_vao *vao,
    if (attribindex >= VERT_ATTRIB_GENERIC_MAX)
       return;
 
-   unsigned elem_size = _mesa_bytes_per_vertex_attrib(size, type);
+   unsigned elem_size = element_size(size, type);
 
    unsigned i = VERT_ATTRIB_GENERIC(attribindex);
    vao->Attrib[i].ElementSize = elem_size;