mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Make context-loss state atomic
This state can be set by other threads, including those without a context in the share group; context loss can originate from the Display and is propagated to all contexts. This change makes the relevant flags atomic which are read with relaxed memory order to minimize their impact on performance. Bug: angleproject:8224 Change-Id: I1f0a29210e07cd153db79fdc01d551cf96df4143 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4678784 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
f5986fbbee
commit
8ae9f28d7a
@@ -639,7 +639,7 @@ Context::Context(egl::Display *display,
|
||||
mCompiler(),
|
||||
mConfig(config),
|
||||
mHasBeenCurrent(false),
|
||||
mContextLost(false),
|
||||
mContextLost(0),
|
||||
mResetStatus(GraphicsResetStatus::NoError),
|
||||
mContextLostForced(false),
|
||||
mResetStrategy(GetResetStrategy(attribs)),
|
||||
@@ -3107,11 +3107,11 @@ void Context::markContextLost(GraphicsResetStatus status)
|
||||
|
||||
void Context::setContextLost()
|
||||
{
|
||||
mContextLost = true;
|
||||
mContextLost = 1;
|
||||
|
||||
// Stop skipping validation, since many implementation entrypoint assume they can't
|
||||
// be called when lost, or with null object arguments, etc.
|
||||
mSkipValidation = false;
|
||||
mSkipValidation = 0;
|
||||
|
||||
// Make sure we update TLS.
|
||||
SetCurrentValidContext(nullptr);
|
||||
@@ -3943,7 +3943,7 @@ Extensions Context::generateSupportedExtensions() const
|
||||
supportedExtensions.multiDrawANGLE = true;
|
||||
|
||||
// Enable the no error extension if the context was created with the flag.
|
||||
supportedExtensions.noErrorKHR = mSkipValidation;
|
||||
supportedExtensions.noErrorKHR = mSkipValidation != 0;
|
||||
|
||||
// Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO
|
||||
supportedExtensions.surfacelessContextOES = mSurfacelessSupported;
|
||||
@@ -3955,7 +3955,7 @@ Extensions Context::generateSupportedExtensions() const
|
||||
supportedExtensions.debugLabelEXT = true;
|
||||
|
||||
// Explicitly enable GL_ANGLE_robust_client_memory if the context supports validation.
|
||||
supportedExtensions.robustClientMemoryANGLE = !mSkipValidation;
|
||||
supportedExtensions.robustClientMemoryANGLE = mSkipValidation == 0;
|
||||
|
||||
// Determine robust resource init availability from EGL.
|
||||
supportedExtensions.robustResourceInitializationANGLE = mState.isRobustResourceInitEnabled();
|
||||
@@ -4348,9 +4348,9 @@ void Context::initCaps()
|
||||
// prevents writing invalid calls to the capture.
|
||||
INFO() << "Enabling validation to prevent invalid calls from being captured. This "
|
||||
"effectively disables GL_KHR_no_error and enables GL_ANGLE_robust_client_memory.";
|
||||
mSkipValidation = false;
|
||||
extensions->noErrorKHR = mSkipValidation;
|
||||
extensions->robustClientMemoryANGLE = !mSkipValidation;
|
||||
mSkipValidation = 0;
|
||||
extensions->noErrorKHR = mSkipValidation != 0;
|
||||
extensions->robustClientMemoryANGLE = mSkipValidation == 0;
|
||||
|
||||
INFO() << "Disabling GL_OES_depth32 during capture, which is not widely supported on "
|
||||
"mobile";
|
||||
@@ -7079,7 +7079,7 @@ void Context::getProgramivRobust(ShaderProgramID program,
|
||||
void Context::getProgramPipelineiv(ProgramPipelineID pipeline, GLenum pname, GLint *params)
|
||||
{
|
||||
ProgramPipeline *programPipeline = nullptr;
|
||||
if (!mContextLost)
|
||||
if (!isContextLost())
|
||||
{
|
||||
programPipeline = getProgramPipeline(pipeline);
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
|
||||
|
||||
void markContextLost(GraphicsResetStatus status);
|
||||
|
||||
bool isContextLost() const { return mContextLost; }
|
||||
bool isContextLost() const { return mContextLost.load(std::memory_order_relaxed) != 0; }
|
||||
void setContextLost();
|
||||
|
||||
GLenum getGraphicsResetStrategy() const { return mResetStrategy; }
|
||||
@@ -599,7 +599,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
|
||||
// Ensure we don't skip validation when context becomes lost, since implementations
|
||||
// generally assume a non-lost context, non-null objects, etc.
|
||||
ASSERT(!isContextLost() || !mSkipValidation);
|
||||
return mSkipValidation;
|
||||
return mSkipValidation.load(std::memory_order_relaxed) != 0;
|
||||
}
|
||||
|
||||
// Specific methods needed for validation.
|
||||
@@ -820,7 +820,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
|
||||
|
||||
State mState;
|
||||
bool mShared;
|
||||
bool mSkipValidation;
|
||||
std::atomic_int mSkipValidation;
|
||||
bool mDisplayTextureShareGroup;
|
||||
bool mDisplaySemaphoreShareGroup;
|
||||
|
||||
@@ -870,7 +870,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
|
||||
|
||||
// Current/lost context flags
|
||||
bool mHasBeenCurrent;
|
||||
bool mContextLost; // Set with setContextLost so that we also set mSkipValidation=false.
|
||||
// Set with setContextLost so that we also set mSkipValidation=false:
|
||||
std::atomic_int mContextLost;
|
||||
GraphicsResetStatus mResetStatus;
|
||||
bool mContextLostForced;
|
||||
GLenum mResetStrategy;
|
||||
|
||||
Reference in New Issue
Block a user