Bug 1682753 - Add device reset handling to RenderCompositorD3D11SWGL r=aosmond

Implementation is borrowed from RenderCompositorANGLE::IsContextLost().

Differential Revision: https://phabricator.services.mozilla.com/D100376
This commit is contained in:
sotaro 2020-12-24 16:35:56 +00:00
Родитель 5e0fb3e867
Коммит 8ba200bf20
4 изменённых файлов: 38 добавлений и 3 удалений

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

@ -110,7 +110,8 @@ CompositorD3D11::CompositorD3D11(CompositorBridgeParent* aParent,
mAllowPartialPresents(false),
mIsDoubleBuffered(false),
mVerifyBuffersFailed(false),
mUseMutexOnPresent(false) {
mUseMutexOnPresent(false),
mUseForSoftwareWebRender(false) {
mUseMutexOnPresent = StaticPrefs::gfx_use_mutex_on_present_AtStartup();
}
@ -1165,8 +1166,11 @@ Maybe<IntRect> CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion,
gfxCriticalNote << "GFX: D3D11 skip BeginFrame with device-removed.";
// If we are in the GPU process then the main process doesn't
// know that a device reset has happened and needs to be informed
if (XRE_IsGPUProcess()) {
// know that a device reset has happened and needs to be informed.
//
// When CompositorD3D11 is used for Software WebRender, it does not need
// to notify device reset. The device reset is notified by WebRender.
if (XRE_IsGPUProcess() && !mUseForSoftwareWebRender) {
GPUParent::GetSingleton()->NotifyDeviceReset();
}
mAttachments->SetDeviceReset();

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

@ -151,6 +151,8 @@ class CompositorD3D11 : public Compositor {
SyncObjectHost* GetSyncObject();
void UseForSoftwareWebRender() { mUseForSoftwareWebRender = true; }
private:
enum Severity {
Recoverable,
@ -280,6 +282,8 @@ class CompositorD3D11 : public Compositor {
bool mVerifyBuffersFailed;
bool mUseMutexOnPresent;
bool mAllowFrameRecording;
bool mUseForSoftwareWebRender;
};
namespace TexSlot {

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

@ -35,6 +35,7 @@ UniquePtr<RenderCompositor> RenderCompositorD3D11SWGL::Create(
<< log.get();
return nullptr;
}
compositor->UseForSoftwareWebRender();
return MakeUnique<RenderCompositorD3D11SWGL>(compositor, std::move(aWidget),
ctx);
@ -196,6 +197,30 @@ LayoutDeviceIntSize RenderCompositorD3D11SWGL::GetBufferSize() {
return mWidget->GetClientSize();
}
GLenum RenderCompositorD3D11SWGL::IsContextLost(bool aForce) {
// CompositorD3D11 uses ID3D11Device for composite. The device status needs to
// be checked.
auto reason = GetDevice()->GetDeviceRemovedReason();
switch (reason) {
case S_OK:
return LOCAL_GL_NO_ERROR;
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
NS_WARNING("Device reset due to system / different device");
return LOCAL_GL_INNOCENT_CONTEXT_RESET_ARB;
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_RESET:
case DXGI_ERROR_INVALID_CALL:
gfxCriticalError() << "Device reset due to WR device: "
<< gfx::hexa(reason);
return LOCAL_GL_GUILTY_CONTEXT_RESET_ARB;
default:
gfxCriticalError() << "Device reset with WR device unexpected reason: "
<< gfx::hexa(reason);
return LOCAL_GL_UNKNOWN_CONTEXT_RESET_ARB;
}
}
CompositorCapabilities RenderCompositorD3D11SWGL::GetCompositorCapabilities() {
CompositorCapabilities caps;

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

@ -41,6 +41,8 @@ class RenderCompositorD3D11SWGL : public RenderCompositor {
LayoutDeviceIntSize GetBufferSize() override;
GLenum IsContextLost(bool aForce) override;
// Should we support this?
bool SupportsExternalBufferTextures() const override { return false; }