diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs index 745b8af22a4..3f6d77e436d 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs @@ -23,18 +23,18 @@ public struct TextureHandle internal TextureHandle(int handle, bool shared = false) { this.handle = new ResourceHandle(handle, RenderGraphResourceType.Texture, shared); } /// - /// Cast to RTHandle + /// Cast to RenderTargetIdentifier /// /// Input TextureHandle. - /// Resource as a RTHandle. - public static implicit operator RTHandle(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null; + /// Resource as a RenderTargetIdentifier. + public static implicit operator RenderTargetIdentifier(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : default(RenderTargetIdentifier); /// - /// Cast to RenderTargetIdentifier + /// Cast to Texture /// /// Input TextureHandle. - /// Resource as a RenderTargetIdentifier. - public static implicit operator RenderTargetIdentifier(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : default(RenderTargetIdentifier); + /// Resource as a Texture. + public static implicit operator Texture(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null; /// /// Cast to RenderTexture @@ -43,6 +43,13 @@ public struct TextureHandle /// Resource as a RenderTexture. public static implicit operator RenderTexture(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null; + /// + /// Cast to RTHandle + /// + /// Input TextureHandle. + /// Resource as a RTHandle. + public static implicit operator RTHandle(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null; + /// /// Return true if the handle is valid. /// diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs index 2fa06156a81..e06218a8585 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs @@ -62,18 +62,13 @@ internal RTHandle(RTHandleSystem owner) } /// - /// Implicit conversion operator to RenderTexture + /// Implicit conversion operator to RenderTargetIdentifier /// /// Input RTHandle - /// RenderTexture representation of the RTHandle. - public static implicit operator RenderTexture(RTHandle handle) + /// RenderTargetIdentifier representation of the RTHandle. + public static implicit operator RenderTargetIdentifier(RTHandle handle) { - // If RTHandle is null then conversion should give a null RenderTexture - if (handle == null) - return null; - - Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture"); - return handle.rt; + return handle != null ? handle.nameID : default(RenderTargetIdentifier); } /// @@ -92,13 +87,18 @@ public static implicit operator Texture(RTHandle handle) } /// - /// Implicit conversion operator to RenderTargetIdentifier + /// Implicit conversion operator to RenderTexture /// /// Input RTHandle - /// RenderTargetIdentifier representation of the RTHandle. - public static implicit operator RenderTargetIdentifier(RTHandle handle) + /// RenderTexture representation of the RTHandle. + public static implicit operator RenderTexture(RTHandle handle) { - return handle != null ? handle.nameID : default(RenderTargetIdentifier); + // If RTHandle is null then conversion should give a null RenderTexture + if (handle == null) + return null; + + Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture"); + return handle.rt; } internal void SetRenderTexture(RenderTexture rt)