tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Fence.cpp (2824B)


      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.cpp: Implements the gl::FenceNV and gl::Sync classes.
      8 
      9 #include "libANGLE/Fence.h"
     10 
     11 #include "angle_gl.h"
     12 
     13 #include "common/utilities.h"
     14 #include "libANGLE/renderer/FenceNVImpl.h"
     15 #include "libANGLE/renderer/GLImplFactory.h"
     16 #include "libANGLE/renderer/SyncImpl.h"
     17 
     18 namespace gl
     19 {
     20 
     21 FenceNV::FenceNV(rx::GLImplFactory *factory)
     22    : mFence(factory->createFenceNV()), mIsSet(false), mStatus(GL_FALSE), mCondition(GL_NONE)
     23 {}
     24 
     25 FenceNV::~FenceNV()
     26 {
     27    SafeDelete(mFence);
     28 }
     29 
     30 void FenceNV::onDestroy(const gl::Context *context)
     31 {
     32    mFence->onDestroy(context);
     33 }
     34 
     35 angle::Result FenceNV::set(const Context *context, GLenum condition)
     36 {
     37    ANGLE_TRY(mFence->set(context, condition));
     38 
     39    mCondition = condition;
     40    mStatus    = GL_FALSE;
     41    mIsSet     = true;
     42 
     43    return angle::Result::Continue;
     44 }
     45 
     46 angle::Result FenceNV::test(const Context *context, GLboolean *outResult)
     47 {
     48    // Flush the command buffer by default
     49    ANGLE_TRY(mFence->test(context, &mStatus));
     50 
     51    *outResult = mStatus;
     52    return angle::Result::Continue;
     53 }
     54 
     55 angle::Result FenceNV::finish(const Context *context)
     56 {
     57    ASSERT(mIsSet);
     58 
     59    ANGLE_TRY(mFence->finish(context));
     60 
     61    mStatus = GL_TRUE;
     62 
     63    return angle::Result::Continue;
     64 }
     65 
     66 Sync::Sync(rx::GLImplFactory *factory, GLuint id)
     67    : RefCountObject(factory->generateSerial(), id),
     68      mFence(factory->createSync()),
     69      mLabel(),
     70      mCondition(GL_SYNC_GPU_COMMANDS_COMPLETE),
     71      mFlags(0)
     72 {}
     73 
     74 void Sync::onDestroy(const Context *context)
     75 {
     76    ASSERT(mFence);
     77    mFence->onDestroy(context);
     78 }
     79 
     80 Sync::~Sync()
     81 {
     82    SafeDelete(mFence);
     83 }
     84 
     85 angle::Result Sync::setLabel(const Context *context, const std::string &label)
     86 {
     87    mLabel = label;
     88    return angle::Result::Continue;
     89 }
     90 
     91 const std::string &Sync::getLabel() const
     92 {
     93    return mLabel;
     94 }
     95 
     96 angle::Result Sync::set(const Context *context, GLenum condition, GLbitfield flags)
     97 {
     98    ANGLE_TRY(mFence->set(context, condition, flags));
     99 
    100    mCondition = condition;
    101    mFlags     = flags;
    102    return angle::Result::Continue;
    103 }
    104 
    105 angle::Result Sync::clientWait(const Context *context,
    106                               GLbitfield flags,
    107                               GLuint64 timeout,
    108                               GLenum *outResult)
    109 {
    110    ASSERT(mCondition != GL_NONE);
    111    return mFence->clientWait(context, flags, timeout, outResult);
    112 }
    113 
    114 angle::Result Sync::serverWait(const Context *context, GLbitfield flags, GLuint64 timeout)
    115 {
    116    return mFence->serverWait(context, flags, timeout);
    117 }
    118 
    119 angle::Result Sync::getStatus(const Context *context, GLint *outResult) const
    120 {
    121    return mFence->getStatus(context, outResult);
    122 }
    123 
    124 }  // namespace gl