Mesa (master): svga: Update the backing resource only if needed

Brian Paul brianp at kemper.freedesktop.org
Wed Apr 26 17:40:28 UTC 2017


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

Author: Charmaine Lee <charmainel at vmware.com>
Date:   Tue Apr 25 14:31:04 2017 -0600

svga: Update the backing resource only if needed

This patch adds a timestamp in svga_surface structure to keep track
of when the backing surface is last sync with the original resource.
This helps to avoid unnecessary surface copy from the original
resource to the backing surface if the original resource has not
since been modified.

This reduces the amount of surface copy with CinebenchR15.

Tested with CinebenchR15, mtt glretrace.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/drivers/svga/svga_surface.c | 14 +++++++++++---
 src/gallium/drivers/svga/svga_surface.h |  3 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index d0dc58d10f..cbeaa2390c 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -416,10 +416,11 @@ create_backed_surface_view(struct svga_context *svga, struct svga_surface *s)
 
       s->backed = svga_surface(backed_view);
    }
-   else {
+   else if (s->backed->age < tex->age) {
       /*
        * There is already an existing backing surface, but we still need to
-       * sync the handles.
+       * sync the backing resource if the original resource has been modified
+       * since the last copy.
        */
       struct svga_surface *bs = s->backed;
       unsigned int layer, zslice;
@@ -445,6 +446,7 @@ create_backed_surface_view(struct svga_context *svga, struct svga_surface *s)
    }
 
    svga_mark_surface_dirty(&s->backed->base);
+   s->backed->age = tex->age;
 
    SVGA_STATS_TIME_POP(svga_sws(svga));
 
@@ -647,8 +649,11 @@ svga_mark_surface_dirty(struct pipe_surface *surf)
 
    /* Increment the view_age and texture age for this surface's mipmap
     * level so that any sampler views into the texture are re-validated too.
+    * Note: we age the texture for backed surface view only when the
+    *       backed surface is propagated to the original surface.
     */
-   svga_age_texture_view(tex, surf->u.tex.level);
+   if (s->handle == tex->handle)
+      svga_age_texture_view(tex, surf->u.tex.level);
 }
 
 
@@ -742,6 +747,9 @@ svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf,
                                   1);
          svga_define_texture_level(tex, layer + i, surf->u.tex.level);
       }
+
+      /* Sync the surface view age with the texture age */
+      s->age = tex->age;
    }
 
    SVGA_STATS_TIME_POP(ss->sws);
diff --git a/src/gallium/drivers/svga/svga_surface.h b/src/gallium/drivers/svga/svga_surface.h
index 7cbb7671de..d1628d5452 100644
--- a/src/gallium/drivers/svga/svga_surface.h
+++ b/src/gallium/drivers/svga/svga_surface.h
@@ -72,6 +72,9 @@ struct svga_surface
     * original surface is the shader resource.
     */
    struct svga_surface *backed;
+   unsigned age;                   /* timestamp when the backed resource is
+                                    * synced with the original resource.
+                                    */
 };
 
 




More information about the mesa-commit mailing list