diff options
author | Marek Olšák <[email protected]> | 2020-03-06 19:00:03 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-30 22:01:55 +0000 |
commit | 47cf310a671b75b1552a7b5d8accc8baa8ecdefb (patch) | |
tree | a1dc75cd3f92372080e23d5d95d9e84d7da23a38 /src/mesa/main | |
parent | 9037005d6034d6bcbeb508e0f783622e2351b957 (diff) |
glthread: track primitive restart state
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/glthread.h | 13 | ||||
-rw-r--r-- | src/mesa/main/glthread_marshal.h | 2 | ||||
-rw-r--r-- | src/mesa/main/glthread_varray.c | 48 |
3 files changed, 63 insertions, 0 deletions
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 <inttypes.h> #include <stdbool.h> #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; |