Browse Source

Renamed RenderTargetView to ResourceView, which is a bit shorter to type and covers the essence well.

master
Nico de Poel 2 years ago
parent
commit
22701fdd17
  1. 30
      Assets/Scripts/Core/Fsr2.cs
  2. 12
      Assets/Scripts/Core/Fsr2Context.cs
  3. 30
      Assets/Scripts/Fsr2ImageEffect.cs

30
Assets/Scripts/Core/Fsr2.cs

@ -166,21 +166,21 @@ namespace FidelityFX
/// <summary>
/// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader.
/// </summary>
public readonly struct RenderTargetView
public readonly struct ResourceView
{
/// <summary>
/// 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.
/// </summary>
public static readonly RenderTargetView Unassigned = new RenderTargetView(default);
public static readonly ResourceView Unassigned = new ResourceView(default);
/// <summary>
/// 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.
/// </summary>
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
/// </summary>
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
/// </summary>
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;

12
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

30
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

Loading…
Cancel
Save