Mesa (main): mesa/st: fixup viewport drawable invalidation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 24 21:35:11 UTC 2022


Module: Mesa
Branch: main
Commit: 5f675630d9662292442ff173197d2131a11b3953
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f675630d9662292442ff173197d2131a11b3953

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Dec 21 16:15:50 2021 +1000

mesa/st: fixup viewport drawable invalidation

This moves the code into more appropriate places

Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>

---

 src/mesa/main/attrib.c                  |  5 +--
 src/mesa/main/viewport.c                | 11 +++---
 src/mesa/meson.build                    |  2 --
 src/mesa/state_tracker/st_cb_viewport.c | 60 ---------------------------------
 src/mesa/state_tracker/st_cb_viewport.h | 33 ------------------
 src/mesa/state_tracker/st_manager.c     | 37 ++++++++++++++++++++
 src/mesa/state_tracker/st_manager.h     | 17 +---------
 7 files changed, 48 insertions(+), 117 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 371c0796dc4..667b890913f 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -61,7 +61,7 @@
 #include "api_exec_decl.h"
 
 #include "state_tracker/st_cb_texture.h"
-#include "state_tracker/st_cb_viewport.h"
+#include "state_tracker/st_manager.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_sampler_view.h"
 
@@ -1093,7 +1093,8 @@ _mesa_PopAttrib(void)
 
             memcpy(&ctx->ViewportArray[i].X, &vp->X, sizeof(float) * 6);
 
-            st_viewport(ctx);
+            if (st_context(ctx)->invalidate_on_gl_viewport)
+               st_manager_invalidate_drawables(ctx);
          }
       }
 
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 698d18b6295..da4d87315b7 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -36,7 +36,7 @@
 #include "viewport.h"
 #include "api_exec_decl.h"
 
-#include "state_tracker/st_cb_viewport.h"
+#include "state_tracker/st_manager.h"
 #include "state_tracker/st_context.h"
 
 static void
@@ -116,7 +116,8 @@ viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width,
    for (unsigned i = 0; i < ctx->Const.MaxViewports; i++)
       set_viewport_no_notify(ctx, i, input.X, input.Y, input.Width, input.Height);
 
-   st_viewport(ctx);
+   if (st_context(ctx)->invalidate_on_gl_viewport)
+      st_manager_invalidate_drawables(ctx);
 }
 
 /**
@@ -168,7 +169,8 @@ _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y,
    clamp_viewport(ctx, &x, &y, &width, &height);
    set_viewport_no_notify(ctx, idx, x, y, width, height);
 
-   st_viewport(ctx);
+   if (st_context(ctx)->invalidate_on_gl_viewport)
+      st_manager_invalidate_drawables(ctx);
 }
 
 static void
@@ -183,7 +185,8 @@ viewport_array(struct gl_context *ctx, GLuint first, GLsizei count,
                              inputs[i].Width, inputs[i].Height);
    }
 
-   st_viewport(ctx);
+   if (st_context(ctx)->invalidate_on_gl_viewport)
+      st_manager_invalidate_drawables(ctx);
 }
 
 void GLAPIENTRY
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index 3b7fb989d20..c6827e9ef25 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -350,8 +350,6 @@ files_libmesa = files(
   'state_tracker/st_cb_readpixels.h',
   'state_tracker/st_cb_texture.c',
   'state_tracker/st_cb_texture.h',
-  'state_tracker/st_cb_viewport.c',
-  'state_tracker/st_cb_viewport.h',
   'state_tracker/st_context.c',
   'state_tracker/st_context.h',
   'state_tracker/st_copytex.c',
diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c
deleted file mode 100644
index a38d615db1e..00000000000
--- a/src/mesa/state_tracker/st_cb_viewport.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "main/glheader.h"
-#include "st_context.h"
-#include "st_manager.h"
-#include "st_cb_viewport.h"
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "util/u_atomic.h"
-
-void st_viewport(struct gl_context *ctx)
-{
-   struct st_context *st = ctx->st;
-   struct gl_framebuffer *stdraw;
-   struct gl_framebuffer *stread;
-
-   if (!st->invalidate_on_gl_viewport)
-      return;
-
-   /*
-    * Normally we'd want the frontend manager to mark the drawables
-    * invalid only when needed. This will force the frontend manager
-    * to revalidate the drawable, rather than just update the context with
-    * the latest cached drawable info.
-    */
-
-   stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
-   stread = st_ws_framebuffer(st->ctx->ReadBuffer);
-
-   if (stdraw)
-      stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
-   if (stread && stread != stdraw)
-      stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
-}
diff --git a/src/mesa/state_tracker/st_cb_viewport.h b/src/mesa/state_tracker/st_cb_viewport.h
deleted file mode 100644
index 2f8b829d468..00000000000
--- a/src/mesa/state_tracker/st_cb_viewport.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef ST_CB_VIEWPORT_H
-#define ST_CB_VIEWPORT_H
-
-void st_viewport(struct gl_context *ctx);
-
-#endif /* ST_CB_VIEW_PORT_H */
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index f9b939dba79..cb27f7a8a7b 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -73,6 +73,21 @@ struct st_manager_private
    simple_mtx_t st_mutex;
 };
 
