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

# CreateDepthStencilView

> 建立用於存取資源資料的深度樣板檢視。

建立用於存取資源資料的深度樣板檢視。

## 語法

```cpp theme={null}
void CreateDepthStencilView(
    ID3D12Resource  pResource,
    const D3D12_DEPTH_STENCIL_VIEW_DESC  pDesc,
    D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor
)
```

### 參數

*pResource \[in, optional]*\
類型：ID3D12Resource \*

指向代表深度樣板之 [ID3D12Resource](/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs) 物件的指標。

必須至少提供 <i>pResource</i> 或 <i>pDesc</i> 其中之一。
null 的 <i>pResource</i> 用於初始化 null 描述元，可保證類似 D3D11 的 null 繫結行為 (讀取 0，寫入會被捨棄)，但必須有有效的 <i>pDesc</i> 才能判斷描述元類型。

*pDesc \[in, optional]*\
類型：const D3D12\_DEPTH\_STENCIL\_VIEW\_DESC \*

指向描述深度樣板檢視之 [D3D12\_DEPTH\_STENCIL\_VIEW\_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_depth_stencil_view_desc_public) 結構的指標。

null 的 <i>pDesc</i> 用於在可能的情況下初始化預設描述元。此行為與 D3D11 的 null 描述元行為相同，會填入預設值。此行為會繼承資源格式和維度 (如果不是無類型)，且 DSV 會以第一個 mip 和所有陣列切片為目標。並非所有資源都支援 null 描述元初始化。

*DestDescriptor \[in]*\
類型：D3D12\_CPU\_DESCRIPTOR\_HANDLE

描述代表保存深度樣板檢視之堆積起點的 CPU 描述元控制代碼。

### 傳回值

類型：void

無。

## 需求

**標頭：** d3d12\_xs.h 或 d3d12\_x.h\
**程式庫：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支援的平台**：XBOX Series 主機與 XBOX One 系列

## 另請參閱

[ID3D12Device](/zh-TW/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)


## Related topics

- [CreateDepthStencilView](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createdepthstencilview_public.md)
- [D3D12_DEPTH_STENCIL_VIEW_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencil_view_desc_public.md)
