Browse Source

Fixed a number of issues to make Quality variant work:

- Removed "fix" to initialize params to 0, as that happens midway through the Accumulation process, resetting a lot of variables. Instead rewrote InitParams to take an inout parameter and clear the params first thing in the Accumulate function.
- Bind first multi-render target as depth target, fixes RenderDoc errors about color/depth buffer size mismatch.
- Ensure keywords that need a value are redefined using the correct value.
- Removed obsolete auto-TCR constants struct.
asr-console
Nico de Poel 11 months ago
parent
commit
943d119706
  1. 10
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs
  2. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
  3. 17
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc
  4. 12
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h
  5. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h

10
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs

@ -300,6 +300,7 @@ namespace ArmASR
public float deltaTime;
public float dynamicResChangeFactor;
public float viewSpaceToMetersFactor;
public float padding;
}
@ -320,15 +321,6 @@ namespace ArmASR
public float binaryValue;
public uint flags;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct GenerateReactiveConstants2
{
public float autoTcThreshold;
public float autoTcScale;
public float autoReactiveScale;
public float autoReactiveMax;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct RcasConstants

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs

@ -109,7 +109,7 @@ namespace ArmASR
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void BlitFragment(CommandBuffer commandBuffer, RenderTargetIdentifier[] renderTargets)
{
commandBuffer.SetRenderTarget(renderTargets, BuiltinRenderTextureType.None);
commandBuffer.SetRenderTarget(renderTargets, renderTargets[0]);
BlitFragment(commandBuffer);
}

17
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc

@ -3,9 +3,26 @@
#pragma warning(disable: 3205) // Conversion from larger type to smaller, possible loss of data
#pragma warning(disable: 3556) // Integer divides might be much slower, try using uints if possible
// If these keywords are set by Unity, redefine them to have a truthy value
#ifdef FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#undef FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#define FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE 1
#endif
#ifdef FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#undef FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#define FFXM_FSR2_OPTION_SHADER_OPT_BALANCED 1
#endif
// Ensure the correct value is defined for this keyword, as it is used to select one of multiple sampler functions
#ifdef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#undef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 1
#endif
// ASR has some special code paths for OpenGL ES 3.2
#if defined(SHADER_API_GLES3)
#define FFXM_SHADER_PLATFORM_GLES_3_2 (1)
#define unorm
#endif
// Work around the lack of texture atomics on Metal

12
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h

@ -244,8 +244,6 @@ FfxFloat32 ComputeTemporalReactiveFactor(const AccumulationPassCommonParams para
void initReactiveMaskFactors(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params)
{
params = (AccumulationPassCommonParams)0;
const FFXM_MIN16_F2 fDilatedReactiveMasks = FFXM_MIN16_F2(SampleDilatedReactiveMasks(params.fLrUv_HwSampler));
params.fDilatedReactiveFactor = fDilatedReactiveMasks.x;
params.fAccumulationMask = fDilatedReactiveMasks.y;
@ -262,11 +260,8 @@ void initIsNewSample(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params)
params.bIsNewSample = (params.bIsExistingSample == false || bIsResetFrame);
}
AccumulationPassCommonParams InitParams(FfxInt32x2 iPxHrPos)
void InitParams(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params, FfxInt32x2 iPxHrPos)
{
AccumulationPassCommonParams params;
params.iPxHrPos = iPxHrPos;
const FfxFloat32x2 fHrUv = (iPxHrPos + 0.5f) / DisplaySize();
params.fHrUv = fHrUv;
@ -278,13 +273,12 @@ AccumulationPassCommonParams InitParams(FfxInt32x2 iPxHrPos)
params.fHrVelocity = GetPxHrVelocity(params.fMotionVector);
ComputeReprojectedUVs(params, params.fReprojectedHrUv, params.bIsExistingSample);
return params;
}
AccumulateOutputs Accumulate(FfxInt32x2 iPxHrPos)
{
AccumulationPassCommonParams params = InitParams(iPxHrPos);
AccumulationPassCommonParams params = (AccumulationPassCommonParams)0;
InitParams(params, iPxHrPos);
FfxFloat32x3 fHistoryColor = FfxFloat32x3(0, 0, 0);
FFXM_MIN16_F2 fLockStatus;

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h

@ -56,7 +56,7 @@ FfxFloat32 GetShadingChangeLuma(FfxInt32x2 iPxHrPos, FfxFloat32x2 fUvCoord)
return fShadingChangeLuma;
}
void UpdateLockStatus(AccumulationPassCommonParams params,
void UpdateLockStatus(const AccumulationPassCommonParams params,
FFXM_PARAMETER_INOUT FfxFloat32 fReactiveFactor, LockState state,
FFXM_PARAMETER_INOUT FfxFloat32x2 fLockStatus,
FFXM_PARAMETER_OUT FfxFloat32 fLockContributionThisFrame,

Loading…
Cancel
Save