diff options
author | Marek Olšák <[email protected]> | 2020-03-21 02:58:51 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-30 22:01:55 +0000 |
commit | 1485a3ff7b52eed21cdc199aaa76ee1692dfa3c8 (patch) | |
tree | 5675599da4be8ac8644a12d35bb130f55bb0e746 /src/mesa | |
parent | 57bf51a97357b0cce293659123a3353d1b726487 (diff) |
glthread: handle gl{Push,Pop}ClientAttrib{DefaultEXT} for glthread states
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/glthread.h | 19 | ||||
-rw-r--r-- | src/mesa/main/glthread_varray.c | 86 |
2 files changed, 105 insertions, 0 deletions
diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 35b5f1981be..db733723e15 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -51,6 +51,7 @@ #include "util/u_queue.h" #include "GL/gl.h" #include "compiler/shader_enums.h" +#include "main/config.h" struct gl_context; struct gl_buffer_object; @@ -99,6 +100,18 @@ struct glthread_batch uint8_t buffer[MARSHAL_MAX_CMD_SIZE]; }; +struct glthread_client_attrib { + struct glthread_vao VAO; + GLuint CurrentArrayBufferName; + int ClientActiveTexture; + GLuint RestartIndex; + bool PrimitiveRestart; + bool PrimitiveRestartFixedIndex; + + /** Whether this element of the client attrib stack contains saved state. */ + bool Valid; +}; + struct glthread_state { /** Multithreaded queue. */ @@ -143,6 +156,8 @@ struct glthread_state struct glthread_vao *CurrentVAO; struct glthread_vao *LastLookedUpVAO; struct glthread_vao DefaultVAO; + struct glthread_client_attrib ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + int ClientAttribStackTop; int ClientActiveTexture; /** Currently-bound buffer object IDs. */ @@ -188,5 +203,9 @@ void _mesa_glthread_DSAAttribPointer(struct gl_context *ctx, GLuint vao, GLuint buffer, gl_vert_attrib attrib, GLint size, GLenum type, GLsizei stride, GLintptr offset); +void _mesa_glthread_PushClientAttrib(struct gl_context *ctx, GLbitfield mask, + bool set_default); +void _mesa_glthread_PopClientAttrib(struct gl_context *ctx); +void _mesa_glthread_ClientAttribDefault(struct gl_context *ctx, GLbitfield mask); #endif /* _GLTHREAD_H*/ diff --git a/src/mesa/main/glthread_varray.c b/src/mesa/main/glthread_varray.c index ff333af0079..8fae4af3123 100644 --- a/src/mesa/main/glthread_varray.c +++ b/src/mesa/main/glthread_varray.c @@ -308,3 +308,89 @@ _mesa_glthread_DSAAttribPointer(struct gl_context *ctx, GLuint vaobj, attrib_pointer(glthread, vao, buffer, attrib, size, type, stride, (const void*)offset); } + +void +_mesa_glthread_PushClientAttrib(struct gl_context *ctx, GLbitfield mask, + bool set_default) +{ + struct glthread_state *glthread = &ctx->GLThread; + + if (glthread->ClientAttribStackTop >= MAX_CLIENT_ATTRIB_STACK_DEPTH) + return; + + struct glthread_client_attrib *top = + &glthread->ClientAttribStack[glthread->ClientAttribStackTop]; + + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + top->VAO = *glthread->CurrentVAO; + top->CurrentArrayBufferName = glthread->CurrentArrayBufferName; + top->ClientActiveTexture = glthread->ClientActiveTexture; + top->RestartIndex = glthread->RestartIndex; + top->PrimitiveRestart = glthread->PrimitiveRestart; + top->PrimitiveRestartFixedIndex = glthread->PrimitiveRestartFixedIndex; + top->Valid = true; + } else { + top->Valid = false; + } + + glthread->ClientAttribStackTop++; + + if (set_default) + _mesa_glthread_ClientAttribDefault(ctx, mask); +} + +void +_mesa_glthread_PopClientAttrib(struct gl_context *ctx) +{ + struct glthread_state *glthread = &ctx->GLThread; + + if (glthread->ClientAttribStackTop == 0) + return; + + glthread->ClientAttribStackTop--; + + struct glthread_client_attrib *top = + &glthread->ClientAttribStack[glthread->ClientAttribStackTop]; + + if (!top->Valid) + return; + + /* Popping a delete VAO is an error. */ + struct glthread_vao *vao = NULL; + if (top->VAO.Name) { + vao = lookup_vao(ctx, top->VAO.Name); + if (!vao) + return; + } + + /* Restore states. */ + glthread->CurrentArrayBufferName = top->CurrentArrayBufferName; + glthread->ClientActiveTexture = top->ClientActiveTexture; + glthread->RestartIndex = top->RestartIndex; + glthread->PrimitiveRestart = top->PrimitiveRestart; + glthread->PrimitiveRestartFixedIndex = top->PrimitiveRestartFixedIndex; + + if (!vao) + vao = &glthread->DefaultVAO; + + assert(top->VAO.Name == vao->Name); + *vao = top->VAO; /* Copy all fields. */ + glthread->CurrentVAO = vao; +} + +void +_mesa_glthread_ClientAttribDefault(struct gl_context *ctx, GLbitfield mask) +{ + struct glthread_state *glthread = &ctx->GLThread; + + if (!(mask & GL_CLIENT_VERTEX_ARRAY_BIT)) + return; + + glthread->CurrentArrayBufferName = 0; + glthread->ClientActiveTexture = 0; + glthread->RestartIndex = 0; + glthread->PrimitiveRestart = false; + glthread->PrimitiveRestartFixedIndex = false; + glthread->CurrentVAO = &glthread->DefaultVAO; + _mesa_glthread_reset_vao(glthread->CurrentVAO); +} |