]> git.sesse.net Git - nageru/commitdiff
Put a global lock around glFenceSync/glDeleteSync calls, to workaround apitrace bug...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 18 Apr 2016 21:12:05 +0000 (23:12 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 18 Apr 2016 21:12:05 +0000 (23:12 +0200)
mixer.cpp
ref_counted_gl_sync.h

index 8c95f386f5f4d94d929d4496be31b6a3f6950a9a..3d4cccb4a6b4a372ca6e7e36c8442925334ac324 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -1205,3 +1205,5 @@ void Mixer::OutputChannel::set_frame_ready_callback(Mixer::new_frame_ready_callb
        new_frame_ready_callback = callback;
        has_new_frame_ready_callback = true;
 }
+
+mutex RefCountedGLsync::fence_lock;
index 8b6a8af58db178a3ecf1789806af776c92f4e05d..8b6db680a2c31ffa66ce36c799f1475769937033 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <epoxy/gl.h>
 #include <memory>
+#include <mutex>
 
 typedef std::shared_ptr<__GLsync> RefCountedGLsyncBase;
 
@@ -16,7 +17,23 @@ public:
        RefCountedGLsync() {}
 
        RefCountedGLsync(GLenum condition, GLbitfield flags) 
-               : RefCountedGLsyncBase(glFenceSync(condition, flags), glDeleteSync) {}
+               : RefCountedGLsyncBase(locked_glFenceSync(condition, flags), glDeleteSync) {}
+
+private:
+       // These are to work around apitrace bug #446.
+       static GLsync locked_glFenceSync(GLenum condition, GLbitfield flags)
+       {
+               std::lock_guard<std::mutex> lock(fence_lock);
+               return glFenceSync(condition, flags);
+       }
+
+       static void locked_glDeleteSync(GLsync sync)
+       {
+               std::lock_guard<std::mutex> lock(fence_lock);
+               glDeleteSync(sync);
+       }
+
+       static std::mutex fence_lock;
 };
 
 #endif  // !defined(_REF_COUNTED_GL_SYNC_H)