> ## 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](/zh-TW/reference/graphics/d3d12/functions/d3d12getinterface_public) 直接存取較新的介面，特別是舊版平台。

## 語法

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

### 參數

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

偵錯介面的全域唯一識別碼 (**GUID**)。
偵錯介面的 **REFIID** (或 **GUID**) 可以使用 \_\_uuidof() 巨集取得。
例如，\_\_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-TW/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddatasettings/id3d12deviceremovedextendeddatasettings_public.md)
- [D3D12EnableExperimentalFeatures](/zh-TW/reference/graphics/d3d12/functions/d3d12enableexperimentalfeatures_public.md)
- [D3D12GetInterface (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/functions/d3d12getinterface_public.md)
- [SetName](/zh-TW/reference/graphics/d3d12/interfaces/id3d12object/methods/id3d12object_setname_public.md)
- [DSTORAGE_DEBUG](/zh-TW/reference/system/dstorage/enums/dstorage_debug.md)
