X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ref_counted_gl_sync.h;h=8b6db680a2c31ffa66ce36c799f1475769937033;hb=b9feb66845bf24465b7671ac9ff7a52b88f6032b;hp=8b6a8af58db178a3ecf1789806af776c92f4e05d;hpb=340de19ccede5808c033e8706070731204b832a4;p=nageru diff --git a/ref_counted_gl_sync.h b/ref_counted_gl_sync.h index 8b6a8af..8b6db68 100644 --- a/ref_counted_gl_sync.h +++ b/ref_counted_gl_sync.h @@ -8,6 +8,7 @@ #include #include +#include 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 lock(fence_lock); + return glFenceSync(condition, flags); + } + + static void locked_glDeleteSync(GLsync sync) + { + std::lock_guard lock(fence_lock); + glDeleteSync(sync); + } + + static std::mutex fence_lock; }; #endif // !defined(_REF_COUNTED_GL_SYNC_H)