Bug 1744186 - A bit of clean up of RenderThread::HandleDeviceReset() r=gfx-reviewers,nical

Differential Revision: https://phabricator.services.mozilla.com/D132762
This commit is contained in:
sotaro 2021-12-06 23:22:53 +00:00
Родитель 240507d02f
Коммит e589a4b731
1 изменённых файлов: 21 добавлений и 19 удалений

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

@ -848,10 +848,16 @@ static DeviceResetReason GLenumToResetReason(GLenum aReason) {
void RenderThread::HandleDeviceReset(const char* aWhere, GLenum aReason) {
MOZ_ASSERT(IsInRenderThread());
if (aReason == LOCAL_GL_NO_ERROR) {
return;
}
if (mHandlingDeviceReset) {
return;
}
mHandlingDeviceReset = true;
#ifndef XP_WIN
// On Windows, see DeviceManagerDx::MaybeResetAndReacquireDevices.
gfx::GPUProcessManager::RecordDeviceReset(GLenumToResetReason(aReason));
@ -865,27 +871,23 @@ void RenderThread::HandleDeviceReset(const char* aWhere, GLenum aReason) {
}
}
mHandlingDeviceReset = aReason != LOCAL_GL_NO_ERROR;
if (mHandlingDeviceReset) {
// All RenderCompositors will be destroyed by the GPUProcessManager in
// either OnRemoteProcessDeviceReset via the GPUChild, or
// OnInProcessDeviceReset here directly.
// On Windows, device will be re-created before sessions re-creation.
gfxCriticalNote << "GFX: RenderThread detected a device reset in "
<< aWhere;
if (XRE_IsGPUProcess()) {
gfx::GPUParent::GetSingleton()->NotifyDeviceReset();
} else {
// All RenderCompositors will be destroyed by the GPUProcessManager in
// either OnRemoteProcessDeviceReset via the GPUChild, or
// OnInProcessDeviceReset here directly.
// On Windows, device will be re-created before sessions re-creation.
gfxCriticalNote << "GFX: RenderThread detected a device reset in " << aWhere;
if (XRE_IsGPUProcess()) {
gfx::GPUParent::GetSingleton()->NotifyDeviceReset();
} else {
#ifndef XP_WIN
// FIXME(aosmond): Do we need to do this on Windows? nsWindow::OnPaint
// seems to do its own detection for the parent process.
bool guilty = aReason == LOCAL_GL_GUILTY_CONTEXT_RESET_ARB;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"gfx::GPUProcessManager::OnInProcessDeviceReset", [guilty]() -> void {
gfx::GPUProcessManager::Get()->OnInProcessDeviceReset(guilty);
}));
// FIXME(aosmond): Do we need to do this on Windows? nsWindow::OnPaint
// seems to do its own detection for the parent process.
bool guilty = aReason == LOCAL_GL_GUILTY_CONTEXT_RESET_ARB;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"gfx::GPUProcessManager::OnInProcessDeviceReset", [guilty]() -> void {
gfx::GPUProcessManager::Get()->OnInProcessDeviceReset(guilty);
}));
#endif
}
}
}