From 22701fdd17df20552cf738528f1d4262723fe586 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Fri, 25 Aug 2023 16:13:40 +0200 Subject: [PATCH] Renamed RenderTargetView to ResourceView, which is a bit shorter to type and covers the essence well. --- Assets/Scripts/Core/Fsr2.cs | 30 +++++++++++++++--------------- Assets/Scripts/Core/Fsr2Context.cs | 12 ++++++------ Assets/Scripts/Fsr2ImageEffect.cs | 30 +++++++++++++++--------------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Assets/Scripts/Core/Fsr2.cs b/Assets/Scripts/Core/Fsr2.cs index 1da9ff2..1ba8192 100644 --- a/Assets/Scripts/Core/Fsr2.cs +++ b/Assets/Scripts/Core/Fsr2.cs @@ -166,21 +166,21 @@ namespace FidelityFX /// /// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader. /// - public readonly struct RenderTargetView + public readonly struct ResourceView { /// /// This value is the equivalent of not setting any value at all; all struct fields will have their default values. /// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader. /// - public static readonly RenderTargetView Unassigned = new RenderTargetView(default); + public static readonly ResourceView Unassigned = new ResourceView(default); /// /// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture. /// Binding this to a shader can be seen as setting the texture variable inside the shader to null. /// - public static readonly RenderTargetView None = new RenderTargetView(BuiltinRenderTextureType.None); + public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None); - public RenderTargetView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) + public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) { RenderTarget = renderTarget; SubElement = subElement; @@ -199,13 +199,13 @@ namespace FidelityFX /// public class DispatchDescription { - public RenderTargetView Color; - public RenderTargetView Depth; - public RenderTargetView MotionVectors; - public RenderTargetView Exposure; // optional - public RenderTargetView Reactive; // optional - public RenderTargetView TransparencyAndComposition; // optional - public RenderTargetView Output; + public ResourceView Color; + public ResourceView Depth; + public ResourceView MotionVectors; + public ResourceView Exposure; // optional + public ResourceView Reactive; // optional + public ResourceView TransparencyAndComposition; // optional + public ResourceView Output; public Vector2 JitterOffset; public Vector2 MotionVectorScale; public Vector2Int RenderSize; @@ -222,7 +222,7 @@ namespace FidelityFX // EXPERIMENTAL reactive mask generation parameters public bool EnableAutoReactive; - public RenderTargetView ColorOpaqueOnly; + public ResourceView ColorOpaqueOnly; public float AutoTcThreshold = 0.05f; public float AutoTcScale = 1.0f; public float AutoReactiveScale = 5.0f; @@ -235,9 +235,9 @@ namespace FidelityFX /// public class GenerateReactiveDescription { - public RenderTargetView ColorOpaqueOnly; - public RenderTargetView ColorPreUpscale; - public RenderTargetView OutReactive; + public ResourceView ColorOpaqueOnly; + public ResourceView ColorPreUpscale; + public ResourceView OutReactive; public Vector2Int RenderSize; public float Scale = 0.5f; public float CutoffThreshold = 0.2f; diff --git a/Assets/Scripts/Core/Fsr2Context.cs b/Assets/Scripts/Core/Fsr2Context.cs index 102b918..bb6c5de 100644 --- a/Assets/Scripts/Core/Fsr2Context.cs +++ b/Assets/Scripts/Core/Fsr2Context.cs @@ -158,9 +158,9 @@ namespace FidelityFX // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) - dispatchParams.Exposure = new Fsr2.RenderTargetView(_resources.AutoExposure); + dispatchParams.Exposure = new Fsr2.ResourceView(_resources.AutoExposure); else if (!dispatchParams.Exposure.IsValid) - dispatchParams.Exposure = new Fsr2.RenderTargetView(_resources.DefaultExposure); + dispatchParams.Exposure = new Fsr2.ResourceView(_resources.DefaultExposure); if (dispatchParams.EnableAutoReactive) { @@ -180,8 +180,8 @@ namespace FidelityFX _resources.DestroyTcrAutogenResources(); } - if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new Fsr2.RenderTargetView(_resources.DefaultReactive); - if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new Fsr2.RenderTargetView(_resources.DefaultReactive); + if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new Fsr2.ResourceView(_resources.DefaultReactive); + if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.DefaultReactive); Fsr2Resources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); SetupConstants(dispatchParams, resetAccumulation); @@ -225,8 +225,8 @@ namespace FidelityFX if (dispatchParams.EnableAutoReactive) { GenerateTransparencyCompositionReactive(dispatchParams, commandBuffer, frameIndex); - dispatchParams.Reactive = new Fsr2.RenderTargetView(_resources.AutoReactive); - dispatchParams.TransparencyAndComposition = new Fsr2.RenderTargetView(_resources.AutoComposition); + dispatchParams.Reactive = new Fsr2.ResourceView(_resources.AutoReactive); + dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.AutoComposition); } // Compute luminance pyramid diff --git a/Assets/Scripts/Fsr2ImageEffect.cs b/Assets/Scripts/Fsr2ImageEffect.cs index e67c364..4b4ac98 100644 --- a/Assets/Scripts/Fsr2ImageEffect.cs +++ b/Assets/Scripts/Fsr2ImageEffect.cs @@ -325,20 +325,20 @@ namespace FidelityFX private void SetupDispatchDescription() { // Set up the main FSR2 dispatch parameters - _dispatchDescription.Color = new Fsr2.RenderTargetView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); - _dispatchDescription.Depth = new Fsr2.RenderTargetView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); - _dispatchDescription.MotionVectors = new Fsr2.RenderTargetView(BuiltinRenderTextureType.MotionVectors); - _dispatchDescription.Exposure = Fsr2.RenderTargetView.Unassigned; - _dispatchDescription.Reactive = Fsr2.RenderTargetView.Unassigned; - _dispatchDescription.TransparencyAndComposition = Fsr2.RenderTargetView.Unassigned; + _dispatchDescription.Color = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); + _dispatchDescription.Depth = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); + _dispatchDescription.MotionVectors = new Fsr2.ResourceView(BuiltinRenderTextureType.MotionVectors); + _dispatchDescription.Exposure = Fsr2.ResourceView.Unassigned; + _dispatchDescription.Reactive = Fsr2.ResourceView.Unassigned; + _dispatchDescription.TransparencyAndComposition = Fsr2.ResourceView.Unassigned; - if (!enableAutoExposure && exposure != null) _dispatchDescription.Exposure = new Fsr2.RenderTargetView(exposure); - if (reactiveMask != null) _dispatchDescription.Reactive = new Fsr2.RenderTargetView(reactiveMask); - if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new Fsr2.RenderTargetView(transparencyAndCompositionMask); + if (!enableAutoExposure && exposure != null) _dispatchDescription.Exposure = new Fsr2.ResourceView(exposure); + if (reactiveMask != null) _dispatchDescription.Reactive = new Fsr2.ResourceView(reactiveMask); + if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new Fsr2.ResourceView(transparencyAndCompositionMask); var scaledRenderSize = GetScaledRenderSize(); - _dispatchDescription.Output = new Fsr2.RenderTargetView(Fsr2ShaderIDs.UavUpscaledOutput); + _dispatchDescription.Output = new Fsr2.ResourceView(Fsr2ShaderIDs.UavUpscaledOutput); _dispatchDescription.PreExposure = preExposure; _dispatchDescription.EnableSharpening = performSharpenPass; _dispatchDescription.Sharpness = sharpness; @@ -357,7 +357,7 @@ namespace FidelityFX _dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition; if (autoGenerateTransparencyAndComposition) { - _dispatchDescription.ColorOpaqueOnly = new Fsr2.RenderTargetView(_colorOpaqueOnly); + _dispatchDescription.ColorOpaqueOnly = new Fsr2.ResourceView(_colorOpaqueOnly); _dispatchDescription.AutoTcThreshold = generateTransparencyAndCompositionParameters.autoTcThreshold; _dispatchDescription.AutoTcScale = generateTransparencyAndCompositionParameters.autoTcScale; _dispatchDescription.AutoReactiveScale = generateTransparencyAndCompositionParameters.autoReactiveScale; @@ -374,9 +374,9 @@ namespace FidelityFX private void SetupAutoReactiveDescription() { // Set up the parameters to auto-generate a reactive mask - _genReactiveDescription.ColorOpaqueOnly = new Fsr2.RenderTargetView(_colorOpaqueOnly); - _genReactiveDescription.ColorPreUpscale = new Fsr2.RenderTargetView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); - _genReactiveDescription.OutReactive = new Fsr2.RenderTargetView(Fsr2ShaderIDs.UavAutoReactive); + _genReactiveDescription.ColorOpaqueOnly = new Fsr2.ResourceView(_colorOpaqueOnly); + _genReactiveDescription.ColorPreUpscale = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); + _genReactiveDescription.OutReactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); _genReactiveDescription.RenderSize = GetScaledRenderSize(); _genReactiveDescription.Scale = generateReactiveParameters.scale; _genReactiveDescription.CutoffThreshold = generateReactiveParameters.cutoffThreshold; @@ -420,7 +420,7 @@ namespace FidelityFX var scaledRenderSize = GetScaledRenderSize(); _dispatchCommandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavAutoReactive, scaledRenderSize.x, scaledRenderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); _context.GenerateReactiveMask(_genReactiveDescription, _dispatchCommandBuffer); - _dispatchDescription.Reactive = new Fsr2.RenderTargetView(Fsr2ShaderIDs.UavAutoReactive); + _dispatchDescription.Reactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); } // The backbuffer is not set up to allow random-write access, so we need a temporary render texture for FSR2 to output to