Hash :
ecf27c71
Author :
Date :
2021-06-16T13:13:31
GL: Fix bug with: Skip redundant flushes. The ANGLE-into-Skia autoroller is blocked because of the following CL: https://chromium-review.googlesource.com/c/angle/angle/+/2956453 Michael Ludwig, a Skia engineer, found that this change fixes the problem and will unblock the auto-roller. Bug: chromium:1181068 Change-Id: I514b2762f6643e25b36aab0290a57af4abf3c660 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2965615 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
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 107 108 109 110
//
// 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);
ContextGL *contextGL = GetImplAs<ContextGL>(context);
mFunctions->setFenceNV(mFence, condition);
contextGL->markWorkSubmitted();
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);
ContextGL *contextGL = GetImplAs<ContextGL>(context);
mSyncObject = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
ANGLE_CHECK(contextGL, mSyncObject != 0, "glFenceSync failed to create a GLsync object.",
GL_OUT_OF_MEMORY);
contextGL->markWorkSubmitted();
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