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

# D3D12_DEPTH_STENCIL_DESC1

> 描述深度樣板狀態。(D3D12_DEPTH_STENCIL_DESC1)

描述深度樣板狀態。

## 語法

```cpp theme={null}
typedef struct D3D12_DEPTH_STENCIL_DESC1
{
    BOOL DepthEnable;
    D3D12_DEPTH_WRITE_MASK DepthWriteMask;
    D3D12_COMPARISON_FUNC DepthFunc;
    BOOL StencilEnable;
    UINT8 StencilReadMask;
    UINT8 StencilWriteMask;
    D3D12_DEPTH_STENCILOP_DESC FrontFace;
    D3D12_DEPTH_STENCILOP_DESC BackFace;
    BOOL DepthBoundsTestEnable;
} D3D12_DEPTH_STENCIL_DESC1
```

### 成員

*DepthEnable*\
類型：BOOL

指定是否要啟用深度測試。將此成員設為 **TRUE** 可啟用深度測試。

*DepthWriteMask*\
類型：D3D12\_DEPTH\_WRITE\_MASK

[D3D12\_DEPTH\_WRITE\_MASK](/zh-TW/reference/graphics/d3d12/enums/d3d12_depth_write_mask_public) 類型的值，識別深度樣板緩衝區中可由深度資料修改的部分。

*DepthFunc*\
類型：D3D12\_COMPARISON\_FUNC

[D3D12\_COMPARISON\_FUNC](/zh-TW/reference/graphics/d3d12/enums/d3d12_comparison_func_public) 類型的值，識別將深度資料與現有深度資料進行比較的函式。

*StencilEnable*\
類型：BOOL

指定是否要啟用樣板測試。將此成員設為 **TRUE** 可啟用樣板測試。

*StencilReadMask*\
類型：UINT8

識別深度樣板緩衝區中用於讀取樣板資料的部分。

*StencilWriteMask*\
類型：UINT8

識別深度樣板緩衝區中用於寫入樣板資料的部分。

*FrontFace*\
類型：D3D12\_DEPTH\_STENCILOP\_DESC

[D3D12\_DEPTH\_STENCILOP\_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) 結構，描述對於表面法線朝向攝影機的像素，如何使用深度測試與樣板測試的結果。

*BackFace*\
類型：D3D12\_DEPTH\_STENCILOP\_DESC

[D3D12\_DEPTH\_STENCILOP\_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) 結構，描述對於表面法線背向攝影機的像素，如何使用深度測試與樣板測試的結果。

*DepthBoundsTestEnable*\
類型：BOOL

TRUE 表示啟用深度界限測試；否則為 FALSE。預設值為 FALSE。

## 備註

[D3D12\_GRAPHICS\_PIPELINE\_STATE\_DESC](/zh-TW/reference/graphics/d3d12_x/structs/d3d12_graphics_pipeline_state_desc) 物件包含深度樣板狀態結構，用以控制輸出合併階段如何執行深度樣板測試。

下表顯示深度樣板狀態的預設值。

<table>
  <tr>
    <th>狀態</th>
    <th>預設值</th>
  </tr>

  <tr>
    <td>DepthEnable</td>
    <td>TRUE</td>
  </tr>

  <tr>
    <td>DepthWriteMask</td>
    <td>D3D12\_DEPTH\_WRITE\_MASK\_ALL</td>
  </tr>

  <tr>
    <td>DepthFunc</td>
    <td>D3D12\_COMPARISON\_LESS</td>
  </tr>

  <tr>
    <td>StencilEnable</td>
    <td>FALSE</td>
  </tr>

  <tr>
    <td>StencilReadMask</td>
    <td>D3D12\_DEFAULT\_STENCIL\_READ\_MASK</td>
  </tr>

  <tr>
    <td>StencilWriteMask</td>
    <td>D3D12\_DEFAULT\_STENCIL\_WRITE\_MASK</td>
  </tr>

  <tr>
    <td>
      FrontFace.StencilFunc

      與

      BackFace.StencilFunc
    </td>

    <td>D3D12\_COMPARISON\_ALWAYS</td>
  </tr>

  <tr>
    <td>
      FrontFace.StencilDepthFailOp

      與

      BackFace.StencilDepthFailOp
    </td>

    <td>D3D12\_STENCIL\_OP\_KEEP</td>
  </tr>

  <tr>
    <td>
      FrontFace.StencilPassOp

      與

      BackFace.StencilPassOp
    </td>

    <td>D3D12\_STENCIL\_OP\_KEEP</td>
  </tr>

  <tr>
    <td>
      FrontFace.StencilFailOp

      與

      BackFace.StencilFailOp
    </td>

    <td>D3D12\_STENCIL\_OP\_KEEP</td>
  </tr>

  <tr>
    <td>DepthBoundsTestEnable</td>
    <td>FALSE</td>
  </tr>
</table>

支援樣板的格式為 DXGI\_FORMAT\_D24\_UNORM\_S8\_UINT 與 DXGI\_FORMAT\_D32\_FLOAT\_S8X24\_UINT。

## 需求

**標頭:** 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-structures)


## Related topics

- [D3D12_PIPELINE_STATE_STREAM_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_pipeline_state_stream_desc_public.md)
- [D3D12_RESOURCE_DESC1](/zh-TW/reference/graphics/d3d12/structs/d3d12_resource_desc1_public.md)
- [D3D12_ROOT_SIGNATURE_DESC1](/zh-TW/reference/graphics/d3d12/structs/d3d12_root_signature_desc1_public.md)
- [D3D12_DEPTH_STENCIL_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_depth_stencil_desc_public.md)
- [D3D12_PROTECTED_RESOURCE_SESSION_DESC1](/zh-TW/reference/graphics/d3d12/structs/d3d12_protected_resource_session_desc1_public.md)
