Mesa (master): iris: Refactor depth/stencil buffer pinning into a helper.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 11 22:04:38 UTC 2019


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sat Mar  9 00:50:24 2019 -0800

iris: Refactor depth/stencil buffer pinning into a helper.

This avoids the code duplication that caused me to put things in the
wrong place in the previous commit.  One used to have extra flushes,
but we moved those out so now these are identical and can be easily
shared.

---

 src/gallium/drivers/iris/iris_state.c | 65 +++++++++++++++--------------------
 1 file changed, 28 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index a686188f701..dd523f695c5 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -3943,6 +3943,32 @@ iris_use_optional_res(struct iris_batch *batch,
    }
 }
 
+static void
+pin_depth_and_stencil_buffers(struct iris_context *ice,
+                              struct iris_batch *batch,
+                              struct pipe_surface *zsbuf)
+{
+   if (!zsbuf)
+      return;
+
+   struct iris_resource *zres, *sres;
+   iris_get_depth_stencil_resources(zsbuf->texture, &zres, &sres);
+
+   if (zres) {
+      iris_use_pinned_bo(batch, zres->bo,
+                         ice->state.depth_writes_enabled);
+      if (zres->aux.bo) {
+         iris_use_pinned_bo(batch, zres->aux.bo,
+                            ice->state.depth_writes_enabled);
+      }
+   }
+
+   if (sres) {
+      iris_use_pinned_bo(batch, sres->bo,
+                         ice->state.stencil_writes_enabled);
+   }
+}
+
 /* ------------------------------------------------------------------- */
 
 /**
@@ -4063,25 +4089,7 @@ iris_restore_render_saved_bos(struct iris_context *ice,
 
    if (clean & IRIS_DIRTY_DEPTH_BUFFER) {
       struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
-
-      if (cso_fb->zsbuf) {
-         struct iris_resource *zres, *sres;
-         iris_get_depth_stencil_resources(cso_fb->zsbuf->texture,
-                                          &zres, &sres);
-         if (zres) {
-            iris_use_pinned_bo(batch, zres->bo,
-                               ice->state.depth_writes_enabled);
-            if (zres->aux.bo) {
-               iris_use_pinned_bo(batch, zres->aux.bo,
-                                  ice->state.depth_writes_enabled);
-            }
-         }
-
-         if (sres) {
-            iris_use_pinned_bo(batch, sres->bo,
-                               ice->state.stencil_writes_enabled);
-         }
-      }
+      pin_depth_and_stencil_buffers(ice, batch, cso_fb->zsbuf);
    }
 
    if (draw->index_size == 0 && ice->state.last_res.index_buffer) {
@@ -4630,24 +4638,7 @@ iris_upload_dirty_render_state(struct iris_context *ice,
 
       iris_batch_emit(batch, cso_z->packets, sizeof(cso_z->packets));
 
-      if (cso_fb->zsbuf) {
-         struct iris_resource *zres, *sres;
-         iris_get_depth_stencil_resources(cso_fb->zsbuf->texture,
-                                          &zres, &sres);
-         if (zres) {
-            iris_use_pinned_bo(batch, zres->bo,
-                               ice->state.depth_writes_enabled);
-            if (zres->aux.bo) {
-               iris_use_pinned_bo(batch, zres->aux.bo,
-                                  ice->state.depth_writes_enabled);
-            }
-         }
-
-         if (sres) {
-            iris_use_pinned_bo(batch, sres->bo,
-                               ice->state.stencil_writes_enabled);
-         }
-      }
+      pin_depth_and_stencil_buffers(ice, batch, cso_fb->zsbuf);
    }
 
    if (dirty & IRIS_DIRTY_POLYGON_STIPPLE) {




More information about the mesa-commit mailing list