]> git.sesse.net Git - nageru/blob - shared/ref_counted_gl_sync.h
Fix some leftovers in warning messages.
[nageru] / shared / ref_counted_gl_sync.h
1 #ifndef _REF_COUNTED_GL_SYNC_H
2 #define _REF_COUNTED_GL_SYNC_H 1
3
4 // A wrapper around GLsync (OpenGL fences) that is automatically refcounted.
5 // Useful since we sometimes want to use the same fence two entirely different
6 // places. (We could set two fences at the same time, but they are not an
7 // unlimited hardware resource, so it would be a bit wasteful.)
8
9 #include <epoxy/gl.h>
10 #include <memory>
11 #include <mutex>
12
13 typedef std::shared_ptr<__GLsync> RefCountedGLsyncBase;
14
15 class RefCountedGLsync : public RefCountedGLsyncBase {
16 public:
17         RefCountedGLsync() {}
18
19         RefCountedGLsync(GLenum condition, GLbitfield flags)
20                 : RefCountedGLsyncBase(locked_glFenceSync(condition, flags), glDeleteSync) {}
21
22 private:
23         // These are to work around apitrace bug #446.
24         static GLsync locked_glFenceSync(GLenum condition, GLbitfield flags)
25         {
26                 std::lock_guard<std::mutex> lock(fence_lock);
27                 return glFenceSync(condition, flags);
28         }
29
30         static std::mutex fence_lock;
31 };
32
33 #endif  // !defined(_REF_COUNTED_GL_SYNC_H)