Struct TextureHandle
An abstract handle representing a texture resource as known by one particular record + execute of the render graph. TextureHandles should not be used outside of the context of a render graph execution.
A render graph needs to do additional state tracking on texture resources (lifetime, how is it used,...) to enable this all textures relevant to the render graph need to be make known to it. A texture handle specifies such a texture as known to the render graph.
It is important to understand that a render graph texture handle does not necessarily represent an actual texture. For example textures could be created the render graph that are only referenced by passes that are later culled when executing the graph. Such textures would never be allocated as actual RenderTextures.
Texture handles are only relevant to one particular record+execute phase of the render graph. After execution all texture handles are invalidated. The system will catch texture handles from a different execution of the render graph but still users should be careful to avoid keeping texture handles around from other render graph executions.
Texture handles do not need to be disposed/freed (they are auto-invalidated at the end of graph execution). The RenderTextures they represent are either freed by the render graph internally (when the handle was acquired through RenderGraph.CreateTexture) or explicitly managed by some external system (when acquired through RenderGraph.ImportTexture).
Inherited Members
Namespace: UnityEngine.Rendering.RenderGraphModule
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
[MovedFrom(true, "UnityEngine.Experimental.Rendering.RenderGraphModule", "UnityEngine.Rendering.RenderGraphModule", null)]
public struct TextureHandle
Properties
nullHandle
Returns a null texture handle
Declaration
public static TextureHandle nullHandle { get; }
Property Value
Type | Description |
---|---|
TextureHandle | A null texture handle. |
Methods
GetDescriptor(RenderGraph)
Get the Descriptor of the texture. This simply calls RenderGraph.GetTextureDesc but is more easily discoverable through auto complete.
Declaration
public TextureDesc GetDescriptor(RenderGraph renderGraph)
Parameters
Type | Name | Description |
---|---|---|
RenderGraph | renderGraph | The rendergraph instance that was used to create the texture on. Texture handles are a lightweight object, all information is stored on the RenderGraph itself. |
Returns
Type | Description |
---|---|
TextureDesc | The texture descriptor for the given texture handle. |
IsValid()
Return true if the handle is valid.
Declaration
public bool IsValid()
Returns
Type | Description |
---|---|
bool | True if the handle is valid. |
Operators
implicit operator RenderTexture(TextureHandle)
Cast to RenderTexture
Declaration
public static implicit operator RenderTexture(TextureHandle texture)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | texture | Input TextureHandle. |
Returns
Type | Description |
---|---|
RenderTexture | Resource as a RenderTexture. |
implicit operator RTHandle(TextureHandle)
Cast to RTHandle
Declaration
public static implicit operator RTHandle(TextureHandle texture)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | texture | Input TextureHandle. |
Returns
Type | Description |
---|---|
RTHandle | Resource as a RTHandle. |
implicit operator RenderTargetIdentifier(TextureHandle)
Cast to RenderTargetIdentifier
Declaration
public static implicit operator RenderTargetIdentifier(TextureHandle texture)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | texture | Input TextureHandle. |
Returns
Type | Description |
---|---|
RenderTargetIdentifier | Resource as a RenderTargetIdentifier. |
implicit operator Texture(TextureHandle)
Cast to Texture
Declaration
public static implicit operator Texture(TextureHandle texture)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | texture | Input TextureHandle. |
Returns
Type | Description |
---|---|
Texture | Resource as a Texture. |