Hash :
7c985f5c
Author :
Date :
2018-11-29T18:16:17
Make angle::Result an enum. This moves away from a class type to a value type. This should improve performance when using angle::Result as a return value. Previously the generated code would return a pointer instead of a value. Improves performance in the most targeted microbenchmark by 10%. In more realistic scanarios it will have a smaller improvement. Also simplifies the class implementation and usage. Includes some unrelated code generation changes. Bug: angleproject:2491 Change-Id: Ifcf86870bf1c00a2f73c39ea6e4f05ca705050aa Reviewed-on: https://chromium-review.googlesource.com/c/1356139 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FenceNVGL.cpp: Implements the class methods for FenceNVGL.
#include "libANGLE/renderer/gl/FenceNVGL.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
namespace rx
{
FenceNVGL::FenceNVGL(const FunctionsGL *functions) : FenceNVImpl(), mFunctions(functions)
{
mFunctions->genFencesNV(1, &mFence);
}
FenceNVGL::~FenceNVGL()
{
mFunctions->deleteFencesNV(1, &mFence);
mFence = 0;
}
angle::Result FenceNVGL::set(const gl::Context *context, GLenum condition)
{
ASSERT(condition == GL_ALL_COMPLETED_NV);
mFunctions->setFenceNV(mFence, condition);
return angle::Result::Continue;
}
angle::Result FenceNVGL::test(const gl::Context *context, GLboolean *outFinished)
{
ASSERT(outFinished);
*outFinished = mFunctions->testFenceNV(mFence);
return angle::Result::Continue;
}
angle::Result FenceNVGL::finish(const gl::Context *context)
{
mFunctions->finishFenceNV(mFence);
return angle::Result::Continue;
}
// static
bool FenceNVGL::Supported(const FunctionsGL *functions)
{
return functions->hasGLESExtension("GL_NV_fence") || functions->hasGLExtension("GL_NV_fence");
}
FenceNVSyncGL::FenceNVSyncGL(const FunctionsGL *functions)
: FenceNVImpl(), mSyncObject(0), mFunctions(functions)
{}
FenceNVSyncGL::~FenceNVSyncGL()
{
if (mSyncObject != 0)
{
mFunctions->deleteSync(mSyncObject);
mSyncObject = 0;
}
}
angle::Result FenceNVSyncGL::set(const gl::Context *context, GLenum condition)
{
ASSERT(condition == GL_ALL_COMPLETED_NV);
mSyncObject = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
ANGLE_CHECK(GetImplAs<ContextGL>(context), mSyncObject != 0,
"glFenceSync failed to create a GLsync object.", GL_OUT_OF_MEMORY);
return angle::Result::Continue;
}
angle::Result FenceNVSyncGL::test(const gl::Context *context, GLboolean *outFinished)
{
ASSERT(mFunctions->isSync(mSyncObject));
GLint result = 0;
mFunctions->getSynciv(mSyncObject, GL_SYNC_STATUS, 1, nullptr, &result);
*outFinished = (result == GL_SIGNALED);
return angle::Result::Continue;
}
angle::Result FenceNVSyncGL::finish(const gl::Context *context)
{
ASSERT(mFunctions->isSync(mSyncObject));
GLenum result =
mFunctions->clientWaitSync(mSyncObject, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
ANGLE_CHECK(GetImplAs<ContextGL>(context),
result == GL_ALREADY_SIGNALED || result == GL_CONDITION_SATISFIED,
"glClientWaitSync did not return GL_ALREADY_SIGNALED or GL_CONDITION_SATISFIED.",
GL_OUT_OF_MEMORY);
return angle::Result::Continue;
}
// static
bool FenceNVSyncGL::Supported(const FunctionsGL *functions)
{
return functions->isAtLeastGL(gl::Version(3, 2)) ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLExtension("GL_ARB_sync");
}
} // namespace rx