diff --git a/Assets/Resources/FSR2/shaders/ffx_core_glsl.h b/Assets/Resources/FSR2/shaders/ffx_core_glsl.h deleted file mode 100644 index 6ec58f3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_glsl.h +++ /dev/null @@ -1,1669 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/// A define for abstracting shared memory between shading languages. -/// -/// @ingroup GPU -#define FFX_GROUPSHARED shared - -/// A define for abstracting compute memory barriers between shading languages. -/// -/// @ingroup GPU -#define FFX_GROUP_MEMORY_BARRIER() barrier() - -/// A define added to accept static markup on functions to aid CPU/GPU portability of code. -/// -/// @ingroup GPU -#define FFX_STATIC - -/// A define for abstracting loop unrolling between shading languages. -/// -/// @ingroup GPU -#define FFX_UNROLL - -/// A define for abstracting a 'greater than' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_GREATER_THAN(x, y) greaterThan(x, y) - -/// A define for abstracting a 'greater than or equal' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_GREATER_THAN_EQUAL(x, y) greaterThanEqual(x, y) - -/// A define for abstracting a 'less than' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_LESS_THAN(x, y) lessThan(x, y) - -/// A define for abstracting a 'less than or equal' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_LESS_THAN_EQUAL(x, y) lessThanEqual(x, y) - -/// A define for abstracting an 'equal' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_EQUAL(x, y) equal(x, y) - -/// A define for abstracting a 'not equal' comparison operator between two types. -/// -/// @ingroup GPU -#define FFX_NOT_EQUAL(x, y) notEqual(x, y) - -/// Broadcast a scalar value to a 1-dimensional floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_FLOAT32(x) FfxFloat32(x) - -/// Broadcast a scalar value to a 2-dimensional floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_FLOAT32X2(x) FfxFloat32x2(FfxFloat32(x)) - -/// Broadcast a scalar value to a 3-dimensional floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_FLOAT32X3(x) FfxFloat32x3(FfxFloat32(x)) - -/// Broadcast a scalar value to a 4-dimensional floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_FLOAT32X4(x) FfxFloat32x4(FfxFloat32(x)) - -/// Broadcast a scalar value to a 1-dimensional unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_UINT32(x) FfxUInt32(x) - -/// Broadcast a scalar value to a 2-dimensional unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_UINT32X2(x) FfxUInt32x2(FfxUInt32(x)) - -/// Broadcast a scalar value to a 3-dimensional unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_UINT32X3(x) FfxUInt32x3(FfxUInt32(x)) - -/// Broadcast a scalar value to a 4-dimensional unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_UINT32X4(x) FfxUInt32x4(FfxUInt32(x)) - -/// Broadcast a scalar value to a 1-dimensional signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_INT32(x) FfxInt32(x) - -/// Broadcast a scalar value to a 2-dimensional signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_INT32X2(x) FfxInt32x2(FfxInt32(x)) - -/// Broadcast a scalar value to a 3-dimensional signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_INT32X3(x) FfxInt32x3(FfxInt32(x)) - -/// Broadcast a scalar value to a 4-dimensional signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_INT32X4(x) FfxInt32x4(FfxInt32(x)) - -/// Broadcast a scalar value to a 1-dimensional half-precision floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_FLOAT16(x) FFX_MIN16_F(x) - -/// Broadcast a scalar value to a 2-dimensional half-precision floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_FLOAT16X2(x) FFX_MIN16_F2(FFX_MIN16_F(x)) - -/// Broadcast a scalar value to a 3-dimensional half-precision floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_FLOAT16X3(x) FFX_MIN16_F3(FFX_MIN16_F(x)) - -/// Broadcast a scalar value to a 4-dimensional half-precision floating point vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_FLOAT16X4(x) FFX_MIN16_F4(FFX_MIN16_F(x)) - -/// Broadcast a scalar value to a 1-dimensional half-precision unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_UINT16(x) FFX_MIN16_U(x) - -/// Broadcast a scalar value to a 2-dimensional half-precision unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_UINT16X2(x) FFX_MIN16_U2(FFX_MIN16_U(x)) - -/// Broadcast a scalar value to a 3-dimensional half-precision unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_UINT16X3(x) FFX_MIN16_U3(FFX_MIN16_U(x)) - -/// Broadcast a scalar value to a 4-dimensional half-precision unsigned integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_UINT16X4(x) FFX_MIN16_U4(FFX_MIN16_U(x)) - -/// Broadcast a scalar value to a 1-dimensional half-precision signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_INT16(x) FFX_MIN16_I(x) - -/// Broadcast a scalar value to a 2-dimensional half-precision signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_INT16X2(x) FFX_MIN16_I2(FFX_MIN16_I(x)) - -/// Broadcast a scalar value to a 3-dimensional half-precision signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_INT16X3(x) FFX_MIN16_I3(FFX_MIN16_I(x)) - -/// Broadcast a scalar value to a 4-dimensional half-precision signed integer vector. -/// -/// @ingroup GPU -#define FFX_BROADCAST_MIN_INT16X4(x) FFX_MIN16_I4(FFX_MIN16_I(x)) - -#if !defined(FFX_SKIP_EXT) -#if FFX_HALF - #extension GL_EXT_shader_16bit_storage : require - #extension GL_EXT_shader_explicit_arithmetic_types : require -#endif // FFX_HALF - -#if defined(FFX_LONG) - #extension GL_ARB_gpu_shader_int64 : require - #extension GL_NV_shader_atomic_int64 : require -#endif // #if defined(FFX_LONG) - -#if defined(FFX_WAVE) - #extension GL_KHR_shader_subgroup_arithmetic : require - #extension GL_KHR_shader_subgroup_ballot : require - #extension GL_KHR_shader_subgroup_quad : require - #extension GL_KHR_shader_subgroup_shuffle : require -#endif // #if defined(FFX_WAVE) -#endif // #if !defined(FFX_SKIP_EXT) - -// Forward declarations -FfxFloat32 ffxSqrt(FfxFloat32 x); -FfxFloat32x2 ffxSqrt(FfxFloat32x2 x); -FfxFloat32x3 ffxSqrt(FfxFloat32x3 x); -FfxFloat32x4 ffxSqrt(FfxFloat32x4 x); - -/// Interprets the bit pattern of x as a floating-point number. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as a floating-point number. -/// -/// @ingroup GLSL -FfxFloat32 ffxAsFloat(FfxUInt32 x) -{ - return uintBitsToFloat(x); -} - -/// Interprets the bit pattern of x as a floating-point number. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as a floating-point number. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x) -{ - return uintBitsToFloat(x); -} - -/// Interprets the bit pattern of x as a floating-point number. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as a floating-point number. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x) -{ - return uintBitsToFloat(x); -} - -/// Interprets the bit pattern of x as a floating-point number. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as a floating-point number. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x) -{ - return uintBitsToFloat(x); -} - -/// Interprets the bit pattern of x as an unsigned integer. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as an unsigned integer. -/// -/// @ingroup GLSL -FfxUInt32 ffxAsUInt32(FfxFloat32 x) -{ - return floatBitsToUint(x); -} - -/// Interprets the bit pattern of x as an unsigned integer. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as an unsigned integer. -/// -/// @ingroup GLSL -FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x) -{ - return floatBitsToUint(x); -} - -/// Interprets the bit pattern of x as an unsigned integer. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as an unsigned integer. -/// -/// @ingroup GLSL -FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x) -{ - return floatBitsToUint(x); -} - -/// Interprets the bit pattern of x as an unsigned integer. -/// -/// @param [in] value The input value. -/// -/// @returns -/// The input interpreted as an unsigned integer. -/// -/// @ingroup GLSL -FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x) -{ - return floatBitsToUint(x); -} - -/// Convert a 32bit IEEE 754 floating point value to its nearest 16bit equivalent. -/// -/// @param [in] value The value to convert. -/// -/// @returns -/// The nearest 16bit equivalent of value. -/// -/// @ingroup GLSL -FfxUInt32 f32tof16(FfxFloat32 value) -{ - return packHalf2x16(FfxFloat32x2(value, 0.0)); -} - -/// Broadcast a scalar value to a 2-dimensional floating point vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 2-dimensional floating point vector with value in each component. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxBroadcast2(FfxFloat32 value) -{ - return FfxFloat32x2(value, value); -} - -/// Broadcast a scalar value to a 3-dimensional floating point vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 3-dimensional floating point vector with value in each component. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxBroadcast3(FfxFloat32 value) -{ - return FfxFloat32x3(value, value, value); -} - -/// Broadcast a scalar value to a 4-dimensional floating point vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 4-dimensional floating point vector with value in each component. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxBroadcast4(FfxFloat32 value) -{ - return FfxFloat32x4(value, value, value, value); -} - -/// Broadcast a scalar value to a 2-dimensional signed integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 2-dimensional signed integer vector with value in each component. -/// -/// @ingroup GLSL -FfxInt32x2 ffxBroadcast2(FfxInt32 value) -{ - return FfxInt32x2(value, value); -} - -/// Broadcast a scalar value to a 3-dimensional signed integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 3-dimensional signed integer vector with value in each component. -/// -/// @ingroup GLSL -FfxInt32x3 ffxBroadcast3(FfxInt32 value) -{ - return FfxInt32x3(value, value, value); -} - -/// Broadcast a scalar value to a 4-dimensional signed integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 4-dimensional signed integer vector with value in each component. -/// -/// @ingroup GLSL -FfxInt32x4 ffxBroadcast4(FfxInt32 value) -{ - return FfxInt32x4(value, value, value, value); -} - -/// Broadcast a scalar value to a 2-dimensional unsigned integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 2-dimensional unsigned integer vector with value in each component. -/// -/// @ingroup GLSL -FfxUInt32x2 ffxBroadcast2(FfxUInt32 value) -{ - return FfxUInt32x2(value, value); -} - -/// Broadcast a scalar value to a 3-dimensional unsigned integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 3-dimensional unsigned integer vector with value in each component. -/// -/// @ingroup GLSL -FfxUInt32x3 ffxBroadcast3(FfxUInt32 value) -{ - return FfxUInt32x3(value, value, value); -} - -/// Broadcast a scalar value to a 4-dimensional unsigned integer vector. -/// -/// @param [in] value The value to to broadcast. -/// -/// @returns -/// A 4-dimensional unsigned integer vector with value in each component. -/// -/// @ingroup GLSL -FfxUInt32x4 ffxBroadcast4(FfxUInt32 value) -{ - return FfxUInt32x4(value, value, value, value); -} - -/// -/// -/// @ingroup GLSL -FfxUInt32 bitfieldExtract(FfxUInt32 src, FfxUInt32 off, FfxUInt32 bits) -{ - return bitfieldExtract(src, FfxInt32(off), FfxInt32(bits)); -} - -/// -/// -/// @ingroup GLSL -FfxUInt32 bitfieldInsert(FfxUInt32 src, FfxUInt32 ins, FfxUInt32 mask) -{ - return (ins & mask) | (src & (~mask)); -} - -// Proxy for V_BFI_B32 where the 'mask' is set as 'bits', 'mask=(1<mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32 t) -{ - return mix(x, y, t); -} - -/// Compute the linear interopation between two values. -/// -/// Implemented by calling the GLSL mix instrinsic function. Implements the -/// following math: -/// -/// (1 - t) * x + t * y -/// -/// @param [in] x The first value to lerp between. -/// @param [in] y The second value to lerp between. -/// @param [in] t The value to determine how much of x and how much of y. -/// -/// @returns -/// A linearly interpolated value between x and y according to t. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 t) -{ - return mix(x, y, t); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN or RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) -{ - return max(x, max(y, z)); -} - -/// Compute the maximum of three values. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the max calculation. -/// @param [in] y The second value to include in the max calcuation. -/// @param [in] z The third value to include in the max calcuation. -/// -/// @returns -/// The maximum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) -{ - return max(x, max(y, z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32 ffxMed3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxMed3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxMed3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxMed3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_I32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxInt32 ffxMed3(FfxInt32 x, FfxInt32 y, FfxInt32 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_I32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxInt32x2 ffxMed3(FfxInt32x2 x, FfxInt32x2 y, FfxInt32x2 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_I32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxInt32x3 ffxMed3(FfxInt32x3 x, FfxInt32x3 y, FfxInt32x3 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - -/// Compute the median of three values. -/// -/// NOTE: This function should compile down to a single V_MED3_I32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the median calculation. -/// @param [in] y The second value to include in the median calcuation. -/// @param [in] z The third value to include in the median calcuation. -/// -/// @returns -/// The median value of x, y, and z. -/// -/// @ingroup GLSL -FfxInt32x4 ffxMed3(FfxInt32x4 x, FfxInt32x4 y, FfxInt32x4 z) -{ - return max(min(x, y), min(max(x, y), z)); -} - - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN and RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) -{ - return min(x, min(y, z)); -} - -/// Compute the minimum of three values. -/// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on -/// GCN/RDNA hardware. -/// -/// @param [in] x The first value to include in the min calculation. -/// @param [in] y The second value to include in the min calcuation. -/// @param [in] z The third value to include in the min calcuation. -/// -/// @returns -/// The minimum value of x, y, and z. -/// -/// @ingroup GLSL -FfxUInt32x4 ffxMin3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) -{ - return min(x, min(y, z)); -} - -/// Compute the reciprocal of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rcp can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal value of x. -/// -/// @ingroup GLSL -FfxFloat32 rcp(FfxFloat32 x) -{ - return FfxFloat32(1.0) / x; -} - -/// Compute the reciprocal of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rcp can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal value of x. -/// -/// @ingroup GLSL -FfxFloat32x2 rcp(FfxFloat32x2 x) -{ - return ffxBroadcast2(1.0) / x; -} - -/// Compute the reciprocal of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rcp can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal value of x. -/// -/// @ingroup GLSL -FfxFloat32x3 rcp(FfxFloat32x3 x) -{ - return ffxBroadcast3(1.0) / x; -} - -/// Compute the reciprocal of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rcp can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal value of x. -/// -/// @ingroup GLSL -FfxFloat32x4 rcp(FfxFloat32x4 x) -{ - return ffxBroadcast4(1.0) / x; -} - -/// Compute the reciprocal square root of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rsqrt can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal square root value of x. -/// -/// @ingroup GLSL -FfxFloat32 rsqrt(FfxFloat32 x) -{ - return FfxFloat32(1.0) / ffxSqrt(x); -} - -/// Compute the reciprocal square root of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rsqrt can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal square root value of x. -/// -/// @ingroup GLSL -FfxFloat32x2 rsqrt(FfxFloat32x2 x) -{ - return ffxBroadcast2(1.0) / ffxSqrt(x); -} - -/// Compute the reciprocal square root of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rsqrt can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal square root value of x. -/// -/// @ingroup GLSL -FfxFloat32x3 rsqrt(FfxFloat32x3 x) -{ - return ffxBroadcast3(1.0) / ffxSqrt(x); -} - -/// Compute the reciprocal square root of a value. -/// -/// NOTE: This function is only provided for GLSL. In HLSL the intrinsic function rsqrt can be used. -/// -/// @param [in] x The value to compute the reciprocal for. -/// -/// @returns -/// The reciprocal square root value of x. -/// -/// @ingroup GLSL -FfxFloat32x4 rsqrt(FfxFloat32x4 x) -{ - return ffxBroadcast4(1.0) / ffxSqrt(x); -} - -/// Clamp a value to a [0..1] range. -/// -/// @param [in] x The value to clamp to [0..1] range. -/// -/// @returns -/// The clamped version of x. -/// -/// @ingroup GLSL -FfxFloat32 ffxSaturate(FfxFloat32 x) -{ - return clamp(x, FfxFloat32(0.0), FfxFloat32(1.0)); -} - -/// Clamp a value to a [0..1] range. -/// -/// @param [in] x The value to clamp to [0..1] range. -/// -/// @returns -/// The clamped version of x. -/// -/// @ingroup GLSL -FfxFloat32x2 ffxSaturate(FfxFloat32x2 x) -{ - return clamp(x, ffxBroadcast2(0.0), ffxBroadcast2(1.0)); -} - -/// Clamp a value to a [0..1] range. -/// -/// @param [in] x The value to clamp to [0..1] range. -/// -/// @returns -/// The clamped version of x. -/// -/// @ingroup GLSL -FfxFloat32x3 ffxSaturate(FfxFloat32x3 x) -{ - return clamp(x, ffxBroadcast3(0.0), ffxBroadcast3(1.0)); -} - -/// Clamp a value to a [0..1] range. -/// -/// @param [in] x The value to clamp to [0..1] range. -/// -/// @returns -/// The clamped version of x. -/// -/// @ingroup GLSL -FfxFloat32x4 ffxSaturate(FfxFloat32x4 x) -{ - return clamp(x, ffxBroadcast4(0.0), ffxBroadcast4(1.0)); -} - -/// Compute the factional part of a decimal value. -/// -/// This function calculates x - floor(x). Where floor is the intrinsic HLSL function. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is -/// worth further noting that this function is intentionally distinct from the HLSL frac intrinsic -/// function. -/// -/// @param [in] x The value to compute the fractional part from. -/// -/// @returns -/// The fractional part of x. -/// -/// @ingroup HLSL -FfxFloat32 ffxFract(FfxFloat32 x) -{ - return fract(x); -} - -/// Compute the factional part of a decimal value. -/// -/// This function calculates x - floor(x). Where floor is the intrinsic HLSL function. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is -/// worth further noting that this function is intentionally distinct from the HLSL frac intrinsic -/// function. -/// -/// @param [in] x The value to compute the fractional part from. -/// -/// @returns -/// The fractional part of x. -/// -/// @ingroup HLSL -FfxFloat32x2 ffxFract(FfxFloat32x2 x) -{ - return fract(x); -} - -/// Compute the factional part of a decimal value. -/// -/// This function calculates x - floor(x). Where floor is the intrinsic HLSL function. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is -/// worth further noting that this function is intentionally distinct from the HLSL frac intrinsic -/// function. -/// -/// @param [in] x The value to compute the fractional part from. -/// -/// @returns -/// The fractional part of x. -/// -/// @ingroup HLSL -FfxFloat32x3 ffxFract(FfxFloat32x3 x) -{ - return fract(x); -} - -/// Compute the factional part of a decimal value. -/// -/// This function calculates x - floor(x). Where floor is the intrinsic HLSL function. -/// -/// NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is -/// worth further noting that this function is intentionally distinct from the HLSL frac intrinsic -/// function. -/// -/// @param [in] x The value to compute the fractional part from. -/// -/// @returns -/// The fractional part of x. -/// -/// @ingroup HLSL -FfxFloat32x4 ffxFract(FfxFloat32x4 x) -{ - return fract(x); -} - -FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b) -{ - return FfxUInt32(FfxInt32(a) >> FfxInt32(b)); -} - -#if FFX_HALF - -#define FFX_UINT32_TO_FLOAT16X2(x) unpackFloat2x16(FfxUInt32(x)) - -FfxFloat16x4 ffxUint32x2ToFloat16x4(FfxUInt32x2 x) -{ - return FfxFloat16x4(unpackFloat2x16(x.x), unpackFloat2x16(x.y)); -} -#define FFX_UINT32X2_TO_FLOAT16X4(x) ffxUint32x2ToFloat16x4(FfxUInt32x2(x)) -#define FFX_UINT32_TO_UINT16X2(x) unpackUint2x16(FfxUInt32(x)) -#define FFX_UINT32X2_TO_UINT16X4(x) unpackUint4x16(pack64(FfxUInt32x2(x))) -//------------------------------------------------------------------------------------------------------------------------------ -#define FFX_FLOAT16X2_TO_UINT32(x) packFloat2x16(FfxFloat16x2(x)) -FfxUInt32x2 ffxFloat16x4ToUint32x2(FfxFloat16x4 x) -{ - return FfxUInt32x2(packFloat2x16(x.xy), packFloat2x16(x.zw)); -} -#define FFX_FLOAT16X4_TO_UINT32X2(x) ffxFloat16x4ToUint32x2(FfxFloat16x4(x)) -#define FFX_UINT16X2_TO_UINT32(x) packUint2x16(FfxUInt16x2(x)) -#define FFX_UINT16X4_TO_UINT32X2(x) unpack32(packUint4x16(FfxUInt16x4(x))) -//============================================================================================================================== -#define FFX_TO_UINT16(x) halfBitsToUint16(FfxFloat16(x)) -#define FFX_TO_UINT16X2(x) halfBitsToUint16(FfxFloat16x2(x)) -#define FFX_TO_UINT16X3(x) halfBitsToUint16(FfxFloat16x3(x)) -#define FFX_TO_UINT16X4(x) halfBitsToUint16(FfxFloat16x4(x)) -//------------------------------------------------------------------------------------------------------------------------------ -#define FFX_TO_FLOAT16(x) uint16BitsToHalf(FfxUInt16(x)) -#define FFX_TO_FLOAT16X2(x) uint16BitsToHalf(FfxUInt16x2(x)) -#define FFX_TO_FLOAT16X3(x) uint16BitsToHalf(FfxUInt16x3(x)) -#define FFX_TO_FLOAT16X4(x) uint16BitsToHalf(FfxUInt16x4(x)) -//============================================================================================================================== -FfxFloat16 ffxBroadcastFloat16(FfxFloat16 a) -{ - return FfxFloat16(a); -} -FfxFloat16x2 ffxBroadcastFloat16x2(FfxFloat16 a) -{ - return FfxFloat16x2(a, a); -} -FfxFloat16x3 ffxBroadcastFloat16x3(FfxFloat16 a) -{ - return FfxFloat16x3(a, a, a); -} -FfxFloat16x4 ffxBroadcastFloat16x4(FfxFloat16 a) -{ - return FfxFloat16x4(a, a, a, a); -} -#define FFX_BROADCAST_FLOAT16(a) FfxFloat16(a) -#define FFX_BROADCAST_FLOAT16X2(a) FfxFloat16x2(FfxFloat16(a)) -#define FFX_BROADCAST_FLOAT16X3(a) FfxFloat16x3(FfxFloat16(a)) -#define FFX_BROADCAST_FLOAT16X4(a) FfxFloat16x4(FfxFloat16(a)) -//------------------------------------------------------------------------------------------------------------------------------ -FfxInt16 ffxBroadcastInt16(FfxInt16 a) -{ - return FfxInt16(a); -} -FfxInt16x2 ffxBroadcastInt16x2(FfxInt16 a) -{ - return FfxInt16x2(a, a); -} -FfxInt16x3 ffxBroadcastInt16x3(FfxInt16 a) -{ - return FfxInt16x3(a, a, a); -} -FfxInt16x4 ffxBroadcastInt16x4(FfxInt16 a) -{ - return FfxInt16x4(a, a, a, a); -} -#define FFX_BROADCAST_INT16(a) FfxInt16(a) -#define FFX_BROADCAST_INT16X2(a) FfxInt16x2(FfxInt16(a)) -#define FFX_BROADCAST_INT16X3(a) FfxInt16x3(FfxInt16(a)) -#define FFX_BROADCAST_INT16X4(a) FfxInt16x4(FfxInt16(a)) -//------------------------------------------------------------------------------------------------------------------------------ -FfxUInt16 ffxBroadcastUInt16(FfxUInt16 a) -{ - return FfxUInt16(a); -} -FfxUInt16x2 ffxBroadcastUInt16x2(FfxUInt16 a) -{ - return FfxUInt16x2(a, a); -} -FfxUInt16x3 ffxBroadcastUInt16x3(FfxUInt16 a) -{ - return FfxUInt16x3(a, a, a); -} -FfxUInt16x4 ffxBroadcastUInt16x4(FfxUInt16 a) -{ - return FfxUInt16x4(a, a, a, a); -} -#define FFX_BROADCAST_UINT16(a) FfxUInt16(a) -#define FFX_BROADCAST_UINT16X2(a) FfxUInt16x2(FfxUInt16(a)) -#define FFX_BROADCAST_UINT16X3(a) FfxUInt16x3(FfxUInt16(a)) -#define FFX_BROADCAST_UINT16X4(a) FfxUInt16x4(FfxUInt16(a)) -//============================================================================================================================== -FfxUInt16 ffxAbsHalf(FfxUInt16 a) -{ - return FfxUInt16(abs(FfxInt16(a))); -} -FfxUInt16x2 ffxAbsHalf(FfxUInt16x2 a) -{ - return FfxUInt16x2(abs(FfxInt16x2(a))); -} -FfxUInt16x3 ffxAbsHalf(FfxUInt16x3 a) -{ - return FfxUInt16x3(abs(FfxInt16x3(a))); -} -FfxUInt16x4 ffxAbsHalf(FfxUInt16x4 a) -{ - return FfxUInt16x4(abs(FfxInt16x4(a))); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxClampHalf(FfxFloat16 x, FfxFloat16 n, FfxFloat16 m) -{ - return clamp(x, n, m); -} -FfxFloat16x2 ffxClampHalf(FfxFloat16x2 x, FfxFloat16x2 n, FfxFloat16x2 m) -{ - return clamp(x, n, m); -} -FfxFloat16x3 ffxClampHalf(FfxFloat16x3 x, FfxFloat16x3 n, FfxFloat16x3 m) -{ - return clamp(x, n, m); -} -FfxFloat16x4 ffxClampHalf(FfxFloat16x4 x, FfxFloat16x4 n, FfxFloat16x4 m) -{ - return clamp(x, n, m); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxFract(FfxFloat16 x) -{ - return fract(x); -} -FfxFloat16x2 ffxFract(FfxFloat16x2 x) -{ - return fract(x); -} -FfxFloat16x3 ffxFract(FfxFloat16x3 x) -{ - return fract(x); -} -FfxFloat16x4 ffxFract(FfxFloat16x4 x) -{ - return fract(x); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxLerp(FfxFloat16 x, FfxFloat16 y, FfxFloat16 a) -{ - return mix(x, y, a); -} -FfxFloat16x2 ffxLerp(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16 a) -{ - return mix(x, y, a); -} -FfxFloat16x2 ffxLerp(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 a) -{ - return mix(x, y, a); -} -FfxFloat16x3 ffxLerp(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 a) -{ - return mix(x, y, a); -} -FfxFloat16x3 ffxLerp(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16 a) -{ - return mix(x, y, a); -} -FfxFloat16x4 ffxLerp(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16 a) -{ - return mix(x, y, a); -} -FfxFloat16x4 ffxLerp(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 a) -{ - return mix(x, y, a); -} -//------------------------------------------------------------------------------------------------------------------------------ -// No packed version of ffxMid3. -FfxFloat16 ffxMed3Half(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxFloat16x2 ffxMed3Half(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxFloat16x3 ffxMed3Half(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxFloat16x4 ffxMed3Half(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxInt16 ffxMed3Half(FfxInt16 x, FfxInt16 y, FfxInt16 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxInt16x2 ffxMed3Half(FfxInt16x2 x, FfxInt16x2 y, FfxInt16x2 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxInt16x3 ffxMed3Half(FfxInt16x3 x, FfxInt16x3 y, FfxInt16x3 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -FfxInt16x4 ffxMed3Half(FfxInt16x4 x, FfxInt16x4 y, FfxInt16x4 z) -{ - return max(min(x, y), min(max(x, y), z)); -} -//------------------------------------------------------------------------------------------------------------------------------ -// No packed version of ffxMax3. -FfxFloat16 ffxMax3Half(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) -{ - return max(x, max(y, z)); -} -FfxFloat16x2 ffxMax3Half(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) -{ - return max(x, max(y, z)); -} -FfxFloat16x3 ffxMax3Half(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) -{ - return max(x, max(y, z)); -} -FfxFloat16x4 ffxMax3Half(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) -{ - return max(x, max(y, z)); -} -//------------------------------------------------------------------------------------------------------------------------------ -// No packed version of ffxMin3. -FfxFloat16 ffxMin3Half(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) -{ - return min(x, min(y, z)); -} -FfxFloat16x2 ffxMin3Half(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) -{ - return min(x, min(y, z)); -} -FfxFloat16x3 ffxMin3Half(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) -{ - return min(x, min(y, z)); -} -FfxFloat16x4 ffxMin3Half(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) -{ - return min(x, min(y, z)); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxReciprocalHalf(FfxFloat16 x) -{ - return FFX_BROADCAST_FLOAT16(1.0) / x; -} -FfxFloat16x2 ffxReciprocalHalf(FfxFloat16x2 x) -{ - return FFX_BROADCAST_FLOAT16X2(1.0) / x; -} -FfxFloat16x3 ffxReciprocalHalf(FfxFloat16x3 x) -{ - return FFX_BROADCAST_FLOAT16X3(1.0) / x; -} -FfxFloat16x4 ffxReciprocalHalf(FfxFloat16x4 x) -{ - return FFX_BROADCAST_FLOAT16X4(1.0) / x; -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxReciprocalSquareRootHalf(FfxFloat16 x) -{ - return FFX_BROADCAST_FLOAT16(1.0) / sqrt(x); -} -FfxFloat16x2 ffxReciprocalSquareRootHalf(FfxFloat16x2 x) -{ - return FFX_BROADCAST_FLOAT16X2(1.0) / sqrt(x); -} -FfxFloat16x3 ffxReciprocalSquareRootHalf(FfxFloat16x3 x) -{ - return FFX_BROADCAST_FLOAT16X3(1.0) / sqrt(x); -} -FfxFloat16x4 ffxReciprocalSquareRootHalf(FfxFloat16x4 x) -{ - return FFX_BROADCAST_FLOAT16X4(1.0) / sqrt(x); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxFloat16 ffxSaturate(FfxFloat16 x) -{ - return clamp(x, FFX_BROADCAST_FLOAT16(0.0), FFX_BROADCAST_FLOAT16(1.0)); -} -FfxFloat16x2 ffxSaturate(FfxFloat16x2 x) -{ - return clamp(x, FFX_BROADCAST_FLOAT16X2(0.0), FFX_BROADCAST_FLOAT16X2(1.0)); -} -FfxFloat16x3 ffxSaturate(FfxFloat16x3 x) -{ - return clamp(x, FFX_BROADCAST_FLOAT16X3(0.0), FFX_BROADCAST_FLOAT16X3(1.0)); -} -FfxFloat16x4 ffxSaturate(FfxFloat16x4 x) -{ - return clamp(x, FFX_BROADCAST_FLOAT16X4(0.0), FFX_BROADCAST_FLOAT16X4(1.0)); -} -//------------------------------------------------------------------------------------------------------------------------------ -FfxUInt16 ffxBitShiftRightHalf(FfxUInt16 a, FfxUInt16 b) -{ - return FfxUInt16(FfxInt16(a) >> FfxInt16(b)); -} -FfxUInt16x2 ffxBitShiftRightHalf(FfxUInt16x2 a, FfxUInt16x2 b) -{ - return FfxUInt16x2(FfxInt16x2(a) >> FfxInt16x2(b)); -} -FfxUInt16x3 ffxBitShiftRightHalf(FfxUInt16x3 a, FfxUInt16x3 b) -{ - return FfxUInt16x3(FfxInt16x3(a) >> FfxInt16x3(b)); -} -FfxUInt16x4 ffxBitShiftRightHalf(FfxUInt16x4 a, FfxUInt16x4 b) -{ - return FfxUInt16x4(FfxInt16x4(a) >> FfxInt16x4(b)); -} -#endif // FFX_HALF - -#if defined(FFX_WAVE) -// Where 'x' must be a compile time literal. -FfxFloat32 AWaveXorF1(FfxFloat32 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxFloat32x2 AWaveXorF2(FfxFloat32x2 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxFloat32x3 AWaveXorF3(FfxFloat32x3 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxFloat32x4 AWaveXorF4(FfxFloat32x4 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxUInt32 AWaveXorU1(FfxUInt32 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxUInt32x2 AWaveXorU2(FfxUInt32x2 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxUInt32x3 AWaveXorU3(FfxUInt32x3 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} -FfxUInt32x4 AWaveXorU4(FfxUInt32x4 v, FfxUInt32 x) -{ - return subgroupShuffleXor(v, x); -} - -//------------------------------------------------------------------------------------------------------------------------------ -#if FFX_HALF -FfxFloat16x2 ffxWaveXorFloat16x2(FfxFloat16x2 v, FfxUInt32 x) -{ - return FFX_UINT32_TO_FLOAT16X2(subgroupShuffleXor(FFX_FLOAT16X2_TO_UINT32(v), x)); -} -FfxFloat16x4 ffxWaveXorFloat16x4(FfxFloat16x4 v, FfxUInt32 x) -{ - return FFX_UINT32X2_TO_FLOAT16X4(subgroupShuffleXor(FFX_FLOAT16X4_TO_UINT32X2(v), x)); -} -FfxUInt16x2 ffxWaveXorUint16x2(FfxUInt16x2 v, FfxUInt32 x) -{ - return FFX_UINT32_TO_UINT16X2(subgroupShuffleXor(FFX_UINT16X2_TO_UINT32(v), x)); -} -FfxUInt16x4 ffxWaveXorUint16x4(FfxUInt16x4 v, FfxUInt32 x) -{ - return FFX_UINT32X2_TO_UINT16X4(subgroupShuffleXor(FFX_UINT16X4_TO_UINT32X2(v), x)); -} -#endif // FFX_HALF -#endif // #if defined(FFX_WAVE) diff --git a/Assets/Resources/FSR2/shaders/ffx_core_glsl.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_glsl.h.meta deleted file mode 100644 index 0e1c0e0..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_glsl.h.meta +++ /dev/null @@ -1,27 +0,0 @@ -fileFormatVersion: 2 -guid: 8b1e08364d8608e4ea7f4372e5b2de67 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl deleted file mode 100644 index 6006fd0..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl +++ /dev/null @@ -1,87 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require -// Needed for rw_upscaled_output declaration -#extension GL_EXT_shader_image_load_formatted : require - -#define FSR2_BIND_SRV_INPUT_EXPOSURE 0 -#define FSR2_BIND_SRV_DILATED_REACTIVE_MASKS 1 -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 2 -#else -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 2 -#endif -#define FSR2_BIND_SRV_INTERNAL_UPSCALED 3 -#define FSR2_BIND_SRV_LOCK_STATUS 4 -#define FSR2_BIND_SRV_INPUT_DEPTH_CLIP 5 -#define FSR2_BIND_SRV_PREPARED_INPUT_COLOR 6 -#define FSR2_BIND_SRV_LUMA_INSTABILITY 7 -#define FSR2_BIND_SRV_LANCZOS_LUT 8 -#define FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 9 -#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 10 -#define FSR2_BIND_SRV_AUTO_EXPOSURE 11 -#define FSR2_BIND_SRV_LUMA_HISTORY 12 - -#define FSR2_BIND_UAV_INTERNAL_UPSCALED 13 -#define FSR2_BIND_UAV_LOCK_STATUS 14 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 15 -#define FSR2_BIND_UAV_NEW_LOCKS 16 -#define FSR2_BIND_UAV_LUMA_HISTORY 17 - -#define FSR2_BIND_CB_FSR2 18 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" -#include "ffx_fsr2_sample.h" -#include "ffx_fsr2_upsample.h" -#include "ffx_fsr2_postprocess_lock_status.h" -#include "ffx_fsr2_reproject.h" -#include "ffx_fsr2_accumulate.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; - -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - uvec2 uGroupId = gl_WorkGroupID.xy; - const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR2_THREAD_GROUP_HEIGHT - 1) / FFX_FSR2_THREAD_GROUP_HEIGHT; - uGroupId.y = GroupRows - uGroupId.y - 1; - - uvec2 uDispatchThreadId = uGroupId * uvec2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + gl_LocalInvocationID.xy; - - Accumulate(ivec2(uDispatchThreadId)); -} \ No newline at end of file diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl.meta deleted file mode 100644 index df1b03a..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a47992654ac46784d976db0091b79aeb -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl deleted file mode 100644 index 7ae41cf..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl +++ /dev/null @@ -1,93 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_INPUT_OPAQUE_ONLY 0 -#define FSR2_BIND_SRV_INPUT_COLOR 1 -#define FSR2_BIND_UAV_AUTOREACTIVE 2 -#define FSR2_BIND_CB_REACTIVE 3 -#define FSR2_BIND_CB_FSR2 4 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" - -// layout (set = 1, binding = FSR2_BIND_SRV_PRE_ALPHA_COLOR) uniform texture2D r_input_color_pre_alpha; -// layout (set = 1, binding = FSR2_BIND_SRV_POST_ALPHA_COLOR) uniform texture2D r_input_color_post_alpha; -// layout (set = 1, binding = FSR2_BIND_UAV_REACTIVE, r8) uniform image2D rw_output_reactive_mask; - - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -#if defined(FSR2_BIND_CB_REACTIVE) -layout (set = 1, binding = FSR2_BIND_CB_REACTIVE, std140) uniform cbGenerateReactive_t -{ - float scale; - float threshold; - float binaryValue; - uint flags; -} cbGenerateReactive; -#endif - -FFX_FSR2_NUM_THREADS -void main() -{ - FfxUInt32x2 uDispatchThreadId = gl_GlobalInvocationID.xy; - - FfxFloat32x3 ColorPreAlpha = LoadOpaqueOnly(FFX_MIN16_I2(uDispatchThreadId)).rgb; - FfxFloat32x3 ColorPostAlpha = LoadInputColor(FFX_MIN16_I2(uDispatchThreadId)).rgb; - - if ((cbGenerateReactive.flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP) != 0) - { - ColorPreAlpha = Tonemap(ColorPreAlpha); - ColorPostAlpha = Tonemap(ColorPostAlpha); - } - - if ((cbGenerateReactive.flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP) != 0) - { - ColorPreAlpha = InverseTonemap(ColorPreAlpha); - ColorPostAlpha = InverseTonemap(ColorPostAlpha); - } - - FfxFloat32 out_reactive_value = 0.f; - FfxFloat32x3 delta = abs(ColorPostAlpha - ColorPreAlpha); - - out_reactive_value = ((cbGenerateReactive.flags & FFX_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX)!=0) ? max(delta.x, max(delta.y, delta.z)) : length(delta); - out_reactive_value *= cbGenerateReactive.scale; - - out_reactive_value = ((cbGenerateReactive.flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD)!=0) ? ((out_reactive_value < cbGenerateReactive.threshold) ? 0 : cbGenerateReactive.binaryValue) : out_reactive_value; - - imageStore(rw_output_autoreactive, FfxInt32x2(uDispatchThreadId), vec4(out_reactive_value)); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl.meta deleted file mode 100644 index 47aaa1f..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9b3697948343bfb42ac4fbc18d2fb8be -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h b/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h deleted file mode 100644 index 10da13f..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h +++ /dev/null @@ -1,681 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -#include "ffx_fsr2_resources.h" - -#if defined(FFX_GPU) -#include "ffx_core.h" -#endif // #if defined(FFX_GPU) - -#if defined(FFX_GPU) -#ifndef FFX_FSR2_PREFER_WAVE64 -#define FFX_FSR2_PREFER_WAVE64 -#endif // #if defined(FFX_GPU) - -#if defined(FSR2_BIND_CB_FSR2) - layout (set = 1, binding = FSR2_BIND_CB_FSR2, std140) uniform cbFSR2_t - { - FfxInt32x2 iRenderSize; - FfxInt32x2 iMaxRenderSize; - FfxInt32x2 iDisplaySize; - FfxInt32x2 iInputColorResourceDimensions; - FfxInt32x2 iLumaMipDimensions; - FfxInt32 iLumaMipLevelToUse; - FfxInt32 iFrameIndex; - - FfxFloat32x4 fDeviceToViewDepth; - FfxFloat32x2 fJitter; - FfxFloat32x2 fMotionVectorScale; - FfxFloat32x2 fDownscaleFactor; - FfxFloat32x2 fMotionVectorJitterCancellation; - FfxFloat32 fPreExposure; - FfxFloat32 fPreviousFramePreExposure; - FfxFloat32 fTanHalfFOV; - FfxFloat32 fJitterSequenceLength; - FfxFloat32 fDeltaTime; - FfxFloat32 fDynamicResChangeFactor; - FfxFloat32 fViewSpaceToMetersFactor; - } cbFSR2; -#endif - -FfxInt32x2 RenderSize() -{ - return cbFSR2.iRenderSize; -} - -FfxInt32x2 MaxRenderSize() -{ - return cbFSR2.iMaxRenderSize; -} - -FfxInt32x2 DisplaySize() -{ - return cbFSR2.iDisplaySize; -} - -FfxInt32x2 InputColorResourceDimensions() -{ - return cbFSR2.iInputColorResourceDimensions; -} - -FfxInt32x2 LumaMipDimensions() -{ - return cbFSR2.iLumaMipDimensions; -} - -FfxInt32 LumaMipLevelToUse() -{ - return cbFSR2.iLumaMipLevelToUse; -} - -FfxInt32 FrameIndex() -{ - return cbFSR2.iFrameIndex; -} - -FfxFloat32x4 DeviceToViewSpaceTransformFactors() -{ - return cbFSR2.fDeviceToViewDepth; -} - -FfxFloat32x2 Jitter() -{ - return cbFSR2.fJitter; -} - -FfxFloat32x2 MotionVectorScale() -{ - return cbFSR2.fMotionVectorScale; -} - -FfxFloat32x2 DownscaleFactor() -{ - return cbFSR2.fDownscaleFactor; -} - -FfxFloat32x2 MotionVectorJitterCancellation() -{ - return cbFSR2.fMotionVectorJitterCancellation; -} - -FfxFloat32 PreExposure() -{ - return cbFSR2.fPreExposure; -} - -FfxFloat32 PreviousFramePreExposure() -{ - return cbFSR2.fPreviousFramePreExposure; -} - -FfxFloat32 TanHalfFoV() -{ - return cbFSR2.fTanHalfFOV; -} - -FfxFloat32 JitterSequenceLength() -{ - return cbFSR2.fJitterSequenceLength; -} - -FfxFloat32 DeltaTime() -{ - return cbFSR2.fDeltaTime; -} - -FfxFloat32 DynamicResChangeFactor() -{ - return cbFSR2.fDynamicResChangeFactor; -} - -FfxFloat32 ViewSpaceToMetersFactor() -{ - return cbFSR2.fViewSpaceToMetersFactor; -} - -layout (set = 0, binding = 0) uniform sampler s_PointClamp; -layout (set = 0, binding = 1) uniform sampler s_LinearClamp; - -// SRVs -#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) - layout (set = 1, binding = FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) uniform texture2D r_input_opaque_only; -#endif -#if defined(FSR2_BIND_SRV_INPUT_COLOR) - layout (set = 1, binding = FSR2_BIND_SRV_INPUT_COLOR) uniform texture2D r_input_color_jittered; -#endif -#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) - layout (set = 1, binding = FSR2_BIND_SRV_INPUT_MOTION_VECTORS) uniform texture2D r_input_motion_vectors; -#endif -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) - layout (set = 1, binding = FSR2_BIND_SRV_INPUT_DEPTH) uniform texture2D r_input_depth; -#endif -#if defined(FSR2_BIND_SRV_INPUT_EXPOSURE) - layout (set = 1, binding = FSR2_BIND_SRV_INPUT_EXPOSURE) uniform texture2D r_input_exposure; -#endif -#if defined(FSR2_BIND_SRV_AUTO_EXPOSURE) - layout(set = 1, binding = FSR2_BIND_SRV_AUTO_EXPOSURE) uniform texture2D r_auto_exposure; -#endif -#if defined(FSR2_BIND_SRV_REACTIVE_MASK) - layout (set = 1, binding = FSR2_BIND_SRV_REACTIVE_MASK) uniform texture2D r_reactive_mask; -#endif -#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) - layout (set = 1, binding = FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) uniform texture2D r_transparency_and_composition_mask; -#endif -#if defined(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) - layout (set = 1, binding = FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) uniform utexture2D r_reconstructed_previous_nearest_depth; -#endif -#if defined(FSR2_BIND_SRV_DILATED_MOTION_VECTORS) - layout (set = 1, binding = FSR2_BIND_SRV_DILATED_MOTION_VECTORS) uniform texture2D r_dilated_motion_vectors; -#endif -#if defined (FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) - layout(set = 1, binding = FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) uniform texture2D r_previous_dilated_motion_vectors; -#endif -#if defined(FSR2_BIND_SRV_DILATED_DEPTH) - layout (set = 1, binding = FSR2_BIND_SRV_DILATED_DEPTH) uniform texture2D r_dilatedDepth; -#endif -#if defined(FSR2_BIND_SRV_INTERNAL_UPSCALED) - layout (set = 1, binding = FSR2_BIND_SRV_INTERNAL_UPSCALED) uniform texture2D r_internal_upscaled_color; -#endif -#if defined(FSR2_BIND_SRV_LOCK_STATUS) - layout (set = 1, binding = FSR2_BIND_SRV_LOCK_STATUS) uniform texture2D r_lock_status; -#endif -#if defined(FSR2_BIND_SRV_LOCK_INPUT_LUMA) - layout (set = 1, binding = FSR2_BIND_SRV_LOCK_INPUT_LUMA) uniform texture2D r_lock_input_luma; -#endif -#if defined(FSR2_BIND_SRV_NEW_LOCKS) - layout(set = 1, binding = FSR2_BIND_SRV_NEW_LOCKS) uniform texture2D r_new_locks; -#endif -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) - layout (set = 1, binding = FSR2_BIND_SRV_PREPARED_INPUT_COLOR) uniform texture2D r_prepared_input_color; -#endif -#if defined(FSR2_BIND_SRV_LUMA_HISTORY) - layout (set = 1, binding = FSR2_BIND_SRV_LUMA_HISTORY) uniform texture2D r_luma_history; -#endif -#if defined(FSR2_BIND_SRV_RCAS_INPUT) - layout (set = 1, binding = FSR2_BIND_SRV_RCAS_INPUT) uniform texture2D r_rcas_input; -#endif -#if defined(FSR2_BIND_SRV_LANCZOS_LUT) - layout (set = 1, binding = FSR2_BIND_SRV_LANCZOS_LUT) uniform texture2D r_lanczos_lut; -#endif -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) - layout (set = 1, binding = FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) uniform texture2D r_imgMips; -#endif -#if defined(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT) - layout (set = 1, binding = FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT) uniform texture2D r_upsample_maximum_bias_lut; -#endif -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) - layout (set = 1, binding = FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) uniform texture2D r_dilated_reactive_masks; -#endif -#if defined(FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR) - layout(set = 1, binding = FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR) uniform texture2D r_input_prev_color_pre_alpha; -#endif -#if defined(FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR) - layout(set = 1, binding = FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR) uniform texture2D r_input_prev_color_post_alpha; -#endif - -// UAV -#if defined FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH - layout (set = 1, binding = FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH, r32ui) uniform uimage2D rw_reconstructed_previous_nearest_depth; -#endif -#if defined FSR2_BIND_UAV_DILATED_MOTION_VECTORS - layout (set = 1, binding = FSR2_BIND_UAV_DILATED_MOTION_VECTORS, rg16f) writeonly uniform image2D rw_dilated_motion_vectors; -#endif -#if defined FSR2_BIND_UAV_DILATED_DEPTH - layout (set = 1, binding = FSR2_BIND_UAV_DILATED_DEPTH, r16f) writeonly uniform image2D rw_dilatedDepth; -#endif -#if defined FSR2_BIND_UAV_INTERNAL_UPSCALED - layout (set = 1, binding = FSR2_BIND_UAV_INTERNAL_UPSCALED, rgba16f) writeonly uniform image2D rw_internal_upscaled_color; -#endif -#if defined FSR2_BIND_UAV_LOCK_STATUS - layout (set = 1, binding = FSR2_BIND_UAV_LOCK_STATUS, rg16f) uniform image2D rw_lock_status; -#endif -#if defined(FSR2_BIND_UAV_LOCK_INPUT_LUMA) - layout(set = 1, binding = FSR2_BIND_UAV_LOCK_INPUT_LUMA, r16f) writeonly uniform image2D rw_lock_input_luma; -#endif -#if defined FSR2_BIND_UAV_NEW_LOCKS - layout(set = 1, binding = FSR2_BIND_UAV_NEW_LOCKS, r8) uniform image2D rw_new_locks; -#endif -#if defined FSR2_BIND_UAV_PREPARED_INPUT_COLOR - layout (set = 1, binding = FSR2_BIND_UAV_PREPARED_INPUT_COLOR, rgba16) writeonly uniform image2D rw_prepared_input_color; -#endif -#if defined FSR2_BIND_UAV_LUMA_HISTORY - layout (set = 1, binding = FSR2_BIND_UAV_LUMA_HISTORY, rgba8) uniform image2D rw_luma_history; -#endif -#if defined FSR2_BIND_UAV_UPSCALED_OUTPUT - layout (set = 1, binding = FSR2_BIND_UAV_UPSCALED_OUTPUT /* app controlled format */) writeonly uniform image2D rw_upscaled_output; -#endif -#if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE - layout (set = 1, binding = FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE, r16f) coherent uniform image2D rw_img_mip_shading_change; -#endif -#if defined FSR2_BIND_UAV_EXPOSURE_MIP_5 - layout (set = 1, binding = FSR2_BIND_UAV_EXPOSURE_MIP_5, r16f) coherent uniform image2D rw_img_mip_5; -#endif -#if defined FSR2_BIND_UAV_DILATED_REACTIVE_MASKS - layout (set = 1, binding = FSR2_BIND_UAV_DILATED_REACTIVE_MASKS, rg8) writeonly uniform image2D rw_dilated_reactive_masks; -#endif -#if defined FSR2_BIND_UAV_EXPOSURE - layout (set = 1, binding = FSR2_BIND_UAV_EXPOSURE, rg32f) uniform image2D rw_exposure; -#endif -#if defined FSR2_BIND_UAV_AUTO_EXPOSURE - layout(set = 1, binding = FSR2_BIND_UAV_AUTO_EXPOSURE, rg32f) uniform image2D rw_auto_exposure; -#endif -#if defined FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC - layout (set = 1, binding = FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC, r32ui) coherent uniform uimage2D rw_spd_global_atomic; -#endif - -#if defined FSR2_BIND_UAV_AUTOREACTIVE - layout(set = 1, binding = FSR2_BIND_UAV_AUTOREACTIVE, r32f) uniform image2D rw_output_autoreactive; -#endif -#if defined FSR2_BIND_UAV_AUTOCOMPOSITION - layout(set = 1, binding = FSR2_BIND_UAV_AUTOCOMPOSITION, r32f) uniform image2D rw_output_autocomposition; -#endif -#if defined FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR - layout(set = 1, binding = FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR, r11f_g11f_b10f) uniform image2D rw_output_prev_color_pre_alpha; -#endif -#if defined FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR - layout(set = 1, binding = FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR, r11f_g11f_b10f) uniform image2D rw_output_prev_color_post_alpha; -#endif - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) -FfxFloat32 LoadMipLuma(FfxInt32x2 iPxPos, FfxInt32 mipLevel) -{ - return texelFetch(r_imgMips, iPxPos, FfxInt32(mipLevel)).r; -} -#endif - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) -FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxInt32 mipLevel) -{ - return textureLod(sampler2D(r_imgMips, s_LinearClamp), fUV, FfxFloat32(mipLevel)).r; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) -FfxFloat32 LoadInputDepth(FfxInt32x2 iPxPos) -{ - return texelFetch(r_input_depth, iPxPos, 0).r; -} -#endif - -#if defined(FSR2_BIND_SRV_REACTIVE_MASK) -FfxFloat32 LoadReactiveMask(FfxInt32x2 iPxPos) -{ - return texelFetch(r_reactive_mask, FfxInt32x2(iPxPos), 0).r; -} -#endif - -#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) -FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) -{ - return texelFetch(r_transparency_and_composition_mask, FfxInt32x2(iPxPos), 0).r; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) -FfxFloat32x3 LoadInputColor(FfxInt32x2 iPxPos) -{ - return texelFetch(r_input_color_jittered, iPxPos, 0).rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) -FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_input_color_jittered, s_LinearClamp), fUV, 0.0f).rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) -FfxFloat32x3 LoadPreparedInputColor(FfxInt32x2 iPxPos) -{ - return texelFetch(r_prepared_input_color, iPxPos, 0).xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) -FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos) -{ - FfxFloat32x2 fSrcMotionVector = texelFetch(r_input_motion_vectors, iPxDilatedMotionVectorPos, 0).xy; - - FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); - -#if FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS - fUvMotionVector -= MotionVectorJitterCancellation(); -#endif - - return fUvMotionVector; -} -#endif - -#if defined(FSR2_BIND_SRV_INTERNAL_UPSCALED) -FfxFloat32x4 LoadHistory(FfxInt32x2 iPxHistory) -{ - return texelFetch(r_internal_upscaled_color, iPxHistory, 0); -} -#endif - -#if defined(FSR2_BIND_UAV_LUMA_HISTORY) -void StoreLumaHistory(FfxInt32x2 iPxPos, FfxFloat32x4 fLumaHistory) -{ - imageStore(rw_luma_history, FfxInt32x2(iPxPos), fLumaHistory); -} -#endif - -#if defined(FSR2_BIND_SRV_LUMA_HISTORY) -FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_luma_history, s_LinearClamp), fUV, 0.0f); -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) -void StoreReprojectedHistory(FfxInt32x2 iPxHistory, FfxFloat32x4 fHistory) -{ - imageStore(rw_internal_upscaled_color, iPxHistory, fHistory); -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) -void StoreInternalColorAndWeight(FfxInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight) -{ - imageStore(rw_internal_upscaled_color, FfxInt32x2(iPxPos), fColorAndWeight); -} -#endif - -#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) -void StoreUpscaledOutput(FfxInt32x2 iPxPos, FfxFloat32x3 fColor) -{ - imageStore(rw_upscaled_output, FfxInt32x2(iPxPos), FfxFloat32x4(fColor, 1.f)); -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_STATUS) -FfxFloat32x2 LoadLockStatus(FfxInt32x2 iPxPos) -{ - FfxFloat32x2 fLockStatus = texelFetch(r_lock_status, iPxPos, 0).rg; - - return fLockStatus; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_STATUS) -void StoreLockStatus(FfxInt32x2 iPxPos, FfxFloat32x2 fLockstatus) -{ - imageStore(rw_lock_status, iPxPos, vec4(fLockstatus, 0.0f, 0.0f)); -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_INPUT_LUMA) -FfxFloat32 LoadLockInputLuma(FfxInt32x2 iPxPos) -{ - return texelFetch(r_lock_input_luma, iPxPos, 0).r; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_INPUT_LUMA) -void StoreLockInputLuma(FfxInt32x2 iPxPos, FfxFloat32 fLuma) -{ - imageStore(rw_lock_input_luma, iPxPos, vec4(fLuma, 0, 0, 0)); -} -#endif - -#if defined(FSR2_BIND_SRV_NEW_LOCKS) -FfxFloat32 LoadNewLocks(FfxInt32x2 iPxPos) -{ - return texelFetch(r_new_locks, iPxPos, 0).r; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) -FfxFloat32 LoadRwNewLocks(FfxInt32x2 iPxPos) -{ - return imageLoad(rw_new_locks, iPxPos).r; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) -void StoreNewLocks(FfxInt32x2 iPxPos, FfxFloat32 newLock) -{ - imageStore(rw_new_locks, iPxPos, vec4(newLock, 0, 0, 0)); -} -#endif - -#if defined(FSR2_BIND_UAV_PREPARED_INPUT_COLOR) -void StorePreparedInputColor(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped) -{ - imageStore(rw_prepared_input_color, iPxPos, fTonemapped); -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) -FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_prepared_input_color, s_LinearClamp), fUV, 0.0f).w; -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_STATUS) -FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV) -{ - FfxFloat32x2 fLockStatus = textureLod(sampler2D(r_lock_status, s_LinearClamp), fUV, 0.0f).rg; - return fLockStatus; -} -#endif - -#if defined(FSR2_BIND_SRV_DEPTH) -FfxFloat32 LoadSceneDepth(FfxInt32x2 iPxInput) -{ - return texelFetch(r_input_depth, iPxInput, 0).r; -} -#endif - -#if defined(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) -FfxFloat32 LoadReconstructedPrevDepth(FfxInt32x2 iPxPos) -{ - return uintBitsToFloat(texelFetch(r_reconstructed_previous_nearest_depth, iPxPos, 0).r); -} -#endif - -#if defined(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) -void StoreReconstructedDepth(FfxInt32x2 iPxSample, FfxFloat32 fDepth) -{ - FfxUInt32 uDepth = floatBitsToUint(fDepth); - - #if FFX_FSR2_OPTION_INVERTED_DEPTH - imageAtomicMax(rw_reconstructed_previous_nearest_depth, iPxSample, uDepth); - #else - imageAtomicMin(rw_reconstructed_previous_nearest_depth, iPxSample, uDepth); // min for standard, max for inverted depth - #endif -} -#endif - -#if defined(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) -void SetReconstructedDepth(FfxInt32x2 iPxSample, FfxUInt32 uValue) -{ - imageStore(rw_reconstructed_previous_nearest_depth, iPxSample, uvec4(uValue, 0, 0, 0)); -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_DEPTH) -void StoreDilatedDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth) -{ - //FfxUInt32 uDepth = f32tof16(fDepth); - imageStore(rw_dilatedDepth, iPxPos, vec4(fDepth, 0.0f, 0.0f, 0.0f)); -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_MOTION_VECTORS) -void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector) -{ - imageStore(rw_dilated_motion_vectors, iPxPos, vec4(fMotionVector, 0.0f, 0.0f)); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_MOTION_VECTORS) -FfxFloat32x2 LoadDilatedMotionVector(FfxInt32x2 iPxInput) -{ - return texelFetch(r_dilated_motion_vectors, iPxInput, 0).rg; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_MOTION_VECTORS) -FfxFloat32x2 SampleDilatedMotionVector(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_dilated_motion_vectors, s_LinearClamp), fUV, 0.0f).rg; -} -#endif - -#if defined(FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) -FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxInt32x2 iPxInput) -{ - return texelFetch(r_previous_dilated_motion_vectors, iPxInput, 0).rg; -} - -FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_previous_dilated_motion_vectors, s_LinearClamp), fUV, 0.0f).xy; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_DEPTH) -FfxFloat32 LoadDilatedDepth(FfxInt32x2 iPxInput) -{ - return texelFetch(r_dilatedDepth, iPxInput, 0).r; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_EXPOSURE) -FfxFloat32 Exposure() -{ - FfxFloat32 exposure = texelFetch(r_input_exposure, FfxInt32x2(0, 0), 0).x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -#if defined(FSR2_BIND_SRV_AUTO_EXPOSURE) -FfxFloat32 AutoExposure() -{ - FfxFloat32 exposure = texelFetch(r_auto_exposure, FfxInt32x2(0, 0), 0).x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -FfxFloat32 SampleLanczos2Weight(FfxFloat32 x) -{ -#if defined(FSR2_BIND_SRV_LANCZOS_LUT) - return textureLod(sampler2D(r_lanczos_lut, s_LinearClamp), FfxFloat32x2(x / 2.0f, 0.5f), 0.0f).x; -#else - return 0.f; -#endif -} - -#if defined(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT) -FfxFloat32 SampleUpsampleMaximumBias(FfxFloat32x2 uv) -{ - // Stored as a SNORM, so make sure to multiply by 2 to retrieve the actual expected range. - return FfxFloat32(2.0f) * FfxFloat32(textureLod(sampler2D(r_upsample_maximum_bias_lut, s_LinearClamp), abs(uv) * 2.0f, 0.0f).r); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) -FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_dilated_reactive_masks, s_LinearClamp), fUV, 0.0f).rg; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) -FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxInt32x2 iPxPos) -{ - return texelFetch(r_dilated_reactive_masks, iPxPos, 0).rg; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_REACTIVE_MASKS) -void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks) -{ - imageStore(rw_dilated_reactive_masks, iPxPos, vec4(fDilatedReactiveMasks, 0.0f, 0.0f)); -} -#endif - -#if defined(FFX_INTERNAL) -FfxFloat32x4 SampleDebug(FfxFloat32x2 fUV) -{ - return textureLod(sampler2D(r_debug_out, s_LinearClamp), fUV, 0.0f).rgba; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) -FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return texelFetch(r_input_opaque_only, iPxPos, 0).xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR) -FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return texelFetch(r_input_prev_color_pre_alpha, iPxPos, 0).xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR) -FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return texelFetch(r_input_prev_color_post_alpha, iPxPos, 0).xyz; -} -#endif - -#if defined(FSR2_BIND_UAV_AUTOREACTIVE) -#if defined(FSR2_BIND_UAV_AUTOCOMPOSITION) -void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive) -{ - imageStore(rw_output_autoreactive, iPxPos, vec4(FfxFloat32(fReactive.x), 0.0f, 0.0f, 0.0f)); - - imageStore(rw_output_autocomposition, iPxPos, vec4(FfxFloat32(fReactive.y), 0.0f, 0.0f, 0.0f)); -} -#endif -#endif - -#if defined(FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR) -void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - imageStore(rw_output_prev_color_pre_alpha, iPxPos, vec4(color, 0.0f)); -} -#endif - -#if defined(FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR) -void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - imageStore(rw_output_prev_color_post_alpha, iPxPos, vec4(color, 0.0f)); -} -#endif - -#endif // #if defined(FFX_GPU) diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h.meta deleted file mode 100644 index b3f8307..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_glsl.h.meta +++ /dev/null @@ -1,27 +0,0 @@ -fileFormatVersion: 2 -guid: 5cb9ad224bca34e4fbc3acf33bd82fbe -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl deleted file mode 100644 index 3c99b98..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl +++ /dev/null @@ -1,134 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_INPUT_COLOR 0 -#define FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC 1 -#define FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 2 -#define FSR2_BIND_UAV_EXPOSURE_MIP_5 3 -#define FSR2_BIND_UAV_AUTO_EXPOSURE 4 -#define FSR2_BIND_CB_FSR2 5 -#define FSR2_BIND_CB_SPD 6 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" - -#if defined(FSR2_BIND_CB_SPD) - layout (set = 1, binding = FSR2_BIND_CB_SPD, std140) uniform cbSPD_t - { - uint mips; - uint numWorkGroups; - uvec2 workGroupOffset; - uvec2 renderSize; - } cbSPD; - - uint MipCount() - { - return cbSPD.mips; - } - - uint NumWorkGroups() - { - return cbSPD.numWorkGroups; - } - - uvec2 WorkGroupOffset() - { - return cbSPD.workGroupOffset; - } - - uvec2 SPD_RenderSize() - { - return cbSPD.renderSize; - } -#endif - -vec2 SPD_LoadExposureBuffer() -{ - return imageLoad(rw_auto_exposure, ivec2(0,0)).xy; -} - -void SPD_SetExposureBuffer(vec2 value) -{ - imageStore(rw_auto_exposure, ivec2(0,0), vec4(value, 0.0f, 0.0f)); -} - -vec4 SPD_LoadMipmap5(ivec2 iPxPos) -{ - return vec4(imageLoad(rw_img_mip_5, iPxPos).x, 0.0f, 0.0f, 0.0f); -} - -void SPD_SetMipmap(ivec2 iPxPos, uint slice, float value) -{ - switch (slice) - { - case FFX_FSR2_SHADING_CHANGE_MIP_LEVEL: - imageStore(rw_img_mip_shading_change, iPxPos, vec4(value, 0.0f, 0.0f, 0.0f)); - break; - case 5: - imageStore(rw_img_mip_5, iPxPos, vec4(value, 0.0f, 0.0f, 0.0f)); - break; - default: - - // avoid flattened side effect -#if defined(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE) - imageStore(rw_img_mip_shading_change, iPxPos, vec4(imageLoad(rw_img_mip_shading_change, iPxPos).x, 0.0f, 0.0f, 0.0f)); -#elif defined(FSR2_BIND_UAV_EXPOSURE_MIP_5) - imageStore(rw_img_mip_5, iPxPos, vec4(imageLoad(rw_img_mip_5, iPxPos).x, 0.0f, 0.0f, 0.0f)); -#endif - break; - } -} - -void SPD_IncreaseAtomicCounter(inout uint spdCounter) -{ - spdCounter = imageAtomicAdd(rw_spd_global_atomic, ivec2(0,0), 1); -} - -void SPD_ResetAtomicCounter() -{ - imageStore(rw_spd_global_atomic, ivec2(0,0), uvec4(0)); -} - -#include "ffx_fsr2_compute_luminance_pyramid.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 256 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - ComputeAutoExposure(gl_WorkGroupID.xyz, gl_LocalInvocationIndex); -} \ No newline at end of file diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl.meta deleted file mode 100644 index d6ba893..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 43b69b4a78d09164aa834576507445c1 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl deleted file mode 100644 index c7e3093..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 -#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 1 -#define FSR2_BIND_SRV_DILATED_DEPTH 2 -#define FSR2_BIND_SRV_REACTIVE_MASK 3 -#define FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 4 -#define FSR2_BIND_SRV_PREPARED_INPUT_COLOR 5 -#define FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS 6 -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 7 -#define FSR2_BIND_SRV_INPUT_COLOR 8 -#define FSR2_BIND_SRV_INPUT_DEPTH 9 -#define FSR2_BIND_SRV_INPUT_EXPOSURE 10 - -#define FSR2_BIND_UAV_DEPTH_CLIP 11 -#define FSR2_BIND_UAV_DILATED_REACTIVE_MASKS 12 -#define FSR2_BIND_UAV_PREPARED_INPUT_COLOR 13 - -#define FSR2_BIND_CB_FSR2 14 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" -#include "ffx_fsr2_sample.h" -#include "ffx_fsr2_depth_clip.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - DepthClip(ivec2(gl_GlobalInvocationID.xy)); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl.meta deleted file mode 100644 index a0459e8..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b02126743783b1942a0777c5e9b7526a -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl deleted file mode 100644 index f7cad59..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl +++ /dev/null @@ -1,56 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_LOCK_INPUT_LUMA 0 -#define FSR2_BIND_UAV_NEW_LOCKS 1 -#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 2 -#define FSR2_BIND_CB_FSR2 3 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" -#include "ffx_fsr2_sample.h" -#include "ffx_fsr2_lock.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - uvec2 uDispatchThreadId = gl_WorkGroupID.xy * uvec2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + gl_LocalInvocationID.xy; - - ComputeLock(ivec2(uDispatchThreadId)); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl.meta deleted file mode 100644 index 982c1d4..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5f63384878e8f1c428f5716f3b8e1065 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl deleted file mode 100644 index d37e0af..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl +++ /dev/null @@ -1,62 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// FSR2 pass 1 -// SRV 1 : m_HDR : r_input_color_jittered -// SRV 4 : FSR2_Exposure : r_exposure -// UAV 7 : FSR2_ReconstructedPrevNearestDepth : rw_reconstructed_previous_nearest_depth -// UAV 13 : FSR2_PreparedInputColor : rw_prepared_input_color -// UAV 14 : FSR2_LumaHistory : rw_luma_history -// CB 0 : cbFSR2 - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_INPUT_COLOR 0 -#define FSR2_BIND_SRV_EXPOSURE 1 -#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 2 -#define FSR2_BIND_UAV_PREPARED_INPUT_COLOR 3 -#define FSR2_BIND_UAV_LUMA_HISTORY 4 -#define FSR2_BIND_CB_FSR2 5 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" -#include "ffx_fsr2_prepare_input_color.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - PrepareInputColor(ivec2(gl_GlobalInvocationID.xy)); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl.meta deleted file mode 100644 index b4f7fb5..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_prepare_input_color_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 130af27aabe0f3347bf8fcfea8d5de84 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl deleted file mode 100644 index 20807a3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require -// Needed for rw_upscaled_output declaration -#extension GL_EXT_shader_image_load_formatted : require - -#define FSR2_BIND_SRV_INPUT_EXPOSURE 0 -#define FSR2_BIND_SRV_RCAS_INPUT 1 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 2 -#define FSR2_BIND_CB_FSR2 3 -#define FSR2_BIND_CB_RCAS 4 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" - -//Move to prototype shader! -#if defined(FSR2_BIND_CB_RCAS) - layout (set = 1, binding = FSR2_BIND_CB_RCAS, std140) uniform cbRCAS_t - { - uvec4 rcasConfig; - } cbRCAS; - - uvec4 RCASConfig() - { - return cbRCAS.rcasConfig; - } -#else - uvec4 RCASConfig() - { - return uvec4(0); - } -#endif - -vec4 LoadRCAS_Input(FfxInt32x2 iPxPos) -{ - return texelFetch(r_rcas_input, iPxPos, 0); -} - -#include "ffx_fsr2_rcas.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 64 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - RCAS(gl_LocalInvocationID.xyz, gl_WorkGroupID.xyz, gl_GlobalInvocationID.xyz); -} \ No newline at end of file diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl.meta deleted file mode 100644 index 160f665..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 6e70536fee1272645bab8093b1c715e7 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl deleted file mode 100644 index 20e17ee..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl +++ /dev/null @@ -1,65 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 0 -#define FSR2_BIND_SRV_INPUT_DEPTH 1 -#define FSR2_BIND_SRV_INPUT_COLOR 2 -#define FSR2_BIND_SRV_INPUT_EXPOSURE 3 -#define FSR2_BIND_SRV_LUMA_HISTORY 4 - -#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 5 -#define FSR2_BIND_UAV_DILATED_MOTION_VECTORS 6 -#define FSR2_BIND_UAV_DILATED_DEPTH 7 -#define FSR2_BIND_UAV_PREPARED_INPUT_COLOR 8 -#define FSR2_BIND_UAV_LUMA_HISTORY 9 -#define FSR2_BIND_UAV_LUMA_INSTABILITY 10 -#define FSR2_BIND_UAV_LOCK_INPUT_LUMA 11 - -#define FSR2_BIND_CB_FSR2 12 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" -#include "ffx_fsr2_sample.h" -#include "ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - ReconstructAndDilate(FFX_MIN16_I2(gl_GlobalInvocationID.xy)); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl.meta deleted file mode 100644 index b76404d..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e3f9c69c87e772f4387b1bd3363a8688 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl deleted file mode 100644 index bebca91..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl +++ /dev/null @@ -1,116 +0,0 @@ -// This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#version 450 - -#extension GL_GOOGLE_include_directive : require -#extension GL_EXT_samplerless_texture_functions : require - -#define FSR2_BIND_SRV_INPUT_OPAQUE_ONLY 0 -#define FSR2_BIND_SRV_INPUT_COLOR 1 -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 2 -#define FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR 3 -#define FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR 4 -#define FSR2_BIND_SRV_REACTIVE_MASK 5 -#define FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 6 - -#define FSR2_BIND_UAV_AUTOREACTIVE 7 -#define FSR2_BIND_UAV_AUTOCOMPOSITION 8 -#define FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR 9 -#define FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR 10 - -#define FSR2_BIND_CB_FSR2 11 -#define FSR2_BIND_CB_REACTIVE 12 - -#include "ffx_fsr2_callbacks_glsl.h" -#include "ffx_fsr2_common.h" - -#ifdef FSR2_BIND_CB_REACTIVE -layout (set = 1, binding = FSR2_BIND_CB_REACTIVE, std140) uniform cbGenerateReactive_t -{ - float fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels - float fTcScale; - float fReactiveScale; - float fReactiveMax; -} cbGenerateReactive; - -float getTcThreshold() -{ - return cbGenerateReactive.fTcThreshold; -} - -#else - float getTcThreshold() - { - return 0.05f; - } -#endif - -#include "ffx_fsr2_tcr_autogen.h" - -#ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#define FFX_FSR2_THREAD_GROUP_WIDTH 8 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH -#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT -#define FFX_FSR2_THREAD_GROUP_HEIGHT 8 -#endif // FFX_FSR2_THREAD_GROUP_HEIGHT -#ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#define FFX_FSR2_THREAD_GROUP_DEPTH 1 -#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH -#ifndef FFX_FSR2_NUM_THREADS -#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in; -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -void main() -{ - FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(gl_GlobalInvocationID.xy); - - // ToDo: take into account jitter (i.e. add delta of previous jitter and current jitter to previous UV - // fetch pre- and post-alpha color values - FFX_MIN16_F2 fUv = ( FFX_MIN16_F2(uDispatchThreadId) + FFX_MIN16_F2(0.5f, 0.5f) ) / FFX_MIN16_F2( RenderSize() ); - FFX_MIN16_F2 fPrevUV = fUv + FFX_MIN16_F2( LoadInputMotionVector(uDispatchThreadId) ); - FFX_MIN16_I2 iPrevIdx = FFX_MIN16_I2(fPrevUV * FFX_MIN16_F2(RenderSize()) - 0.5f); - - FFX_MIN16_F3 colorPreAlpha = FFX_MIN16_F3( LoadOpaqueOnly( uDispatchThreadId ) ); - FFX_MIN16_F3 colorPostAlpha = FFX_MIN16_F3( LoadInputColor( uDispatchThreadId ) ); - - FFX_MIN16_F2 outReactiveMask = FFX_MIN16_F2( 0.f, 0.f ); - - outReactiveMask.y = ComputeTransparencyAndComposition(uDispatchThreadId, iPrevIdx); - - if (outReactiveMask.y > 0.5f) - { - outReactiveMask.x = ComputeReactive(uDispatchThreadId, iPrevIdx); - outReactiveMask.x *= FFX_MIN16_F(cbGenerateReactive.fReactiveScale); - outReactiveMask.x = outReactiveMask.x < cbGenerateReactive.fReactiveMax ? outReactiveMask.x : FFX_MIN16_F( cbGenerateReactive.fReactiveMax ); - } - - outReactiveMask.y *= FFX_MIN16_F(cbGenerateReactive.fTcScale); - - outReactiveMask.x = ffxMax(outReactiveMask.x, FFX_MIN16_F(LoadReactiveMask(uDispatchThreadId))); - outReactiveMask.y = ffxMax(outReactiveMask.y, FFX_MIN16_F(LoadTransparencyAndCompositionMask(uDispatchThreadId))); - - StoreAutoReactive(uDispatchThreadId, outReactiveMask); - - StorePrevPreAlpha(uDispatchThreadId, colorPreAlpha); - StorePrevPostAlpha(uDispatchThreadId, colorPostAlpha); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl.meta deleted file mode 100644 index fb3bba0..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.glsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9fa6f2f6f5a17084da2790fb96ee4c03 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: