Mesa (master): mesa: only pop states in glPopAttrib that have been changed since glPushAttrib
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jan 30 21:52:58 UTC 2021
Module: Mesa
Branch: master
Commit: 68030bbf73c82a16f394fab807076d5c64258dcf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=68030bbf73c82a16f394fab807076d5c64258dcf
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sat Dec 19 02:46:03 2020 -0500
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 at gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8181>
---
src/mesa/main/attrib.c | 15 ++++++++++++++-
src/mesa/main/mtypes.h | 1 +
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 14c3fd9f5d0..583dc518d42 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -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;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index edd466f4ca8..fc596dba496 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
More information about the mesa-commit
mailing list