Mesa (master): mesa: optimize glPopAttrib(GL_VIEWPORT_BIT)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jan 30 21:52:58 UTC 2021


Module: Mesa
Branch: master
Commit: 6c0a8ddb6fbd07f8cc7783c734c3fa8b2e3ffe32
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c0a8ddb6fbd07f8cc7783c734c3fa8b2e3ffe32

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sat Dec 19 03:14:01 2020 -0500

mesa: optimize glPopAttrib(GL_VIEWPORT_BIT)

We can just copy the variables because they are already clamped
to ctx->Const limits.

Reviewed-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 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 7229b3f1a18..92dc1d3d1ac 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1140,9 +1140,18 @@ _mesa_PopAttrib(void)
 
       for (i = 0; i < ctx->Const.MaxViewports; i++) {
          const struct gl_viewport_attrib *vp = &attr->Viewport.ViewportArray[i];
-         _mesa_set_viewport(ctx, i, vp->X, vp->Y, vp->Width,
-                            vp->Height);
-         _mesa_set_depth_range(ctx, i, vp->Near, vp->Far);
+
+         if (memcmp(&ctx->ViewportArray[i].X, &vp->X, sizeof(float) * 6)) {
+            ctx->NewState |= _NEW_VIEWPORT;
+            ctx->NewDriverState |= ctx->DriverFlags.NewViewport;
+
+            memcpy(&ctx->ViewportArray[i].X, &vp->X, sizeof(float) * 6);
+
+            if (ctx->Driver.Viewport)
+               ctx->Driver.Viewport(ctx);
+            if (ctx->Driver.DepthRange)
+               ctx->Driver.DepthRange(ctx);
+         }
       }
 
       if (ctx->Extensions.NV_conservative_raster) {



More information about the mesa-commit mailing list