svga, winsys/svga: Fix persistent memory discard maps
[mesa.git] / src / gallium / winsys / svga / drm / vmw_surface.c
index 6aa09e11b76762ff582728c47900aa5dcc03b406..698cd11a28e58a0a4a56b98cfc82d94a31146674 100644 (file)
@@ -38,7 +38,8 @@
 void *
 vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
                             struct svga_winsys_surface *srf,
-                            unsigned flags, boolean *retry)
+                            unsigned flags, boolean *retry,
+                            boolean *rebind)
 {
    struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
    void *data = NULL;
@@ -47,6 +48,7 @@ vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
    struct vmw_winsys_screen *vws = vsrf->screen;
 
    *retry = FALSE;
+   *rebind = FALSE;
    assert((flags & (PIPE_TRANSFER_READ | PIPE_TRANSFER_WRITE)) != 0);
    mtx_lock(&vsrf->mutex);
 
@@ -121,6 +123,12 @@ vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
             if (vsrf->buf)
                vmw_svga_winsys_buffer_destroy(&vws->base, vsrf->buf);
             vsrf->buf = vbuf;
+
+            /* Rebind persistent maps immediately */
+            if (flags & PIPE_TRANSFER_PERSISTENT) {
+               *rebind = TRUE;
+               vsrf->rebind = FALSE;
+            }
             goto out_mapped;
          } else
             vmw_svga_winsys_buffer_destroy(&vws->base, vbuf);