docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class RenderGraph

    This class is the main entry point of the Render Graph system.

    Inheritance
    object
    RenderGraph
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Experimental.Rendering.RenderGraphModule
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public class RenderGraph

    Constructors

    RenderGraph(string)

    Render Graph constructor.

    Declaration
    public RenderGraph(string name = "RenderGraph")
    Parameters
    Type Name Description
    string name

    Optional name used to identify the render graph instnace.

    Fields

    kMaxMRTCount

    Maximum number of MRTs supported by Render Graph.

    Declaration
    public static readonly int kMaxMRTCount
    Field Value
    Type Description
    int

    Properties

    NativeRenderPassesEnabled

    Declaration
    public bool NativeRenderPassesEnabled { get; set; }
    Property Value
    Type Description
    bool

    defaultResources

    Set of default resources usable in a pass rendering code.

    Declaration
    public RenderGraphDefaultResources defaultResources { get; }
    Property Value
    Type Description
    RenderGraphDefaultResources

    isRenderGraphViewerActive

    If true, the Render Graph Viewer is active.

    Declaration
    public static bool isRenderGraphViewerActive { get; }
    Property Value
    Type Description
    bool

    name

    Name of the Render Graph.

    Declaration
    public string name { get; }
    Property Value
    Type Description
    string

    Methods

    AddComputePass<PassData>(string, out PassData)

    Add a new Compute Render Pass to the Render Graph. Raster passes can execute rasterization workloads but cannot do other GPU work like copies or compute.

    Declaration
    public IComputeRenderGraphBuilder AddComputePass<PassData>(string passName, out PassData passData)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    Returns
    Type Description
    IComputeRenderGraphBuilder

    A new instance of a IRasterRenderGraphBuilder used to setup the new Rasterization Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddComputePass<PassData>(string, out PassData, ProfilingSampler)

    Add a new Compute Render Pass to the Render Graph. Compute passes can execute compute workloads but cannot do rasterization.

    Declaration
    public IComputeRenderGraphBuilder AddComputePass<PassData>(string passName, out PassData passData, ProfilingSampler sampler)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    ProfilingSampler sampler

    Profiling sampler used around the pass.

    Returns
    Type Description
    IComputeRenderGraphBuilder

    A new instance of a IComputeRenderGraphBuilder used to setup the new Compute Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddLowLevelPass<PassData>(string, out PassData)

    Add a new Low Level Render Pass to the Render Graph. Low level passes can do certain operations compute/raster render passes cannot do and have access to the full command buffer API. The low level API should be used sparingly as it has the following downsides

    • All native render passes will be serialized out.
    • In the future the render graph compiler may generate a sub-optimal command stream for low level passes. When using a low level pass the graph will also not automatically set-up graphics state like rendertargets. The pass should do this itself using cmd.SetRenderTarget and related commands.
    Declaration
    public ILowLevelRenderGraphBuilder AddLowLevelPass<PassData>(string passName, out PassData passData)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    Returns
    Type Description
    ILowLevelRenderGraphBuilder

    A new instance of a ILowLevelRenderGraphBuilder used to setup the new Low Level Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddLowLevelPass<PassData>(string, out PassData, ProfilingSampler)

    Add a new Low Level Render Pass to the Render Graph. Low level passes can do certain operations compute/raster render passes cannot do and have access to the full command buffer API. The low level API should be used sparingly as it has the following downsides

    • All native render passes will be serialized out.
    • In the future the render graph compiler may generate a sub-optimal command stream for low level passes. When using a low level pass the graph will also not automatically set-up graphics state like rendertargets. The pass should do this itself using cmd.SetRenderTarget and related commands.
    Declaration
    public ILowLevelRenderGraphBuilder AddLowLevelPass<PassData>(string passName, out PassData passData, ProfilingSampler sampler)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    ProfilingSampler sampler

    Profiling sampler used around the pass.

    Returns
    Type Description
    ILowLevelRenderGraphBuilder

    A new instance of a ILowLevelRenderGraphBuilder used to setup the new Low Level Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddMovePass(TextureHandle, TextureHandle)

    Add a new move pass to the Render Graph. This pass moves data from one texture to another. Note that this pass is more limited in functionality than for example doing a blit from one texture to another. It cannot do any type conversions, the textures have to be the same size,... This pass may be optimized away by the RenderGraph depending on the dependencies within the graph. E.g. if the destination resource is the only resource ever using the data in source the graph may decide to directly render to the destination instead of rendering to source and then doing an copy to destination.

    Declaration
    public void AddMovePass(TextureHandle source, TextureHandle destination)
    Parameters
    Type Name Description
    TextureHandle source

    Texture to read data from.

    TextureHandle destination

    Texture to copy data into.

    AddRasterRenderPass<PassData>(string, out PassData)

    Add a new Raster Render Pass to the Render Graph. Raster passes can execute rasterization workloads but cannot do other GPU work like copies or compute.

    Declaration
    public IRasterRenderGraphBuilder AddRasterRenderPass<PassData>(string passName, out PassData passData)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    Returns
    Type Description
    IRasterRenderGraphBuilder

    A new instance of a IRasterRenderGraphBuilder used to setup the new Rasterization Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddRasterRenderPass<PassData>(string, out PassData, ProfilingSampler)

    Add a new Raster Render Pass to the Render Graph. Raster passes can execute rasterization workloads but cannot do other GPU work like copies or compute.

    Declaration
    public IRasterRenderGraphBuilder AddRasterRenderPass<PassData>(string passName, out PassData passData, ProfilingSampler sampler)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    ProfilingSampler sampler

    Profiling sampler used around the pass.

    Returns
    Type Description
    IRasterRenderGraphBuilder

    A new instance of a IRasterRenderGraphBuilder used to setup the new Rasterization Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddRenderPass<PassData>(string, out PassData)

    Add a new Render Pass to the Render Graph.

    Declaration
    public RenderGraphBuilder AddRenderPass<PassData>(string passName, out PassData passData)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    Returns
    Type Description
    RenderGraphBuilder

    A new instance of a RenderGraphBuilder used to setup the new Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddRenderPass<PassData>(string, out PassData, ProfilingSampler)

    Add a new Render Pass to the Render Graph.

    Declaration
    public RenderGraphBuilder AddRenderPass<PassData>(string passName, out PassData passData, ProfilingSampler sampler)
    Parameters
    Type Name Description
    string passName

    Name of the new Render Pass (this is also be used to generate a GPU profiling marker).

    PassData passData

    Instance of PassData that is passed to the render function and you must fill.

    ProfilingSampler sampler

    Profiling sampler used around the pass.

    Returns
    Type Description
    RenderGraphBuilder

    A new instance of a RenderGraphBuilder used to setup the new Render Pass.

    Type Parameters
    Name Description
    PassData

    Type of the class to use to provide data to the Render Pass.

    AddResolvePass(TextureHandle, TextureHandle)

    Add a new Render Pass to the Render Graph that resolves the source texture into the destination texture. Note this is a special pass that depending on the GPU configuration might be "semi-free" and not execute any additional GPU commands. It is highly recommended to use resolve passes instead of making small passes that for example do commandBuffer.ResolveAntiAliasedSurface If the source and destination texture are both non MSAA this is equivalent to a move (see AddMovePass).

    Declaration
    public void AddResolvePass(TextureHandle source, TextureHandle destination)
    Parameters
    Type Name Description
    TextureHandle source

    Texture to read data from.

    TextureHandle destination

    Texture to copy data into.

    BeginProfilingSampler(ProfilingSampler, string, int)

    Begin a profiling scope.

    Declaration
    public void BeginProfilingSampler(ProfilingSampler sampler, string file = "", int line = 0)
    Parameters
    Type Name Description
    ProfilingSampler sampler

    Sampler used for profiling.

    string file

    File name of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.

    int line

    File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.

    Cleanup()

    Cleanup the Render Graph.

    Declaration
    public void Cleanup()

    CreateBuffer(in BufferDesc)

    Create a new Render Graph Graphics Buffer resource.

    Declaration
    public BufferHandle CreateBuffer(in BufferDesc desc)
    Parameters
    Type Name Description
    BufferDesc desc

    Graphics Buffer descriptor.

    Returns
    Type Description
    BufferHandle

    A new GraphicsBufferHandle.

    CreateBuffer(in BufferHandle)

    Create a new Render Graph Graphics Buffer resource using the descriptor from another graphics buffer.

    Declaration
    public BufferHandle CreateBuffer(in BufferHandle graphicsBuffer)
    Parameters
    Type Name Description
    BufferHandle graphicsBuffer

    Graphics Buffer from which the descriptor should be used.

    Returns
    Type Description
    BufferHandle

    A new GraphicsBufferHandle.

    CreateGizmoRendererList(in Camera, in GizmoSubset)

    Creates a new Gizmo Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateGizmoRendererList(in Camera camera, in GizmoSubset gizmoSubset)
    Parameters
    Type Name Description
    Camera camera

    The camera that is used for rendering the Gizmo.

    GizmoSubset gizmoSubset

    GizmoSubset that specifies whether gizmos render before or after postprocessing for a camera render.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    CreateRendererList(in RendererListParams)

    Creates a new Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateRendererList(in RendererListParams desc)
    Parameters
    Type Name Description
    RendererListParams desc

    Renderer List descriptor.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    CreateRendererList(in RendererListDesc)

    Creates a new Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateRendererList(in RendererListDesc desc)
    Parameters
    Type Name Description
    RendererListDesc desc

    Renderer List descriptor.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    CreateShadowRendererList(ref ShadowDrawingSettings)

    Creates a new Shadow Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateShadowRendererList(ref ShadowDrawingSettings shadowDrawingSettings)
    Parameters
    Type Name Description
    ShadowDrawingSettings shadowDrawingSettings

    DrawSettings that describe the shadow drawcall.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    CreateSharedTexture(in TextureDesc, bool)

    Create a new Render Graph Shared Texture resource. This texture will be persistent across render graph executions.

    Declaration
    public TextureHandle CreateSharedTexture(in TextureDesc desc, bool explicitRelease = false)
    Parameters
    Type Name Description
    TextureDesc desc

    Creation descriptor of the texture.

    bool explicitRelease

    Set to true if you want to manage the lifetime of the resource yourself. Otherwise the resource will be released automatically if unused for a time.

    Returns
    Type Description
    TextureHandle

    A new TextureHandle.

    CreateTexture(in TextureDesc)

    Create a new Render Graph Texture resource.

    Declaration
    public TextureHandle CreateTexture(in TextureDesc desc)
    Parameters
    Type Name Description
    TextureDesc desc

    Texture descriptor.

    Returns
    Type Description
    TextureHandle

    A new TextureHandle.

    CreateTexture(TextureHandle)

    Create a new Render Graph Texture resource using the descriptor from another texture.

    Declaration
    public TextureHandle CreateTexture(TextureHandle texture)
    Parameters
    Type Name Description
    TextureHandle texture

    Texture from which the descriptor should be used.

    Returns
    Type Description
    TextureHandle

    A new TextureHandle.

    CreateTextureIfInvalid(in TextureDesc, ref TextureHandle)

    Create a new Render Graph Texture if the passed handle is invalid and use said handle as output. If the passed handle is valid, no texture is created.

    Declaration
    public void CreateTextureIfInvalid(in TextureDesc desc, ref TextureHandle texture)
    Parameters
    Type Name Description
    TextureDesc desc

    Desc used to create the texture.

    TextureHandle texture

    Texture from which the descriptor should be used.

    CreateUIOverlayRendererList(in Camera)

    Creates a new UIOverlay Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateUIOverlayRendererList(in Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The camera that is used for rendering the UIOverlay.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    CreateWireOverlayRendererList(in Camera)

    Creates a new WireOverlay Renderer List Render Graph resource.

    Declaration
    public RendererListHandle CreateWireOverlayRendererList(in Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The camera that is used for rendering the WireOverlay.

    Returns
    Type Description
    RendererListHandle

    A new RendererListHandle.

    EndFrame()

    End frame processing. Purge resources that have been used since last frame and resets internal states. This need to be called once per frame.

    Declaration
    public void EndFrame()

    EndProfilingSampler(ProfilingSampler, string, int)

    End a profiling scope.

    Declaration
    public void EndProfilingSampler(ProfilingSampler sampler, string file = "", int line = 0)
    Parameters
    Type Name Description
    ProfilingSampler sampler

    Sampler used for profiling.

    string file

    File name of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.

    int line

    File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.

    GetBufferDesc(in BufferHandle)

    Gets the descriptor of the specified Graphics Buffer resource.

    Declaration
    public BufferDesc GetBufferDesc(in BufferHandle graphicsBuffer)
    Parameters
    Type Name Description
    BufferHandle graphicsBuffer

    Graphics Buffer resource from which the descriptor is requested.

    Returns
    Type Description
    BufferDesc

    The input graphics buffer descriptor.

    GetRegisteredRenderGraphs()

    Get the list of all registered render graphs.

    Declaration
    public static List<RenderGraph> GetRegisteredRenderGraphs()
    Returns
    Type Description
    List<RenderGraph>

    The list of all registered render graphs.

    GetTextureDesc(TextureHandle)

    Gets the descriptor of the specified Texture resource.

    Declaration
    public TextureDesc GetTextureDesc(TextureHandle texture)
    Parameters
    Type Name Description
    TextureHandle texture

    Texture resource from which the descriptor is requested.

    Returns
    Type Description
    TextureDesc

    The input texture descriptor.

    ImportBackbuffer(RenderTargetIdentifier)

    Import the final backbuffer to render graph.

    Declaration
    public TextureHandle ImportBackbuffer(RenderTargetIdentifier rt)
    Parameters
    Type Name Description
    RenderTargetIdentifier rt

    Backbuffer render target identifier.

    Returns
    Type Description
    TextureHandle

    A new TextureHandle for the backbuffer.

    ImportBackbuffer(RenderTargetIdentifier, RenderTargetInfo, ImportResourceParams)

    Import the final backbuffer to render graph.

    Declaration
    public TextureHandle ImportBackbuffer(RenderTargetIdentifier rt, RenderTargetInfo info, ImportResourceParams importParams = default)
    Parameters
    Type Name Description
    RenderTargetIdentifier rt

    Backbuffer render target identifier.

    RenderTargetInfo info
    ImportResourceParams importParams
    Returns
    Type Description
    TextureHandle

    A new TextureHandle for the backbuffer.

    ImportBuffer(GraphicsBuffer, bool)

    Import an external Graphics Buffer to the Render Graph. Any pass writing to an imported graphics buffer will be considered having side effects and can't be automatically culled.

    Declaration
    public BufferHandle ImportBuffer(GraphicsBuffer graphicsBuffer, bool forceRelease = false)
    Parameters
    Type Name Description
    GraphicsBuffer graphicsBuffer

    External Graphics Buffer that needs to be imported.

    bool forceRelease

    The imported graphics buffer will be released after usage.

    Returns
    Type Description
    BufferHandle

    A new GraphicsBufferHandle.

    ImportRayTracingAccelerationStructure(in RayTracingAccelerationStructure, string)

    Import an external RayTracingAccelerationStructure to the Render Graph. Any pass writing to (building) an imported RayTracingAccelerationStructure will be considered having side effects and can't be automatically culled.

    Declaration
    public RayTracingAccelerationStructureHandle ImportRayTracingAccelerationStructure(in RayTracingAccelerationStructure accelStruct, string name = null)
    Parameters
    Type Name Description
    RayTracingAccelerationStructure accelStruct

    External RayTracingAccelerationStructure that needs to be imported.

    string name

    Optional name for identifying the RayTracingAccelerationStructure in the Render Graph.

    Returns
    Type Description
    RayTracingAccelerationStructureHandle

    A new RayTracingAccelerationStructureHandle.

    ImportTexture(RTHandle)

    Import an external texture to the Render Graph. Any pass writing to an imported texture will be considered having side effects and can't be automatically culled.

    Declaration
    public TextureHandle ImportTexture(RTHandle rt)
    Parameters
    Type Name Description
    RTHandle rt

    External RTHandle that needs to be imported.

    Returns
    Type Description
    TextureHandle

    A new TextureHandle.

    ImportTexture(RTHandle, ImportResourceParams)

    Declaration
    public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParams)
    Parameters
    Type Name Description
    RTHandle rt
    ImportResourceParams importParams
    Returns
    Type Description
    TextureHandle

    ImportTexture(RTHandle, RenderTargetInfo, ImportResourceParams)

    Declaration
    public TextureHandle ImportTexture(RTHandle rt, RenderTargetInfo info, ImportResourceParams importParams = default)
    Parameters
    Type Name Description
    RTHandle rt
    RenderTargetInfo info
    ImportResourceParams importParams
    Returns
    Type Description
    TextureHandle

    RecordAndExecute(in RenderGraphParameters)

    Starts the recording of the the render graph and then automatically execute when the return value goes out of scope. This must be called before adding any pass to the render graph.

    Declaration
    public RenderGraphExecution RecordAndExecute(in RenderGraphParameters parameters)
    Parameters
    Type Name Description
    RenderGraphParameters parameters

    Parameters necessary for the render graph execution.

    Returns
    Type Description
    RenderGraphExecution

    RenderGraphExecution

    Examples

    This shows how to increment an integer.

    using (renderGraph.RecordAndExecute(parameters))
    {
        // Add your render graph passes here.
    }
    See Also
    RenderGraphExecution

    RefreshSharedTextureDesc(TextureHandle, in TextureDesc)

    Refresh a shared texture with a new descriptor.

    Declaration
    public void RefreshSharedTextureDesc(TextureHandle handle, in TextureDesc desc)
    Parameters
    Type Name Description
    TextureHandle handle

    Shared texture that needs to be updated.

    TextureDesc desc

    New Descriptor for the texture.

    RegisterDebug(Panel)

    Register the render graph to the debug window.

    Declaration
    public void RegisterDebug(DebugUI.Panel panel = null)
    Parameters
    Type Name Description
    DebugUI.Panel panel

    ReleaseSharedTexture(TextureHandle)

    Release a Render Graph shared texture resource.

    Declaration
    public void ReleaseSharedTexture(TextureHandle texture)
    Parameters
    Type Name Description
    TextureHandle texture

    The handle to the texture that needs to be release.

    UnRegisterDebug()

    Unregister render graph from the debug window.

    Declaration
    public void UnRegisterDebug()

    Extension Methods

    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)