From: Marek Olšák Date: Sat, 7 Mar 2020 00:00:03 +0000 (-0500) Subject: glthread: track primitive restart state X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47cf310a671b75b1552a7b5d8accc8baa8ecdefb;p=mesa.git glthread: track primitive restart state Part-of: --- diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index ced4e10f101..6c256922fe8 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -563,7 +563,8 @@ - + diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 74aeb2f1c31..2ee1c7f9eda 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -2372,13 +2372,14 @@ - + + marshal_call_after='if (cap == GL_PRIMITIVE_RESTART || cap == GL_PRIMITIVE_RESTART_FIXED_INDEX) { _mesa_glthread_set_prim_restart(ctx, cap, true); } else if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) { _mesa_glthread_disable(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)"); }'> diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index c13ca9e8236..2c6e59adac9 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -43,6 +43,9 @@ */ #define MARSHAL_MAX_BATCHES 8 +/* Special value for glEnableClientState(GL_PRIMITIVE_RESTART_NV). */ +#define VERT_ATTRIB_PRIMITIVE_RESTART_NV -1 + #include #include #include "util/u_queue.h" @@ -127,6 +130,13 @@ struct glthread_state /** Caps. */ GLboolean SupportsBufferUploads; + /** Primitive restart state. */ + bool PrimitiveRestart; + bool PrimitiveRestartFixedIndex; + bool _PrimitiveRestart; + GLuint RestartIndex; + GLuint _RestartIndex[4]; /**< Restart index for index_size = 1,2,4. */ + /** Vertex Array objects tracked by glthread independently of Mesa. */ struct _mesa_HashTable *VAOs; struct glthread_vao *CurrentVAO; @@ -162,6 +172,9 @@ 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_set_prim_restart(struct gl_context *ctx, GLenum cap, + bool value); +void _mesa_glthread_PrimitiveRestartIndex(struct gl_context *ctx, GLuint index); void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, gl_vert_attrib attrib, bool enable); void _mesa_glthread_AttribDivisor(struct gl_context *ctx, const GLuint *vaobj, diff --git a/src/mesa/main/glthread_marshal.h b/src/mesa/main/glthread_marshal.h index a519ff0c5cf..c8cf733f9ce 100644 --- a/src/mesa/main/glthread_marshal.h +++ b/src/mesa/main/glthread_marshal.h @@ -399,6 +399,8 @@ _mesa_array_to_attrib(struct gl_context *ctx, GLenum array) return VERT_ATTRIB_COLOR1; case GL_POINT_SIZE_ARRAY_OES: return VERT_ATTRIB_POINT_SIZE; + case GL_PRIMITIVE_RESTART_NV: + return VERT_ATTRIB_PRIMITIVE_RESTART_NV; default: if (array >= GL_TEXTURE0 && array <= GL_TEXTURE7) return VERT_ATTRIB_TEX(array - GL_TEXTURE0); diff --git a/src/mesa/main/glthread_varray.c b/src/mesa/main/glthread_varray.c index bcbd229320b..2aa4a6d65fb 100644 --- a/src/mesa/main/glthread_varray.c +++ b/src/mesa/main/glthread_varray.c @@ -31,6 +31,7 @@ #include "main/mtypes.h" #include "main/hash.h" #include "main/dispatch.h" +#include "main/varray.h" /* TODO: * - Handle ARB_vertex_attrib_binding (incl. EXT_dsa and ARB_dsa) @@ -140,10 +141,57 @@ get_vao(struct gl_context *ctx, const GLuint *vaobj) return ctx->GLThread.CurrentVAO; } +static void +update_primitive_restart(struct gl_context *ctx) +{ + struct glthread_state *glthread = &ctx->GLThread; + + glthread->_PrimitiveRestart = glthread->PrimitiveRestart || + glthread->PrimitiveRestartFixedIndex; + glthread->_RestartIndex[0] = + _mesa_get_prim_restart_index(glthread->PrimitiveRestartFixedIndex, + glthread->RestartIndex, 1); + glthread->_RestartIndex[1] = + _mesa_get_prim_restart_index(glthread->PrimitiveRestartFixedIndex, + glthread->RestartIndex, 2); + glthread->_RestartIndex[3] = + _mesa_get_prim_restart_index(glthread->PrimitiveRestartFixedIndex, + glthread->RestartIndex, 4); +} + +void +_mesa_glthread_set_prim_restart(struct gl_context *ctx, GLenum cap, bool value) +{ + switch (cap) { + case GL_PRIMITIVE_RESTART: + ctx->GLThread.PrimitiveRestart = value; + break; + case GL_PRIMITIVE_RESTART_FIXED_INDEX: + ctx->GLThread.PrimitiveRestartFixedIndex = value; + break; + } + + update_primitive_restart(ctx); +} + +void +_mesa_glthread_PrimitiveRestartIndex(struct gl_context *ctx, GLuint index) +{ + ctx->GLThread.RestartIndex = index; + update_primitive_restart(ctx); +} + void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj, gl_vert_attrib attrib, bool enable) { + /* The primitive restart client state uses a special value. */ + if (attrib == VERT_ATTRIB_PRIMITIVE_RESTART_NV) { + ctx->GLThread.PrimitiveRestart = enable; + update_primitive_restart(ctx); + return; + } + if (attrib >= VERT_ATTRIB_MAX) return;