Bug 1779069 - Assert that we only ever use a GLContext on its original thread. r=gfx-reviewers,aosmond

Differential Revision: https://phabricator.services.mozilla.com/D151540
This commit is contained in:
Kelsey Gilbert 2022-07-12 00:00:28 +00:00
parent 925ea31507
commit a8ef6e3480
3 changed files with 9 additions and 6 deletions

View File

@ -283,9 +283,9 @@ GLContext::GLContext(const GLContextDesc& desc, GLContext* sharedContext,
mUseTLSIsCurrent(ShouldUseTLSIsCurrent(useTLSIsCurrent)),
mDebugFlags(ChooseDebugFlags(mDesc.flags)),
mSharedContext(sharedContext),
mOwningThreadId(PlatformThread::CurrentId()),
mWorkAroundDriverBugs(
StaticPrefs::gfx_work_around_driver_bugs_AtStartup()) {
mOwningThreadId = PlatformThread::CurrentId();
MOZ_ALWAYS_TRUE(sCurrentContext.init());
sCurrentContext.set(0);
}
@ -2097,7 +2097,7 @@ bool GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const {
return biggerDimension <= maxAllowed;
}
bool GLContext::IsOwningThreadCurrent() {
bool GLContext::IsOwningThread() const {
return PlatformThread::CurrentId() == mOwningThreadId;
}
@ -2429,7 +2429,10 @@ bool GLContext::MakeCurrent(bool aForce) const {
return true;
}
}
if (!IsOwningThread()) {
gfxCriticalError() << "MakeCurrent called on a thread other than the"
<< " creating thread!";
}
if (!MakeCurrentImpl()) return false;
sCurrentContext.set(reinterpret_cast<uintptr_t>(this));

View File

@ -3442,7 +3442,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
* Returns true if the thread on which this context was created is the
* currently executing thread.
*/
bool IsOwningThreadCurrent();
bool IsOwningThread() const;
static void PlatformStartup();
@ -3569,7 +3569,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
RefPtr<GLContext> mSharedContext;
// The thread id which this context was created.
PlatformThreadId mOwningThreadId;
const PlatformThreadId mOwningThreadId;
GLContextSymbols mSymbols = {};

View File

@ -80,7 +80,7 @@ void TextureImage::UpdateUploadSize(size_t amount) {
BasicTextureImage::~BasicTextureImage() {
GLContext* ctx = mGLContext;
if (ctx->IsDestroyed() || !ctx->IsOwningThreadCurrent()) {
if (ctx->IsDestroyed() || !ctx->IsOwningThread()) {
ctx = ctx->GetSharedContext();
}