Search Unity

Question Minimal example of custom SRP using RenderGraph

Discussion in 'General Graphics' started by burningmime, Oct 3, 2022.

  1. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Is there a simple example somewhere of a custom SRP that makes use of RenderGraph? I am reading this...

    https://docs.unity3d.com/Packages/c...l/render-graph-writing-a-render-pipeline.html

    However, there's more than a little missing in various places. For example, they have a snippet that shows
    var renderGraphParams = new RenderGraphExecuteParams() { commandBuffer = cmd, /* ... */}
    . That one little code snippet brings up a lot of questions...
    • The struct was been renamed to
      RenderGraphParams
      without the Execute part. Are the docs even up to date?
    • Where does this
      cmd
      variable come from? (I assume a
      CommandBufferPool.Get()
      )
    • It don't explain whether this execution is supposed to be per-camera or per-frame. Can multiple cameras be done with the same render graph?
    • Do I need to Execute() the CommandBuffer myself?
    • How about whether this will be returned to CommandBufferPool automatically or if I should manually release it?
    The snippet above that (example render pipeline) doesn't even compile since it's missing a method and kind of implies the
    InitializeRenderGraph()
    will be called somehow by the system while it actually should be part of the constructor AFAICT. There's no mention of how to handle cases where one pass is per-frame and other passes are per-camera. There's no mention of UI cameras, gizmos, etc (I guess just draw these normally outside the render graph?). Like, there's some nuggets of good info there, but it's quite incomplete.

    The most complete example I can find from how to go from zero to a working SRP is https://catlikecoding.com/unity/tutorials/custom-srp/custom-render-pipeline/ , but that's from Unity 2019 and doesn't make use of RenderGraph. The other option is to trawl through the HDRP code base which may show best practices but parsing out the minimal set of what's needed to get this going is a bit confusing.

    Thanks for any help you can provide!
     
    poka_ likes this.