glthread: track all matrix stack depths
This just tracks matrix stack depths in MatrixStackDepth and everything else here is needed to make it correct. Matrix stack depths will be returned by glGetIntegerv without synchronizing. Display lists will be handled by a separate commit. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8297>
This commit is contained in:
@@ -93,10 +93,12 @@
|
||||
<param name="n" type="GLdouble" />
|
||||
<param name="f" type="GLdouble" />
|
||||
</function>
|
||||
<function name="MatrixPushEXT" offset="assign">
|
||||
<function name="MatrixPushEXT" offset="assign"
|
||||
marshal_call_after="_mesa_glthread_MatrixPushEXT(ctx, matrixMode);">
|
||||
<param name="matrixMode" type="GLenum" />
|
||||
</function>
|
||||
<function name="MatrixPopEXT" offset="assign">
|
||||
<function name="MatrixPopEXT" offset="assign"
|
||||
marshal_call_after="_mesa_glthread_MatrixPopEXT(ctx, matrixMode);">
|
||||
<param name="matrixMode" type="GLenum" />
|
||||
</function>
|
||||
|
||||
|
@@ -2402,11 +2402,13 @@
|
||||
<glx sop="142" handcode="true"/>
|
||||
</function>
|
||||
|
||||
<function name="PopAttrib" deprecated="3.1">
|
||||
<function name="PopAttrib" deprecated="3.1"
|
||||
marshal_call_after="_mesa_glthread_PopAttrib(ctx);">
|
||||
<glx rop="141"/>
|
||||
</function>
|
||||
|
||||
<function name="PushAttrib" deprecated="3.1">
|
||||
<function name="PushAttrib" deprecated="3.1"
|
||||
marshal_call_after="_mesa_glthread_PushAttrib(ctx, mask);">
|
||||
<param name="mask" type="GLbitfield"/>
|
||||
<glx rop="142"/>
|
||||
</function>
|
||||
@@ -2910,7 +2912,8 @@
|
||||
<glx rop="178"/>
|
||||
</function>
|
||||
|
||||
<function name="MatrixMode" es1="1.0" deprecated="3.1">
|
||||
<function name="MatrixMode" es1="1.0" deprecated="3.1"
|
||||
marshal_call_after="_mesa_glthread_MatrixMode(ctx, mode);">
|
||||
<param name="mode" type="GLenum"/>
|
||||
<glx rop="179"/>
|
||||
</function>
|
||||
@@ -2935,11 +2938,13 @@
|
||||
<glx rop="182"/>
|
||||
</function>
|
||||
|
||||
<function name="PopMatrix" es1="1.0" deprecated="3.1">
|
||||
<function name="PopMatrix" es1="1.0" deprecated="3.1"
|
||||
marshal_call_after="_mesa_glthread_PopMatrix(ctx);">
|
||||
<glx rop="183"/>
|
||||
</function>
|
||||
|
||||
<function name="PushMatrix" es1="1.0" deprecated="3.1">
|
||||
<function name="PushMatrix" es1="1.0" deprecated="3.1"
|
||||
marshal_call_after="_mesa_glthread_PushMatrix(ctx);">
|
||||
<glx rop="184"/>
|
||||
</function>
|
||||
|
||||
@@ -4292,7 +4297,8 @@
|
||||
<enum name="DOT3_RGB" value="0x86AE"/>
|
||||
<enum name="DOT3_RGBA" value="0x86AF"/>
|
||||
|
||||
<function name="ActiveTexture" es1="1.0" es2="2.0" no_error="true">
|
||||
<function name="ActiveTexture" es1="1.0" es2="2.0" no_error="true"
|
||||
marshal_call_after="ctx->GLThread.ActiveTexture = texture - GL_TEXTURE0; if (ctx->GLThread.MatrixMode == GL_TEXTURE) ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, texture);">
|
||||
<param name="texture" type="GLenum"/>
|
||||
<glx rop="197"/>
|
||||
</function>
|
||||
|
@@ -124,6 +124,24 @@ struct glthread_client_attrib {
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
/* For glPushAttrib / glPopAttrib. */
|
||||
struct glthread_attrib_node {
|
||||
GLbitfield Mask;
|
||||
int ActiveTexture;
|
||||
GLenum MatrixMode;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
M_MODELVIEW,
|
||||
M_PROJECTION,
|
||||
M_PROGRAM0,
|
||||
M_PROGRAM_LAST = M_PROGRAM0 + MAX_PROGRAM_MATRICES - 1,
|
||||
M_TEXTURE0,
|
||||
M_TEXTURE_LAST = M_TEXTURE0 + MAX_TEXTURE_UNITS - 1,
|
||||
M_DUMMY, /* used instead of reporting errors */
|
||||
M_NUM_MATRIX_STACKS,
|
||||
} gl_matrix_index;
|
||||
|
||||
struct glthread_state
|
||||
{
|
||||
/** Multithreaded queue. */
|
||||
@@ -191,6 +209,14 @@ struct glthread_state
|
||||
* glDeleteProgram or -1 if there is no such enqueued call.
|
||||
*/
|
||||
int LastProgramChangeBatch;
|
||||
|
||||
/** Basic matrix state tracking. */
|
||||
int ActiveTexture;
|
||||
GLenum MatrixMode;
|
||||
gl_matrix_index MatrixIndex;
|
||||
struct glthread_attrib_node AttribStack[MAX_ATTRIB_STACK_DEPTH];
|
||||
int AttribStackDepth;
|
||||
int MatrixStackDepth[M_NUM_MATRIX_STACKS];
|
||||
};
|
||||
|
||||
void _mesa_glthread_init(struct gl_context *ctx);
|
||||
|
0
src/mesa/main/glthread_get.c
Normal file
0
src/mesa/main/glthread_get.c
Normal file
@@ -405,4 +405,92 @@ _mesa_array_to_attrib(struct gl_context *ctx, GLenum array)
|
||||
}
|
||||
}
|
||||
|
||||
static inline gl_matrix_index
|
||||
_mesa_get_matrix_index(struct gl_context *ctx, GLenum mode)
|
||||
{
|
||||
if (mode == GL_MODELVIEW || mode == GL_PROJECTION)
|
||||
return M_MODELVIEW + (mode - GL_MODELVIEW);
|
||||
|
||||
if (mode == GL_TEXTURE)
|
||||
return M_TEXTURE0 + ctx->GLThread.ActiveTexture;
|
||||
|
||||
if (mode >= GL_TEXTURE0 && mode <= GL_TEXTURE0 + MAX_TEXTURE_UNITS - 1)
|
||||
return M_TEXTURE0 + (mode - GL_TEXTURE0);
|
||||
|
||||
if (mode >= GL_MATRIX0_ARB && mode <= GL_MATRIX0_ARB + MAX_PROGRAM_MATRICES - 1)
|
||||
return M_PROGRAM0 + (mode - GL_MATRIX0_ARB);
|
||||
|
||||
return M_DUMMY;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_PushAttrib(struct gl_context *ctx, GLbitfield mask)
|
||||
{
|
||||
struct glthread_attrib_node *attr =
|
||||
&ctx->GLThread.AttribStack[ctx->GLThread.AttribStackDepth++];
|
||||
|
||||
attr->Mask = mask;
|
||||
|
||||
if (mask & GL_TEXTURE_BIT)
|
||||
attr->ActiveTexture = ctx->GLThread.ActiveTexture;
|
||||
|
||||
if (mask & GL_TRANSFORM_BIT)
|
||||
attr->MatrixMode = ctx->GLThread.MatrixMode;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_PopAttrib(struct gl_context *ctx)
|
||||
{
|
||||
struct glthread_attrib_node *attr =
|
||||
&ctx->GLThread.AttribStack[--ctx->GLThread.AttribStackDepth];
|
||||
unsigned mask = attr->Mask;
|
||||
|
||||
if (mask & GL_TEXTURE_BIT)
|
||||
ctx->GLThread.ActiveTexture = attr->ActiveTexture;
|
||||
|
||||
if (mask & GL_TRANSFORM_BIT) {
|
||||
ctx->GLThread.MatrixMode = attr->MatrixMode;
|
||||
ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, attr->MatrixMode);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_MatrixPushEXT(struct gl_context *ctx, GLenum matrixMode)
|
||||
{
|
||||
ctx->GLThread.MatrixStackDepth[_mesa_get_matrix_index(ctx, matrixMode)]++;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_MatrixPopEXT(struct gl_context *ctx, GLenum matrixMode)
|
||||
{
|
||||
ctx->GLThread.MatrixStackDepth[_mesa_get_matrix_index(ctx, matrixMode)]--;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_ActiveTexture(struct gl_context *ctx, GLenum texture)
|
||||
{
|
||||
ctx->GLThread.ActiveTexture = texture - GL_TEXTURE0;
|
||||
if (ctx->GLThread.MatrixMode == GL_TEXTURE)
|
||||
ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, texture);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_PushMatrix(struct gl_context *ctx)
|
||||
{
|
||||
ctx->GLThread.MatrixStackDepth[ctx->GLThread.MatrixIndex]++;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_PopMatrix(struct gl_context *ctx)
|
||||
{
|
||||
ctx->GLThread.MatrixStackDepth[ctx->GLThread.MatrixIndex]--;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_mesa_glthread_MatrixMode(struct gl_context *ctx, GLenum mode)
|
||||
{
|
||||
ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, mode);
|
||||
ctx->GLThread.MatrixMode = mode;
|
||||
}
|
||||
|
||||
#endif /* MARSHAL_H */
|
||||
|
Reference in New Issue
Block a user