Describes depth-stencil state.
typedef struct D3D11_DEPTH_STENCIL_DESC {
BOOL DepthEnable;
D3D11_DEPTH_WRITE_MASK DepthWriteMask;
D3D11_COMPARISON_FUNC DepthFunc;
BOOL StencilEnable;
UINT8 StencilReadMask;
UINT8 StencilWriteMask;
D3D11_DEPTH_STENCILOP_DESC FrontFace;
D3D11_DEPTH_STENCILOP_DESC BackFace;
BOOL BackfaceEnable;
BOOL DepthBoundsEnable;
BOOL ColorWritesOnDepthFailEnable;
BOOL ColorWritesOnDepthPassDisable;
UINT8 StencilReadMaskBack;
UINT8 StencilWriteMaskBack;
UINT8 StencilTestRefValueFront;
UINT8 StencilTestRefValueBack;
UINT8 StencilOpRefValueFront;
UINT8 StencilOpRefValueBack;
} D3D11_DEPTH_STENCIL_DESC;
DepthEnable
Enable depth testing.
DepthWriteMask
Identify a portion of the depth-stencil buffer that can be modified by depth data (see D3D11_DEPTH_WRITE_MASK).
DepthFunc
A function that compares depth data against existing depth data. The function options are listed in D3D11_COMPARISON_FUNC.
StencilEnable
Enable stencil testing.
StencilReadMask
Identify a portion of the depth-stencil buffer for reading stencil data.
StencilWriteMask
Identify a portion of the depth-stencil buffer for writing stencil data.
FrontFace
Identify how to use the results of the depth test and the stencil test for pixels whose surface normal is facing towards the camera (see D3D11_DEPTH_STENCILOP_DESC).
BackFace
Identify how to use the results of the depth test and the stencil test for pixels whose surface normal is facing away from the camera (see D3D11_DEPTH_STENCILOP_DESC).
BackfaceEnable
Enable using the results of the depth test and the stencil test for pixels whose surface normal is facing away from the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
DepthBoundsEnable
Enable depth bounds. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
ColorWritesOnDepthFailEnable
Enable color writes when there is a depth detection failure. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
ColorWritesOnDepthPassDisable
Disable color writes on depth pass. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilReadMaskBack
Enable stencil read mask for pixels whose surface normal is facing away from the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilWriteMaskBack
Enable stencil write mask for pixels whose surface normal is facing away from the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilTestRefValueFront
Enable stencil test reference value for pixels whose surface normal is facing towards the camera This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilTestRefValueBack
Enable stencil test reference value for pixels whose surface normal is facing away from the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilOpRefValueFront
Enable stencil operation reference value for pixels whose surface normal is facing towards the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
StencilOpRefValueBack
Enable stencil operation reference value for pixels whose surface normal is facing away from the camera. This is a D3D11X extension; only D3D11X (Xbox-specific) APIs accept this value.
Depth-stencil state controls how depth-stencil testing is performed by the output-merger stage.
The following table shows the default values of depth-stencil states.
| State | Default Value |
|---|---|
| DepthEnable | TRUE |
| DepthWriteMask | D3D11_DEPTH_WRITE_MASK_ALL |
| DepthFunc | D3D11_COMPARISON_LESS |
| StencilEnable | FALSE |
| StencilReadMask | D3D11_DEFAULT_STENCIL_READ_MASK |
| StencilWriteMask | D3D11_DEFAULT_STENCIL_WRITE_MASK |
| FrontFace.StencilFuncandBackFace.StencilFunc | D3D11_COMPARISON_ALWAYS |
| FrontFace.StencilDepthFailOpandBackFace.StencilDepthFailOp | D3D11_STENCIL_OP_KEEP |
| FrontFace.StencilPassOpandBackFace.StencilPassOp | D3D11_STENCIL_OP_KEEP |
| FrontFace.StencilFailOpandBackFace.StencilFailOp | D3D11_STENCIL_OP_KEEP |
| BackfaceEnable (this and the below members are D3D11X (Xbox) extensions) | FALSE |
| DepthBoundsEnable | FALSE |
| ColorWritesOnDepthFailEnable | FALSE |
| ColorWritesOnDepthPassDisable | FALSE |
| StencilReadMaskBack | 0 |
| StencilWriteMaskBack | 0 |
| StencilTestRefValueFront | 0 |
| StencilTestRefValueBack | 0 |
| StencilOpRefValueFront | 0 |
| StencilOpRefValueBack | 0 |
The formats that support stenciling are DXGI_FORMAT_D24_UNORM_S8_UINT and DXGI_FORMAT_D32_FLOAT_S8X24_UINT.
Header: Declared in d3d11_x.h (d3d11.h on other Windows platforms).