diff --git a/Shaders/ffx_fsr2_accumulate_pass.compute b/Shaders/ffx_fsr2_accumulate_pass.compute index 63a4387..618b1e4 100644 --- a/Shaders/ffx_fsr2_accumulate_pass.compute +++ b/Shaders/ffx_fsr2_accumulate_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_autogen_reactive_pass.compute b/Shaders/ffx_fsr2_autogen_reactive_pass.compute index 063e5d7..701e068 100644 --- a/Shaders/ffx_fsr2_autogen_reactive_pass.compute +++ b/Shaders/ffx_fsr2_autogen_reactive_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute b/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute index c63dfe6..61488ed 100644 --- a/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute +++ b/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_depth_clip_pass.compute b/Shaders/ffx_fsr2_depth_clip_pass.compute index 582ca6b..137694a 100644 --- a/Shaders/ffx_fsr2_depth_clip_pass.compute +++ b/Shaders/ffx_fsr2_depth_clip_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_lock_pass.compute b/Shaders/ffx_fsr2_lock_pass.compute index 2e86474..3cea4ad 100644 --- a/Shaders/ffx_fsr2_lock_pass.compute +++ b/Shaders/ffx_fsr2_lock_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_rcas_pass.compute b/Shaders/ffx_fsr2_rcas_pass.compute index 39c7ef3..a403c34 100644 --- a/Shaders/ffx_fsr2_rcas_pass.compute +++ b/Shaders/ffx_fsr2_rcas_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute b/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute index 12f2ec3..ae60489 100644 --- a/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute +++ b/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr2_tcr_autogen_pass.compute b/Shaders/ffx_fsr2_tcr_autogen_pass.compute index bb1b780..bb9db56 100644 --- a/Shaders/ffx_fsr2_tcr_autogen_pass.compute +++ b/Shaders/ffx_fsr2_tcr_autogen_pass.compute @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Nico de Poel +// Copyright (c) 2026 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/Shaders/ffx_fsr_unity_common.cginc b/Shaders/ffx_fsr_unity_common.cginc index f1681f3..696a338 100644 --- a/Shaders/ffx_fsr_unity_common.cginc +++ b/Shaders/ffx_fsr_unity_common.cginc @@ -18,6 +18,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if !defined(UNITY_FSR_TEXTURE2D_X_ARRAY) +#define DISABLE_TEXTURE2D_X_ARRAY +#endif + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl" + // 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 @@ -44,44 +51,20 @@ // #endif // Hack to work around the lack of texture atomics on Metal +// TODO: replace texture atomics with a compute buffer setup #if defined(SHADER_API_METAL) #define InterlockedAdd(dest, val, orig) { (orig) = (dest); (dest) += (val); } #define InterlockedMin(dest, val) { (dest) = min((dest), (val)); } #define InterlockedMax(dest, val) { (dest) = max((dest), (val)); } #endif -// Workaround for HDRP using texture arrays for its camera buffers on some platforms -// The below defines are adapted from: Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl -#if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL) - #define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED -#endif - -// Control if TEXTURE2D_X macros will expand to texture arrays -#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && defined(UNITY_FSR_TEXTURE2D_X_ARRAY) - #define USE_TEXTURE2D_X_AS_ARRAY -#endif - -// Early defines for single-pass instancing -#if defined(STEREO_INSTANCING_ON) && defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) - #define UNITY_STEREO_INSTANCING_ENABLED -#endif - // Helper macros to handle XR single-pass with Texture2DArray +// TODO: replace all declarations in callbacks.hlsl with TEXTURE2D_X #if defined(USE_TEXTURE2D_X_AS_ARRAY) - - // Only single-pass stereo instancing used array indexing - #if defined(UNITY_STEREO_INSTANCING_ENABLED) - static uint unity_StereoEyeIndex; - #define SLICE_ARRAY_INDEX unity_StereoEyeIndex - #else - #define SLICE_ARRAY_INDEX 0 - #endif - // Declare and sample camera buffers as texture arrays #define UNITY_FSR_TEX2D(type) Texture2DArray #define UNITY_FSR_RWTEX2D(type) RWTexture2DArray #define UNITY_FSR_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) #define UNITY_FSR_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) #define UNITY_FSR_GETDIMS(tex, w, h) { FfxUInt32 uElements; (tex).GetDimensions((w), (h), uElements); } - #endif diff --git a/Shaders/shaders/fsr2/ffx_fsr2_sample.h b/Shaders/shaders/fsr2/ffx_fsr2_sample.h index cd7142a..035d420 100644 --- a/Shaders/shaders/fsr2/ffx_fsr2_sample.h +++ b/Shaders/shaders/fsr2/ffx_fsr2_sample.h @@ -127,7 +127,6 @@ FFX_MIN16_F4 Bilinear(FetchedBilinearSamplesMin16 BilinearSamples, FFX_MIN16_F2 FfxFloat32 Lanczos2NoClamp(FfxFloat32 x) { - const FfxFloat32 PI = 3.141592653589793f; // TODO: share SDK constants return abs(x) < FSR2_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); } diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h index 7a723d5..7a32f42 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h @@ -127,7 +127,6 @@ FFX_MIN16_F4 Bilinear(FetchedBilinearSamplesMin16 BilinearSamples, FFX_MIN16_F2 FfxFloat32 Lanczos2NoClamp(FfxFloat32 x) { - const FfxFloat32 PI = 3.141592653589793f; // TODO: share SDK constants return abs(x) < FSR3UPSCALER_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); }