diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs
index 590f5f2..158c196 100644
--- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs
+++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs
@@ -44,7 +44,7 @@ namespace ArmASR
flags |= InitializationFlags.EnableDebugChecking;
#endif
- Debug.Log($"Setting up Arm ASR with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}");
+ Debug.Log($"Setting up ASR with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}");
var contextDescription = new ContextDescription
{
@@ -211,7 +211,7 @@ namespace ArmASR
///
/// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 2.
///
- public class DispatchDescription // TODO: make into struct
+ public struct DispatchDescription
{
public ResourceView Color;
public ResourceView Depth;
@@ -239,16 +239,24 @@ namespace ArmASR
///
/// A structure encapsulating the parameters for automatic generation of a reactive mask.
///
- public class GenerateReactiveDescription // TODO: make into struct (with static readonly Default property)
+ public struct GenerateReactiveDescription
{
public ResourceView ColorOpaqueOnly;
public ResourceView ColorPreUpscale;
public ResourceView OutReactive;
public Vector2Int RenderSize;
- public float Scale = 0.5f;
- public float CutoffThreshold = 0.2f;
- public float BinaryValue = 0.9f;
- public GenerateReactiveFlags Flags = GenerateReactiveFlags.ApplyTonemap | GenerateReactiveFlags.ApplyThreshold | GenerateReactiveFlags.UseComponentsMax;
+ public float Scale;
+ public float CutoffThreshold;
+ public float BinaryValue;
+ public GenerateReactiveFlags Flags;
+
+ public static readonly GenerateReactiveDescription Default = new GenerateReactiveDescription
+ {
+ Scale = 0.5f,
+ CutoffThreshold = 0.2f,
+ BinaryValue = 0.9f,
+ Flags = GenerateReactiveFlags.ApplyTonemap | GenerateReactiveFlags.ApplyThreshold | GenerateReactiveFlags.UseComponentsMax,
+ };
}
[Flags]
diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
index a1587af..4857108 100644
--- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
+++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
@@ -71,10 +71,10 @@ namespace ArmASR
private Vector2 _previousJitterOffset;
private int _resourceFrameIndex;
- public void Create(Asr.ContextDescription contextDescription)
+ public void Create(in Asr.ContextDescription contextDescription)
{
_contextDescription = contextDescription;
- _commandBuffer = new CommandBuffer { name = "Arm ASR" };
+ _commandBuffer = new CommandBuffer { name = "ASR" };
_upscalerConstantsBuffer = CreateConstantBuffer();
_spdConstantsBuffer = CreateConstantBuffer();
@@ -127,7 +127,7 @@ namespace ArmASR
}
}
- public void Dispatch(Asr.DispatchDescription dispatchParams)
+ public void Dispatch(in Asr.DispatchDescription dispatchParams)
{
_commandBuffer.Clear();
Dispatch(dispatchParams, _commandBuffer);
@@ -198,7 +198,7 @@ namespace ArmASR
commandBuffer.ClearRenderTarget(false, true, Color.clear);
}
- // FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
+ // Need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
bool depthInverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) == Asr.InitializationFlags.EnableDepthInverted;
commandBuffer.SetRenderTarget(AsrShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white);
@@ -245,29 +245,25 @@ namespace ArmASR
commandBuffer.DisableShaderKeyword("UNITY_FFXM_TEXTURE2D_X_ARRAY");
}
- public void GenerateReactiveMask(Asr.GenerateReactiveDescription dispatchParams)
+ public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams)
{
_commandBuffer.Clear();
GenerateReactiveMask(dispatchParams, _commandBuffer);
Graphics.ExecuteCommandBuffer(_commandBuffer);
}
- public void GenerateReactiveMask(Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer)
+ public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer)
{
- const int threadGroupWorkRegionDim = 8;
- int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
- int dispatchSrcY = (dispatchParams.RenderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
-
GenReactiveConsts.scale = dispatchParams.Scale;
GenReactiveConsts.threshold = dispatchParams.CutoffThreshold;
GenReactiveConsts.binaryValue = dispatchParams.BinaryValue;
GenReactiveConsts.flags = (uint)dispatchParams.Flags;
commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray);
- ((AsrGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY);
+ ((AsrGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams);
}
- private void SetupConstants(Asr.DispatchDescription dispatchParams, bool resetAccumulation)
+ private void SetupConstants(in Asr.DispatchDescription dispatchParams, bool resetAccumulation)
{
ref Asr.UpscalerConstants constants = ref UpscalerConsts;
@@ -331,7 +327,7 @@ namespace ArmASR
constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv);
}
- private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Asr.DispatchDescription dispatchParams)
+ private Vector4 SetupDeviceDepthToViewSpaceDepthParams(in Asr.DispatchDescription dispatchParams)
{
bool inverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) != 0;
bool infinite = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInfinite) != 0;
@@ -364,13 +360,13 @@ namespace ArmASR
1.0f / cotHalfFovY);
}
- private void SetupRcasConstants(Asr.DispatchDescription dispatchParams)
+ private void SetupRcasConstants(in Asr.DispatchDescription dispatchParams)
{
int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (RcasConfigs.Length - 1));
RcasConsts = RcasConfigs[sharpnessIndex];
}
- private void SetupSpdConstants(Asr.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount)
+ private void SetupSpdConstants(in Asr.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount)
{
RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y);
SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips);
@@ -402,7 +398,7 @@ namespace ArmASR
}
}
- private void DebugCheckDispatch(Asr.DispatchDescription dispatchParams)
+ private void DebugCheckDispatch(in Asr.DispatchDescription dispatchParams)
{
if (!dispatchParams.Color.IsValid)
{
diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
index 8fce782..2070b61 100644
--- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
+++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
@@ -313,7 +313,7 @@ namespace ArmASR
{
}
- public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY)
+ public void ScheduleDispatch(CommandBuffer commandBuffer, in Asr.GenerateReactiveDescription dispatchParams)
{
BeginSample(commandBuffer);