svga: Treat forced coherent maps as maps of persistent memory
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 31 Mar 2020 07:10:17 +0000 (09:10 +0200)
committerThomas Hellstrom (VMware) <thomas_os@shipmail.org>
Wed, 1 Apr 2020 06:58:28 +0000 (08:58 +0200)
A previous commit made sure we sent a BindGBSurface command at map time
rather than at unmap time for persistent memory. To be consistent, do the
same for forced coherent maps. This makes it possible to avoid the
explicit UpdateGBSurface at unmap time for discard maps and to instead rely
on the kernel's dirty-tracking mechanism at the cost of an additional flush.

Tested with SVGA_FORCE_COHERENT=1, piglit run quick. No regressions.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4399>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4399>

src/gallium/drivers/svga/svga_resource_buffer.h
src/gallium/drivers/svga/svga_resource_texture.c

index b3559446fa9cd6d01548c29967e3a2ed12fd3450..bd219742e6864f70d306b99acacda60bd429af68 100644 (file)
@@ -289,6 +289,9 @@ svga_buffer_hw_storage_map(struct svga_context *svga,
       boolean rebind;
       void *map;
 
+      if (swc->force_coherent) {
+         flags |= PIPE_TRANSFER_PERSISTENT | PIPE_TRANSFER_COHERENT;
+      }
       map = swc->surface_map(swc, sbuf->handle, flags, retry, &rebind);
       if (map && rebind) {
          enum pipe_error ret;
@@ -330,15 +333,6 @@ svga_buffer_hw_storage_unmap(struct svga_context *svga,
             ret = SVGA3D_BindGBSurface(swc, sbuf->handle);
             assert(ret == PIPE_OK);
          }
-         if (swc->force_coherent) {
-            ret = SVGA3D_UpdateGBSurface(swc, sbuf->handle);
-            if (ret != PIPE_OK) {
-               /* flush and retry */
-               svga_context_flush(svga, NULL);
-               ret = SVGA3D_UpdateGBSurface(swc, sbuf->handle);
-               assert(ret == PIPE_OK);
-            }
-         }
       }
    } else
       sws->buffer_unmap(sws, sbuf->hwbuf);
index 58b2f64d0b7630eba4abdc661f3098fc5928469b..2385da2e99950dcfd750cb3d25ce5fde0c42bb0b 100644 (file)
@@ -462,6 +462,10 @@ svga_texture_transfer_map_direct(struct svga_context *svga,
       unsigned offset, mip_width, mip_height;
       struct svga_winsys_context *swc = svga->swc;
 
+      if (swc->force_coherent) {
+         usage |= PIPE_TRANSFER_PERSISTENT | PIPE_TRANSFER_COHERENT;
+      }
+
       map = swc->surface_map(swc, surf, usage, &retry, &rebind);
       if (map == NULL && retry) {
          /*
@@ -709,15 +713,6 @@ svga_texture_surface_unmap(struct svga_context *svga,
          ret = SVGA3D_BindGBSurface(swc, surf);
          assert(ret == PIPE_OK);
       }
-      if (swc->force_coherent) {
-         ret = SVGA3D_UpdateGBSurface(swc, surf);
-         if (ret != PIPE_OK) {
-            /* flush and retry */
-            svga_context_flush(svga, NULL);
-            ret = SVGA3D_UpdateGBSurface(swc, surf);
-            assert(ret == PIPE_OK);
-         }
-      }
    }
 }