]> git.sesse.net Git - nageru/blobdiff - ref_counted_gl_sync.h
Enable the video grid display for simple video mode, too.
[nageru] / ref_counted_gl_sync.h
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)