Перейти к содержанию

External Render Target Resources in Framegraph Pipelines

Problem

Framegraph pipeline output is currently represented by special resource names such as OUTPUT and DISPLAY. Runtime execution treats those names as external render target textures, but graph analysis and FBO introspection can still treat them as ordinary internal framegraph resources. This allows invalid aliases such as:

OUTPUT == fbo_1

The intended relationship is different:

RT_COLOR == current RenderTarget.color texture
RT_DEPTH == current RenderTarget.depth texture

Internal FBOs keep their own allocation and format. External render target textures are provided by the render target that executes the pipeline.

Target Model

Render target textures enter the graph explicitly as external resources:

RenderTargetInput.color -> RT_COLOR
RenderTargetInput.depth -> RT_DEPTH

The final output node only marks pipeline completion:

PipelineOutput.color <- some resource
PipelineOutput.depth <- some resource

PipelineOutput does not allocate textures, copy/blit data, or rewrite resource names. If a copy into the render target is needed, the pipeline author adds an explicit pass:

fbo_1 -> BlitPass(input_res=fbo_1, output_res=RT_COLOR)
RT_COLOR -> PipelineOutput.color

If a pass can write directly to the render target texture, it uses RT_COLOR as its output:

RT_COLOR -> InplacePass(input_res=RT_COLOR, output_res=RT_COLOR)
RT_COLOR -> PipelineOutput.color

Rules

  • RT_COLOR and RT_DEPTH are external resources bound to the current render target.
  • External resources are not allocated by FBOPool.
  • Internal resources may alias other internal resources.
  • External resources must not be canonicalized to internal FBOs.
  • No implicit blit is inserted by the compiler.
  • Blits/copies into render target textures are explicit graph passes.
  • Framegraph Debugger must show the actual runtime texture behind an external resource.
  • Legacy OUTPUT/DISPLAY may remain as compatibility aliases during migration, but new graph authoring should use explicit external resources.

Migration Plan

  1. Add compiler/runtime support for external resource names:
  2. RT_COLOR
  3. RT_DEPTH
  4. temporary compatibility: OUTPUT, DISPLAY
  5. Add graph nodes:
  6. RenderTargetInput with outputs color, depth
  7. PipelineOutput with inputs color, depth
  8. Update graph compiler:
  9. register RenderTargetInput outputs as external resources
  10. stop rewriting upstream pass outputs to OUTPUT
  11. make PipelineOutput a validation/completion marker only
  12. keep legacy output-node handling behind compatibility logic
  13. Update RenderEngine:
  14. map external color resources to ViewportContext.output_color_tex
  15. map external depth resources to ViewportContext.output_depth_tex
  16. skip FBOPool allocation for external resources
  17. Update Framegraph Debugger:
  18. list external resources as resources
  19. show real runtime texture info for external resources
  20. keep internal FBO info from FBOPool
  21. Rewrite built-in pipelines:
  22. Default pipeline
  23. Editor pipeline
  24. Migrate saved .pipeline graph files:
  25. old RenderTarget output nodes become PipelineOutput
  26. add RenderTargetInput
  27. insert explicit blit/copy pass when old graph expected an implicit final write
  28. Add tests:
  29. compiler does not alias external resources to internal FBOs
  30. external resources are not allocated by FBOPool
  31. debugger reports external resource format from the actual render target texture
  32. Default and Editor pipelines finish through explicit external resources

First Vertical Slice

Implement external resources in compiler/runtime while preserving legacy names:

RT_COLOR -> output_color_tex
RT_DEPTH -> output_depth_tex
OUTPUT   -> output_color_tex  (legacy)
DISPLAY  -> output_color_tex  (legacy)

Then migrate FovPipeline.pipeline to use explicit render-target input/output nodes and verify:

fbo_1:    r32f
RT_COLOR: rgba16f
RT_DEPTH: depth32f

Progress

  • Done: compiler parses render_target_input and pipeline_output graph-boundary nodes.
  • Done: RenderTargetInput.color resolves to external RT_COLOR; RenderTargetInput.depth resolves to external RT_DEPTH.
  • Done: runtime skips FBOPool allocation for RT_COLOR/RT_DEPTH and binds them to the current render target textures.
  • Done: tcgui pipeline editor can load, save, and create explicit render target input/output nodes.
  • Done: Framegraph Debugger queries actual render target texture info for OUTPUT, DISPLAY, RT_COLOR, and RT_DEPTH before consulting internal FBO aliases.
  • Done: graph compiler initializes the C++ inspect dispatcher before applying socket/param fields, so compiled passes receive input_res/output_res instead of keeping constructor defaults.
  • Done: /home/mirmik/project/chronosquad-termin/Assets/Pipelines/FovPipeline.pipeline migrated to RenderTargetInput + PipelineOutput; DepthPass.output_res resolves to RT_COLOR, while the internal FBO remains fbo_1.
  • Still pending: rewrite built-in Default/Editor pipelines to the explicit input/output model.
  • Still pending: migrate remaining project pipeline assets.