docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IRenderAttachmentRenderGraphBuilder

    An intermediary interface for builders that can set render attachments and random access attachments (UAV).

    Inherited Members
    IBaseRenderGraphBuilder.UseTexture(in TextureHandle, AccessFlags)
    IBaseRenderGraphBuilder.UseGlobalTexture(int, AccessFlags)
    IBaseRenderGraphBuilder.UseAllGlobalTextures(bool)
    IBaseRenderGraphBuilder.SetGlobalTextureAfterPass(in TextureHandle, int)
    IBaseRenderGraphBuilder.UseBuffer(in BufferHandle, AccessFlags)
    IBaseRenderGraphBuilder.CreateTransientTexture(in TextureDesc)
    IBaseRenderGraphBuilder.CreateTransientTexture(in TextureHandle)
    IBaseRenderGraphBuilder.CreateTransientBuffer(in BufferDesc)
    IBaseRenderGraphBuilder.CreateTransientBuffer(in BufferHandle)
    IBaseRenderGraphBuilder.UseRendererList(in RendererListHandle)
    IBaseRenderGraphBuilder.EnableAsyncCompute(bool)
    IBaseRenderGraphBuilder.AllowPassCulling(bool)
    IBaseRenderGraphBuilder.AllowGlobalStateModification(bool)
    IBaseRenderGraphBuilder.EnableFoveatedRasterization(bool)
    IBaseRenderGraphBuilder.GenerateDebugData(bool)
    IDisposable.Dispose()
    Namespace: UnityEngine.Rendering.RenderGraphModule
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public interface IRenderAttachmentRenderGraphBuilder : IBaseRenderGraphBuilder, IDisposable

    Methods

    SetRandomAccessAttachment(TextureHandle, int, AccessFlags)

    Use the texture as an random access attachment. This is called "Unordered Access View" in DX12 and "Storage Image" in Vulkan.

    This informs the graph that any shaders in the pass will access the texture as a random access attachment through RWTexture2d<T>, RWTexture3d<T>,... The texture can then be read/written by regular HLSL commands (including atomics, etc.).

    As in other parts of the Unity graphics APIs random access textures share the index-based slots with render targets and input attachments (if any). See CommandBuffer.SetRandomWriteTarget for details.

    Declaration
    TextureHandle SetRandomAccessAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.ReadWrite)
    Parameters
    Type Name Description
    TextureHandle tex

    Texture to use during this pass.

    int index

    Index the shader will use to access this texture. This is set in the shader through the register(ux) keyword.

    AccessFlags flags

    How this pass will access the texture. Default value is set to AccessFlag.ReadWrite.

    Returns
    Type Description
    TextureHandle

    The value passed to 'input'. You should not use the returned value it will be removed in the future.

    SetRenderAttachment(TextureHandle, int, AccessFlags)

    Use the texture as an rendertarget attachment.

    Writing: Indicate this pass will write a texture through rendertarget rasterization writes. The graph will automatically bind the texture as an MRT output on the indicated index slot. Write in shader as float4 out : SV_Target = value; This texture always needs to be written as an render target (SV_Targetx) writing using other methods (like operator[] = ) may not work even if using the current fragment+sampleIdx pos. When using operator[] please use the UseTexture function instead. Reading: Indicates this pass will read a texture on the current fragment position but not unnecessarily modify it. Although not explicitly visible in shader code Reading may happen depending on the rasterization state, e.g. Blending (read and write) or Z-Testing (read only) may read the buffer.

    Note: The rendergraph does not know what content will be rendered in the bound texture. By default it assumes only partial data is written (e.g. a small rectangle is drawn on the screen) so it will preserve the existing rendertarget content (e.g. behind/around the triangle) if you know you will write the full screen the AccessFlags.WriteAll should be used instead as it will give better performance.

    Declaration
    void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.Write)
    Parameters
    Type Name Description
    TextureHandle tex

    Texture to use during this pass.

    int index

    Index the shader will use to access this texture.

    AccessFlags flags

    How this pass will access the texture. Default value is set to AccessFlag.Write

    SetRenderAttachment(TextureHandle, int, AccessFlags, int, int)

    Use the texture as an rendertarget attachment.

    Writing: Indicate this pass will write a texture through rendertarget rasterization writes. The graph will automatically bind the texture as an MRT output on the indicated index slot. Write in shader as float4 out : SV_Target = value; This texture always needs to be written as an render target (SV_Targetx) writing using other methods (like operator[] = ) may not work even if using the current fragment+sampleIdx pos. When using operator[] please use the UseTexture function instead. Reading: Indicates this pass will read a texture on the current fragment position but not unnecessarily modify it. Although not explicitly visible in shader code Reading may happen depending on the rasterization state, e.g. Blending (read and write) or Z-Testing (read only) may read the buffer.

    Declaration
    void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags, int mipLevel, int depthSlice)
    Parameters
    Type Name Description
    TextureHandle tex

    Texture to use during this pass.

    int index

    Index the shader will use to access this texture.

    AccessFlags flags

    How this pass will access the texture.

    int mipLevel

    Selects which mip map to used.

    int depthSlice

    Used to index into a texture array. Use -1 to use bind all slices.

    Remarks

    Note: The rendergraph does not know what content will be rendered in the bound texture. By default it assumes only partial data is written (e.g. a small rectangle is drawn on the screen) so it will preserve the existing rendertarget content (e.g. behind/around the triangle) if you know you will write the full screen the AccessFlags.WriteAll should be used instead as it will give better performance.

    Note: Using same texture handle with different depth slices at different rendertarget indices is not supported.

    SetRenderAttachmentDepth(TextureHandle, AccessFlags)

    Use the texture as a depth buffer for the Z-Buffer hardware. Note you can only test-against and write-to a single depth texture in a pass. If you want to write depth to more than one texture you will need to register the second texture as SetRenderAttachment and manually calculate and write the depth value in the shader. Calling SetRenderAttachmentDepth twice on the same builder is an error. Write: Indicate a texture will be written with the current fragment depth by the ROPs (but not for depth reading (i.e. z-test == always)). Read: Indicate a texture will be used as an input for the depth testing unit.

    Declaration
    void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags = AccessFlags.Write)
    Parameters
    Type Name Description
    TextureHandle tex

    Texture to use during this pass.

    AccessFlags flags

    How this pass will access the texture. Default value is set to AccessFlag.Write

    SetRenderAttachmentDepth(TextureHandle, AccessFlags, int, int)

    Use the texture as a depth buffer for the Z-Buffer hardware. Note you can only test-against and write-to a single depth texture in a pass. If you want to write depth to more than one texture you will need to register the second texture as SetRenderAttachment and manually calculate and write the depth value in the shader. Calling SetRenderAttachmentDepth twice on the same builder is an error. Write: Indicate a texture will be written with the current fragment depth by the ROPs (but not for depth reading (i.e. z-test == always)). Read: Indicate a texture will be used as an input for the depth testing unit.

    Declaration
    void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags, int mipLevel, int depthSlice)
    Parameters
    Type Name Description
    TextureHandle tex

    Texture to use during this pass.

    AccessFlags flags

    How this pass will access the texture.

    int mipLevel

    Selects which mip map to used.

    int depthSlice

    Used to index into a texture array. Use -1 to use bind all slices.

    Remarks

    Using same texture handle with different depth slices at different rendertarget indices is not supported.

    UseBufferRandomAccess(BufferHandle, int, bool, AccessFlags)

    Use the buffer as an random access attachment. This is called "Unordered Access View" in DX12 and "Storage Buffer" in Vulkan.

    This informs the graph that any shaders in the pass will access the buffer as a random access attachment through RWStructuredBuffer, RWByteAddressBuffer,... The buffer can then be read/written by regular HLSL commands (including atomics, etc.).

    As in other parts of the Unity graphics APIs random access buffers share the index-based slots with render targets and input attachments (if any). See CommandBuffer.SetRandomWriteTarget for details.

    Declaration
    BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, bool preserveCounterValue, AccessFlags flags = AccessFlags.Read)
    Parameters
    Type Name Description
    BufferHandle tex

    Buffer to use during this pass.

    int index

    Index the shader will use to access this texture. This is set in the shader through the register(ux) keyword.

    bool preserveCounterValue

    Whether to leave the append/consume counter value unchanged. The default is to preserve the value.

    AccessFlags flags

    How this pass will access the buffer. Default value is set to AccessFlag.Read.

    Returns
    Type Description
    BufferHandle

    The value passed to 'input'. You should not use the returned value it will be removed in the future.

    UseBufferRandomAccess(BufferHandle, int, AccessFlags)

    Use the buffer as an random access attachment. This is called "Unordered Access View" in DX12 and "Storage Buffer" in Vulkan.

    This informs the graph that any shaders in the pass will access the buffer as a random access attachment through RWStructuredBuffer, RWByteAddressBuffer,... The buffer can then be read/written by regular HLSL commands (including atomics, etc.).

    As in other parts of the Unity graphics APIs random access buffers share the index-based slots with render targets and input attachments (if any). See CommandBuffer.SetRandomWriteTarget for details.

    Declaration
    BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, AccessFlags flags = AccessFlags.Read)
    Parameters
    Type Name Description
    BufferHandle tex

    Buffer to use during this pass.

    int index

    Index the shader will use to access this texture. This is set in the shader through the register(ux) keyword.

    AccessFlags flags

    How this pass will access the buffer. Default value is set to AccessFlag.Read.

    Returns
    Type Description
    BufferHandle

    The value passed to 'input'. You should not use the returned value it will be removed in the future.

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    In This Article
    Back to top
    Copyright © 2025 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)