> ## 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.

# D3D12GetDebugInterface

> 获取调试接口。

获取调试接口。

使用 [D3D12GetInterface](/reference/graphics/d3d12/functions/d3d12getinterface_public) 可直接访问较新的接口，尤其是低级接口。

## 语法

```cpp theme={null}
HRESULT D3D12GetDebugInterface(
    const IID & riid,
    void  ppvDebug
)
```

### 参数

*riid \[in]*\
类型：const IID &

调试接口的全局唯一标识符 (**GUID**)。
可使用 \_\_uuidof() 宏获得调试接口的 **REFIID** 或 **GUID**。
例如，\_\_uuidof([ID3D12Debug](https://learn.microsoft.com/en-us/windows/desktop/api/d3d12sdklayers/nn-d3d12sdklayers-id3d12debug)) 将获得调试接口的 **GUID**。

*ppvDebug \[out, optional]*\
类型：void \*\*

调试接口，以指向 void 的指针的指针形式。
请参阅
[ID3D12Debug](https://learn.microsoft.com/en-us/windows/desktop/api/d3d12sdklayers/nn-d3d12sdklayers-id3d12debug) 和
[ID3D12DebugDevice](https://learn.microsoft.com/en-us/windows/desktop/api/d3d12sdklayers/nn-d3d12sdklayers-id3d12debugdevice)。

### 返回值

类型：HRESULT

此方法返回 [Direct3D 12 返回代码](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/d3d12-graphics-reference-returnvalues)之一。

## 备注

函数签名 PFN\_D3D12\_GET\_DEBUG\_INTERFACE 以 typedef 形式提供，以便您使用动态链接技术（[GetProcAddress](https://learn.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-getprocaddress)），而无需静态链接。

#### 示例

启用 D3D12 调试层。

```cpp theme={null}
// Enable the D3D12 debug layer.
{

ComPtr<ID3D12Debug> debugController;
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController))))
{
debugController->EnableDebugLayer();
}
}

```

请参阅 [D3D12 参考中的示例代码](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code)。

<div class="code" />

## 要求

**头文件：** d3d12\_xs.h 或 d3d12\_x.h\
**库：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支持的平台**：XBOX Series 主机和 XBOX One 系列

## 另请参阅

[核心函数](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/direct3d-12-functions)


## Related topics

- [ID3D12DeviceRemovedExtendedDataSettings](/zh-CN/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddatasettings/id3d12deviceremovedextendeddatasettings_public.md)
- [D3D12EnableExperimentalFeatures](/zh-CN/reference/graphics/d3d12/functions/d3d12enableexperimentalfeatures_public.md)
- [D3D12GetInterface（XBOX Series 主机）](/zh-CN/reference/graphics/d3d12/functions/d3d12getinterface_public.md)
- [SetName](/zh-CN/reference/graphics/d3d12/interfaces/id3d12object/methods/id3d12object_setname_public.md)
- [DSTORAGE_DEBUG](/zh-CN/reference/system/dstorage/enums/dstorage_debug.md)
