> ## 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](/reference/graphics/d3d12/enums/d3d12_depth_write_mask_public) 类型的值，用于标识深度模板缓冲区中可由深度数据修改的部分。

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

一个 [D3D12\_COMPARISON\_FUNC](/reference/graphics/d3d12/enums/d3d12_comparison_func_public) 类型的值，用于标识将深度数据与现有深度数据进行比较的函数。

*StencilEnable*\
类型：BOOL

指定是否启用模板测试。将此成员设置为 **TRUE** 可启用模板测试。

*StencilReadMask*\
类型：UINT8

标识深度模板缓冲区中用于读取模板数据的部分。

*StencilWriteMask*\
类型：UINT8

标识深度模板缓冲区中用于写入模板数据的部分。

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

一个 [D3D12\_DEPTH\_STENCILOP\_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) 结构，描述如何为表面法线朝向摄像机的像素使用深度测试和模板测试的结果。

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

一个 [D3D12\_DEPTH\_STENCILOP\_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) 结构，描述如何为表面法线背向摄像机的像素使用深度测试和模板测试的结果。

*DepthBoundsTestEnable*\
类型：BOOL

TRUE 表示启用深度边界测试；否则为 FALSE。默认值为 FALSE。

## 备注

[D3D12\_GRAPHICS\_PIPELINE\_STATE\_DESC](/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-CN/reference/graphics/d3d12/structs/d3d12_pipeline_state_stream_desc_public.md)
- [D3D12_RESOURCE_DESC1](/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_desc1_public.md)
- [D3D12_ROOT_SIGNATURE_DESC1](/zh-CN/reference/graphics/d3d12/structs/d3d12_root_signature_desc1_public.md)
- [D3D12_DEPTH_STENCIL_DESC](/zh-CN/reference/graphics/d3d12/structs/d3d12_depth_stencil_desc_public.md)
- [D3D12_PROTECTED_RESOURCE_SESSION_DESC1](/zh-CN/reference/graphics/d3d12/structs/d3d12_protected_resource_session_desc1_public.md)
