From: Thomas Hellstrom Date: Fri, 5 Apr 2019 07:09:19 +0000 (+0200) Subject: winsys/svga: Make it possible to specify coherent resources X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f59d51d829098a01a5b0af5525372b401d2c789;p=mesa.git winsys/svga: Make it possible to specify coherent resources Add a flag in the surface cache key and a winsys usage flag to specify coherent memory. Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul --- diff --git a/src/gallium/drivers/svga/svga_screen_cache.c b/src/gallium/drivers/svga/svga_screen_cache.c index e2282d6a15c..1916a64245c 100644 --- a/src/gallium/drivers/svga/svga_screen_cache.c +++ b/src/gallium/drivers/svga/svga_screen_cache.c @@ -550,6 +550,8 @@ svga_screen_surface_create(struct svga_screen *svgascreen, usage |= SVGA_SURFACE_USAGE_SHARED; if (key->scanout) usage |= SVGA_SURFACE_USAGE_SCANOUT; + if (key->coherent) + usage |= SVGA_SURFACE_USAGE_COHERENT; handle = sws->surface_create(sws, key->flags, diff --git a/src/gallium/drivers/svga/svga_screen_cache.h b/src/gallium/drivers/svga/svga_screen_cache.h index a239b761fc2..055a267c189 100644 --- a/src/gallium/drivers/svga/svga_screen_cache.h +++ b/src/gallium/drivers/svga/svga_screen_cache.h @@ -69,6 +69,7 @@ struct svga_host_surface_cache_key uint32_t cachable:1; /* False if this is a shared surface */ uint32_t sampleCount:5; uint32_t scanout:1; + uint32_t coherent:1; }; diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index ee39db3bbbc..30d3f8776d9 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -81,8 +81,9 @@ struct winsys_handle; #define SVGA_FENCE_FLAG_EXEC (1 << 0) #define SVGA_FENCE_FLAG_QUERY (1 << 1) -#define SVGA_SURFACE_USAGE_SHARED (1 << 0) -#define SVGA_SURFACE_USAGE_SCANOUT (1 << 1) +#define SVGA_SURFACE_USAGE_SHARED (1 << 0) +#define SVGA_SURFACE_USAGE_SCANOUT (1 << 1) +#define SVGA_SURFACE_USAGE_COHERENT (1 << 2) #define SVGA_QUERY_FLAG_SET (1 << 0) #define SVGA_QUERY_FLAG_REF (1 << 1) @@ -677,6 +678,8 @@ struct svga_winsys_screen /** Can we do DMA with guest-backed objects enabled? */ bool have_gb_dma; + /** Do we support coherent surface memory? */ + bool have_coherent; /** * Create and define a GB shader. */ diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c index 91b5b259435..34c5e341782 100644 --- a/src/gallium/winsys/svga/drm/vmw_buffer.c +++ b/src/gallium/winsys/svga/drm/vmw_buffer.c @@ -315,7 +315,7 @@ vmw_svga_winsys_buffer_wrap(struct pb_buffer *buffer) } buf->pb_buf = buffer; - buf->fbuf = debug_flush_buf_create(TRUE, VMW_DEBUG_FLUSH_STACK); + buf->fbuf = debug_flush_buf_create(FALSE, VMW_DEBUG_FLUSH_STACK); return buf; } @@ -365,7 +365,7 @@ vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws, STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED == (unsigned) PIPE_TRANSFER_UNSYNCHRONIZED); - map = pb_map(vmw_pb_buffer(buf), flags, NULL); + map = pb_map(vmw_pb_buffer(buf), flags & PB_USAGE_ALL, NULL); #ifdef DEBUG if (map != NULL) diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c index a02d31c2bcb..2e84c811e82 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c @@ -246,7 +246,7 @@ vmw_ioctl_gb_surface_create(struct vmw_winsys_screen *vws, if (usage & SVGA_SURFACE_USAGE_SHARED) req->base.drm_surface_flags |= drm_vmw_surface_flag_shareable; - if (vws->force_coherent) + if ((usage & SVGA_SURFACE_USAGE_COHERENT) || vws->force_coherent) req->base.drm_surface_flags |= drm_vmw_surface_flag_coherent; req->base.drm_surface_flags |= drm_vmw_surface_flag_create_buffer; @@ -1117,6 +1117,7 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws) vws->ioctl.num_cap_3d = SVGA3D_DEVCAP_MAX; if (have_drm_2_16) { + vws->base.have_coherent = TRUE; getenv_val = getenv("SVGA_FORCE_COHERENT"); if (getenv_val && strcmp(getenv_val, "0") != 0) vws->force_coherent = TRUE; diff --git a/src/gallium/winsys/svga/drm/vmw_surface.c b/src/gallium/winsys/svga/drm/vmw_surface.c index 69408ffe9d9..6aa09e11b76 100644 --- a/src/gallium/winsys/svga/drm/vmw_surface.c +++ b/src/gallium/winsys/svga/drm/vmw_surface.c @@ -45,21 +45,14 @@ vmw_svga_winsys_surface_map(struct svga_winsys_context *swc, struct pb_buffer *pb_buf; uint32_t pb_flags; struct vmw_winsys_screen *vws = vsrf->screen; - + *retry = FALSE; assert((flags & (PIPE_TRANSFER_READ | PIPE_TRANSFER_WRITE)) != 0); mtx_lock(&vsrf->mutex); if (vsrf->mapcount) { - /* - * Only allow multiple readers to map. - */ - if ((flags & PIPE_TRANSFER_WRITE) || - (vsrf->map_mode & PIPE_TRANSFER_WRITE)) - goto out_unlock; - - data = vsrf->data; - goto out_mapped; + /* Other mappers will get confused if we discard. */ + flags &= ~PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE; } vsrf->rebind = FALSE; @@ -89,7 +82,8 @@ vmw_svga_winsys_surface_map(struct svga_winsys_context *swc, goto out_unlock; } - pb_flags = flags & (PIPE_TRANSFER_READ_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED); + pb_flags = flags & (PIPE_TRANSFER_READ_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED | + PIPE_TRANSFER_PERSISTENT); if (flags & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) { struct pb_manager *provider; @@ -169,10 +163,10 @@ vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc, if (--vsrf->mapcount == 0) { *rebind = vsrf->rebind; vsrf->rebind = FALSE; - vmw_svga_winsys_buffer_unmap(&vsrf->screen->base, vsrf->buf); } else { *rebind = FALSE; } + vmw_svga_winsys_buffer_unmap(&vsrf->screen->base, vsrf->buf); mtx_unlock(&vsrf->mutex); }