X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ref_counted_gl_sync.h;fp=ref_counted_gl_sync.h;h=0000000000000000000000000000000000000000;hb=392f9d1ccb835c05a3874c4bea163788b2c37024;hp=8b6db680a2c31ffa66ce36c799f1475769937033;hpb=330ca2f0052b06d91004c6ceb73cd57ab95e7fe1;p=nageru diff --git a/ref_counted_gl_sync.h b/ref_counted_gl_sync.h deleted file mode 100644 index 8b6db68..0000000 --- a/ref_counted_gl_sync.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _REF_COUNTED_GL_SYNC_H -#define _REF_COUNTED_GL_SYNC_H 1 - -// A wrapper around GLsync (OpenGL fences) that is automatically refcounted. -// Useful since we sometimes want to use the same fence two entirely different -// places. (We could set two fences at the same time, but they are not an -// unlimited hardware resource, so it would be a bit wasteful.) - -#include -#include -#include - -typedef std::shared_ptr<__GLsync> RefCountedGLsyncBase; - -class RefCountedGLsync : public RefCountedGLsyncBase { -public: - RefCountedGLsync() {} - - RefCountedGLsync(GLenum condition, GLbitfield flags) - : 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)