Interface IRenderAttachmentRenderGraphBuilder
An intermediary interface for builders that can set render attachments and random access attachments (UAV).
Inherited Members
Namespace: UnityEngine.Rendering.RenderGraphModule
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public interface IRenderAttachmentRenderGraphBuilder : IBaseRenderGraphBuilder, IDisposable
Methods
SetRandomAccessAttachment(TextureHandle, int, AccessFlags)
Binds the texture as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Image).
Declaration
TextureHandle SetRandomAccessAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.ReadWrite)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureHandle | tex | The texture to expose as a UAV in this pass. |
| int | index | The binding slot the shader uses to access this UAV (HLSL: |
| AccessFlags | flags | Access mode for this texture in the pass. Defaults to |
Returns
| Type | Description |
|---|---|
| TextureHandle | This declares that shaders in the pass will access the texture via
The value passed to the |
Remarks
Random-access (UAV) textures share index-based binding slots with
render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget
for platform-specific details and constraints.
SetRenderAttachment(TextureHandle, int, AccessFlags)
Binds the texture as a color render target (MRT attachment) for this pass.
Declaration
void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.Write)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureHandle | tex | The texture to bind as a render target for this pass. |
| int | index | The MRT slot the shader writes to. This maps to |
| AccessFlags | flags | The access mode for the texture. The default value is |
Remarks
Potential access flags:
- Write: This pass outputs to the texture using render target rasterization. The render graph binds
the texture to the specified MRT slot (index). In HLSL, write to the slot using
float4 outColor : SV_Target{index} = value;. To use random-access writes, useSetRandomAccessAttachment(UAV). Don't write to this target with UAV-style indexed access (operator[]). - Read: This pass might read the current contents of the render target implicitly, depending on rasterization state (for example, blending operations that read before writing).
The render graph can't determine how much of the target you overwrite. By default, it
assumes partial updates and preserves existing content. If you fully overwrite the target
(for example, in a fullscreen pass), use AccessFlags.WriteAll for better performance.
SetRenderAttachment(TextureHandle, int, AccessFlags, int, int)
Binds the texture as a color render target (MRT attachment) for this pass.
Declaration
void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags, int mipLevel, int depthSlice)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureHandle | tex | The texture to bind as a render target for this pass. |
| int | index | The MRT slot the shader writes to (corresponds to |
| AccessFlags | flags | How this pass accesses the texture. Defaults to |
| int | mipLevel | The mip level to bind. |
| int | depthSlice | The array slice to bind. Use -1 to bind all slices. |
Remarks
Potential access flags:
- Write: This pass outputs to the texture using render target rasterization. The render graph binds
the texture to the specified MRT slot (index). In HLSL, write to the slot using
float4 outColor : SV_Target{index} = value;. To use random-access writes, useSetRandomAccessAttachment(UAV). Don't write to this target with UAV-style indexed access (operator[]). - Read: This pass might read the current contents of the render target implicitly, depending on rasterization state (for example, blending operations that read before writing).
The render graph can't determine how much of the target you overwrite. By default, it
assumes partial updates and preserves existing content. If you fully overwrite the target
(for example, in a fullscreen pass), use AccessFlags.WriteAll for better performance.
Using the same texture handle with different depth slices at different render target indices is not supported.
SetRenderAttachmentDepth(TextureHandle, AccessFlags)
Binds the texture as the depth buffer for this pass.
Declaration
void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags = AccessFlags.ReadWrite)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureHandle | tex | The texture to use as the depth buffer for this pass. |
| AccessFlags | flags | Access mode for the texture in this pass. Defaults to |
Remarks
Potential access flags:
- Write: The pass writes fragment depth to the bound depth buffer (required if
ZWriteis enabled in shader code). - Read: The pass reads from the bound depth buffer for depth testing (required if
ZTestis set to an operation other thanDisabled,Never, orAlwaysin shader code).
Only one depth buffer can be tested against or written to in a single pass.
To output depth to multiple textures, register the additional texture as a color
attachment using SetRenderAttachment(), then compute and write the depth value in the shader.
If you call SetRenderAttachmentDepth() more than once on the same builder, it results in an error.
SetRenderAttachmentDepth(TextureHandle, AccessFlags, int, int)
Binds the texture as the depth buffer for this pass.
Declaration
void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags, int mipLevel, int depthSlice)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureHandle | tex | The texture to use as the depth buffer for this pass. |
| AccessFlags | flags | How this pass will access the depth texture (for example, |
| int | mipLevel | The mip level to bind. |
| int | depthSlice | The array slice to bind. Use -1 to bind all slices. |
Remarks
Potential access flags:
- Write: The pass writes fragment depth to the bound depth buffer (required if
ZWriteis enabled in shader code). - Read: The pass reads from the bound depth buffer for depth testing (required if
ZTestis set to an operation other thanDisabled,Never, orAlwaysin shader code).
Only one depth texture can be read from or written to in a single pass.
To output depth to multiple textures, register the additional texture as a color
attachment using SetRenderAttachment(), then compute and write the depth value in the shader.
If you call SetRenderAttachmentDepth() more than once on the same builder, it results in an error.
Using the same texture handle with different depth slices at different render target indices is not supported.
UseBufferRandomAccess(BufferHandle, int, bool, AccessFlags)
Binds the buffer as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Buffer).
Declaration
BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, bool preserveCounterValue, AccessFlags flags = AccessFlags.Read)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferHandle | tex | The buffer to expose as a UAV in this pass. |
| int | index | The binding slot the shader uses to access this UAV (HLSL: |
| bool | preserveCounterValue | Whether to keep the current append/consume counter unchanged for this UAV buffer. Defaults to preserving the existing counter value. |
| AccessFlags | flags | Access mode for this buffer in the pass. Defaults to |
Returns
| Type | Description |
|---|---|
| BufferHandle | The value passed to the |
Remarks
This declares that shaders in the pass will access the buffer via
RWStructuredBuffer, RWByteAddressBuffer, etc., enabling read/write,
atomics, and other UAV-style operations using standard HLSL.
Random-access (UAV) buffers share index-based binding slots with
render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget
for platform-specific details and constraints.
UseBufferRandomAccess(BufferHandle, int, AccessFlags)
Binds the buffer as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Buffer).
Declaration
BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, AccessFlags flags = AccessFlags.Read)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferHandle | tex | The buffer to expose as a UAV in this pass. |
| int | index | The binding slot the shader uses to access this UAV (HLSL: |
| AccessFlags | flags | Access mode for this buffer in the pass. Defaults to |
Returns
| Type | Description |
|---|---|
| BufferHandle | The value passed to the |
Remarks
This declares that shaders in the pass will access the buffer via
RWStructuredBuffer, RWByteAddressBuffer, etc., enabling read/write,
atomics, and other UAV-style operations using standard HLSL.
Random-access (UAV) buffers share index-based binding slots with
render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget
for platform-specific details and constraints.