[Mesa-dev] [PATCH 1/5] svga: Remove the surface_invalidate winsys function

Thomas Hellstrom thellstrom at vmware.com
Thu May 16 09:13:38 UTC 2019


Instead unconditionally call SVGA3D_InvalidateGBSurface() since it's needed
also for Linux for dirty buffers and operation without SurfaceDMA.
For non-guest-backed operation, remove the surface cache surface invalidation
altogether.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Charmaine Lee <charmainel at vmware.com>
---
 src/gallium/drivers/svga/svga_screen_cache.c | 14 ++++++++++----
 src/gallium/drivers/svga/svga_surface.c      |  4 ++--
 src/gallium/drivers/svga/svga_winsys.h       |  7 -------
 src/gallium/winsys/svga/drm/vmw_context.c    |  1 -
 src/gallium/winsys/svga/drm/vmw_surface.c    | 13 -------------
 src/gallium/winsys/svga/drm/vmw_surface.h    |  4 ----
 6 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_screen_cache.c b/src/gallium/drivers/svga/svga_screen_cache.c
index 82dd2b2c3a0..e2282d6a15c 100644
--- a/src/gallium/drivers/svga/svga_screen_cache.c
+++ b/src/gallium/drivers/svga/svga_screen_cache.c
@@ -33,7 +33,7 @@
 #include "svga_screen.h"
 #include "svga_screen_cache.h"
 #include "svga_context.h"
-
+#include "svga_cmd.h"
 
 #define SVGA_SURFACE_CACHE_ENABLED 1
 
@@ -291,7 +291,12 @@ svga_screen_cache_add(struct svga_screen *svgascreen,
 
       SVGA_DBG(DEBUG_CACHE|DEBUG_DMA,
                "cache sid %p\n", entry->handle);
-      LIST_ADD(&entry->head, &cache->validated);
+
+      /* If we don't have gb objects, we don't need to invalidate. */
+      if (sws->have_gb_objects)
+         LIST_ADD(&entry->head, &cache->validated);
+      else
+         LIST_ADD(&entry->head, &cache->invalidated);
 
       cache->total_size += surf_size;
    }
@@ -355,6 +360,7 @@ svga_screen_cache_flush(struct svga_screen *svgascreen,
       entry = LIST_ENTRY(struct svga_host_surface_cache_entry, curr, head);
 
       assert(entry->handle);
+      assert(svga_have_gb_objects(svga));
 
       if (sws->surface_is_flushed(sws, entry->handle)) {
          /* remove entry from the validated list */
@@ -363,7 +369,7 @@ svga_screen_cache_flush(struct svga_screen *svgascreen,
          /* It is now safe to invalidate the surface content.
           * It will be done using the current context.
           */
-         if (svga->swc->surface_invalidate(svga->swc, entry->handle) != PIPE_OK) {
+         if (SVGA3D_InvalidateGBSurface(svga->swc, entry->handle) != PIPE_OK) {
             MAYBE_UNUSED enum pipe_error ret;
 
             /* Even though surface invalidation here is done after the command
@@ -375,7 +381,7 @@ svga_screen_cache_flush(struct svga_screen *svgascreen,
              * this function itself is called inside svga_context_flush().
              */
             svga->swc->flush(svga->swc, NULL);
-            ret = svga->swc->surface_invalidate(svga->swc, entry->handle);
+            ret = SVGA3D_InvalidateGBSurface(svga->swc, entry->handle);
             assert(ret == PIPE_OK);
          }
 
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index 73208cf58ac..5d1f369fa90 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -591,9 +591,9 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
           * need to update the host-side copy with the invalid
           * content when the associated mob is first bound to the surface.
           */
-         if (svga->swc->surface_invalidate(svga->swc, stex->handle) != PIPE_OK) {
+         if (SVGA3D_InvalidateGBSurface(svga->swc, stex->handle) != PIPE_OK) {
             svga_context_flush(svga, NULL);
-            ret = svga->swc->surface_invalidate(svga->swc, stex->handle);
+            ret = SVGA3D_InvalidateGBSurface(svga->swc, stex->handle);
             assert(ret == PIPE_OK);
          }
          stex->validated = TRUE;
diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h
index 14782e19a7d..174b5f3b78f 100644
--- a/src/gallium/drivers/svga/svga_winsys.h
+++ b/src/gallium/drivers/svga/svga_winsys.h
@@ -411,13 +411,6 @@ struct svga_winsys_context
                     struct svga_winsys_surface *surface,
                     boolean *rebind);
 
-   /**
-    * Invalidate the content of this surface
-    */
-   enum pipe_error
-   (*surface_invalidate)(struct svga_winsys_context *swc,
-                         struct svga_winsys_surface *surface);
-
    /**
     * Create and define a DX GB shader that resides in the device COTable.
     * Caller of this function will issue the DXDefineShader command.
diff --git a/src/gallium/winsys/svga/drm/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c
index 59963ff7a82..938a3b4a5bc 100644
--- a/src/gallium/winsys/svga/drm/vmw_context.c
+++ b/src/gallium/winsys/svga/drm/vmw_context.c
@@ -816,7 +816,6 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
    vswc->base.flush = vmw_swc_flush;
    vswc->base.surface_map = vmw_svga_winsys_surface_map;
    vswc->base.surface_unmap = vmw_svga_winsys_surface_unmap;
-   vswc->base.surface_invalidate = vmw_svga_winsys_surface_invalidate;
 
    vswc->base.shader_create = vmw_svga_winsys_vgpu10_shader_create;
    vswc->base.shader_destroy = vmw_svga_winsys_vgpu10_shader_destroy;
diff --git a/src/gallium/winsys/svga/drm/vmw_surface.c b/src/gallium/winsys/svga/drm/vmw_surface.c
index 04aa932784b..69408ffe9d9 100644
--- a/src/gallium/winsys/svga/drm/vmw_surface.c
+++ b/src/gallium/winsys/svga/drm/vmw_surface.c
@@ -176,19 +176,6 @@ vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc,
    mtx_unlock(&vsrf->mutex);
 }
 
-enum pipe_error
-vmw_svga_winsys_surface_invalidate(struct svga_winsys_context *swc,
-                                   struct svga_winsys_surface *surf)
-{
-   /* this is a noop since surface invalidation is not needed for DMA path.
-    * DMA is enabled when guest-backed surface is not enabled or
-    * guest-backed dma is enabled.  Since guest-backed dma is enabled
-    * when guest-backed surface is enabled, that implies DMA is always enabled;
-    * hence, surface invalidation is not needed.
-    */
-   return PIPE_OK;
-}
-
 void
 vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
                                   struct vmw_svga_winsys_surface *src)
diff --git a/src/gallium/winsys/svga/drm/vmw_surface.h b/src/gallium/winsys/svga/drm/vmw_surface.h
index 0fdc8de1d56..b1a1ce746b3 100644
--- a/src/gallium/winsys/svga/drm/vmw_surface.h
+++ b/src/gallium/winsys/svga/drm/vmw_surface.h
@@ -94,8 +94,4 @@ void
 vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc,
                               struct svga_winsys_surface *srf,
                               boolean *rebind);
-enum pipe_error
-vmw_svga_winsys_surface_invalidate(struct svga_winsys_context *swc,
-                                   struct svga_winsys_surface *srf);
-
 #endif /* VMW_SURFACE_H_ */
-- 
2.20.1



More information about the mesa-dev mailing list