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:
Marek Olšák 2020-12-19 02:46:03 -05:00
parent 807c365c5e
commit 68030bbf73
2 changed files with 15 additions and 1 deletions

View file

@ -87,7 +87,9 @@ _mesa_PushAttrib(GLbitfield mask)
}
ctx->AttribStack[ctx->AttribStackDepth] = head;
}
head->Mask = mask;
head->OldPopAttribStateMask = ctx->PopAttribState;
if (mask & GL_ACCUM_BUFFER_BIT)
memcpy(&head->Accum, &ctx->Accum, sizeof(head->Accum));
@ -276,6 +278,7 @@ _mesa_PushAttrib(GLbitfield mask)
memcpy(&head->Multisample, &ctx->Multisample, sizeof(head->Multisample));
ctx->AttribStackDepth++;
ctx->PopAttribState = 0;
}
@ -666,6 +669,15 @@ _mesa_PopAttrib(void)
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) {
_mesa_ClearAccum(attr->Accum.ClearColor[0],
attr->Accum.ClearColor[1],
@ -805,7 +817,6 @@ _mesa_PopAttrib(void)
}
if (mask & GL_CURRENT_BIT) {
FLUSH_CURRENT(ctx, 0);
memcpy(&ctx->Current, &attr->Current,
sizeof(struct gl_current_attrib));
/* Set _NEW_LIGHT because current attribs may reference materials. */
@ -1202,6 +1213,8 @@ _mesa_PopAttrib(void)
TEST_AND_CALL1(Multisample.SampleAlphaToCoverageDitherControl,
AlphaToCoverageDitherControlNV);
}
ctx->PopAttribState = attr->OldPopAttribStateMask;
}

View file

@ -5073,6 +5073,7 @@ struct gl_texture_attrib_node
struct gl_attrib_node
{
GLbitfield Mask;
GLbitfield OldPopAttribStateMask;
struct gl_accum_attrib Accum;
struct gl_colorbuffer_attrib Color;
struct gl_current_attrib Current;