> ## 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-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getdeviceremovedreason_public.md)
- [ID3D12DeviceRemovedExtendedData](/zh-CN/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddata/id3d12deviceremovedextendeddata_public.md)
- [D3D12_DEVICE_REMOVED_EXTENDED_DATA](/zh-CN/reference/graphics/d3d12/structs/d3d12_device_removed_extended_data_public.md)
- [ID3D12DeviceRemovedExtendedDataSettings](/zh-CN/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddatasettings/id3d12deviceremovedextendeddatasettings_public.md)
- [D3D12_DEVICE_REMOVED_EXTENDED_DATA1](/zh-CN/reference/graphics/d3d12/structs/d3d12_device_removed_extended_data1_public.md)
