Bug 1706510 - If no frontbuffer, reuse BindDefaultFBForRead. r=lsalzman

Don't bind mDefaultFB->mFB directly, since it might be multisampled.

Differential Revision: https://phabricator.services.mozilla.com/D112881
This commit is contained in:
Jeff Gilbert 2021-04-21 01:03:32 +00:00
Родитель d27126e56f
Коммит 2ec500123f
1 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -991,13 +991,6 @@ bool WebGLContext::FrontBufferSnapshotInto(Range<uint8_t> dest) {
if (!IsWebGL2()) {
fbTarget = LOCAL_GL_FRAMEBUFFER;
}
gl->fBindFramebuffer(fbTarget,
front->mFb ? front->mFb->mFB : mDefaultFB->mFB);
if (pboWas) {
BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, nullptr);
}
auto reset2 = MakeScopeExit([&] {
DoBindFB(readFbWas, fbTarget);
if (pboWas) {
@ -1005,6 +998,20 @@ bool WebGLContext::FrontBufferSnapshotInto(Range<uint8_t> dest) {
}
});
if (front->mFb) {
gl->fBindFramebuffer(fbTarget, front->mFb->mFB);
} else {
if (!BindDefaultFBForRead()) {
gfxCriticalError() << "BindDefaultFBForRead failed";
return false;
}
}
if (pboWas) {
BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, nullptr);
}
// -
const auto& size = front->mDesc.size;
const size_t stride = size.width * 4;
MOZ_ASSERT(dest.length() == stride * size.height);