From 0ab4f99e13f0e8958d94df97c9fc176479af5efb Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 9 Jul 2024 17:16:52 +0200 Subject: [PATCH] Fixes for accumulate pass --- .../Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute | 2 +- Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc | 1 + .../FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h | 3 ++- .../FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute index 5cbfb80..e8e0034 100644 --- a/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Nico de Poel +// Copyright (c) 2024 Nico de Poel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc index 758bb0c..5a02519 100644 --- a/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc @@ -21,6 +21,7 @@ // Suppress a few warnings produced by FFX's HLSL code #pragma warning(disable: 3078) // Loop control variable conflicts #pragma warning(disable: 3203) // Signed/unsigned mismatch +#pragma warning(disable: 3556) // Integer divides might be much slower, try using uints if possible #define FFX_GPU // Compiling for GPU #define FFX_HLSL // Compile for plain HLSL diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h index 0e728d5..766cba3 100644 --- a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h @@ -114,7 +114,7 @@ void InitPassData(FfxInt32x2 iPxHrPos, FFX_PARAMETER_INOUT AccumulationPassCommo params.fMotionVector = GetMotionVector(iPxHrPos, fHrUv); params.f4KVelocity = Get4KVelocity(params.fMotionVector); - ComputeReprojectedUVs(params); + ComputeReprojectedUVs(params, params.fReprojectedHrUv, params.bIsExistingSample); const FfxFloat32x2 fLumaInstabilityUv_HW = ClampUv(fHrUv, RenderSize(), MaxRenderSize()); params.fLumaInstabilityFactor = SampleLumaInstability(fLumaInstabilityUv_HW); @@ -131,6 +131,7 @@ void InitPassData(FfxInt32x2 iPxHrPos, FFX_PARAMETER_INOUT AccumulationPassCommo params.fAccumulation *= FfxFloat32(round(params.fAccumulation * 100.0f) > 1.0f); // Init variable data + data = (AccumulationPassData)0; data.fUpsampledColor = FfxFloat32x3(0.0f, 0.0f, 0.0f); data.fHistoryColor = FfxFloat32x3(0.0f, 0.0f, 0.0f); data.fHistoryWeight = 1.0f; diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h index 45812a6..153a9b7 100644 --- a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h @@ -43,11 +43,11 @@ FfxFloat32x2 GetMotionVector(FfxInt32x2 iPxHrPos, FfxFloat32x2 fHrUv) return fDilatedMotionVector; } -void ComputeReprojectedUVs(FFX_PARAMETER_INOUT AccumulationPassCommonParams params) +void ComputeReprojectedUVs(const AccumulationPassCommonParams params, FFX_PARAMETER_OUT FfxFloat32x2 fReprojectedHrUv, FFX_PARAMETER_OUT FfxBoolean bIsExistingSample) { - params.fReprojectedHrUv = params.fHrUv + params.fMotionVector; + fReprojectedHrUv = params.fHrUv + params.fMotionVector; - params.bIsExistingSample = IsUvInside(params.fReprojectedHrUv); + bIsExistingSample = IsUvInside(fReprojectedHrUv); } void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT AccumulationPassData data)