mesa: Fix PopAttrib not restoring states that changed on deeper stack level

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 <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30038>
This commit is contained in:
Sviatoslav Peleshko 2024-07-04 11:44:30 +03:00 committed by Marge Bot
parent e9f63df2f2
commit b0b1907fa5

View file

@ -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);
}