Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Microsoft.DotNet.Wpf/src/WpfGfx/core/hw/d3ddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3378,6 +3378,17 @@ CD3DDeviceLevel1::PresentWithD3D(

hr = S_OK;
}
else if (hr == DXGI_ERROR_DEVICE_REMOVED)
{
//
// On ARM64, the D3D9-over-DXGI compatibility layer surfaces
// DXGI_ERROR_DEVICE_REMOVED directly when the GPU is suspended or
// removed, instead of mapping it to D3DERR_DEVICELOST.
// Convert here so HandlePresentFailure can recognize and handle it
// gracefully rather than letting MIL_THR trigger a fatal crash.
//
hr = D3DERR_DEVICELOST;
}

//
// !!! Critical Note: After this point hr may not be S_OK. Make sure not
Expand Down Expand Up @@ -3477,9 +3488,11 @@ CD3DDeviceLevel1::HandlePresentFailure(
hr == D3DERR_DEVICEHUNG || // Hw Adapter timed out and has
// been reset by the OS (LH Only)
//
hr == D3DERR_DEVICEREMOVED // Hw Adapter has been removed (LH
// Only)
//
hr == D3DERR_DEVICEREMOVED || // Hw Adapter has been removed (LH
// Only)
//
hr == DXGI_ERROR_DEVICE_REMOVED // surfaced directly by D3D9-over-DXGI
// on ARM64 when GPU is suspended or removed
)
{
hr = WGXERR_DISPLAYSTATEINVALID;
Expand Down
10 changes: 10 additions & 0 deletions src/Microsoft.DotNet.Wpf/src/WpfGfx/include/wgx_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

#pragma once

/*=========================================================================*\
DXGI error codes
Defined here to avoid a dependency on dxgi.h, which is not included
in WpfGfx. These values are stable ABI constants defined by DirectX.
\*=========================================================================*/

#ifndef DXGI_ERROR_DEVICE_REMOVED
#define DXGI_ERROR_DEVICE_REMOVED ((HRESULT)0x887A0005L)
#endif

/*=========================================================================*\
MIL Status Codes
\*=========================================================================*/
Expand Down