From 4dab2b426c1d4eb918dda550a547b33858617395 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 4 Jul 2013 23:49:26 +0200
Subject: wined3d: Don't synchronize NOOVERWRITE buffer maps

TODO: Put the patch that makes PreLoad ignore the mapped state here.
---
 dlls/wined3d/buffer.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index de0eaec..fd03fb5 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -958,13 +958,6 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
 
     TRACE("buffer %p, offset %u, size %u, data %p, flags %#x\n", buffer, offset, size, data, flags);
 
-    if (wined3d_settings.cs_multithreaded)
-    {
-        FIXME("Waiting for cs.\n");
-        wined3d_cs_emit_glfinish(device->cs);
-        device->cs->ops->finish(device->cs);
-    }
-
     flags = wined3d_resource_sanitize_map_flags(&buffer->resource, flags);
     /* Filter redundant WINED3D_MAP_DISCARD maps. The 3DMark2001 multitexture
      * fill rate test seems to depend on this. When we map a buffer with
@@ -995,6 +988,13 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
                 struct wined3d_context *context;
                 const struct wined3d_gl_info *gl_info;
 
+                if (wined3d_settings.cs_multithreaded)
+                {
+                    FIXME("waiting for cs\n");
+                    wined3d_cs_emit_glfinish(device->cs);
+                    device->cs->ops->finish(device->cs);
+                }
+
                 context = context_acquire(device, NULL);
                 gl_info = context->gl_info;
 
@@ -1056,6 +1056,12 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
             buffer->flags |= WINED3D_BUFFER_SYNC;
     }
 
+    if (!(flags & WINED3D_MAP_NOOVERWRITE) && wined3d_settings.cs_multithreaded)
+    {
+        FIXME("waiting for cs.\n");
+        device->cs->ops->finish(device->cs);
+    }
+
     base = buffer->map_ptr ? buffer->map_ptr : buffer->resource.heap_memory;
     *data = base + offset;
 
-- 
2.1.3

