> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RemoveDevice (XBOX Series 主機)

> 您可以呼叫 **RemoveDevice** 向 Direct3D 12 執行階段表示 GPU 裝置發生問題，且無法再使用。

您可以呼叫 **RemoveDevice** 向 Direct3D 12 執行階段表示 GPU 裝置發生問題，且無法再使用。這麼做會使所有裝置受監視的柵欄收到訊號。您的應用程式通常不需要明確呼叫 **RemoveDevice**。

## 備註

由於裝置移除會觸發所有柵欄收到 `UINT64_MAX` 訊號，因此您可以使用事件建立裝置移除的回呼。

```cpp theme={null}
HANDLE deviceRemovedEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
assert(deviceRemovedEvent != NULL);
_deviceFence->SetEventOnCompletion(UINT64_MAX, deviceRemoved);

HANDLE waitHandle;
RegisterWaitForSingleObject(
&waitHandle,
deviceRemovedEvent,
OnDeviceRemoved,
_device.Get(), // Pass the device as our context
INFINITE, // No timeout
0 // No flags
);

void OnDeviceRemoved(PVOID context, BOOLEAN)
{
ID3D12Device* removedDevice = (ID3D12Device*)context;
HRESULT removedReason = removedDevice->GetDeviceRemovedReason();
// Perform app-specific device removed operation, such as logging or inspecting DRED output
}
```

## 需求

**標頭:** d3d12\_xs.h\
**程式庫:** d3d12\_xs.lib\
**支援的平台**: XBOX Series 主機

## 另請參閱


## Related topics

- [GetDeviceRemovedReason](/zh-TW/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getdeviceremovedreason_public.md)
- [ID3D12DeviceRemovedExtendedData](/zh-TW/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddata/id3d12deviceremovedextendeddata_public.md)
- [D3D12_DEVICE_REMOVED_EXTENDED_DATA](/zh-TW/reference/graphics/d3d12/structs/d3d12_device_removed_extended_data_public.md)
- [ID3D12DeviceRemovedExtendedDataSettings](/zh-TW/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddatasettings/id3d12deviceremovedextendeddatasettings_public.md)
- [D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA](/zh-TW/reference/graphics/d3d12/structs/d3d12_versioned_device_removed_extended_data_public.md)