+/**
+ * Cast wrapper to convert a struct gl_framebuffer to an gl_framebuffer.
+ * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
+ * We'll only return non-null for window system framebuffers.
+ * Note that this function may fail.
+ */
+static inline struct gl_framebuffer *
+st_ws_framebuffer(struct gl_framebuffer *fb)
+{
+   /* FBO cannot be casted.  See st_new_framebuffer */
+   if (fb && _mesa_is_winsys_fbo(fb) &&
+       fb != _mesa_get_incomplete_framebuffer())
+      return fb;
+   return NULL;
+}
 
 /**
  * Map an attachment to a buffer index.
@@ -1454,3 +1469,25 @@ st_gl_api_create(void)
 {
    return (struct st_api *) &st_gl_api;
 }
+
+void
+st_manager_invalidate_drawables(struct gl_context *ctx)
+{
+   struct gl_framebuffer *stdraw;
+   struct gl_framebuffer *stread;
+
+   /*
+    * Normally we'd want the frontend manager to mark the drawables
+    * invalid only when needed. This will force the frontend manager
+    * to revalidate the drawable, rather than just update the context with
+    * the latest cached drawable info.
+    */
+
+   stdraw = st_ws_framebuffer(ctx->DrawBuffer);
+   stread = st_ws_framebuffer(ctx->ReadBuffer);
+
+   if (stdraw)
+      stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
+   if (stread && stread != stdraw)
+      stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
+}
diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h
index 562ff9de6f9..64fea78fa47 100644
--- a/src/mesa/state_tracker/st_manager.h
+++ b/src/mesa/state_tracker/st_manager.h
@@ -40,22 +40,6 @@ struct st_framebuffer_interface;
 struct gl_renderbuffer;
 struct pipe_surface;
 
-/**
- * Cast wrapper to convert a struct gl_framebuffer to an gl_framebuffer.
- * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
- * We'll only return non-null for window system framebuffers.
- * Note that this function may fail.
- */
-static inline struct gl_framebuffer *
-st_ws_framebuffer(struct gl_framebuffer *fb)
-{
-   /* FBO cannot be casted.  See st_new_framebuffer */
-   if (fb && _mesa_is_winsys_fbo(fb) &&
-       fb != _mesa_get_incomplete_framebuffer())
-      return fb;
-   return NULL;
-}
-
 void
 st_manager_flush_frontbuffer(struct st_context *st);
 
@@ -76,4 +60,5 @@ void
 st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb,
                                struct pipe_surface *surf);
 
+void st_manager_invalidate_drawables(struct gl_context *ctx);
 #endif /* ST_MANAGER_H */



More information about the mesa-commit mailing list