Files
XCEngine/docs/api/rhi/command-list/set-depth-stencil-state.md

35 lines
880 B
Markdown
Raw Normal View History

# RHICommandList::SetDepthStencilState
```cpp
virtual void SetDepthStencilState(const DepthStencilState& state) = 0;
```
2026-03-20 02:35:45 +08:00
设置深度测试和模板测试的状态配置。控制像素是否根据深度值和模板值被丢弃。
**参数:**
2026-03-20 02:35:45 +08:00
- `state` - 深度模板状态结构体(包含 depthEnable、depthWriteMask、depthFunc、stencilEnable 等)
**返回:** `void`
**异常:** 无
**线程安全:** ❌
**复杂度:** O(1)
**示例:**
```cpp
DepthStencilState dsState;
dsState.depthEnable = true;
dsState.depthWriteMask = true;
dsState.depthFunc = ComparisonFunc::Less;
2026-03-20 02:35:45 +08:00
dsState.stencilEnable = false;
cmdList->SetDepthStencilState(dsState);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览
2026-03-20 02:35:45 +08:00
- [SetStencilRef](set-stencil-ref.md) - 设置模板参考值
- [SetPipelineState](set-pipeline-state.md) - 设置管线状态