mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 19:40:10 +01:00
mesa: only pop states in glPopAttrib that have been changed since glPushAttrib
PopAttribState records all state changes. glPopAttrib uses it to skip restoring state groups that haven't been changed. This eliminates a lot of glPopAttrib overhead. Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>
This commit is contained in:
parent
807c365c5e
commit
68030bbf73
2 changed files with 15 additions and 1 deletions
|
|
@ -87,7 +87,9 @@ _mesa_PushAttrib(GLbitfield mask)
|
||||||
}
|
}
|
||||||
ctx->AttribStack[ctx->AttribStackDepth] = head;
|
ctx->AttribStack[ctx->AttribStackDepth] = head;
|
||||||
}
|
}
|
||||||
|
|
||||||
head->Mask = mask;
|
head->Mask = mask;
|
||||||
|
head->OldPopAttribStateMask = ctx->PopAttribState;
|
||||||
|
|
||||||
if (mask & GL_ACCUM_BUFFER_BIT)
|
if (mask & GL_ACCUM_BUFFER_BIT)
|
||||||
memcpy(&head->Accum, &ctx->Accum, sizeof(head->Accum));
|
memcpy(&head->Accum, &ctx->Accum, sizeof(head->Accum));
|
||||||
|
|
@ -276,6 +278,7 @@ _mesa_PushAttrib(GLbitfield mask)
|
||||||
memcpy(&head->Multisample, &ctx->Multisample, sizeof(head->Multisample));
|
memcpy(&head->Multisample, &ctx->Multisample, sizeof(head->Multisample));
|
||||||
|
|
||||||
ctx->AttribStackDepth++;
|
ctx->AttribStackDepth++;
|
||||||
|
ctx->PopAttribState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -666,6 +669,15 @@ _mesa_PopAttrib(void)
|
||||||
|
|
||||||
unsigned mask = attr->Mask;
|
unsigned mask = attr->Mask;
|
||||||
|
|
||||||
|
/* Flush current attribs. This must be done before PopAttribState is
|
||||||
|
* applied.
|
||||||
|
*/
|
||||||
|
if (mask & GL_CURRENT_BIT)
|
||||||
|
FLUSH_CURRENT(ctx, 0);
|
||||||
|
|
||||||
|
/* Only restore states that have been changed since glPushAttrib. */
|
||||||
|
mask &= ctx->PopAttribState;
|
||||||
|
|
||||||
if (mask & GL_ACCUM_BUFFER_BIT) {
|
if (mask & GL_ACCUM_BUFFER_BIT) {
|
||||||
_mesa_ClearAccum(attr->Accum.ClearColor[0],
|
_mesa_ClearAccum(attr->Accum.ClearColor[0],
|
||||||
attr->Accum.ClearColor[1],
|
attr->Accum.ClearColor[1],
|
||||||
|
|
@ -805,7 +817,6 @@ _mesa_PopAttrib(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & GL_CURRENT_BIT) {
|
if (mask & GL_CURRENT_BIT) {
|
||||||
FLUSH_CURRENT(ctx, 0);
|
|
||||||
memcpy(&ctx->Current, &attr->Current,
|
memcpy(&ctx->Current, &attr->Current,
|
||||||
sizeof(struct gl_current_attrib));
|
sizeof(struct gl_current_attrib));
|
||||||
/* Set _NEW_LIGHT because current attribs may reference materials. */
|
/* Set _NEW_LIGHT because current attribs may reference materials. */
|
||||||
|
|
@ -1202,6 +1213,8 @@ _mesa_PopAttrib(void)
|
||||||
TEST_AND_CALL1(Multisample.SampleAlphaToCoverageDitherControl,
|
TEST_AND_CALL1(Multisample.SampleAlphaToCoverageDitherControl,
|
||||||
AlphaToCoverageDitherControlNV);
|
AlphaToCoverageDitherControlNV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->PopAttribState = attr->OldPopAttribStateMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5073,6 +5073,7 @@ struct gl_texture_attrib_node
|
||||||
struct gl_attrib_node
|
struct gl_attrib_node
|
||||||
{
|
{
|
||||||
GLbitfield Mask;
|
GLbitfield Mask;
|
||||||
|
GLbitfield OldPopAttribStateMask;
|
||||||
struct gl_accum_attrib Accum;
|
struct gl_accum_attrib Accum;
|
||||||
struct gl_colorbuffer_attrib Color;
|
struct gl_colorbuffer_attrib Color;
|
||||||
struct gl_current_attrib Current;
|
struct gl_current_attrib Current;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue