1 // 2 // Copyright 2002 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Fence.h: Defines the gl::FenceNV and gl::Sync classes, which support the GL_NV_fence 8 // extension and GLES3 sync objects. 9 10 #ifndef LIBANGLE_FENCE_H_ 11 #define LIBANGLE_FENCE_H_ 12 13 #include "libANGLE/Debug.h" 14 #include "libANGLE/Error.h" 15 #include "libANGLE/RefCountObject.h" 16 17 #include "common/angleutils.h" 18 19 namespace rx 20 { 21 class GLImplFactory; 22 class FenceNVImpl; 23 class SyncImpl; 24 } // namespace rx 25 26 namespace gl 27 { 28 29 class FenceNV final : angle::NonCopyable 30 { 31 public: 32 explicit FenceNV(rx::GLImplFactory *factory); 33 virtual ~FenceNV(); 34 35 void onDestroy(const gl::Context *context); 36 angle::Result set(const Context *context, GLenum condition); 37 angle::Result test(const Context *context, GLboolean *outResult); 38 angle::Result finish(const Context *context); 39 isSet()40 bool isSet() const { return mIsSet; } getStatus()41 GLboolean getStatus() const { return mStatus; } getCondition()42 GLenum getCondition() const { return mCondition; } 43 44 private: 45 rx::FenceNVImpl *mFence; 46 47 bool mIsSet; 48 49 GLboolean mStatus; 50 GLenum mCondition; 51 }; 52 53 class Sync final : public RefCountObject<GLuint>, public LabeledObject 54 { 55 public: 56 Sync(rx::GLImplFactory *factory, GLuint id); 57 ~Sync() override; 58 59 void onDestroy(const Context *context) override; 60 61 void setLabel(const Context *context, const std::string &label) override; 62 const std::string &getLabel() const override; 63 64 angle::Result set(const Context *context, GLenum condition, GLbitfield flags); 65 angle::Result clientWait(const Context *context, 66 GLbitfield flags, 67 GLuint64 timeout, 68 GLenum *outResult); 69 angle::Result serverWait(const Context *context, GLbitfield flags, GLuint64 timeout); 70 angle::Result getStatus(const Context *context, GLint *outResult) const; 71 getCondition()72 GLenum getCondition() const { return mCondition; } getFlags()73 GLbitfield getFlags() const { return mFlags; } 74 getImplementation()75 rx::SyncImpl *getImplementation() const { return mFence; } 76 77 private: 78 rx::SyncImpl *mFence; 79 80 std::string mLabel; 81 82 GLenum mCondition; 83 GLbitfield mFlags; 84 }; 85 86 } // namespace gl 87 88 #endif // LIBANGLE_FENCE_H_ 89