mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1779166 - Mark two GLContexts as not owned by single threads. r=gfx-reviewers,lsalzman
1. In AndroidSharedBlitGL. 2. In DMABufSurface. Differential Revision: https://phabricator.services.mozilla.com/D152141
This commit is contained in:
parent
142a78ca7c
commit
b5f2464c70
@ -88,6 +88,7 @@ class AndroidSharedBlitGL final {
|
||||
NS_WARNING("Fail to create GL context for native blitter.");
|
||||
return nullptr;
|
||||
}
|
||||
gl->mOwningThreadId = Nothing();
|
||||
|
||||
// Yield the current state made in constructor.
|
||||
UnmakeCurrent(gl);
|
||||
|
@ -283,7 +283,7 @@ GLContext::GLContext(const GLContextDesc& desc, GLContext* sharedContext,
|
||||
mUseTLSIsCurrent(ShouldUseTLSIsCurrent(useTLSIsCurrent)),
|
||||
mDebugFlags(ChooseDebugFlags(mDesc.flags)),
|
||||
mSharedContext(sharedContext),
|
||||
mOwningThreadId(PlatformThread::CurrentId()),
|
||||
mOwningThreadId(Some(PlatformThread::CurrentId())),
|
||||
mWorkAroundDriverBugs(
|
||||
StaticPrefs::gfx_work_around_driver_bugs_AtStartup()) {
|
||||
MOZ_ALWAYS_TRUE(sCurrentContext.init());
|
||||
@ -2097,8 +2097,9 @@ bool GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const {
|
||||
return biggerDimension <= maxAllowed;
|
||||
}
|
||||
|
||||
bool GLContext::IsOwningThread() const {
|
||||
return PlatformThread::CurrentId() == mOwningThreadId;
|
||||
bool GLContext::IsValidOwningThread() const {
|
||||
if (!mOwningThreadId) return true;
|
||||
return PlatformThread::CurrentId() == *mOwningThreadId;
|
||||
}
|
||||
|
||||
GLBlitHelper* GLContext::BlitHelper() {
|
||||
@ -2429,7 +2430,7 @@ bool GLContext::MakeCurrent(bool aForce) const {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!IsOwningThread()) {
|
||||
if (!IsValidOwningThread()) {
|
||||
gfxCriticalError() << "MakeCurrent called on a thread other than the"
|
||||
<< " creating thread!";
|
||||
}
|
||||
|
@ -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 IsOwningThread() const;
|
||||
bool IsValidOwningThread() const;
|
||||
|
||||
static void PlatformStartup();
|
||||
|
||||
@ -3568,9 +3568,11 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
|
||||
protected:
|
||||
RefPtr<GLContext> mSharedContext;
|
||||
|
||||
public:
|
||||
// The thread id which this context was created.
|
||||
const PlatformThreadId mOwningThreadId;
|
||||
Maybe<PlatformThreadId> mOwningThreadId;
|
||||
|
||||
protected:
|
||||
GLContextSymbols mSymbols = {};
|
||||
|
||||
UniquePtr<GLBlitHelper> mBlitHelper;
|
||||
|
@ -80,7 +80,7 @@ void TextureImage::UpdateUploadSize(size_t amount) {
|
||||
|
||||
BasicTextureImage::~BasicTextureImage() {
|
||||
GLContext* ctx = mGLContext;
|
||||
if (ctx->IsDestroyed() || !ctx->IsOwningThread()) {
|
||||
if (ctx->IsDestroyed() || !ctx->IsValidOwningThread()) {
|
||||
ctx = ctx->GetSharedContext();
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ RefPtr<GLContext> ClaimSnapshotGLContext() {
|
||||
LOGDMABUF(("GetAsSourceSurface: Failed to create snapshot GLContext."));
|
||||
return nullptr;
|
||||
}
|
||||
sSnapshotContext->mOwningThreadId = Nothing(); // No singular owner.
|
||||
}
|
||||
if (!sSnapshotContext->MakeCurrent()) {
|
||||
LOGDMABUF(("GetAsSourceSurface: Failed to make GLContext current."));
|
||||
|
Loading…
Reference in New Issue
Block a user