# D3D12CommandList::ClearDepthStencilView 清除深度模板视图(句柄重载)。 ```cpp void ClearDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE depthStencilHandle, uint32_t clearFlags, float depth = 1.0f, uint8_t stencil = 0, uint32_t rectCount = 0, const D3D12_RECT* rects = nullptr); ``` ## 参数 - `depthStencilHandle` - 深度模板视图 CPU 句柄 - `clearFlags` - 清除标志(D3D12_CLEAR_FLAG_DEPTH / D3D12_CLEAR_FLAG_STENCIL) - `depth` - 深度值(默认1.0f) - `stencil` - 模板值(默认0) - `rectCount` - 矩形数量(默认为0表示整个资源) - `rects` - 要清除的矩形数组(默认为nullptr表示整个资源) ## 返回值 无 **线程安全:** ❌ **复杂度:** O(n) ## 示例 ```cpp commandList.ClearDepthStencilView(depthStencilHandle, D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 1.0f, 0); ``` ## 相关文档 - [D3D12CommandList 总览](command-list.md) - [ClearDepthStencil](clear-depth-stencil.md) - 清除深度模板