[PATCH 1/2] wined3d: Add sync object after query buffer issue.

Andrew Wesie awesie at gmail.com
Sat Oct 13 16:38:24 CDT 2018


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45932
Signed-off-by: Andrew Wesie <awesie at gmail.com>
---

Notes:
    Fixes regression on NVIDIA cards due to query buffer objects. Change tested on
    NVIDIA proprietary driver, Intel Mesa driver, and AMD Mesa driver.

 dlls/wined3d/query.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 26c32b1f13..d968b0a744 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -40,7 +40,7 @@ static BOOL wined3d_query_buffer_is_valid(struct wined3d_query *query)
 static void wined3d_query_create_buffer_object(struct wined3d_context *context, struct wined3d_query *query)
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
-    const GLuint map_flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
+    const GLuint map_flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT;
     GLuint buffer_object;
 
     GL_EXTCALL(glGenBuffers(1, &buffer_object));
@@ -76,6 +76,7 @@ static void wined3d_query_destroy_buffer_object(struct wined3d_context *context,
 static BOOL wined3d_query_buffer_queue_result(struct wined3d_context *context, struct wined3d_query *query, GLuint id)
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    GLsync tmp_sync;
 
     if (!gl_info->supported[ARB_QUERY_BUFFER_OBJECT] || !gl_info->supported[ARB_BUFFER_STORAGE])
         return FALSE;
@@ -101,9 +102,15 @@ static BOOL wined3d_query_buffer_queue_result(struct wined3d_context *context, s
     /* Read the same value twice. We know we have the result if map_ptr[0] == map_ptr[1]. */
     GL_EXTCALL(glGetQueryObjectui64v(id, GL_QUERY_RESULT, (void *)0));
     GL_EXTCALL(glGetQueryObjectui64v(id, GL_QUERY_RESULT, (void *)sizeof(query->map_ptr[0])));
+    GL_EXTCALL(glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT));
     GL_EXTCALL(glBindBuffer(GL_QUERY_BUFFER, 0));
     checkGLcall("queue query result");
 
+    /* NVIDIA requires a sync object. */
+    tmp_sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
+    GL_EXTCALL(glDeleteSync(tmp_sync));
+    checkGLcall("query buffer sync");
+
     return TRUE;
 }
 
-- 
2.17.1




More information about the wine-devel mailing list