[PATCH 5/5] wined3d: Explicitly synchronise in wined3d_context_gl_map_bo_address().

Henri Verbeet hverbeet at codeweavers.com
Thu Dec 3 09:17:59 CST 2020


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/buffer.c     | 7 -------
 dlls/wined3d/context_gl.c | 9 +++++++++
 dlls/wined3d/resource.c   | 4 ++--
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 7a4e48fd9c6..5dbc66449f4 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -741,7 +741,6 @@ void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
 static void wined3d_buffer_gl_sync_apple(struct wined3d_buffer_gl *buffer_gl,
         uint32_t flags, struct wined3d_context_gl *context_gl)
 {
-    struct wined3d_device_gl *device_gl = wined3d_device_gl(buffer_gl->b.resource.device);
     const struct wined3d_gl_info *gl_info = context_gl->gl_info;
     struct wined3d_bo_gl *bo = &buffer_gl->bo;
 
@@ -759,12 +758,6 @@ static void wined3d_buffer_gl_sync_apple(struct wined3d_buffer_gl *buffer_gl,
         bo->command_fence_id = 0;
         return;
     }
-
-    TRACE("Synchronizing buffer %p.\n", buffer_gl);
-
-    if (bo->command_fence_id == device_gl->current_fence_id)
-        wined3d_context_gl_submit_command_fence(context_gl);
-    wined3d_context_gl_wait_command_fence(context_gl, bo->command_fence_id);
 }
 
 static void buffer_mark_used(struct wined3d_buffer *buffer)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index 83c61834f5a..406b325cda8 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2653,6 +2653,7 @@ void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_
 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
         const struct wined3d_bo_address *data, size_t size, uint32_t flags)
 {
+    struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
     const struct wined3d_gl_info *gl_info;
     struct wined3d_bo_gl *bo;
     BYTE *memory;
@@ -2660,6 +2661,14 @@ void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
     if (!(bo = (struct wined3d_bo_gl *)data->buffer_object))
         return data->addr;
 
+    if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
+        goto map;
+
+    if (bo->command_fence_id == device_gl->current_fence_id)
+        wined3d_context_gl_submit_command_fence(context_gl);
+    wined3d_context_gl_wait_command_fence(context_gl, bo->command_fence_id);
+
+map:
     gl_info = context_gl->gl_info;
     wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
 
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 97b8b68374d..f6e233d8057 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -451,11 +451,11 @@ GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags)
         ret |= GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
     if (d3d_flags & WINED3D_MAP_READ)
         ret |= GL_MAP_READ_BIT;
+    else if (!(d3d_flags & WINED3D_MAP_DISCARD))
+        ret |= GL_MAP_UNSYNCHRONIZED_BIT;
 
     if (d3d_flags & WINED3D_MAP_DISCARD)
         ret |= GL_MAP_INVALIDATE_BUFFER_BIT;
-    if (d3d_flags & WINED3D_MAP_NOOVERWRITE)
-        ret |= GL_MAP_UNSYNCHRONIZED_BIT;
 
     return ret;
 }
-- 
2.20.1




More information about the wine-devel mailing list