From c9c9f57b022ab47251c260825e81241fdad9b3ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 27 Feb 2020 21:58:35 -0500 Subject: [PATCH] glthread: track pointers and strides for Pointer & EXT_dsa attrib functions Part-of: --- src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml | 5 ++- src/mapi/glapi/gen/EXT_direct_state_access.xml | 35 ++++++++++------ src/mapi/glapi/gen/GL3x.xml | 2 +- src/mapi/glapi/gen/es_EXT.xml | 2 +- src/mapi/glapi/gen/gl_API.xml | 30 +++++++------- src/mesa/main/glthread.h | 15 ++++++- src/mesa/main/glthread_varray.c | 56 +++++++++++++++++++++----- 7 files changed, 102 insertions(+), 43 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml b/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml index fcbb167..9014494 100644 --- a/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml +++ b/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml @@ -52,7 +52,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_GENERIC(index), size, type, stride, pointer);"> @@ -66,7 +66,8 @@ - + diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml b/src/mapi/glapi/gen/EXT_direct_state_access.xml index 5c52573..d570f68 100644 --- a/src/mapi/glapi/gen/EXT_direct_state_access.xml +++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml @@ -658,7 +658,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_TEX(texunit - GL_TEXTURE0), size, type, stride, pointer);"> @@ -1055,7 +1055,8 @@ - + @@ -1064,7 +1065,8 @@ - + @@ -1073,14 +1075,16 @@ - + - + @@ -1088,7 +1092,8 @@ - + @@ -1096,7 +1101,8 @@ - + @@ -1105,7 +1111,8 @@ - + @@ -1115,7 +1122,8 @@ - + @@ -1123,7 +1131,8 @@ - + @@ -1132,7 +1141,8 @@ - + @@ -1143,7 +1153,8 @@ - + diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index 19875bc..ced4e10 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -258,7 +258,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_GENERIC(index), size, type, stride, pointer);"> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml index de3c14d..dd987b8 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -320,7 +320,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_POINT_SIZE, 1, type, stride, pointer);"> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 4477f58..74aeb2f 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -3166,7 +3166,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_COLOR0, size, type, stride, pointer);"> @@ -3199,7 +3199,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_EDGEFLAG, 1, GL_UNSIGNED_BYTE, stride, pointer);"> @@ -3219,7 +3219,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_COLOR_INDEX, 1, type, stride, pointer);"> @@ -3235,7 +3235,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_NORMAL, 3, type, stride, pointer);"> @@ -3244,7 +3244,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture), size, type, stride, pointer);"> @@ -3254,7 +3254,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_POS, size, type, stride, pointer);"> @@ -4751,7 +4751,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_FOG, 1, type, stride, pointer);"> @@ -4892,7 +4892,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_COLOR1, size, type, stride, pointer);"> @@ -5853,7 +5853,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_GENERIC(index), size, type, stride, pointer);"> @@ -9251,7 +9251,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_COLOR0, size, type, stride, pointer);"> @@ -9267,7 +9267,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_EDGEFLAG, 1, GL_UNSIGNED_BYTE, stride, pointer);"> @@ -9280,7 +9280,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_COLOR_INDEX, 1, type, stride, pointer);"> @@ -9289,7 +9289,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_NORMAL, 3, type, stride, pointer);"> @@ -9298,7 +9298,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture), size, type, stride, pointer);"> @@ -9308,7 +9308,7 @@ + marshal_call_after="if (COMPAT) _mesa_glthread_AttribPointer(ctx, VERT_ATTRIB_POS, size, type, stride, pointer);"> diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 64b82ac..c111787 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -64,6 +64,12 @@ struct glthread_vao { GLuint CurrentElementBufferName; GLbitfield Enabled; GLbitfield UserPointerMask; + + struct { + GLuint ElementSize; + GLsizei Stride; + const void *Pointer; + } Attrib[VERT_ATTRIB_MAX]; }; /** A single batch of commands queued up for execution. */ @@ -156,7 +162,12 @@ 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, - gl_vert_attrib attrib); +void _mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + const void *pointer); +void _mesa_glthread_DSAAttribPointer(struct gl_context *ctx, GLuint vao, + GLuint buffer, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + GLintptr offset); #endif /* _GLTHREAD_H*/ diff --git a/src/mesa/main/glthread_varray.c b/src/mesa/main/glthread_varray.c index fbd08f4..53a9736 100644 --- a/src/mesa/main/glthread_varray.c +++ b/src/mesa/main/glthread_varray.c @@ -27,16 +27,14 @@ */ #include "main/glthread.h" +#include "main/glformats.h" #include "main/mtypes.h" #include "main/hash.h" #include "main/dispatch.h" /* TODO: - * - Implement better tracking of user pointers - * - These can unbind user pointers: - * ARB_vertex_attrib_binding - * ARB_direct_state_access - * EXT_direct_state_access + * - Handle GL_ARB_instanced_arrays (incl. EXT_dsa) + * - Handle ARB_vertex_attrib_binding (incl. EXT_dsa and ARB_dsa) */ static struct glthread_vao * @@ -157,14 +155,52 @@ _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, vao->Enabled &= ~(1u << attrib); } -void -_mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib) +static void +attrib_pointer(struct glthread_state *glthread, struct glthread_vao *vao, + GLuint buffer, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + const void *pointer) { - struct glthread_state *glthread = &ctx->GLThread; - struct glthread_vao *vao = glthread->CurrentVAO; + if (attrib >= VERT_ATTRIB_MAX) + return; + + unsigned elem_size = _mesa_bytes_per_vertex_attrib(size, type); + + vao->Attrib[attrib].ElementSize = elem_size; + vao->Attrib[attrib].Stride = stride ? stride : elem_size; + vao->Attrib[attrib].Pointer = pointer; - if (glthread->CurrentArrayBufferName != 0) + if (buffer != 0) vao->UserPointerMask &= ~(1u << attrib); else vao->UserPointerMask |= 1u << attrib; } + +void +_mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + const void *pointer) +{ + struct glthread_state *glthread = &ctx->GLThread; + + attrib_pointer(glthread, glthread->CurrentVAO, + glthread->CurrentArrayBufferName, + attrib, size, type, stride, pointer); +} + +void +_mesa_glthread_DSAAttribPointer(struct gl_context *ctx, GLuint vaobj, + GLuint buffer, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + GLintptr offset) +{ + struct glthread_state *glthread = &ctx->GLThread; + struct glthread_vao *vao; + + vao = lookup_vao(ctx, vaobj); + if (!vao) + return; + + attrib_pointer(glthread, vao, buffer, attrib, size, type, stride, + (const void*)offset); +} -- 2.7.4