Henri Verbeet : wined3d: Use the access flags used to create the bo for persistent maps in wined3d_bo_gl_map().

Alexandre Julliard julliard at winehq.org
Thu Dec 9 15:34:29 CST 2021


Module: wine
Branch: master
Commit: 194b47b4fd92dda8ebf24e88ca7a14fc926c84ab
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=194b47b4fd92dda8ebf24e88ca7a14fc926c84ab

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Dec  9 17:45:15 2021 +0100

wined3d: Use the access flags used to create the bo for persistent maps in wined3d_bo_gl_map().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/context_gl.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index 6391f6788e9..c08e44ce372 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2711,14 +2711,24 @@ map:
     gl_info = context_gl->gl_info;
     wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id);
 
-    if (gl_info->supported[ARB_BUFFER_STORAGE])
-    {
-        if ((map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size,
-                GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | wined3d_resource_gl_map_flags(bo, flags)))))
-        {
-            if (wined3d_map_persistent())
-                bo->b.map_ptr = map_ptr;
-        }
+    if (gl_info->supported[ARB_BUFFER_STORAGE] && wined3d_map_persistent())
+    {
+        GLbitfield gl_flags;
+
+        /* When mapping the bo persistently, we need to use the access flags
+         * used to create the bo, instead of the access flags passed to the
+         * map call. Otherwise, if for example the initial map call that
+         * caused the bo to be persistently mapped was a read-only map,
+         * subsequent write access to the bo would be undefined. */
+        gl_flags = bo->flags & ~GL_CLIENT_STORAGE_BIT;
+        gl_flags |= GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
+        if (!(gl_flags & GL_MAP_READ_BIT))
+            gl_flags |= GL_MAP_UNSYNCHRONIZED_BIT;
+        if (gl_flags & GL_MAP_WRITE_BIT)
+            gl_flags |= GL_MAP_FLUSH_EXPLICIT_BIT;
+
+        if ((map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, gl_flags))))
+            bo->b.map_ptr = map_ptr;
     }
     else if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
     {




More information about the wine-cvs mailing list