ID3D11Device4::RegisterDeviceRemovedEvent method (d3d11_4.h)

Registers the "device removed" event and indicates when a Direct3D device has become removed for any reason, using an asynchronous notification mechanism.

Syntax

HRESULT RegisterDeviceRemovedEvent(
  [in]  HANDLE hEvent,
  [out] DWORD  *pdwCookie
);

Parameters

[in] hEvent

Type: HANDLE

The handle to the "device removed" event.

[out] pdwCookie

Type: DWORD*

A pointer to information about the "device removed" event, which can be used in UnregisterDeviceRemoved to unregister the event.

Return value

Type: HRESULT

See Direct3D 11 Return Codes.

Remarks

Indicates when a Direct3D device has become removed for any reason, using an asynchronous notification mechanism, rather than as an HRESULT from Present. The reason for device removal can be retrieved using ID3D11Device::GetDeviceRemovedReason after being notified of the occurrence.

Applications register and un-register a Win32 event handle with a particular device. That event handle will be signaled when the device becomes removed. A poll into the device's ID3D11Device::GetDeviceRemovedReason method indicates that the device is removed.

ISignalableNotifier or SetThreadpoolWait can be used by UWP apps.

When the graphics device is lost, the app or title will receive the graphics event, so that the app or title knows that its graphics device is no longer valid and it is safe for the app or title to re-create its DirectX devices. In response to this event, the app or title needs to re-create its rendering device and pass it into a SetRenderingDevice call on the composition graphics device objects.

After setting this new rendering device, the app or title needs to redraw content of all the pre-existing surfaces after the composition graphics device's OnRenderingDeviceReplaced event is fired.

This method supports Composition for device loss.

The event is not signaled when it is most ideal to re-create. So, instead, we recommend iterating through the adapter ordinals and creating the first ordinal that will succeed.

The application can register an event with the device. The application will be signaled when the device becomes removed.

If the device is already removed, calls to RegisterDeviceRemovedEvent will signal the event immediately. No device-removed error code will be returned from RegisterDeviceRemovedEvent.

Each "device removed" event is never signaled, or is signaled only once. These events are not signaled during device destruction. These events are unregistered during destruction.

The semantics of RegisterDeviceRemovedEvent are similar to IDXGIFactory2::RegisterOcclusionStatusEvent.

Requirements

Requirement Value
Target Platform Windows
Header d3d11_4.h
Library D3d11.lib

See also

ID3D11Device4

UnregisterDeviceRemoved