mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1829026 - Allow invalidating the current TLS context on establishing TLS scope. r=aosmond
On a given thread, if there are outside users of OpenGL (such as WebRender) that don't go through the GLContext interface to set the current context, the TLS current context value may be incorrect. To solve this, we need to assume that on establishing some TLS scopes, that the current context value is unreliable and invalidate it so that it gets properly reset. Differential Revision: https://phabricator.services.mozilla.com/D194350
This commit is contained in:
parent
f88c86a77e
commit
772134201a
@ -308,6 +308,13 @@ GLContext::~GLContext() {
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void GLContext::InvalidateCurrentContext() {
|
||||
if (sCurrentContext.init()) {
|
||||
sCurrentContext.set(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void GLContext::StaticDebugCallback(GLenum source, GLenum type, GLuint id,
|
||||
GLenum severity, GLsizei length,
|
||||
@ -2406,7 +2413,7 @@ bool GLContext::MakeCurrent(bool aForce) const {
|
||||
}
|
||||
if (MOZ_LIKELY(isCurrent)) {
|
||||
MOZ_ASSERT(IsCurrentImpl() ||
|
||||
!MakeCurrentImpl()); // Might have lost context.
|
||||
MakeCurrentImpl()); // Might have lost context.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +181,8 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
|
||||
public:
|
||||
static MOZ_THREAD_LOCAL(const GLContext*) sCurrentContext;
|
||||
|
||||
static void InvalidateCurrentContext();
|
||||
|
||||
const GLContextDesc mDesc;
|
||||
|
||||
bool mImplicitMakeCurrent = false;
|
||||
@ -191,9 +193,12 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
|
||||
const bool mWasTlsOk;
|
||||
|
||||
public:
|
||||
explicit TlsScope(GLContext* const gl)
|
||||
explicit TlsScope(GLContext* const gl, bool invalidate = false)
|
||||
: mGL(gl), mWasTlsOk(gl && gl->mUseTLSIsCurrent) {
|
||||
if (mGL) {
|
||||
if (invalidate) {
|
||||
InvalidateCurrentContext();
|
||||
}
|
||||
mGL->mUseTLSIsCurrent = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user