RenderGraph Serializable Resource Descriptors
May 16, 2026 ยท View on GitHub
Overview
VividRP's RenderGraph now includes serializable resource descriptor classes that mirror Unity's TextureDesc, BufferDesc, and RayTracingAccelerationStructureDesc but can be fully serialized in assets. This allows pass nodes to define resource properties declaratively.
Core Classes
RenderGraphTextureDesc
Location: Runtime/RenderGraph/Resource/RenderGraphTextureDesc.cs
Serializable texture descriptor with full support for:
- Dimensions (width, height, slices, dimension)
- Format (color format, depth bits)
- Sampling (MSAA, filter mode, wrap mode, aniso level, mip bias)
- Mip maps (enable, auto-generate, count)
- Clear settings (clear buffer, clear color)
- Flags (random write, bind MS, dynamic scale)
- Metadata (name, fallback texture)
Key Methods:
ToTextureDesc()- Converts to Unity'sTextureDescFromTextureDesc(TextureDesc)- Creates from Unity's descriptorCreateColorTarget(width, height, format)- Factory for color targetsCreateDepthTarget(width, height, depthBits)- Factory for depth targets
RenderGraphBufferDesc
Location: Runtime/RenderGraph/Resource/RenderGraphBufferDesc.cs
Serializable buffer descriptor with support for:
- Count and stride
- Buffer target type (Default, Structured, Append, IndirectArguments, etc.)
- Name metadata
Key Methods:
ToBufferDesc()- Converts to Unity'sBufferDescFromBufferDesc(BufferDesc)- Creates from Unity's descriptorCreateStructured(count, stride)- Factory for structured buffersCreateAppend(count, stride)- Factory for append/consume buffersCreateIndirectArguments(count)- Factory for indirect args buffers
RenderGraphAccelerationStructureDesc
Location: Runtime/RenderGraph/Resource/RenderGraphAccelerationStructureDesc.cs
Serializable acceleration structure descriptor for ray tracing:
- Name metadata for debugging and profiling
Key Methods:
ToAccelerationStructureDesc()- Converts to Unity'sRayTracingAccelerationStructureDescFromAccelerationStructureDesc(RayTracingAccelerationStructureDesc)- Creates from Unity's descriptorCreate(name)- Factory for acceleration structures
Port Integration
RenderGraphPortData
Location: Runtime/RenderGraph/Data/RenderGraphPortData.cs
Ports now optionally store resource descriptors:
TextureDesc- For texture portsBufferDesc- For buffer portsAccelerationStructureDesc- For acceleration structure ports (ray tracing)
Key Methods:
GetDescriptor()- Returns the appropriate descriptor based on port typeSetDescriptor(object)- Sets the descriptor and clears the other type
Node Updates
All resource and pass nodes have been updated to use the new descriptor system:
Resource Nodes
TextureNodeData
- Now uses
RenderGraphTextureDescinstead of individual fields - Descriptor is initialized with
CreateColorTarget(1920, 1080) - Port stores reference to the descriptor
BufferNodeData
- Now uses
RenderGraphBufferDescinstead of Count/Stride fields - Descriptor is initialized with
CreateStructured(1, 4) - Port stores reference to the descriptor
HistoryTextureNodeData
- Uses
RenderGraphTextureDescwithTextureSizeModesupport - Both Current and History ports reference the same descriptor
- Resolves size based on camera or explicit dimensions
HistoryBufferNodeData
- Uses
RenderGraphBufferDesc - Both Current and History ports reference the same descriptor
Pass Nodes
FullScreenPassNodeData
- Now uses
RenderGraphTextureDescfor output texture - Descriptor is initialized with
CreateColorTarget(1920, 1080) - Output port stores reference to the descriptor
RasterPassNodeData
- Uses data-driven approach with reflection-based compilation
- Creates transient attachments using existing serialized fields
- Can be extended to use descriptors per-attachment in the future
Ray Tracing Support
VividRP now includes full support for ray tracing acceleration structures through the descriptor system.
- Authoring RTAS Resources -
Editor/RenderGraph/Nodes/AccelerationStructureResourceNodeData.csexposes RTAS descriptors in the graph editor - Building Scene RTAS -
Runtime/RenderPass/Core/RTASBuildPass.csbuilds a scene RTAS into a RenderGraph resource - Passing RTAS Between Passes - downstream passes can consume
RenderGraphAccelerationStructurefields through explicit graph edges
Ray Tracing Usage Example
// Producer pass
[RenderGraphResource(Name = "SceneRTAS", Access = AccessFlags.Write)]
private RenderGraphAccelerationStructure m_SceneAccelerationStructure = new();
// Consumer pass
[RenderGraphResource(Name = "SceneRTAS", Access = AccessFlags.Read)]
private RenderGraphAccelerationStructure m_SceneAccelerationStructure = new();
Benefits
- Declarative Configuration - Resource properties are defined in the asset, not hardcoded
- Editor Integration - Descriptors can be exposed in custom inspectors for visual editing
- Reusability - Descriptors can be shared between ports and nodes
- Type Safety - Compile-time checking of descriptor properties
- Extensibility - Easy to add new descriptor types for future resource types
- Serialization - Full Unity serialization support with
[SerializeReference] - Ray Tracing Ready - First-class support for acceleration structures
Usage Example
// Create a texture node with custom descriptor
var textureNode = new TextureNodeData();
textureNode.TextureDesc = RenderGraphTextureDesc.CreateColorTarget(2048, 2048, GraphicsFormat.R16G16B16A16_SFloat);
textureNode.TextureDesc.UseMipMap = true;
textureNode.TextureDesc.AutoGenerateMips = true;
// Create a buffer node with custom descriptor
var bufferNode = new BufferNodeData();
bufferNode.BufferDesc = RenderGraphBufferDesc.CreateStructured(1024, 16);
bufferNode.BufferDesc.Target = GraphicsBuffer.Target.Append;
// Create an acceleration structure descriptor
var accelStructDesc = RenderGraphAccelerationStructureDesc.Create("MyAccelerationStructure");
// Access descriptor from port
var port = textureNode.Ports[0];
var desc = port.TextureDesc; // Returns RenderGraphTextureDesc
Pass Bypass
Passes that produce a replacement texture or buffer can declare a zero-GPU bypass path for disabled frames:
[RenderGraphResource(Access = AccessFlags.Read)]
private RenderGraphTexture m_Source = new();
[RenderGraphResource(Access = AccessFlags.Write)]
[PassBypass(nameof(m_Source))]
private RenderGraphTexture m_Output = new();
public override bool IsActive(ContextContainer frameData)
{
return MySettings.Resolve(frameData).enabled;
}
When IsActive returns false, PassRecorder skips the RenderGraph builder for that pass and forwards the output handle to the source handle. The PassBypass argument must be the C# field name, not the RenderGraphResource.Name display name. V1 supports RenderGraphTexture and RenderGraphBuffer fields only; source and output fields must use the same type, source must be readable, and output must be writable.
StopNaNPass follows this model: it is no longer injected by PassRecorder; add it explicitly to a .vrdg graph and wire its output downstream. When the camera Stop NaNs option is off, its output is forwarded to its input without recording GPU work.
ReadWrite resources do not need PassBypass: because the input and output are the same field, skipping an inactive pass naturally leaves the existing handle available for downstream readers.
Future Enhancements
- Editor UI - Custom property drawers for descriptors in the graph editor
- Descriptor Presets - Library of common descriptor configurations
- Validation - Runtime validation of descriptor properties
- Per-Attachment Descriptors - RasterPassNodeData could use descriptors per color/depth attachment
- Descriptor Inheritance - Ports could inherit descriptors from connected ports
- Ray Tracing Node - Dedicated node type for ray tracing passes with RTAS inputs