Files
XCEngine/docs/api/XCEngine/Rendering/RenderSurface/SetDepthAttachment.md

1.5 KiB

RenderSurface::SetDepthAttachment

设置 surface 的深度附件。

void SetDepthAttachment(RHI::RHIResourceView* depthAttachment);

参数

  • depthAttachment - 深度/模板视图;允许传入 nullptr

当前语义

  • 当前实现只是把指针直接写入 m_depthAttachment,不会做额外资源操作。
  • 新值会覆盖旧值,不会尝试关闭、释放或验证旧附件。
  • 保存的是非拥有裸指针,RenderSurface 不负责它的生命周期。

调用方影响

  • BuiltinForwardPipeline::Render() 可以在深度附件为空时继续绑定颜色目标,只是深度清除和深度写入是否真正可用取决于具体后端与 pass 配置。
  • ScenePassRenderRequest::IsValid()BuiltinDepthStylePassBase::Execute 也把“深度附件非空”当作必要条件;否则 depth-only / shadow-caster 请求不会通过校验。
  • BuiltinObjectIdPass::Render()BuiltinInfiniteGridPass::Render() 都要求深度附件非空;否则会直接返回失败。
  • ObjectIdRenderRequest::IsValid() 也把“深度附件非空”列为必要条件之一。

测试覆盖

  • tests/Editor/test_viewport_host_surface_utils.cpptests/Editor/test_viewport_render_targets.cpp 都验证了 viewport surface 会把 depth view 写入这里。

相关文档