From b0b1907fa567d6142b0ba11ec972dfe3ef94e308 Mon Sep 17 00:00:00 2001 From: Sviatoslav Peleshko Date: Thu, 4 Jul 2024 11:44:30 +0300 Subject: [PATCH] mesa: Fix PopAttrib not restoring states that changed on deeper stack level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently on each pop we reset the PopAttribState to the value from the last push. But if we assume a sequence "push(X), push(Y), changeX(), pop(), pop()": the first pop will remove X from PopAttribState, so the second pop will not even try to restore X, leaving a wrong value forever. Fix this by "bubbling up" the changed states that were not restored by pop. Fixes: 68030bbf ("mesa: only pop states in glPopAttrib that have been changed since glPushAttrib") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11417 Signed-off-by: Sviatoslav Peleshko Reviewed-by: Lionel Landwerlin Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/attrib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 1c3057957f5..3d960f962d4 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1124,7 +1124,11 @@ _mesa_PopAttrib(void) AlphaToCoverageDitherControlNV); } - ctx->PopAttribState = attr->OldPopAttribStateMask; + /* Restore the previous PopAttribStateMask as well as any modified state + * that was not restored in the current pop. + */ + ctx->PopAttribState = attr->OldPopAttribStateMask | + (ctx->PopAttribState & ~attr->Mask); }