SVGA_RELOC_INTERNAL indicates a transfer between surface and backing mob.
This means that if the GPU for example reads from the surface it writes
to the backing mob. But since the buffer mapping code allows for
simultaneous gpu- and cpu read access, a read from the surface to the mob
will not synchronize a subsequent map to the readback.

Fix this by inverting the mob access mode in a surface relocation with
SVGA_RELOC_INTERNAL set.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Brian Paul <bri...@vmware.com>
Reviewed-by: Charmaine Lee <charmai...@vmware.com>
---
 src/gallium/winsys/svga/drm/vmw_context.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/svga/drm/vmw_context.c 
b/src/gallium/winsys/svga/drm/vmw_context.c
index 938a3b4a5bc..addb58d165a 100644
--- a/src/gallium/winsys/svga/drm/vmw_context.c
+++ b/src/gallium/winsys/svga/drm/vmw_context.c
@@ -566,7 +566,15 @@ vmw_swc_surface_relocation(struct svga_winsys_context *swc,
 
       mtx_lock(&vsurf->mutex);
       assert(vsurf->buf != NULL);
-      
+
+      /*
+       * An internal reloc means that the surface transfer direction
+       * is opposite to the MOB transfer direction...
+       */
+      if ((flags & SVGA_RELOC_INTERNAL) &&
+          (flags & (SVGA_RELOC_READ | SVGA_RELOC_WRITE)) !=
+          (SVGA_RELOC_READ | SVGA_RELOC_WRITE))
+         flags ^= (SVGA_RELOC_READ | SVGA_RELOC_WRITE);
       vmw_swc_mob_relocation(swc, mobid, NULL, (struct svga_winsys_buffer *)
                              vsurf->buf, 0, flags);
       mtx_unlock(&vsurf->mutex);
-- 
2.20.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to