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

> Describes depth-stencil state. (D3D12_DEPTH_STENCIL_DESC)

Describes depth-stencil state.

## Syntax

```cpp theme={null}
typedef struct D3D12_DEPTH_STENCIL_DESC
{
    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;
} D3D12_DEPTH_STENCIL_DESC
```

### Members

*DepthEnable*\
Type: BOOL

Specifies whether to enable depth testing. Set this member to **TRUE** to enable depth testing.

*DepthWriteMask*\
Type: D3D12\_DEPTH\_WRITE\_MASK

A [D3D12\_DEPTH\_WRITE\_MASK](/reference/graphics/d3d12/enums/d3d12_depth_write_mask_public)-typed value that identifies a portion of the depth-stencil buffer that can be modified by depth data.

*DepthFunc*\
Type: D3D12\_COMPARISON\_FUNC

A [D3D12\_COMPARISON\_FUNC](/reference/graphics/d3d12/enums/d3d12_comparison_func_public)-typed value that identifies a function that compares depth data against existing depth data.

*StencilEnable*\
Type: BOOL

Specifies whether to enable stencil testing. Set this member to **TRUE** to enable stencil testing.

*StencilReadMask*\
Type: UINT8

Identify a portion of the depth-stencil buffer for reading stencil data.

*StencilWriteMask*\
Type: UINT8

Identify a portion of the depth-stencil buffer for writing stencil data.

*FrontFace*\
Type: D3D12\_DEPTH\_STENCILOP\_DESC

A [D3D12\_DEPTH\_STENCILOP\_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) structure that describes how to use the results of the depth test and the stencil test for pixels whose surface normal is facing towards the camera.

*BackFace*\
Type: D3D12\_DEPTH\_STENCILOP\_DESC

A [D3D12\_DEPTH\_STENCILOP\_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public) structure that describes how to use the results of the depth test and the stencil test for pixels whose surface normal is facing away from the camera.

## Remarks

A [D3D12\_GRAPHICS\_PIPELINE\_STATE\_DESC](/reference/graphics/d3d12_x/structs/d3d12_graphics_pipeline_state_desc) object contains a depth-stencil-state structure that controls how depth-stencil testing is performed by the output-merger stage.

This table shows the default values of depth-stencil states.

<table>
  <tr>
    <th>State</th>
    <th>Default Value</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\_FUNC\_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.StencilFailOp

      and

      BackFace.StencilFailOp
    </td>

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

  <tr>
    <td>
      FrontFace.StencilDepthFailOp

      and

      BackFace.StencilDepthFailOp
    </td>

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

  <tr>
    <td>
      FrontFace.StencilPassOp

      and

      BackFace.StencilPassOp
    </td>

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

  <tr>
    <td>
      FrontFace.StencilFunc

      and

      BackFace.StencilFunc
    </td>

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

The formats that support stenciling are DXGI\_FORMAT\_D24\_UNORM\_S8\_UINT and DXGI\_FORMAT\_D32\_FLOAT\_S8X24\_UINT.

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

[CD3DX12\_DEPTH\_STENCIL\_DESC](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/cd3dx12-depth-stencil-desc)

[Core Structures](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/direct3d-12-structures)


## Related topics

- [D3D12_DEPTH_STENCILOP_DESC](/reference/graphics/d3d12/structs/d3d12_depth_stencilop_desc_public.md)
- [D3D12_DEPTH_WRITE_MASK](/reference/graphics/d3d12/enums/d3d12_depth_write_mask_public.md)
- [D3D12_COMPARISON_FUNC](/reference/graphics/d3d12/enums/d3d12_comparison_func_public.md)
- [D3D12_PIPELINE_STATE_STREAM_DESC](/reference/graphics/d3d12/structs/d3d12_pipeline_state_stream_desc_public.md)
- [D3D12_DEPTH_STENCIL_DESC1](/reference/graphics/d3d12/structs/d3d12_depth_stencil_desc1_public.md)
