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

1.5 KiB

RenderSurface::GetDepthAttachment

返回当前绑定的深度附件指针。

RHI::RHIResourceView* GetDepthAttachment() const;

返回值

  • 返回内部缓存的深度附件裸指针;如果未设置则返回 nullptr

当前语义

  • 返回值完全由 SetDepthAttachment 最近一次写入决定。
  • RenderSurface 不会检查这个 view 是否仍然存活,也不会校验它是否真的是 depth-stencil 视图。
  • 该指针是非拥有引用,生命周期仍由外部资源管理方负责。

调用方影响

  • BuiltinForwardPipeline::Render() 会把它传给 SetRenderTargets(...),并在需要清深度时调用 ClearDepthStencil(...)
  • ScenePassRenderRequest::IsValid()BuiltinDepthStylePassBase::Execute 都要求这里非空,否则 depth-only / shadow-caster 路径不会执行。
  • BuiltinObjectIdPass::Render()BuiltinInfiniteGridPass::Render() 都把 nullptr 视为无效输入。
  • ObjectIdRenderRequest::IsValid() 也要求这里非空,才能把 object-id surface 判定为合法。

测试覆盖

  • tests/Editor/test_viewport_host_surface_utils.cpptests/Editor/test_viewport_render_targets.cpp 都断言了构建出来的 surface 能返回正确 depth view。

相关文档