From 46fdc288fb52345134fd9aacd6d7ff71c7b747bb Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Sat, 28 Mar 2020 18:02:25 +0100 Subject: svga, winsys/svga: Fix persistent memory discard maps The kernel driver requires immediate notification using a BindGBSurface command when a graphics coherent memory resource changes backing MOB, so that it can start dirty-tracking the new MOB. Since we always use graphics coherent memory for persistent memory, enqueue and flush a BindGBSurface commmand at map time rather than at unmap time. Since we're dealing with persistent memory, It's OK to flush while mapped. This fixes an issue with gnome-shell / Wayland which uses persistent memory together with discard maps when we advertise ARB_buffer_storage. XWayland clients will render incorrectly. Fixes: 71b43490dd ("svga: Support ARB_buffer_storage") Signed-off-by: Thomas Hellstrom Reviewed-by: Neha Bhende Reviewed-by: Brian Paul Reviewed-by: Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/winsys/svga/drm/vmw_surface.c | 10 +++++++++- src/gallium/winsys/svga/drm/vmw_surface.h | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/gallium/winsys') diff --git a/src/gallium/winsys/svga/drm/vmw_surface.c b/src/gallium/winsys/svga/drm/vmw_surface.c index 6aa09e11b76..698cd11a28e 100644 --- a/src/gallium/winsys/svga/drm/vmw_surface.c +++ b/src/gallium/winsys/svga/drm/vmw_surface.c @@ -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); diff --git a/src/gallium/winsys/svga/drm/vmw_surface.h b/src/gallium/winsys/svga/drm/vmw_surface.h index b1a1ce746b3..ab75fed5f97 100644 --- a/src/gallium/winsys/svga/drm/vmw_surface.h +++ b/src/gallium/winsys/svga/drm/vmw_surface.h @@ -88,8 +88,9 @@ vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst, struct vmw_svga_winsys_surface *src); void * vmw_svga_winsys_surface_map(struct svga_winsys_context *swc, - struct svga_winsys_surface *srf, - unsigned flags, boolean *retry); + struct svga_winsys_surface *srf, + unsigned flags, boolean *retry, + boolean *rebind); void vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc, struct svga_winsys_surface *srf, -- cgit v1.2.3