mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 23:30:13 +01:00
glthread: handle gl{Push,Pop}ClientAttrib{DefaultEXT} for glthread states
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
This commit is contained in:
parent
57bf51a973
commit
1485a3ff7b
4 changed files with 113 additions and 4 deletions
|
|
@ -102,11 +102,13 @@
|
|||
|
||||
<!-- OpenGL 1.1 -->
|
||||
|
||||
<function name="ClientAttribDefaultEXT">
|
||||
<function name="ClientAttribDefaultEXT"
|
||||
marshal_call_after="if (COMPAT) _mesa_glthread_ClientAttribDefault(ctx, mask);">
|
||||
<param name="mask" type="GLbitfield" />
|
||||
</function>
|
||||
|
||||
<function name="PushClientAttribDefaultEXT">
|
||||
<function name="PushClientAttribDefaultEXT"
|
||||
marshal_call_after="if (COMPAT) _mesa_glthread_PushClientAttrib(ctx, mask, true);">
|
||||
<param name="mask" type="GLbitfield" />
|
||||
</function>
|
||||
|
||||
|
|
|
|||
|
|
@ -3388,11 +3388,13 @@
|
|||
<glx rop="194"/>
|
||||
</function>
|
||||
|
||||
<function name="PopClientAttrib" deprecated="3.1">
|
||||
<function name="PopClientAttrib" deprecated="3.1"
|
||||
marshal_call_after="if (COMPAT) _mesa_glthread_PopClientAttrib(ctx);">
|
||||
<glx handcode="true"/>
|
||||
</function>
|
||||
|
||||
<function name="PushClientAttrib" deprecated="3.1">
|
||||
<function name="PushClientAttrib" deprecated="3.1"
|
||||
marshal_call_after="if (COMPAT) _mesa_glthread_PushClientAttrib(ctx, mask, false);">
|
||||
<param name="mask" type="GLbitfield"/>
|
||||
<glx handcode="true"/>
|
||||
</function>
|
||||
|
|
|
|||
|
|
@ -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*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue