diff --git a/Assets/Fsr3UpscalerAssets.asset b/Assets/Fsr3UpscalerAssets.asset new file mode 100644 index 0000000..f3f30ea --- /dev/null +++ b/Assets/Fsr3UpscalerAssets.asset @@ -0,0 +1,23 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db26e15a33db6ab42a38daab0ba2712f, type: 3} + m_Name: Fsr3UpscalerAssets + m_EditorClassIdentifier: + shaders: + computeLuminancePyramidPass: {fileID: 7200000, guid: d253be05abcdc80428503d3e4cce3a36, type: 3} + reconstructPreviousDepthPass: {fileID: 7200000, guid: 4f59e5b9179d74844ae06a30ae1e0629, type: 3} + depthClipPass: {fileID: 7200000, guid: 20e44016ed34b0d4b8de499d1b566c69, type: 3} + lockPass: {fileID: 7200000, guid: a135306e6d1857e43a86ef20db2a47fe, type: 3} + accumulatePass: {fileID: 7200000, guid: c9b45f0ae7673694ba57a4aadfe212e9, type: 3} + sharpenPass: {fileID: 7200000, guid: 7aaf5cfff022de2499e9b0412f947f6c, type: 3} + autoGenReactivePass: {fileID: 7200000, guid: 5716b91fdaa4e9e439df6b96a796fe6e, type: 3} + tcrAutoGenPass: {fileID: 7200000, guid: 75cdc6ef23f08ed498d4da511923fcea, type: 3} diff --git a/Assets/Fsr3UpscalerAssets.asset.meta b/Assets/Fsr3UpscalerAssets.asset.meta new file mode 100644 index 0000000..1aa49b3 --- /dev/null +++ b/Assets/Fsr3UpscalerAssets.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4151befafd86e8740ab09463b4f1bdbb +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute.meta b/Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute.meta deleted file mode 100644 index a197b49..0000000 --- a/Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3c96d72b39a840c428c901628dab92c0 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute.meta b/Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute.meta deleted file mode 100644 index ea6c978..0000000 --- a/Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5a82801f160ff6a4eb47db567216e592 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta b/Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta deleted file mode 100644 index 6396b86..0000000 --- a/Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6ef1b4c25874e334dad5ba3ac6345e32 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta b/Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta deleted file mode 100644 index 0002090..0000000 --- a/Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b478fba0a6a87b44b8be7c35deb5f0dc -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_common_types.h.meta b/Assets/Resources/FSR2/shaders/ffx_common_types.h.meta deleted file mode 100644 index f2cc805..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_common_types.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: c6da07d8aae05f04f87e4db20f84c73e -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core.h.meta b/Assets/Resources/FSR2/shaders/ffx_core.h.meta deleted file mode 100644 index a5f80a7..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: b37eb663a0ae01b469b0b5a54365b301 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core_cpu.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_cpu.h.meta deleted file mode 100644 index 7edf590..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_cpu.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 9d1d6ed5c9da0c64b882f3ebc2bac307 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_gpu_common.h.meta deleted file mode 100644 index 8f9711f..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 402c509393f5bf647b41a962a48ed8e2 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common_half.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_gpu_common_half.h.meta deleted file mode 100644 index 1d826e4..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common_half.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 142bf3947ada43541a0f31a328fdec07 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core_hlsl.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_hlsl.h.meta deleted file mode 100644 index 5a91c43..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_hlsl.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 89d6e02f97594f64ca2da4c8124df6cf -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_core_portability.h.meta b/Assets/Resources/FSR2/shaders/ffx_core_portability.h.meta deleted file mode 100644 index aad361f..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_core_portability.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 5d6e692075988194382122bac7819f02 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr1.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr1.h.meta deleted file mode 100644 index cf43a8b..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr1.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 7524e42f73f97f34bbeb414ea412a808 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate.h.meta deleted file mode 100644 index 51859c3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: a04cb2522aaff1045869a272ed129964 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl deleted file mode 100644 index 747f380..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl +++ /dev/null @@ -1,78 +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. - -#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_PREPARED_INPUT_COLOR 5 -#define FSR2_BIND_SRV_LANCZOS_LUT 6 -#define FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7 -#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 8 -#define FSR2_BIND_SRV_AUTO_EXPOSURE 9 -#define FSR2_BIND_SRV_LUMA_HISTORY 10 - -#define FSR2_BIND_UAV_INTERNAL_UPSCALED 0 -#define FSR2_BIND_UAV_LOCK_STATUS 1 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 2 -#define FSR2_BIND_UAV_NEW_LOCKS 3 -#define FSR2_BIND_UAV_LUMA_HISTORY 4 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR2_THREAD_GROUP_HEIGHT - 1) / FFX_FSR2_THREAD_GROUP_HEIGHT; - uGroupId.y = GroupRows - uGroupId.y - 1; - - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - Accumulate(uDispatchThreadId); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl deleted file mode 100644 index a78a8e3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl +++ /dev/null @@ -1,85 +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. - -#define FSR2_BIND_SRV_INPUT_OPAQUE_ONLY 0 -#define FSR2_BIND_SRV_INPUT_COLOR 1 -#define FSR2_BIND_UAV_AUTOREACTIVE 0 - -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_REACTIVE 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -#if defined(FSR2_BIND_CB_REACTIVE) -cbuffer cbGenerateReactive : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_REACTIVE) -{ - float scale; - float threshold; - float binaryValue; - uint flags; -}; -#endif - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - float3 ColorPreAlpha = LoadOpaqueOnly( FFX_MIN16_I2(uDispatchThreadId) ).rgb; - float3 ColorPostAlpha = LoadInputColor(uDispatchThreadId).rgb; - - if (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP) - { - ColorPreAlpha = Tonemap(ColorPreAlpha); - ColorPostAlpha = Tonemap(ColorPostAlpha); - } - - if (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP) - { - ColorPreAlpha = InverseTonemap(ColorPreAlpha); - ColorPostAlpha = InverseTonemap(ColorPostAlpha); - } - - float out_reactive_value = 0.f; - float3 delta = abs(ColorPostAlpha - ColorPreAlpha); - - out_reactive_value = (flags & FFX_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta); - out_reactive_value *= scale; - - out_reactive_value = (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < threshold ? 0 : binaryValue) : out_reactive_value; - - rw_output_autoreactive[uDispatchThreadId] = out_reactive_value; -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h b/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h deleted file mode 100644 index de79c82..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h +++ /dev/null @@ -1,817 +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) -#ifdef __hlsl_dx_compiler -#pragma dxc diagnostic push -#pragma dxc diagnostic ignored "-Wambig-lit-shift" -#endif //__hlsl_dx_compiler -#include "ffx_core.h" -#ifdef __hlsl_dx_compiler -#pragma dxc diagnostic pop -#endif //__hlsl_dx_compiler -#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(FFX_GPU) -#pragma warning(disable: 3205) // conversion from larger type to smaller -#endif // #if defined(FFX_GPU) - -#define DECLARE_SRV_REGISTER(regIndex) t##regIndex -#define DECLARE_UAV_REGISTER(regIndex) u##regIndex -#define DECLARE_CB_REGISTER(regIndex) b##regIndex -#define FFX_FSR2_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) -#define FFX_FSR2_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) -#define FFX_FSR2_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) - -#if defined(FSR2_BIND_CB_FSR2) || defined(FFX_INTERNAL) - cbuffer cbFSR2 : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_FSR2) - { - 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; - - FfxInt32 iDummy; - }; - -#define FFX_FSR2_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR2) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR2 size. -#endif - -#if defined(FFX_GPU) -#define FFX_FSR2_ROOTSIG_STRINGIFY(p) FFX_FSR2_ROOTSIG_STR(p) -#define FFX_FSR2_ROOTSIG_STR(p) #p -#define FFX_FSR2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_1_SIZE) ", b0), " \ - "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ - "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] - -#define FFX_FSR2_CONSTANT_BUFFER_2_SIZE 6 // Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size. - -#define FFX_FSR2_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_1_SIZE) ", b0), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_2_SIZE) ", b1), " \ - "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ - "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] -#if defined(FFX_FSR2_EMBED_ROOTSIG) -#define FFX_FSR2_EMBED_ROOTSIG_CONTENT FFX_FSR2_ROOTSIG -#define FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT FFX_FSR2_CB2_ROOTSIG -#else -#define FFX_FSR2_EMBED_ROOTSIG_CONTENT -#define FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -#endif // #if FFX_FSR2_EMBED_ROOTSIG -#endif // #if defined(FFX_GPU) - -// Declare and sample camera buffers as regular textures, unless overridden -#if !defined(UNITY_FSR2_TEX2D) -#define UNITY_FSR2_TEX2D(type) Texture2D -#endif -#if !defined(UNITY_FSR2_POS) -#define UNITY_FSR2_POS(pxPos) (pxPos) -#endif -#if !defined(UNITY_FSR2_UV) -#define UNITY_FSR2_UV(uv) (uv) -#endif - -/* Define getter functions in the order they are defined in the CB! */ -FfxInt32x2 RenderSize() -{ - return iRenderSize; -} - -FfxInt32x2 MaxRenderSize() -{ - return iMaxRenderSize; -} - -FfxInt32x2 DisplaySize() -{ - return iDisplaySize; -} - -FfxInt32x2 InputColorResourceDimensions() -{ - return iInputColorResourceDimensions; -} - -FfxInt32x2 LumaMipDimensions() -{ - return iLumaMipDimensions; -} - -FfxInt32 LumaMipLevelToUse() -{ - return iLumaMipLevelToUse; -} - -FfxInt32 FrameIndex() -{ - return iFrameIndex; -} - -FfxFloat32x2 Jitter() -{ - return fJitter; -} - -FfxFloat32x4 DeviceToViewSpaceTransformFactors() -{ - return fDeviceToViewDepth; -} - -FfxFloat32x2 MotionVectorScale() -{ - return fMotionVectorScale; -} - -FfxFloat32x2 DownscaleFactor() -{ - return fDownscaleFactor; -} - -FfxFloat32x2 MotionVectorJitterCancellation() -{ - return fMotionVectorJitterCancellation; -} - -FfxFloat32 PreExposure() -{ - return fPreExposure; -} - -FfxFloat32 PreviousFramePreExposure() -{ - return fPreviousFramePreExposure; -} - -FfxFloat32 TanHalfFoV() -{ - return fTanHalfFOV; -} - -FfxFloat32 JitterSequenceLength() -{ - return fJitterSequenceLength; -} - -FfxFloat32 DeltaTime() -{ - return fDeltaTime; -} - -FfxFloat32 DynamicResChangeFactor() -{ - return fDynamicResChangeFactor; -} - -FfxFloat32 ViewSpaceToMetersFactor() -{ - return fViewSpaceToMetersFactor; -} - - -SamplerState s_PointClamp : register(s0); -SamplerState s_LinearClamp : register(s1); - -// SRVs -#if defined(FFX_INTERNAL) - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY); - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_COLOR); - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS); - UNITY_FSR2_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_DEPTH); - Texture2D r_input_exposure : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_EXPOSURE); - Texture2D r_auto_exposure : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE); - Texture2D r_reactive_mask : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK); - Texture2D r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK); - Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH); - Texture2D r_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS); - Texture2D r_previous_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS); - Texture2D r_dilatedDepth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH); - Texture2D r_internal_upscaled_color : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR); - Texture2D r_lock_status : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS); - Texture2D r_lock_input_luma : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA); - Texture2D r_new_locks : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS); - Texture2D r_prepared_input_color : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR); - Texture2D r_luma_history : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY); - Texture2D r_rcas_input : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_RCAS_INPUT); - Texture2D r_lanczos_lut : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LANCZOS_LUT); - Texture2D r_imgMips : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE); - Texture2D r_upsample_maximum_bias_lut : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT); - Texture2D r_dilated_reactive_masks : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS); - Texture2D r_input_prev_color_pre_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - Texture2D r_input_prev_color_post_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - - Texture2D r_debug_out : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT); - - // UAV declarations - RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH); - RWTexture2D rw_dilated_motion_vectors : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS); - RWTexture2D rw_dilatedDepth : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH); - RWTexture2D rw_internal_upscaled_color : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR); - RWTexture2D rw_lock_status : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS); - RWTexture2D rw_lock_input_luma : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA); - RWTexture2D rw_new_locks : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS); - RWTexture2D rw_prepared_input_color : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR); - RWTexture2D rw_luma_history : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY); - RWTexture2D rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT); - - globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE); - globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5); - RWTexture2D rw_dilated_reactive_masks : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS); - RWTexture2D rw_auto_exposure : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE); - globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT); - RWTexture2D rw_debug_out : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT); - - RWTexture2D rw_output_autoreactive : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTOREACTIVE); - RWTexture2D rw_output_autocomposition : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTOCOMPOSITION); - RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - -#else // #if defined(FFX_INTERNAL) - #if defined FSR2_BIND_SRV_INPUT_COLOR - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); - #endif - #if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); - #endif - #if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_INPUT_DEPTH - UNITY_FSR2_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); - #endif - #if defined FSR2_BIND_SRV_INPUT_EXPOSURE - Texture2D r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); - #endif - #if defined FSR2_BIND_SRV_AUTO_EXPOSURE - Texture2D r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); - #endif - #if defined FSR2_BIND_SRV_REACTIVE_MASK - Texture2D r_reactive_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); - #endif - #if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK - Texture2D r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); - #endif - #if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH - Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); - #endif - #if defined FSR2_BIND_SRV_DILATED_MOTION_VECTORS - Texture2D r_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS - Texture2D r_previous_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_DILATED_DEPTH - Texture2D r_dilatedDepth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_DEPTH); - #endif - #if defined FSR2_BIND_SRV_INTERNAL_UPSCALED - Texture2D r_internal_upscaled_color : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INTERNAL_UPSCALED); - #endif - #if defined FSR2_BIND_SRV_LOCK_STATUS - Texture2D r_lock_status : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LOCK_STATUS); - #endif - #if defined FSR2_BIND_SRV_LOCK_INPUT_LUMA - Texture2D r_lock_input_luma : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LOCK_INPUT_LUMA); - #endif - #if defined FSR2_BIND_SRV_NEW_LOCKS - Texture2D r_new_locks : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_NEW_LOCKS); - #endif - #if defined FSR2_BIND_SRV_PREPARED_INPUT_COLOR - Texture2D r_prepared_input_color : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_PREPARED_INPUT_COLOR); - #endif - #if defined FSR2_BIND_SRV_LUMA_HISTORY - Texture2D r_luma_history : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LUMA_HISTORY); - #endif - #if defined FSR2_BIND_SRV_RCAS_INPUT - Texture2D r_rcas_input : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RCAS_INPUT); - #endif - #if defined FSR2_BIND_SRV_LANCZOS_LUT - Texture2D r_lanczos_lut : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LANCZOS_LUT); - #endif - #if defined FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS - Texture2D r_imgMips : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS); - #endif - #if defined FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT - Texture2D r_upsample_maximum_bias_lut : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT); - #endif - #if defined FSR2_BIND_SRV_DILATED_REACTIVE_MASKS - Texture2D r_dilated_reactive_masks : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS); - #endif - - #if defined FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR - Texture2D r_input_prev_color_pre_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - #endif - #if defined FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR - Texture2D r_input_prev_color_post_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - #endif - - // UAV declarations - #if defined FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH - RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH); - #endif - #if defined FSR2_BIND_UAV_DILATED_MOTION_VECTORS - RWTexture2D rw_dilated_motion_vectors : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_UAV_DILATED_DEPTH - RWTexture2D rw_dilatedDepth : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_DEPTH); - #endif - #if defined FSR2_BIND_UAV_INTERNAL_UPSCALED - RWTexture2D rw_internal_upscaled_color : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_INTERNAL_UPSCALED); - #endif - #if defined FSR2_BIND_UAV_LOCK_STATUS - RWTexture2D rw_lock_status : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LOCK_STATUS); - #endif - #if defined FSR2_BIND_UAV_LOCK_INPUT_LUMA - RWTexture2D rw_lock_input_luma : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LOCK_INPUT_LUMA); - #endif - #if defined FSR2_BIND_UAV_NEW_LOCKS - RWTexture2D rw_new_locks : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_NEW_LOCKS); - #endif - #if defined FSR2_BIND_UAV_PREPARED_INPUT_COLOR - RWTexture2D rw_prepared_input_color : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREPARED_INPUT_COLOR); - #endif - #if defined FSR2_BIND_UAV_LUMA_HISTORY - RWTexture2D rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); - #endif - #if defined FSR2_BIND_UAV_UPSCALED_OUTPUT - RWTexture2D rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE - globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE_MIP_5 - globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_5); - #endif - #if defined FSR2_BIND_UAV_DILATED_REACTIVE_MASKS - RWTexture2D rw_dilated_reactive_masks : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_REACTIVE_MASKS); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE - RWTexture2D rw_exposure : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE); - #endif - #if defined FSR2_BIND_UAV_AUTO_EXPOSURE - RWTexture2D rw_auto_exposure : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTO_EXPOSURE); - #endif - #if defined FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC - globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC); - #endif - - #if defined FSR2_BIND_UAV_AUTOREACTIVE - RWTexture2D rw_output_autoreactive : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTOREACTIVE); - #endif - #if defined FSR2_BIND_UAV_AUTOCOMPOSITION - RWTexture2D rw_output_autocomposition : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTOCOMPOSITION); - #endif - #if defined FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR - RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR); - #endif - #if defined FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR - RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR); - #endif -#endif // #if defined(FFX_INTERNAL) - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) || defined(FFX_INTERNAL) -FfxFloat32 LoadMipLuma(FfxUInt32x2 iPxPos, FfxUInt32 mipLevel) -{ - return r_imgMips.mips[mipLevel][iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) || defined(FFX_INTERNAL) -FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) -{ - return r_imgMips.SampleLevel(s_LinearClamp, fUV, mipLevel); -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) -{ - return r_input_depth[UNITY_FSR2_POS(iPxPos)]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) -{ - return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR2_UV(fUV), 0).x; -} -#endif - -#if defined(FSR2_BIND_SRV_REACTIVE_MASK) || defined(FFX_INTERNAL) -FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) -{ - return r_reactive_mask[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) || defined(FFX_INTERNAL) -FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) -{ - return r_transparency_and_composition_mask[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) -{ - return r_input_color_jittered[UNITY_FSR2_POS(iPxPos)].rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) -{ - return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR2_UV(fUV), 0).rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos) -{ - return r_prepared_input_color[iPxPos].xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) -{ - FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR2_POS(iPxDilatedMotionVectorPos)].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) || defined(FFX_INTERNAL) -FfxFloat32x4 LoadHistory(FfxUInt32x2 iPxHistory) -{ - return r_internal_upscaled_color[iPxHistory]; -} -#endif - -#if defined(FSR2_BIND_UAV_LUMA_HISTORY) || defined(FFX_INTERNAL) -void StoreLumaHistory(FfxUInt32x2 iPxPos, FfxFloat32x4 fLumaHistory) -{ - rw_luma_history[iPxPos] = fLumaHistory; -} - -FfxFloat32x4 LoadRwLumaHistory(FFX_MIN16_I2 iPxPos) -{ - return rw_luma_history[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_LUMA_HISTORY) || defined(FFX_INTERNAL) -FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV) -{ - return r_luma_history.SampleLevel(s_LinearClamp, fUV, 0); -} -#endif - -#if defined(FFX_INTERNAL) -FfxFloat32x4 SampleDebug(FfxFloat32x2 fUV) -{ - return r_debug_out.SampleLevel(s_LinearClamp, fUV, 0).w; -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) || defined(FFX_INTERNAL) -void StoreReprojectedHistory(FfxUInt32x2 iPxHistory, FfxFloat32x4 fHistory) -{ - rw_internal_upscaled_color[iPxHistory] = fHistory; -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) || defined(FFX_INTERNAL) -void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight) -{ - rw_internal_upscaled_color[iPxPos] = fColorAndWeight; -} -#endif - -#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) || defined(FFX_INTERNAL) -void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) -{ - rw_upscaled_output[iPxPos] = FfxFloat32x4(fColor, 1.f); -} -#endif - -//LOCK_LIFETIME_REMAINING == 0 -//Should make LockInitialLifetime() return a const 1.0f later -#if defined(FSR2_BIND_SRV_LOCK_STATUS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadLockStatus(FfxUInt32x2 iPxPos) -{ - return r_lock_status[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_STATUS) || defined(FFX_INTERNAL) -void StoreLockStatus(FfxUInt32x2 iPxPos, FfxFloat32x2 fLockStatus) -{ - rw_lock_status[iPxPos] = fLockStatus; -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_INPUT_LUMA) || defined(FFX_INTERNAL) -FfxFloat32 LoadLockInputLuma(FfxUInt32x2 iPxPos) -{ - return r_lock_input_luma[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_INPUT_LUMA) || defined(FFX_INTERNAL) -void StoreLockInputLuma(FfxUInt32x2 iPxPos, FfxFloat32 fLuma) -{ - rw_lock_input_luma[iPxPos] = fLuma; -} -#endif - -#if defined(FSR2_BIND_SRV_NEW_LOCKS) || defined(FFX_INTERNAL) -FfxFloat32 LoadNewLocks(FfxUInt32x2 iPxPos) -{ - return r_new_locks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) || defined(FFX_INTERNAL) -FfxFloat32 LoadRwNewLocks(FfxUInt32x2 iPxPos) -{ - return rw_new_locks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) || defined(FFX_INTERNAL) -void StoreNewLocks(FfxUInt32x2 iPxPos, FfxFloat32 newLock) -{ - rw_new_locks[iPxPos] = newLock; -} -#endif - -#if defined(FSR2_BIND_UAV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -void StorePreparedInputColor(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped) -{ - rw_prepared_input_color[iPxPos] = fTonemapped; -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV) -{ - return r_prepared_input_color.SampleLevel(s_LinearClamp, fUV, 0).w; -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_STATUS) || defined(FFX_INTERNAL) -FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV) -{ - FfxFloat32x2 fLockStatus = r_lock_status.SampleLevel(s_LinearClamp, fUV, 0); - return fLockStatus; -} -#endif - -#if defined(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadReconstructedPrevDepth(FfxUInt32x2 iPxPos) -{ - return asfloat(r_reconstructed_previous_nearest_depth[iPxPos]); -} -#endif - -#if defined(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) || defined(FFX_INTERNAL) -void StoreReconstructedDepth(FfxUInt32x2 iPxSample, FfxFloat32 fDepth) -{ - FfxUInt32 uDepth = asuint(fDepth); - - #if FFX_FSR2_OPTION_INVERTED_DEPTH - InterlockedMax(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); - #else - InterlockedMin(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) || defined(FFX_INTERNAL) -void SetReconstructedDepth(FfxUInt32x2 iPxSample, const FfxUInt32 uValue) -{ - rw_reconstructed_previous_nearest_depth[iPxSample] = uValue; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_DEPTH) || defined(FFX_INTERNAL) -void StoreDilatedDepth(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth) -{ - rw_dilatedDepth[iPxPos] = fDepth; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector) -{ - rw_dilated_motion_vectors[iPxPos] = fMotionVector; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadDilatedMotionVector(FfxUInt32x2 iPxInput) -{ - return r_dilated_motion_vectors[iPxInput].xy; -} -#endif - -#if defined(FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxUInt32x2 iPxInput) -{ - return r_previous_dilated_motion_vectors[iPxInput].xy; -} - -FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 uv) -{ - return r_previous_dilated_motion_vectors.SampleLevel(s_LinearClamp, uv, 0).xy; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadDilatedDepth(FfxUInt32x2 iPxInput) -{ - return r_dilatedDepth[iPxInput]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_EXPOSURE) || defined(FFX_INTERNAL) -FfxFloat32 Exposure() -{ - FfxFloat32 exposure = r_input_exposure[FfxUInt32x2(0, 0)].x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -#if defined(FSR2_BIND_SRV_AUTO_EXPOSURE) || defined(FFX_INTERNAL) -FfxFloat32 AutoExposure() -{ - FfxFloat32 exposure = r_auto_exposure[FfxUInt32x2(0, 0)].x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -FfxFloat32 SampleLanczos2Weight(FfxFloat32 x) -{ -#if defined(FSR2_BIND_SRV_LANCZOS_LUT) || defined(FFX_INTERNAL) - return r_lanczos_lut.SampleLevel(s_LinearClamp, FfxFloat32x2(x / 2, 0.5f), 0); -#else - return 0.f; -#endif -} - -#if defined(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT) || defined(FFX_INTERNAL) -FfxFloat32 SampleUpsampleMaximumBias(FfxFloat32x2 uv) -{ - // Stored as a SNORM, so make sure to multiply by 2 to retrieve the actual expected range. - return FfxFloat32(2.0) * r_upsample_maximum_bias_lut.SampleLevel(s_LinearClamp, abs(uv) * 2.0, 0); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV) -{ - return r_dilated_reactive_masks.SampleLevel(s_LinearClamp, fUV, 0); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos) -{ - return r_dilated_reactive_masks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks) -{ - rw_dilated_reactive_masks[iPxPos] = fDilatedReactiveMasks; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_opaque_only[UNITY_FSR2_POS(iPxPos)].xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_prev_color_pre_alpha[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_prev_color_post_alpha[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_AUTOREACTIVE) || defined(FFX_INTERNAL) -#if defined(FSR2_BIND_UAV_AUTOCOMPOSITION) || defined(FFX_INTERNAL) -void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive) -{ - rw_output_autoreactive[iPxPos] = fReactive.x; - - rw_output_autocomposition[iPxPos] = fReactive.y; -} -#endif -#endif - -#if defined(FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR) || defined(FFX_INTERNAL) -void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - rw_output_prev_color_pre_alpha[iPxPos] = color; - -} -#endif - -#if defined(FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR) || defined(FFX_INTERNAL) -void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - rw_output_prev_color_post_alpha[iPxPos] = color; -} -#endif - -#endif // #if defined(FFX_GPU) diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta deleted file mode 100644 index 97858ae..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: eb121968296f9ba44b35d7e18d2b79df -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_common.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_common.h.meta deleted file mode 100644 index 0e3bb9c..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_common.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 2176dca22b6e9604da8329c79abae68d -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta deleted file mode 100644 index c8cb631..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: dbcdb6dfb36311a49aa7b05bc5054280 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl deleted file mode 100644 index 2b96636..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl +++ /dev/null @@ -1,131 +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. - -#define FSR2_BIND_SRV_INPUT_COLOR 0 -#define FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC 0 -#define FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 1 -#define FSR2_BIND_UAV_EXPOSURE_MIP_5 2 -#define FSR2_BIND_UAV_AUTO_EXPOSURE 3 -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_SPD 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -#if defined(FSR2_BIND_CB_SPD) - cbuffer cbSPD : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_SPD) { - - FfxUInt32 mips; - FfxUInt32 numWorkGroups; - FfxUInt32x2 workGroupOffset; - FfxUInt32x2 renderSize; - }; - - FfxUInt32 MipCount() - { - return mips; - } - - FfxUInt32 NumWorkGroups() - { - return numWorkGroups; - } - - FfxUInt32x2 WorkGroupOffset() - { - return workGroupOffset; - } - - FfxUInt32x2 SPD_RenderSize() - { - return renderSize; - } -#endif - - -FfxFloat32x2 SPD_LoadExposureBuffer() -{ - return rw_auto_exposure[FfxInt32x2(0,0)]; -} - -void SPD_SetExposureBuffer(FfxFloat32x2 value) -{ - rw_auto_exposure[FfxInt32x2(0,0)] = value; -} - -FfxFloat32x4 SPD_LoadMipmap5(FfxInt32x2 iPxPos) -{ - return FfxFloat32x4(rw_img_mip_5[iPxPos], 0, 0, 0); -} - -void SPD_SetMipmap(FfxInt32x2 iPxPos, FfxInt32 slice, FfxFloat32 value) -{ - switch (slice) - { - case FFX_FSR2_SHADING_CHANGE_MIP_LEVEL: - rw_img_mip_shading_change[iPxPos] = value; - break; - case 5: - rw_img_mip_5[iPxPos] = value; - break; - default: - - // avoid flattened side effect -#if defined(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE) || defined(FFX_INTERNAL) - rw_img_mip_shading_change[iPxPos] = rw_img_mip_shading_change[iPxPos]; -#elif defined(FSR2_BIND_UAV_EXPOSURE_MIP_5) || defined(FFX_INTERNAL) - rw_img_mip_5[iPxPos] = rw_img_mip_5[iPxPos]; -#endif - break; - } -} - -void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter) -{ - InterlockedAdd(rw_spd_global_atomic[FfxInt32x2(0,0)], 1, spdCounter); -} - -void SPD_ResetAtomicCounter() -{ - rw_spd_global_atomic[FfxInt32x2(0,0)] = 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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -void CS(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex) -{ - ComputeAutoExposure(WorkGroupId, LocalThreadIndex); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip.h.meta deleted file mode 100644 index dbdf299..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: f7c16477aeb3a9b4f94f4ef818d10d9b -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl deleted file mode 100644 index 3cf501c..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl +++ /dev/null @@ -1,66 +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. - -#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_PREVIOUS_DILATED_MOTION_VECTORS 5 -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 6 -#define FSR2_BIND_SRV_INPUT_COLOR 7 -#define FSR2_BIND_SRV_INPUT_DEPTH 8 -#define FSR2_BIND_SRV_INPUT_EXPOSURE 9 - -#define FSR2_BIND_UAV_DILATED_REACTIVE_MASKS 0 -#define FSR2_BIND_UAV_PREPARED_INPUT_COLOR 1 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS( - int2 iGroupId : SV_GroupID, - int2 iDispatchThreadId : SV_DispatchThreadID, - int2 iGroupThreadId : SV_GroupThreadID, - int iGroupIndex : SV_GroupIndex) -{ - DepthClip(iDispatchThreadId); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_lock.h.meta deleted file mode 100644 index 21f4814..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 9b4cdc5f81194ac4fa946c31b86234ed -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl deleted file mode 100644 index 1409dce..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl +++ /dev/null @@ -1,53 +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. - -#define FSR2_BIND_SRV_LOCK_INPUT_LUMA 0 -#define FSR2_BIND_UAV_NEW_LOCKS 0 -#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 1 -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - ComputeLock(uDispatchThreadId); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta deleted file mode 100644 index 4ded638..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 471a3f7a033c72f4fa737d4f8238a9bd -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta deleted file mode 100644 index ddb6dda..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 3945c3cfd2cc1a64cb0513864d88d8ca -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas.h.meta deleted file mode 100644 index e962499..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 7bd7d4eb34c626342966cb9b3fe00363 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl deleted file mode 100644 index f447b7e..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl +++ /dev/null @@ -1,75 +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. - -#define FSR2_BIND_SRV_INPUT_EXPOSURE 0 -#define FSR2_BIND_SRV_RCAS_INPUT 1 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 0 -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_RCAS 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -//Move to prototype shader! -#if defined(FSR2_BIND_CB_RCAS) - cbuffer cbRCAS : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_RCAS) - { - uint4 rcasConfig; - }; - - uint4 RCASConfig() - { - return rcasConfig; - } -#else - uint4 RCASConfig() - { - return 0; - } -#endif - - -float4 LoadRCAS_Input(FfxInt32x2 iPxPos) -{ - return r_rcas_input[iPxPos]; -} - -#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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID) -{ - RCAS(LocalThreadId, WorkGroupId, Dtid); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta deleted file mode 100644 index b7e089b..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 871ca1938c701d64f94ef8ec00ef06f4 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta deleted file mode 100644 index 9b82a1a..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 13cd33c3d34a317409049dfd939e64ef -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl b/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl deleted file mode 100644 index 33c044e..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl +++ /dev/null @@ -1,63 +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. - -#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_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 -#define FSR2_BIND_UAV_DILATED_MOTION_VECTORS 1 -#define FSR2_BIND_UAV_DILATED_DEPTH 2 -#define FSR2_BIND_UAV_LOCK_INPUT_LUMA 3 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS( - int2 iGroupId : SV_GroupID, - int2 iDispatchThreadId : SV_DispatchThreadID, - int2 iGroupThreadId : SV_GroupThreadID, - int iGroupIndex : SV_GroupIndex -) -{ - ReconstructAndDilate(iDispatchThreadId); -} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta deleted file mode 100644 index 4f5036c..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9355c255c8505ae48ae89af286943747 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_reproject.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_reproject.h.meta deleted file mode 100644 index ef8ce86..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reproject.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 63fc917ca6895cb4aac237ea35edb838 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h b/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h deleted file mode 100644 index 535dbc3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h +++ /dev/null @@ -1,105 +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. - -#ifndef FFX_FSR2_RESOURCES_H -#define FFX_FSR2_RESOURCES_H - -#if defined(FFX_CPU) || defined(FFX_GPU) -#define FFX_FSR2_RESOURCE_IDENTIFIER_NULL 0 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_COLOR 2 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_DEPTH 4 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7 -#define FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH 10 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS 12 -#define FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS 13 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY 15 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LANCZOS_LUT 17 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18 -#define FFX_FSR2_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19 -#define FFX_FSR2_RESOURCE_IDENTIFIER_RCAS_INPUT 20 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26 -#define FFX_FSR2_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTOREACTIVE 44 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTOCOMPOSITION 45 - -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR 46 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR 47 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_1 48 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_1 49 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_2 50 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_2 51 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 52 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_1 53 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_2 54 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 55 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 56 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 57 - -// Shading change detection mip level setting, value must be in the range [FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12] -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 -#define FFX_FSR2_SHADING_CHANGE_MIP_LEVEL (FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE) - -#define FFX_FSR2_RESOURCE_IDENTIFIER_COUNT 58 - -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_FSR2 0 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_SPD 1 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_RCAS 2 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3 - -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1 -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2 -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4 -#define FFX_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8 - -#endif // #if defined(FFX_CPU) || defined(FFX_GPU) - -#endif //!defined( FFX_FSR2_RESOURCES_H ) diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h.meta deleted file mode 100644 index 69e95a4..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_resources.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: fd5bed2bf4ba07444ae815390168a15d -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_sample.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_sample.h.meta deleted file mode 100644 index acc8bab..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_sample.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: ba3ee190167b6c240aaeb1f8f4dbcb67 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta deleted file mode 100644 index a2af34e..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 18b8590c99b171a4e9af68dfd2c3ff02 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta deleted file mode 100644 index d133259..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9feb1fa4d6cff5a4799298dc69b12a8e -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_upsample.h.meta b/Assets/Resources/FSR2/shaders/ffx_fsr2_upsample.h.meta deleted file mode 100644 index c9fa0a3..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_upsample.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 1ff3a385cfe07db4387e4d7b457238f8 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_spd.h.meta b/Assets/Resources/FSR2/shaders/ffx_spd.h.meta deleted file mode 100644 index d896fc1..0000000 --- a/Assets/Resources/FSR2/shaders/ffx_spd.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 3ef69a900a925bb498651c10581e0979 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 7dbd2f5..c1a3dff 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -314,7 +314,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 955cb66a9ecc20441a7e32934c9b4690, type: 3} m_Name: m_EditorClassIdentifier: - qualityMode: 1 + qualityMode: 2 performSharpenPass: 1 sharpness: 0.8 enableFP16: 0 @@ -335,7 +335,7 @@ MonoBehaviour: autoTcScale: 1 autoReactiveScale: 5 autoReactiveMax: 0.9 - outputMotionVectors: {fileID: 0} + assets: {fileID: 11400000, guid: 4151befafd86e8740ab09463b4f1bdbb, type: 2} --- !u!1001 &1313173313 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/SampleScenePPV2.unity b/Assets/Scenes/SampleScenePPV2.unity index 9cbd013..600d5e0 100644 --- a/Assets/Scenes/SampleScenePPV2.unity +++ b/Assets/Scenes/SampleScenePPV2.unity @@ -317,7 +317,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 955cb66a9ecc20441a7e32934c9b4690, type: 3} m_Name: m_EditorClassIdentifier: - qualityMode: 1 + qualityMode: 2 performSharpenPass: 1 sharpness: 0.8 enableFP16: 0 @@ -332,7 +332,13 @@ MonoBehaviour: cutoffThreshold: 0.2 binaryValue: 0.9 flags: 13 - outputMotionVectors: {fileID: 0} + autoGenerateTransparencyAndComposition: 0 + generateTransparencyAndCompositionParameters: + autoTcThreshold: 0.05 + autoTcScale: 1 + autoReactiveScale: 5 + autoReactiveMax: 0.9 + assets: {fileID: 11400000, guid: 4151befafd86e8740ab09463b4f1bdbb, type: 2} --- !u!114 &963194232 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs b/Assets/Scripts/Core/Fsr3ShaderIDs.cs similarity index 96% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs rename to Assets/Scripts/Core/Fsr3ShaderIDs.cs index b07c967..3a28843 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs +++ b/Assets/Scripts/Core/Fsr3ShaderIDs.cs @@ -22,7 +22,7 @@ using UnityEngine; namespace FidelityFX { - internal static class Fsr2ShaderIDs + internal static class Fsr3ShaderIDs { // Shader resource views, i.e. read-only bindings internal static readonly int SrvInputColor = Shader.PropertyToID("r_input_color_jittered"); @@ -36,7 +36,7 @@ namespace FidelityFX internal static readonly int SrvReconstructedPrevNearestDepth = Shader.PropertyToID("r_reconstructed_previous_nearest_depth"); internal static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors"); internal static readonly int SrvPrevDilatedMotionVectors = Shader.PropertyToID("r_previous_dilated_motion_vectors"); - internal static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilatedDepth"); + internal static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilated_depth"); internal static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color"); internal static readonly int SrvLockStatus = Shader.PropertyToID("r_lock_status"); internal static readonly int SrvLockInputLuma = Shader.PropertyToID("r_lock_input_luma"); @@ -53,7 +53,7 @@ namespace FidelityFX // Unordered access views, i.e. random read/write bindings internal static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth"); internal static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors"); - internal static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilatedDepth"); + internal static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilated_depth"); internal static readonly int UavInternalUpscaled = Shader.PropertyToID("rw_internal_upscaled_color"); internal static readonly int UavLockStatus = Shader.PropertyToID("rw_lock_status"); internal static readonly int UavLockInputLuma = Shader.PropertyToID("rw_lock_input_luma"); @@ -72,7 +72,7 @@ namespace FidelityFX internal static readonly int UavPrevColorPostAlpha = Shader.PropertyToID("rw_output_prev_color_post_alpha"); // Constant buffer bindings - internal static readonly int CbFsr2 = Shader.PropertyToID("cbFSR2"); + internal static readonly int CbFsr3Upscaler = Shader.PropertyToID("cbFSR3Upscaler"); internal static readonly int CbSpd = Shader.PropertyToID("cbSPD"); internal static readonly int CbRcas = Shader.PropertyToID("cbRCAS"); internal static readonly int CbGenReactive = Shader.PropertyToID("cbGenerateReactive"); diff --git a/Assets/Scripts/Core/Fsr2ShaderIDs.cs.meta b/Assets/Scripts/Core/Fsr3ShaderIDs.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2ShaderIDs.cs.meta rename to Assets/Scripts/Core/Fsr3ShaderIDs.cs.meta diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs b/Assets/Scripts/Core/Fsr3Upscaler.cs similarity index 79% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs rename to Assets/Scripts/Core/Fsr3Upscaler.cs index 1ba8192..c636c93 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs +++ b/Assets/Scripts/Core/Fsr3Upscaler.cs @@ -26,14 +26,14 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// A collection of helper functions and data structures required by the FSR2 process. + /// A collection of helper functions and data structures required by the FSR3 Upscaler process. /// - public static class Fsr2 + public static class Fsr3Upscaler { /// - /// Creates a new FSR2 context with standard parameters that are appropriate for the current platform. + /// Creates a new FSR3 Upscaler context with standard parameters that are appropriate for the current platform. /// - public static Fsr2Context CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, IFsr2Callbacks callbacks, InitializationFlags flags = 0) + public static Fsr3UpscalerContext CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, Fsr3UpscalerShaders shaders, InitializationFlags flags = 0) { if (SystemInfo.usesReversedZBuffer) flags |= InitializationFlags.EnableDepthInverted; @@ -44,17 +44,17 @@ namespace FidelityFX flags |= InitializationFlags.EnableDebugChecking; #endif - Debug.Log($"Setting up FSR2 with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}"); + Debug.Log($"Setting up FSR3 Upscaler with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}"); var contextDescription = new ContextDescription { Flags = flags, DisplaySize = displaySize, MaxRenderSize = maxRenderSize, - Callbacks = callbacks, + Shaders = shaders, }; - var context = new Fsr2Context(); + var context = new Fsr3UpscalerContext(); context.Create(contextDescription); return context; } @@ -63,6 +63,8 @@ namespace FidelityFX { switch (qualityMode) { + case QualityMode.NativeAA: + return 1.0f; case QualityMode.UltraQuality: return 1.2f; case QualityMode.Quality: @@ -134,11 +136,12 @@ namespace FidelityFX public enum QualityMode { - UltraQuality = 0, - Quality = 1, - Balanced = 2, - Performance = 3, - UltraPerformance = 4, + NativeAA = 0, + UltraQuality = 1, + Quality = 2, + Balanced = 3, + Performance = 4, + UltraPerformance = 5, } [Flags] @@ -155,47 +158,19 @@ namespace FidelityFX EnableDebugChecking = 1 << 8, } + /// + /// A structure encapsulating the parameters required to initialize FidelityFX Super Resolution 3 upscaling. + /// public struct ContextDescription { public InitializationFlags Flags; public Vector2Int MaxRenderSize; public Vector2Int DisplaySize; - public IFsr2Callbacks Callbacks; - } - - /// - /// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader. - /// - public readonly struct ResourceView - { - /// - /// This value is the equivalent of not setting any value at all; all struct fields will have their default values. - /// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader. - /// - public static readonly ResourceView Unassigned = new ResourceView(default); - - /// - /// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture. - /// Binding this to a shader can be seen as setting the texture variable inside the shader to null. - /// - public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None); - - public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) - { - RenderTarget = renderTarget; - SubElement = subElement; - MipLevel = mipLevel; - } - - public bool IsValid => !RenderTarget.Equals(default); - - public readonly RenderTargetIdentifier RenderTarget; - public readonly RenderTextureSubElement SubElement; - public readonly int MipLevel; + public Fsr3UpscalerShaders Shaders; } /// - /// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 2. + /// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 3. /// public class DispatchDescription { @@ -231,7 +206,7 @@ namespace FidelityFX /// /// A structure encapsulating the parameters for automatic generation of a reactive mask. - /// The default values for Scale, CutoffThreshold, BinaryValue and Flags were taken from the FSR2 demo project. + /// The default values for Scale, CutoffThreshold, BinaryValue and Flags were taken from the FSR3 demo project. /// public class GenerateReactiveDescription { @@ -255,7 +230,7 @@ namespace FidelityFX } [Serializable, StructLayout(LayoutKind.Sequential)] - internal struct Fsr2Constants + internal struct UpscalerConstants { public Vector2Int renderSize; public Vector2Int maxRenderSize; @@ -324,4 +299,35 @@ namespace FidelityFX public readonly uint dummy1; } } + + /// + /// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader. + /// + public readonly struct ResourceView + { + /// + /// This value is the equivalent of not setting any value at all; all struct fields will have their default values. + /// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader. + /// + public static readonly ResourceView Unassigned = new ResourceView(default); + + /// + /// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture. + /// Binding this to a shader can be seen as setting the texture variable inside the shader to null. + /// + public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None); + + public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) + { + RenderTarget = renderTarget; + SubElement = subElement; + MipLevel = mipLevel; + } + + public bool IsValid => !RenderTarget.Equals(default); + + public readonly RenderTargetIdentifier RenderTarget; + public readonly RenderTextureSubElement SubElement; + public readonly int MipLevel; + } } diff --git a/Assets/Scripts/Core/Fsr2.cs.meta b/Assets/Scripts/Core/Fsr3Upscaler.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2.cs.meta rename to Assets/Scripts/Core/Fsr3Upscaler.cs.meta diff --git a/Assets/Scripts/Core/Fsr3UpscalerAssets.cs b/Assets/Scripts/Core/Fsr3UpscalerAssets.cs new file mode 100644 index 0000000..3e4e24f --- /dev/null +++ b/Assets/Scripts/Core/Fsr3UpscalerAssets.cs @@ -0,0 +1,151 @@ +// Copyright (c) 2023 Nico de Poel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// 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. + +using UnityEngine; + +namespace FidelityFX +{ + /// + /// Scriptable object containing all shader resources required by FidelityFX Super Resolution 3 (FSR3) Upscaler. + /// These can be stored in an asset file and referenced from a scene or prefab, avoiding the need to load the shaders from a Resources folder. + /// + public class Fsr3UpscalerAssets : ScriptableObject + { + public Fsr3UpscalerShaders shaders; + +#if UNITY_EDITOR + private void Reset() + { + shaders = new Fsr3UpscalerShaders + { + computeLuminancePyramidPass = FindComputeShader("ffx_fsr3upscaler_compute_luminance_pyramid_pass"), + reconstructPreviousDepthPass = FindComputeShader("ffx_fsr3upscaler_reconstruct_previous_depth_pass"), + depthClipPass = FindComputeShader("ffx_fsr3upscaler_depth_clip_pass"), + lockPass = FindComputeShader("ffx_fsr3upscaler_lock_pass"), + accumulatePass = FindComputeShader("ffx_fsr3upscaler_accumulate_pass"), + sharpenPass = FindComputeShader("ffx_fsr3upscaler_rcas_pass"), + autoGenReactivePass = FindComputeShader("ffx_fsr3upscaler_autogen_reactive_pass"), + tcrAutoGenPass = FindComputeShader("ffx_fsr3upscaler_tcr_autogen_pass"), + }; + } + + private static ComputeShader FindComputeShader(string name) + { + string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); + if (assetGuids == null || assetGuids.Length == 0) + return null; + + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); + return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); + } +#endif + } + + /// + /// All the compute shaders used by the FSR3 Upscaler. + /// + [System.Serializable] + public class Fsr3UpscalerShaders + { + /// + /// The compute shader used by the luminance pyramid computation pass. + /// + public ComputeShader computeLuminancePyramidPass; + + /// + /// The compute shader used by the previous depth reconstruction pass. + /// + public ComputeShader reconstructPreviousDepthPass; + + /// + /// The compute shader used by the depth clip pass. + /// + public ComputeShader depthClipPass; + + /// + /// The compute shader used by the lock pass. + /// + public ComputeShader lockPass; + + /// + /// The compute shader used by the accumulation pass. + /// + public ComputeShader accumulatePass; + + /// + /// The compute shader used by the RCAS sharpening pass. + /// + public ComputeShader sharpenPass; + + /// + /// The compute shader used to auto-generate a reactive mask. + /// + public ComputeShader autoGenReactivePass; + + /// + /// The compute shader used to auto-generate a transparency & composition mask. + /// + public ComputeShader tcrAutoGenPass; + + /// + /// Returns a copy of this class and its contents. + /// + public Fsr3UpscalerShaders Clone() + { + return (Fsr3UpscalerShaders)MemberwiseClone(); + } + + /// + /// Returns a copy of this class with clones of all its shaders. + /// This can be useful if you're running multiple FSR3 Upscaler instances with different shader configurations. + /// Be sure to clean up these clones through Dispose once you're done with them. + /// + public Fsr3UpscalerShaders DeepCopy() + { + return new Fsr3UpscalerShaders + { + computeLuminancePyramidPass = Object.Instantiate(computeLuminancePyramidPass), + reconstructPreviousDepthPass = Object.Instantiate(reconstructPreviousDepthPass), + depthClipPass = Object.Instantiate(depthClipPass), + lockPass = Object.Instantiate(lockPass), + accumulatePass = Object.Instantiate(accumulatePass), + sharpenPass = Object.Instantiate(sharpenPass), + autoGenReactivePass = Object.Instantiate(autoGenReactivePass), + tcrAutoGenPass = Object.Instantiate(tcrAutoGenPass), + }; + } + + /// + /// Destroy all the shaders within this instance. + /// Use this only on clones created through DeepCopy. + /// + public void Dispose() + { + Object.Destroy(computeLuminancePyramidPass); + Object.Destroy(reconstructPreviousDepthPass); + Object.Destroy(depthClipPass); + Object.Destroy(lockPass); + Object.Destroy(accumulatePass); + Object.Destroy(sharpenPass); + Object.Destroy(autoGenReactivePass); + Object.Destroy(tcrAutoGenPass); + } + } +} diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs.meta b/Assets/Scripts/Core/Fsr3UpscalerAssets.cs.meta similarity index 83% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs.meta rename to Assets/Scripts/Core/Fsr3UpscalerAssets.cs.meta index abc4d96..3c446ad 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs.meta +++ b/Assets/Scripts/Core/Fsr3UpscalerAssets.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5906deeb6ec2854449bf33db2e71a046 +guid: db26e15a33db6ab42a38daab0ba2712f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs b/Assets/Scripts/Core/Fsr3UpscalerCallbacks.cs similarity index 76% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs rename to Assets/Scripts/Core/Fsr3UpscalerCallbacks.cs index ad41d98..5b2c89c 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerCallbacks.cs @@ -23,16 +23,11 @@ using UnityEngine; namespace FidelityFX { /// - /// A collection of callbacks required by the FSR2 process. - /// This allows some customization by the game dev on how to integrate FSR2 into their own game setup. + /// A collection of callbacks required by the FSR3 Upscaler process. + /// This allows some customization by the game dev on how to integrate FSR3 upscaling into their own game setup. /// - public interface IFsr2Callbacks + public interface IFsr3UpscalerCallbacks { - Shader LoadShader(string name); - void UnloadShader(Shader shader); - ComputeShader LoadComputeShader(string name); - void UnloadComputeShader(ComputeShader shader); - /// /// Apply a mipmap bias to in-game textures to prevent them from becoming blurry as the internal rendering resolution lowers. /// This will need to be customized on a per-game basis, as there is no clear universal way to determine what are "in-game" textures. @@ -47,32 +42,12 @@ namespace FidelityFX } /// - /// Default implementation of IFsr2Callbacks using simple Resources calls. + /// Default implementation of IFsr3UpscalerCallbacks using simple Resources calls. /// These are fine for testing but a proper game will want to extend and override these methods. /// - public class Fsr2CallbacksBase: IFsr2Callbacks + public class Fsr3UpscalerCallbacksBase: IFsr3UpscalerCallbacks { protected float CurrentBiasOffset = 0; - - public virtual Shader LoadShader(string name) - { - return Resources.Load(name); - } - - public virtual void UnloadShader(Shader shader) - { - Resources.UnloadAsset(shader); - } - - public virtual ComputeShader LoadComputeShader(string name) - { - return Resources.Load(name); - } - - public virtual void UnloadComputeShader(ComputeShader shader) - { - Resources.UnloadAsset(shader); - } public virtual void ApplyMipmapBias(float biasOffset) { diff --git a/Assets/Scripts/Core/Fsr2Callbacks.cs.meta b/Assets/Scripts/Core/Fsr3UpscalerCallbacks.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2Callbacks.cs.meta rename to Assets/Scripts/Core/Fsr3UpscalerCallbacks.cs.meta diff --git a/Assets/Scripts/Core/Fsr2Context.cs b/Assets/Scripts/Core/Fsr3UpscalerContext.cs similarity index 70% rename from Assets/Scripts/Core/Fsr2Context.cs rename to Assets/Scripts/Core/Fsr3UpscalerContext.cs index 5c8975c..da02d9f 100644 --- a/Assets/Scripts/Core/Fsr2Context.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerContext.cs @@ -19,7 +19,6 @@ // THE SOFTWARE. using System; -using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.Rendering; @@ -27,69 +26,69 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// This class loosely matches the FfxFsr2Context struct from the original FSR2 codebase. - /// It manages the various resources and compute passes required by the FSR2 process. + /// This class loosely matches the FfxFsr3UpscalerContext struct from the original FSR3 codebase. + /// It manages the various resources and compute passes required by the FSR3 Upscaler process. /// Note that this class does not know anything about Unity render pipelines; all it knows is CommandBuffers and RenderTargetIdentifiers. /// This should make it suitable for integration with any of the available Unity render pipelines. /// - public class Fsr2Context + public class Fsr3UpscalerContext { private const int MaxQueuedFrames = 16; - private Fsr2.ContextDescription _contextDescription; + private Fsr3Upscaler.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; - private Fsr2Pass _depthClipPass; - private Fsr2Pass _reconstructPreviousDepthPass; - private Fsr2Pass _lockPass; - private Fsr2Pass _accumulatePass; - private Fsr2Pass _rcasPass; - private Fsr2Pass _computeLuminancePyramidPass; - private Fsr2Pass _generateReactivePass; - private Fsr2Pass _tcrAutogeneratePass; + private Fsr3UpscalerPass _depthClipPass; + private Fsr3UpscalerPass _reconstructPreviousDepthPass; + private Fsr3UpscalerPass _lockPass; + private Fsr3UpscalerPass _accumulatePass; + private Fsr3UpscalerPass _sharpenPass; + private Fsr3UpscalerPass _computeLuminancePyramidPass; + private Fsr3UpscalerPass _generateReactivePass; + private Fsr3UpscalerPass _tcrAutogeneratePass; - private readonly Fsr2Resources _resources = new Fsr2Resources(); + private readonly Fsr3UpscalerResources _resources = new Fsr3UpscalerResources(); - private ComputeBuffer _fsr2ConstantsBuffer; - private readonly Fsr2.Fsr2Constants[] _fsr2ConstantsArray = { new Fsr2.Fsr2Constants() }; - private ref Fsr2.Fsr2Constants Constants => ref _fsr2ConstantsArray[0]; + private ComputeBuffer _upscalerConstantsBuffer; + private readonly Fsr3Upscaler.UpscalerConstants[] _upscalerConstantsArray = { new Fsr3Upscaler.UpscalerConstants() }; + private ref Fsr3Upscaler.UpscalerConstants UpscalerConsts => ref _upscalerConstantsArray[0]; private ComputeBuffer _spdConstantsBuffer; - private readonly Fsr2.SpdConstants[] _spdConstantsArray = { new Fsr2.SpdConstants() }; - private ref Fsr2.SpdConstants SpdConsts => ref _spdConstantsArray[0]; + private readonly Fsr3Upscaler.SpdConstants[] _spdConstantsArray = { new Fsr3Upscaler.SpdConstants() }; + private ref Fsr3Upscaler.SpdConstants SpdConsts => ref _spdConstantsArray[0]; private ComputeBuffer _rcasConstantsBuffer; - private readonly Fsr2.RcasConstants[] _rcasConstantsArray = new Fsr2.RcasConstants[1]; - private ref Fsr2.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; + private readonly Fsr3Upscaler.RcasConstants[] _rcasConstantsArray = new Fsr3Upscaler.RcasConstants[1]; + private ref Fsr3Upscaler.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; private ComputeBuffer _generateReactiveConstantsBuffer; - private readonly Fsr2.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Fsr2.GenerateReactiveConstants() }; - private ref Fsr2.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; + private readonly Fsr3Upscaler.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants() }; + private ref Fsr3Upscaler.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; private ComputeBuffer _tcrAutogenerateConstantsBuffer; - private readonly Fsr2.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = { new Fsr2.GenerateReactiveConstants2() }; - private ref Fsr2.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; + private readonly Fsr3Upscaler.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants2() }; + private ref Fsr3Upscaler.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; private bool _firstExecution; private Vector2 _previousJitterOffset; private int _resourceFrameIndex; - public void Create(Fsr2.ContextDescription contextDescription) + public void Create(Fsr3Upscaler.ContextDescription contextDescription) { _contextDescription = contextDescription; - _commandBuffer = new CommandBuffer { name = "FSR2" }; + _commandBuffer = new CommandBuffer { name = "FSR3 Upscaler" }; - _fsr2ConstantsBuffer = CreateConstantBuffer(); - _spdConstantsBuffer = CreateConstantBuffer(); - _rcasConstantsBuffer = CreateConstantBuffer(); - _generateReactiveConstantsBuffer = CreateConstantBuffer(); - _tcrAutogenerateConstantsBuffer = CreateConstantBuffer(); + _upscalerConstantsBuffer = CreateConstantBuffer(); + _spdConstantsBuffer = CreateConstantBuffer(); + _rcasConstantsBuffer = CreateConstantBuffer(); + _generateReactiveConstantsBuffer = CreateConstantBuffer(); + _tcrAutogenerateConstantsBuffer = CreateConstantBuffer(); // Set defaults _firstExecution = true; _resourceFrameIndex = 0; - Constants.displaySize = _contextDescription.DisplaySize; + UpscalerConsts.displaySize = _contextDescription.DisplaySize; _resources.Create(_contextDescription); CreatePasses(); @@ -97,14 +96,14 @@ namespace FidelityFX private void CreatePasses() { - _computeLuminancePyramidPass = new Fsr2ComputeLuminancePyramidPass(_contextDescription, _resources, _fsr2ConstantsBuffer, _spdConstantsBuffer); - _reconstructPreviousDepthPass = new Fsr2ReconstructPreviousDepthPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _depthClipPass = new Fsr2DepthClipPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _lockPass = new Fsr2LockPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _accumulatePass = new Fsr2AccumulatePass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _rcasPass = new Fsr2RcasPass(_contextDescription, _resources, _fsr2ConstantsBuffer, _rcasConstantsBuffer); - _generateReactivePass = new Fsr2GenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); - _tcrAutogeneratePass = new Fsr2TcrAutogeneratePass(_contextDescription, _resources, _fsr2ConstantsBuffer, _tcrAutogenerateConstantsBuffer); + _computeLuminancePyramidPass = new Fsr3UpscalerComputeLuminancePyramidPass(_contextDescription, _resources, _upscalerConstantsBuffer, _spdConstantsBuffer); + _reconstructPreviousDepthPass = new Fsr3UpscalerReconstructPreviousDepthPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _depthClipPass = new Fsr3UpscalerDepthClipPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _lockPass = new Fsr3UpscalerLockPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _accumulatePass = new Fsr3UpscalerAccumulatePass(_contextDescription, _resources, _upscalerConstantsBuffer); + _sharpenPass = new Fsr3UpscalerSharpenPass(_contextDescription, _resources, _upscalerConstantsBuffer, _rcasConstantsBuffer); + _generateReactivePass = new Fsr3UpscalerGenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); + _tcrAutogeneratePass = new Fsr3UpscalerTcrAutogeneratePass(_contextDescription, _resources, _upscalerConstantsBuffer, _tcrAutogenerateConstantsBuffer); } public void Destroy() @@ -112,7 +111,7 @@ namespace FidelityFX DestroyPass(ref _tcrAutogeneratePass); DestroyPass(ref _generateReactivePass); DestroyPass(ref _computeLuminancePyramidPass); - DestroyPass(ref _rcasPass); + DestroyPass(ref _sharpenPass); DestroyPass(ref _accumulatePass); DestroyPass(ref _lockPass); DestroyPass(ref _reconstructPreviousDepthPass); @@ -124,22 +123,22 @@ namespace FidelityFX DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); DestroyConstantBuffer(ref _spdConstantsBuffer); - DestroyConstantBuffer(ref _fsr2ConstantsBuffer); + DestroyConstantBuffer(ref _upscalerConstantsBuffer); _commandBuffer.Dispose(); _commandBuffer = null; } - public void Dispatch(Fsr2.DispatchDescription dispatchParams) + public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { _commandBuffer.Clear(); Dispatch(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - public void Dispatch(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer) + public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer) { - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableDebugChecking) != 0) + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDebugChecking) != 0) { DebugCheckDispatch(dispatchParams); } @@ -157,10 +156,10 @@ namespace FidelityFX _firstExecution = false; // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) - dispatchParams.Exposure = new Fsr2.ResourceView(_resources.AutoExposure); + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) + dispatchParams.Exposure = new ResourceView(_resources.AutoExposure); else if (!dispatchParams.Exposure.IsValid) - dispatchParams.Exposure = new Fsr2.ResourceView(_resources.DefaultExposure); + dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); if (dispatchParams.EnableAutoReactive) { @@ -170,7 +169,7 @@ namespace FidelityFX if (resetAccumulation) { - RenderTargetIdentifier opaqueOnly = dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : Fsr2ShaderIDs.SrvOpaqueOnly; + RenderTargetIdentifier opaqueOnly = dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : Fsr3ShaderIDs.SrvOpaqueOnly; commandBuffer.Blit(_resources.PrevPreAlpha[frameIndex ^ 1], opaqueOnly); } } @@ -180,16 +179,16 @@ namespace FidelityFX _resources.DestroyTcrAutogenResources(); } - if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new Fsr2.ResourceView(_resources.DefaultReactive); - if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.DefaultReactive); - Fsr2Resources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); + if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive); + if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive); + Fsr3UpscalerResources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); SetupConstants(dispatchParams, resetAccumulation); // Reactive mask bias const int threadGroupWorkRegionDim = 8; - int dispatchSrcX = (Constants.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; - int dispatchSrcY = (Constants.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstX = (_contextDescription.DisplaySize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstY = (_contextDescription.DisplaySize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -214,19 +213,24 @@ namespace FidelityFX commandBuffer.ClearRenderTarget(false, true, Color.clear); } + // FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option + bool depthInverted = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) == Fsr3Upscaler.InitializationFlags.EnableDepthInverted; + commandBuffer.SetRenderTarget(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); // Initialize constant buffers data - commandBuffer.SetBufferData(_fsr2ConstantsBuffer, _fsr2ConstantsArray); + commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); // Auto reactive if (dispatchParams.EnableAutoReactive) { GenerateTransparencyCompositionReactive(dispatchParams, commandBuffer, frameIndex); - dispatchParams.Reactive = new Fsr2.ResourceView(_resources.AutoReactive); - dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.AutoComposition); + dispatchParams.Reactive = new ResourceView(_resources.AutoReactive); + dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); } // Compute luminance pyramid @@ -254,22 +258,22 @@ namespace FidelityFX const int threadGroupWorkRegionDimRcas = 16; int threadGroupsX = (Screen.width + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; int threadGroupsY = (Screen.height + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; - _rcasPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); + _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); } _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; - Fsr2Resources.DestroyAliasableResources(commandBuffer); + Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); } - public void GenerateReactiveMask(Fsr2.GenerateReactiveDescription dispatchParams) + public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams) { _commandBuffer.Clear(); GenerateReactiveMask(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - public void GenerateReactiveMask(Fsr2.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) + public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) { const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -281,10 +285,10 @@ namespace FidelityFX GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); - ((Fsr2GenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); + ((Fsr3UpscalerGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); } - private void GenerateTransparencyCompositionReactive(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) + private void GenerateTransparencyCompositionReactive(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) { const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -299,9 +303,9 @@ namespace FidelityFX _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); } - private void SetupConstants(Fsr2.DispatchDescription dispatchParams, bool resetAccumulation) + private void SetupConstants(Fsr3Upscaler.DispatchDescription dispatchParams, bool resetAccumulation) { - ref Fsr2.Fsr2Constants constants = ref Constants; + ref Fsr3Upscaler.UpscalerConstants constants = ref UpscalerConsts; constants.jitterOffset = dispatchParams.JitterOffset; constants.renderSize = dispatchParams.RenderSize; @@ -323,17 +327,17 @@ namespace FidelityFX constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f; // Motion vector data - Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; + Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; constants.motionVectorScale = dispatchParams.MotionVectorScale / motionVectorsTargetSize; // Compute jitter cancellation - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { constants.motionVectorJitterCancellation = (_previousJitterOffset - constants.jitterOffset) / motionVectorsTargetSize; _previousJitterOffset = constants.jitterOffset; } - int jitterPhaseCount = Fsr2.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x); + int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x); if (resetAccumulation || constants.jitterPhaseCount == 0) { constants.jitterPhaseCount = jitterPhaseCount; @@ -356,17 +360,17 @@ namespace FidelityFX constants.frameIndex++; // Shading change usage of the SPD mip levels - constants.lumaMipLevelToUse = Fsr2Pass.ShadingChangeMipLevel; + constants.lumaMipLevelToUse = Fsr3UpscalerPass.ShadingChangeMipLevel; float mipDiv = 2 << constants.lumaMipLevelToUse; constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv); constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv); } - private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr2.DispatchDescription dispatchParams) + private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr3Upscaler.DispatchDescription dispatchParams) { - bool inverted = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; - bool infinite = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInfinite) != 0; + bool inverted = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0; + bool infinite = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; // make sure it has no impact if near and far plane values are swapped in dispatch params // the flags "inverted" and "infinite" will decide what transform to use @@ -396,19 +400,19 @@ namespace FidelityFX 1.0f / cotHalfFovY); } - private void SetupRcasConstants(Fsr2.DispatchDescription dispatchParams) + private void SetupRcasConstants(Fsr3Upscaler.DispatchDescription dispatchParams) { int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (RcasConfigs.Length - 1)); RcasConsts = RcasConfigs[sharpnessIndex]; } - private void SetupSpdConstants(Fsr2.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) + private void SetupSpdConstants(Fsr3Upscaler.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) { RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y); SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); // Downsample - ref Fsr2.SpdConstants spdConstants = ref SpdConsts; + ref Fsr3Upscaler.SpdConstants spdConstants = ref SpdConsts; spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; spdConstants.mips = (uint)numWorkGroupsAndMips.y; spdConstants.workGroupOffsetX = (uint)workGroupOffset.x; @@ -434,7 +438,7 @@ namespace FidelityFX } } - private void DebugCheckDispatch(Fsr2.DispatchDescription dispatchParams) + private void DebugCheckDispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { if (!dispatchParams.Color.IsValid) { @@ -456,7 +460,7 @@ namespace FidelityFX Debug.LogError("Output resource is null"); } - if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) + if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) { Debug.LogWarning("Exposure resource provided, however auto exposure flag is present"); } @@ -496,8 +500,8 @@ namespace FidelityFX Debug.LogError("PreExposure provided as 0.0f which is invalid"); } - bool infiniteDepth = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInfinite) != 0; - bool inverseDepth = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; + bool infiniteDepth = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; + bool inverseDepth = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0; if (inverseDepth) { @@ -552,32 +556,32 @@ namespace FidelityFX } /// - /// The FSR2 C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the RCAS shader. + /// The FSR3 C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the RCAS shader. /// This is not possible in C# without enabling unsafe code compilation, so to avoid that we instead use a table of precomputed values. /// - private static readonly Fsr2.RcasConstants[] RcasConfigs = new [] + private static readonly Fsr3Upscaler.RcasConstants[] RcasConfigs = new [] { - new Fsr2.RcasConstants(1048576000u, 872428544u), - new Fsr2.RcasConstants(1049178080u, 877212745u), - new Fsr2.RcasConstants(1049823372u, 882390168u), - new Fsr2.RcasConstants(1050514979u, 887895276u), - new Fsr2.RcasConstants(1051256227u, 893859143u), - new Fsr2.RcasConstants(1052050675u, 900216232u), - new Fsr2.RcasConstants(1052902144u, 907032080u), - new Fsr2.RcasConstants(1053814727u, 914306687u), - new Fsr2.RcasConstants(1054792807u, 922105590u), - new Fsr2.RcasConstants(1055841087u, 930494326u), - new Fsr2.RcasConstants(1056964608u, 939538432u), - new Fsr2.RcasConstants(1057566688u, 944322633u), - new Fsr2.RcasConstants(1058211980u, 949500056u), - new Fsr2.RcasConstants(1058903587u, 955005164u), - new Fsr2.RcasConstants(1059644835u, 960969031u), - new Fsr2.RcasConstants(1060439283u, 967326120u), - new Fsr2.RcasConstants(1061290752u, 974141968u), - new Fsr2.RcasConstants(1062203335u, 981416575u), - new Fsr2.RcasConstants(1063181415u, 989215478u), - new Fsr2.RcasConstants(1064229695u, 997604214u), - new Fsr2.RcasConstants(1065353216u, 1006648320), + new Fsr3Upscaler.RcasConstants(1048576000u, 872428544u), + new Fsr3Upscaler.RcasConstants(1049178080u, 877212745u), + new Fsr3Upscaler.RcasConstants(1049823372u, 882390168u), + new Fsr3Upscaler.RcasConstants(1050514979u, 887895276u), + new Fsr3Upscaler.RcasConstants(1051256227u, 893859143u), + new Fsr3Upscaler.RcasConstants(1052050675u, 900216232u), + new Fsr3Upscaler.RcasConstants(1052902144u, 907032080u), + new Fsr3Upscaler.RcasConstants(1053814727u, 914306687u), + new Fsr3Upscaler.RcasConstants(1054792807u, 922105590u), + new Fsr3Upscaler.RcasConstants(1055841087u, 930494326u), + new Fsr3Upscaler.RcasConstants(1056964608u, 939538432u), + new Fsr3Upscaler.RcasConstants(1057566688u, 944322633u), + new Fsr3Upscaler.RcasConstants(1058211980u, 949500056u), + new Fsr3Upscaler.RcasConstants(1058903587u, 955005164u), + new Fsr3Upscaler.RcasConstants(1059644835u, 960969031u), + new Fsr3Upscaler.RcasConstants(1060439283u, 967326120u), + new Fsr3Upscaler.RcasConstants(1061290752u, 974141968u), + new Fsr3Upscaler.RcasConstants(1062203335u, 981416575u), + new Fsr3Upscaler.RcasConstants(1063181415u, 989215478u), + new Fsr3Upscaler.RcasConstants(1064229695u, 997604214u), + new Fsr3Upscaler.RcasConstants(1065353216u, 1006648320), }; private static ComputeBuffer CreateConstantBuffer() where TConstants: struct @@ -594,7 +598,7 @@ namespace FidelityFX bufferRef = null; } - private static void DestroyPass(ref Fsr2Pass pass) + private static void DestroyPass(ref Fsr3UpscalerPass pass) { if (pass == null) return; diff --git a/Assets/Scripts/Core/Fsr2Context.cs.meta b/Assets/Scripts/Core/Fsr3UpscalerContext.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2Context.cs.meta rename to Assets/Scripts/Core/Fsr3UpscalerContext.cs.meta diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs b/Assets/Scripts/Core/Fsr3UpscalerPass.cs similarity index 56% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs rename to Assets/Scripts/Core/Fsr3UpscalerPass.cs index 23b8e6c..e1dc225 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerPass.cs @@ -26,24 +26,22 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// Base class for all of the compute passes that make up the FSR2 process. - /// This loosely matches the FfxPipelineState struct from the original FSR2 codebase, wrapped in an object-oriented blanket. + /// Base class for all of the compute passes that make up the FSR3 Upscaler process. + /// This loosely matches the FfxPipelineState struct from the original FSR3 codebase, wrapped in an object-oriented blanket. /// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders. /// - internal abstract class Fsr2Pass: IDisposable + internal abstract class Fsr3UpscalerPass: IDisposable { - internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define + internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL define - protected readonly Fsr2.ContextDescription ContextDescription; - protected readonly Fsr2Resources Resources; + protected readonly Fsr3Upscaler.ContextDescription ContextDescription; + protected readonly Fsr3UpscalerResources Resources; protected readonly ComputeBuffer Constants; protected ComputeShader ComputeShader; protected int KernelIndex; - protected virtual bool AllowFP16 => true; - - protected Fsr2Pass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + protected Fsr3UpscalerPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) { ContextDescription = contextDescription; Resources = resources; @@ -52,26 +50,24 @@ namespace FidelityFX public virtual void Dispose() { - UnloadComputeShader(); } - public abstract void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); + public abstract void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); - protected void LoadComputeShader(string name) + protected void InitComputeShader(string passName, ComputeShader shader) { - LoadComputeShader(name, ContextDescription.Flags, ref ComputeShader, out KernelIndex); + InitComputeShader(passName, shader, ContextDescription.Flags); } - private void LoadComputeShader(string name, Fsr2.InitializationFlags flags, ref ComputeShader shaderRef, out int kernelIndex) + private void InitComputeShader(string passName, ComputeShader shader, Fsr3Upscaler.InitializationFlags flags) { - if (shaderRef == null) + if (shader == null) { - shaderRef = ContextDescription.Callbacks.LoadComputeShader(name); - if (shaderRef == null) - throw new MissingReferenceException($"Shader '{name}' could not be loaded! Please ensure it is included in the project correctly."); + throw new MissingReferenceException($"Shader for FSR3 Upscaler '{passName}' could not be loaded! Please ensure it is included in the project correctly."); } - kernelIndex = shaderRef.FindKernel("CS"); + ComputeShader = shader; + KernelIndex = ComputeShader.FindKernel("CS"); bool useLut = false; #if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+ @@ -81,106 +77,89 @@ namespace FidelityFX } #endif - // Allow 16-bit floating point as a configuration option, except on passes that explicitly disable it - bool supportedFP16 = ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0 && AllowFP16); - // This matches the permutation rules from the CreatePipeline* functions - if ((flags & Fsr2.InitializationFlags.EnableHighDynamicRange) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_HDR_COLOR_INPUT"); - if ((flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); - if ((flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS"); - if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_INVERTED_DEPTH"); - if (useLut) shaderRef.EnableKeyword("FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); - if (supportedFP16) shaderRef.EnableKeyword("FFX_HALF"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); + if (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); // Inform the shader which render pipeline we're currently using var pipeline = GraphicsSettings.currentRenderPipeline; if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline")) { - shaderRef.EnableKeyword("UNITY_FSR2_HDRP"); + ComputeShader.EnableKeyword("UNITY_FSR3UPSCALER_HDRP"); } } - - private void UnloadComputeShader() - { - UnloadComputeShader(ref ComputeShader); - } - - private void UnloadComputeShader(ref ComputeShader shaderRef) - { - if (shaderRef == null) - return; - - ContextDescription.Callbacks.UnloadComputeShader(shaderRef); - shaderRef = null; - } } - internal class Fsr2ComputeLuminancePyramidPass : Fsr2Pass + internal class Fsr3UpscalerComputeLuminancePyramidPass : Fsr3UpscalerPass { private readonly ComputeBuffer _spdConstants; - public Fsr2ComputeLuminancePyramidPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer spdConstants) + public Fsr3UpscalerComputeLuminancePyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) : base(contextDescription, resources, constants) { _spdConstants = spdConstants; - LoadComputeShader("FSR2/ffx_fsr2_compute_luminance_pyramid_pass"); + InitComputeShader("compute_luminance_pyramid_pass", contextDescription.Shaders.computeLuminancePyramidPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoExposure, Resources.AutoExposure); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoExposure, Resources.AutoExposure); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2ReconstructPreviousDepthPass : Fsr2Pass + internal class Fsr3UpscalerReconstructPreviousDepthPass : Fsr3UpscalerPass { - public Fsr2ReconstructPreviousDepthPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerReconstructPreviousDepthPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_reconstruct_previous_depth_pass"); + InitComputeShader("reconstruct_previous_depth_pass", contextDescription.Shaders.reconstructPreviousDepthPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var depth = ref dispatchParams.Depth; ref var motionVectors = ref dispatchParams.MotionVectors; ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2DepthClipPass : Fsr2Pass + internal class Fsr3UpscalerDepthClipPass : Fsr3UpscalerPass { - public Fsr2DepthClipPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerDepthClipPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_depth_clip_pass"); + InitComputeShader("depth_clip_pass", contextDescription.Shaders.depthClipPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var depth = ref dispatchParams.Depth; @@ -189,62 +168,59 @@ namespace FidelityFX ref var reactive = ref dispatchParams.Reactive; ref var tac = ref dispatchParams.TransparencyAndComposition; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReconstructedPrevNearestDepth, Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedDepth, Fsr2ShaderIDs.UavDilatedDepth); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReconstructedPrevNearestDepth, Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedDepth, Fsr3ShaderIDs.UavDilatedDepth); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); + + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2LockPass : Fsr2Pass + internal class Fsr3UpscalerLockPass : Fsr3UpscalerPass { - public Fsr2LockPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerLockPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_lock_pass"); + InitComputeShader("lock_pass", contextDescription.Shaders.lockPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockInputLuma, Fsr2ShaderIDs.UavLockInputLuma); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLockInputLuma, Fsr3ShaderIDs.UavLockInputLuma); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2AccumulatePass : Fsr2Pass + internal class Fsr3UpscalerAccumulatePass : Fsr3UpscalerPass { - private const string SharpeningKeyword = "FFX_FSR2_OPTION_APPLY_SHARPENING"; - - // Workaround: Disable FP16 path for the accumulate pass on NVIDIA due to reduced occupancy and high VRAM throughput. - protected override bool AllowFP16 => SystemInfo.graphicsDeviceVendorID != 0x10DE; + private const string SharpeningKeyword = "FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING"; #if UNITY_2021_2_OR_NEWER private readonly LocalKeyword _sharpeningKeyword; #endif - public Fsr2AccumulatePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerAccumulatePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass"); + InitComputeShader("accumulate_pass", contextDescription.Shaders.accumulatePass); #if UNITY_2021_2_OR_NEWER _sharpeningKeyword = new LocalKeyword(ComputeShader, SharpeningKeyword); #endif } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { #if UNITY_2021_2_OR_NEWER if (dispatchParams.EnableSharpening) @@ -258,115 +234,115 @@ namespace FidelityFX commandBuffer.DisableShaderKeyword(SharpeningKeyword); #endif - if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) + if ((ContextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) { - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); } else { ref var motionVectors = ref dispatchParams.MotionVectors; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); } ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedReactiveMasks, Fsr2ShaderIDs.UavDilatedReactiveMasks); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPreparedInputColor, Fsr2ShaderIDs.UavPreparedInputColor); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLanczosLut, Resources.LanczosLut); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvAutoExposure, Resources.AutoExposure); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreparedInputColor, Fsr3ShaderIDs.UavPreparedInputColor); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLanczosLut, Resources.LanczosLut); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvAutoExposure, Resources.AutoExposure); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); ref var output = ref dispatchParams.Output; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2RcasPass : Fsr2Pass + internal class Fsr3UpscalerSharpenPass : Fsr3UpscalerPass { private readonly ComputeBuffer _rcasConstants; - public Fsr2RcasPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) + public Fsr3UpscalerSharpenPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) : base(contextDescription, resources, constants) { _rcasConstants = rcasConstants; - LoadComputeShader("FSR2/ffx_fsr2_rcas_pass"); + InitComputeShader("rcas_pass", contextDescription.Shaders.sharpenPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]); ref var output = ref dispatchParams.Output; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2GenerateReactivePass : Fsr2Pass + internal class Fsr3UpscalerGenerateReactivePass : Fsr3UpscalerPass { private readonly ComputeBuffer _generateReactiveConstants; - public Fsr2GenerateReactivePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer generateReactiveConstants) + public Fsr3UpscalerGenerateReactivePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer generateReactiveConstants) : base(contextDescription, resources, null) { _generateReactiveConstants = generateReactiveConstants; - LoadComputeShader("FSR2/ffx_fsr2_autogen_reactive_pass"); + InitComputeShader("autogen_reactive_pass", contextDescription.Shaders.autoGenReactivePass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { } - public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) + public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref var color = ref dispatchParams.ColorPreUpscale; ref var reactive = ref dispatchParams.OutReactive; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2TcrAutogeneratePass : Fsr2Pass + internal class Fsr3UpscalerTcrAutogeneratePass : Fsr3UpscalerPass { private readonly ComputeBuffer _tcrAutogenerateConstants; - public Fsr2TcrAutogeneratePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) + public Fsr3UpscalerTcrAutogeneratePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) : base(contextDescription, resources, constants) { _tcrAutogenerateConstants = tcrAutogenerateConstants; - LoadComputeShader("FSR2/ffx_fsr2_tcr_autogen_pass"); + InitComputeShader("tcr_autogen_pass", contextDescription.Shaders.tcrAutoGenPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var motionVectors = ref dispatchParams.MotionVectors; @@ -374,21 +350,21 @@ namespace FidelityFX ref var reactive = ref dispatchParams.Reactive; ref var tac = ref dispatchParams.TransparencyAndComposition; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, Resources.AutoReactive); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoComposition, Resources.AutoComposition); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, Resources.AutoReactive); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoComposition, Resources.AutoComposition); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } diff --git a/Assets/Scripts/Core/Fsr2Pass.cs.meta b/Assets/Scripts/Core/Fsr3UpscalerPass.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2Pass.cs.meta rename to Assets/Scripts/Core/Fsr3UpscalerPass.cs.meta diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs b/Assets/Scripts/Core/Fsr3UpscalerResources.cs similarity index 64% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs rename to Assets/Scripts/Core/Fsr3UpscalerResources.cs index a3e8e27..676867b 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerResources.cs @@ -26,10 +26,10 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// Helper class for bundling and managing persistent resources required by the FSR2 process. + /// Helper class for bundling and managing persistent resources required by the FSR3 Upscaler process. /// This includes lookup tables, default fallback resources and double-buffered resources that get swapped between frames. /// - internal class Fsr2Resources + internal class Fsr3UpscalerResources { public Texture2D DefaultExposure; public Texture2D DefaultReactive; @@ -47,7 +47,7 @@ namespace FidelityFX public readonly RenderTexture[] PrevPreAlpha = new RenderTexture[2]; public readonly RenderTexture[] PrevPostAlpha = new RenderTexture[2]; - public void Create(Fsr2.ContextDescription contextDescription) + public void Create(Fsr3Upscaler.ContextDescription contextDescription) { // Generate the data for the LUT const int lanczos2LutWidth = 128; @@ -55,7 +55,7 @@ namespace FidelityFX for (int currentLanczosWidthIndex = 0; currentLanczosWidthIndex < lanczos2LutWidth; ++currentLanczosWidthIndex) { float x = 2.0f * currentLanczosWidthIndex / (lanczos2LutWidth - 1); - float y = Fsr2.Lanczos2(x); + float y = Fsr3Upscaler.Lanczos2(x); lanczos2Weights[currentLanczosWidthIndex] = y; } @@ -65,108 +65,108 @@ namespace FidelityFX maximumBias[i] = MaximumBias[i] / 2.0f; } - // Resource FSR2_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE + // Resource FSR3UPSCALER_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE // R16_SNorm textures are not supported by Unity on most platforms, strangely enough. So instead we use R32_SFloat and upload pre-normalized float data. - LanczosLut = new Texture2D(lanczos2LutWidth, 1, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR2_LanczosLutData" }; + LanczosLut = new Texture2D(lanczos2LutWidth, 1, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_LanczosLutData" }; LanczosLut.SetPixelData(lanczos2Weights, 0); LanczosLut.Apply(); - // Resource FSR2_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE - MaximumBiasLut = new Texture2D(MaximumBiasTextureWidth, MaximumBiasTextureHeight, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR2_MaximumUpsampleBias" }; + // Resource FSR3UPSCALER_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE + MaximumBiasLut = new Texture2D(MaximumBiasTextureWidth, MaximumBiasTextureHeight, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_MaximumUpsampleBias" }; MaximumBiasLut.SetPixelData(maximumBias, 0); MaximumBiasLut.Apply(); - // Resource FSR2_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE - DefaultExposure = new Texture2D(1, 1, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None) { name = "FSR2_DefaultExposure" }; + // Resource FSR3UPSCALER_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE + DefaultExposure = new Texture2D(1, 1, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_DefaultExposure" }; DefaultExposure.SetPixel(0, 0, Color.clear); DefaultExposure.Apply(); - // Resource FSR2_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - DefaultReactive = new Texture2D(1, 1, GraphicsFormat.R8_UNorm, TextureCreationFlags.None) { name = "FSR2_DefaultReactivityMask" }; + // Resource FSR3UPSCALER_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + DefaultReactive = new Texture2D(1, 1, GraphicsFormat.R8_UNorm, TextureCreationFlags.None) { name = "FSR3UPSCALER_DefaultReactivityMask" }; DefaultReactive.SetPixel(0, 0, Color.clear); DefaultReactive.Apply(); - // Resource FSR2_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE - // Despite what the original FSR2 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal. - SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "FSR2_SpdAtomicCounter", enableRandomWrite = true }; + // Resource FSR3UPSCALER_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE + // Despite what the original FSR3 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal. + SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "FSR3UPSCALER_SpdAtomicCounter", enableRandomWrite = true }; SpdAtomicCounter.Create(); - // Resource FSR2_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE - AutoExposure = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32_SFloat) { name = "FSR2_AutoExposure", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE + AutoExposure = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32_SFloat) { name = "FSR3UPSCALER_AutoExposure", enableRandomWrite = true }; AutoExposure.Create(); - // Resource FSR2_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + // Resource FSR3UPSCALER_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE // This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this. int w = contextDescription.MaxRenderSize.x / 2, h = contextDescription.MaxRenderSize.y / 2; int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Math.Max(w, h), 2.0f)); - SceneLuminance = new RenderTexture(w, h, 0, GraphicsFormat.R16_SFloat, mipCount) { name = "FSR2_ExposureMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + SceneLuminance = new RenderTexture(w, h, 0, GraphicsFormat.R16_SFloat, mipCount) { name = "FSR3UPSCALER_ExposureMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; SceneLuminance.Create(); - // Resources FSR2_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(DilatedMotionVectors, "FSR2_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat); + // Resources FSR3UPSCALER_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(DilatedMotionVectors, "FSR3UPSCALER_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat); - // Resources FSR2_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(LockStatus, "FSR2_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat); + // Resources FSR3UPSCALER_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(LockStatus, "FSR3UPSCALER_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat); - // Resources FSR2_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(InternalUpscaled, "FSR2_InternalUpscaled", contextDescription.DisplaySize, GraphicsFormat.R16G16B16A16_SFloat); + // Resources FSR3UPSCALER_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(InternalUpscaled, "FSR3UPSCALER_InternalUpscaled", contextDescription.DisplaySize, GraphicsFormat.R16G16B16A16_SFloat); - // Resources FSR2_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(LumaHistory, "FSR2_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm); + // Resources FSR3UPSCALER_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(LumaHistory, "FSR3UPSCALER_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm); } - public void CreateTcrAutogenResources(Fsr2.ContextDescription contextDescription) + public void CreateTcrAutogenResources(Fsr3Upscaler.ContextDescription contextDescription) { - // Resource FSR2_AutoReactive: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - AutoReactive = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR2_AutoReactive", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoReactive: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + AutoReactive = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR3UPSCALER_AutoReactive", enableRandomWrite = true }; AutoReactive.Create(); - // Resource FSR2_AutoComposition: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - AutoComposition = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR2_AutoComposition", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoComposition: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + AutoComposition = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR3UPSCALER_AutoComposition", enableRandomWrite = true }; AutoComposition.Create(); - // Resources FSR2_PrevPreAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(PrevPreAlpha, "FSR2_PrevPreAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); + // Resources FSR3UPSCALER_PrevPreAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(PrevPreAlpha, "FSR3UPSCALER_PrevPreAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); - // Resources FSR2_PrevPostAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(PrevPostAlpha, "FSR2_PrevPostAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); + // Resources FSR3UPSCALER_PrevPostAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(PrevPostAlpha, "FSR3UPSCALER_PrevPostAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); } // Set up shared aliasable resources, i.e. temporary render textures // These do not need to persist between frames, but they do need to be available between passes - public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr2.ContextDescription contextDescription, Fsr2.DispatchDescription dispatchParams) + public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr3Upscaler.ContextDescription contextDescription, Fsr3Upscaler.DispatchDescription dispatchParams) { Vector2Int displaySize = contextDescription.DisplaySize; Vector2Int maxRenderSize = contextDescription.MaxRenderSize; - // FSR2_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); + // FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); - // FSR2_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); + // FSR3UPSCALER_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); - // FSR2_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); + // FSR3UPSCALER_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); - // FSR2_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); + // FSR3UPSCALER_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); - // FSR2_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); + // FSR3UPSCALER_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); - // FSR2_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); + // FSR3UPSCALER_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); } public static void DestroyAliasableResources(CommandBuffer commandBuffer) { // Release all of the aliasable resources used this frame - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavNewLocks); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavDilatedDepth); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavLockInputLuma); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavPreparedInputColor); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavNewLocks); } private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format) diff --git a/Assets/Scripts/Core/Fsr2Resources.cs.meta b/Assets/Scripts/Core/Fsr3UpscalerResources.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2Resources.cs.meta rename to Assets/Scripts/Core/Fsr3UpscalerResources.cs.meta diff --git a/Assets/Scripts/Fsr2ImageEffect.cs b/Assets/Scripts/Fsr3UpscalerImageEffect.cs similarity index 76% rename from Assets/Scripts/Fsr2ImageEffect.cs rename to Assets/Scripts/Fsr3UpscalerImageEffect.cs index e0f87d7..a5591a5 100644 --- a/Assets/Scripts/Fsr2ImageEffect.cs +++ b/Assets/Scripts/Fsr3UpscalerImageEffect.cs @@ -19,7 +19,6 @@ // THE SOFTWARE. using System; -using System.Collections; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; @@ -27,17 +26,17 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// This class is responsible for hooking into various Unity events and translating them to the FSR2 subsystem. - /// This includes creation and destruction of the FSR2 context, as well as dispatching commands at the right time. - /// This component also exposes various FSR2 parameters to the Unity inspector. + /// This class is responsible for hooking into various Unity events and translating them to the FSR3 Upscaler subsystem. + /// This includes creation and destruction of the FSR3 Upscaler context, as well as dispatching commands at the right time. + /// This component also exposes various FSR3 Upscaler parameters to the Unity inspector. /// [RequireComponent(typeof(Camera))] - public class Fsr2ImageEffect : MonoBehaviour + public class Fsr3UpscalerImageEffect : MonoBehaviour { - public IFsr2Callbacks Callbacks { get; set; } = new Fsr2CallbacksBase(); + public IFsr3UpscalerCallbacks Callbacks { get; set; } = new Fsr3UpscalerCallbacksBase(); [Tooltip("Standard scaling ratio presets.")] - public Fsr2.QualityMode qualityMode = Fsr2.QualityMode.Quality; + public Fsr3Upscaler.QualityMode qualityMode = Fsr3Upscaler.QualityMode.Quality; [Tooltip("Apply RCAS sharpening to the image after upscaling.")] public bool performSharpenPass = true; @@ -76,7 +75,7 @@ namespace FidelityFX [Tooltip("A value to set for the binary reactive mask")] [Range(0, 1)] public float binaryValue = 0.9f; [Tooltip("Flags to determine how to generate the reactive mask")] - public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax; + public Fsr3Upscaler.GenerateReactiveFlags flags = Fsr3Upscaler.GenerateReactiveFlags.ApplyTonemap | Fsr3Upscaler.GenerateReactiveFlags.ApplyThreshold | Fsr3Upscaler.GenerateReactiveFlags.UseComponentsMax; } [Tooltip("(Experimental) Automatically generate and use Reactive mask and Transparency & composition mask internally.")] @@ -98,26 +97,25 @@ namespace FidelityFX [Range(0, 1)] public float autoReactiveMax = 0.9f; } - [Header("Output resources")] - [Tooltip("Optional render texture to copy motion vector data to, for additional post-processing after upscaling.")] - public RenderTexture outputMotionVectors; + [SerializeField] + private Fsr3UpscalerAssets assets; - private Fsr2Context _context; + private Fsr3UpscalerContext _context; private Vector2Int _maxRenderSize; private Vector2Int _displaySize; private bool _resetHistory; - private readonly Fsr2.DispatchDescription _dispatchDescription = new Fsr2.DispatchDescription(); - private readonly Fsr2.GenerateReactiveDescription _genReactiveDescription = new Fsr2.GenerateReactiveDescription(); + private readonly Fsr3Upscaler.DispatchDescription _dispatchDescription = new Fsr3Upscaler.DispatchDescription(); + private readonly Fsr3Upscaler.GenerateReactiveDescription _genReactiveDescription = new Fsr3Upscaler.GenerateReactiveDescription(); - private Fsr2ImageEffectHelper _helper; + private Fsr3UpscalerImageEffectHelper _helper; private Camera _renderCamera; private RenderTexture _originalRenderTarget; private DepthTextureMode _originalDepthTextureMode; private Rect _originalRect; - private Fsr2.QualityMode _prevQualityMode; + private Fsr3Upscaler.QualityMode _prevQualityMode; private Vector2Int _prevDisplaySize; private bool _prevAutoExposure; @@ -129,7 +127,7 @@ namespace FidelityFX private void OnEnable() { - // Set up the original camera to output all of the required FSR2 input resources at the desired resolution + // Set up the original camera to output all of the required FSR3 input resources at the desired resolution _renderCamera = GetComponent(); _originalRenderTarget = _renderCamera.targetTexture; _originalDepthTextureMode = _renderCamera.depthTextureMode; @@ -138,24 +136,31 @@ namespace FidelityFX // Determine the desired rendering and display resolutions _displaySize = GetDisplaySize(); - Fsr2.GetRenderResolutionFromQualityMode(out var maxRenderWidth, out var maxRenderHeight, _displaySize.x, _displaySize.y, qualityMode); + Fsr3Upscaler.GetRenderResolutionFromQualityMode(out var maxRenderWidth, out var maxRenderHeight, _displaySize.x, _displaySize.y, qualityMode); _maxRenderSize = new Vector2Int(maxRenderWidth, maxRenderHeight); if (!SystemInfo.supportsComputeShaders) { - Debug.LogError("FSR2 requires compute shader support!"); + Debug.LogError("FSR3 Upscaler requires compute shader support!"); + enabled = false; + return; + } + + if (assets == null) + { + Debug.LogError($"FSR3 Upscaler assets are not assigned! Please ensure an {nameof(Fsr3UpscalerAssets)} asset is assigned to the Assets property of this component."); enabled = false; return; } if (_maxRenderSize.x == 0 || _maxRenderSize.y == 0) { - Debug.LogError($"FSR2 render size is invalid: {_maxRenderSize.x}x{_maxRenderSize.y}. Please check your screen resolution and camera viewport parameters."); + Debug.LogError($"FSR3 Upscaler render size is invalid: {_maxRenderSize.x}x{_maxRenderSize.y}. Please check your screen resolution and camera viewport parameters."); enabled = false; return; } - _helper = GetComponent(); + _helper = GetComponent(); _copyWithDepthMaterial = new Material(Shader.Find("Hidden/BlitCopyWithDepth")); CreateFsrContext(); @@ -180,14 +185,14 @@ namespace FidelityFX private void CreateFsrContext() { - // Initialize FSR2 context - Fsr2.InitializationFlags flags = 0; - if (_renderCamera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; - if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; - if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure; - if (UsingDynamicResolution()) flags |= Fsr2.InitializationFlags.EnableDynamicResolution; + // Initialize FSR3 Upscaler context + Fsr3Upscaler.InitializationFlags flags = 0; + if (_renderCamera.allowHDR) flags |= Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange; + if (enableFP16) flags |= Fsr3Upscaler.InitializationFlags.EnableFP16Usage; + if (enableAutoExposure) flags |= Fsr3Upscaler.InitializationFlags.EnableAutoExposure; + if (UsingDynamicResolution()) flags |= Fsr3Upscaler.InitializationFlags.EnableDynamicResolution; - _context = Fsr2.CreateContext(_displaySize, _maxRenderSize, Callbacks, flags); + _context = Fsr3Upscaler.CreateContext(_displaySize, _maxRenderSize, assets.shaders, flags); _prevDisplaySize = _displaySize; _prevQualityMode = qualityMode; @@ -209,8 +214,8 @@ namespace FidelityFX private void CreateCommandBuffers() { - _dispatchCommandBuffer = new CommandBuffer { name = "FSR2 Dispatch" }; - _opaqueInputCommandBuffer = new CommandBuffer { name = "FSR2 Opaque Input" }; + _dispatchCommandBuffer = new CommandBuffer { name = "FSR3 Upscaler Dispatch" }; + _opaqueInputCommandBuffer = new CommandBuffer { name = "FSR3 Upscaler Opaque Input" }; _renderCamera.AddCommandBuffer(CameraEvent.BeforeForwardAlpha, _opaqueInputCommandBuffer); } @@ -233,7 +238,7 @@ namespace FidelityFX private void ApplyMipmapBias() { // Apply a mipmap bias so that textures retain their sharpness - float biasOffset = Fsr2.GetMipmapBiasOffset(_maxRenderSize.x, _displaySize.x); + float biasOffset = Fsr3Upscaler.GetMipmapBiasOffset(_maxRenderSize.x, _displaySize.x); if (!float.IsNaN(biasOffset) && !float.IsInfinity(biasOffset)) { Callbacks.ApplyMipmapBias(biasOffset); @@ -248,7 +253,7 @@ namespace FidelityFX private void Update() { - // Monitor for any changes in parameters that require a reset of the FSR2 context + // Monitor for any changes in parameters that require a reset of the FSR3 Upscaler context var displaySize = GetDisplaySize(); if (displaySize.x != _prevDisplaySize.x || displaySize.y != _prevDisplaySize.y || qualityMode != _prevQualityMode || enableAutoExposure != _prevAutoExposure) { @@ -275,7 +280,7 @@ namespace FidelityFX if (_helper == null || !_helper.enabled) { // Render to a smaller portion of the screen by manipulating the camera's viewport rect - _renderCamera.aspect = (_displaySize.x * _originalRect.width) / (_displaySize.y * _originalRect.height); + _renderCamera.aspect = (float)_displaySize.x / _displaySize.y; _renderCamera.rect = new Rect(0, 0, _originalRect.width * _maxRenderSize.x / _renderCamera.pixelWidth, _originalRect.height * _maxRenderSize.y / _renderCamera.pixelHeight); } @@ -300,21 +305,21 @@ namespace FidelityFX private void SetupDispatchDescription() { - // Set up the main FSR2 dispatch parameters - _dispatchDescription.Color = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); - _dispatchDescription.Depth = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); - _dispatchDescription.MotionVectors = new Fsr2.ResourceView(BuiltinRenderTextureType.MotionVectors); - _dispatchDescription.Exposure = Fsr2.ResourceView.Unassigned; - _dispatchDescription.Reactive = Fsr2.ResourceView.Unassigned; - _dispatchDescription.TransparencyAndComposition = Fsr2.ResourceView.Unassigned; + // Set up the main FSR3 Upscaler dispatch parameters + _dispatchDescription.Color = new ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); + _dispatchDescription.Depth = new ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); + _dispatchDescription.MotionVectors = new ResourceView(BuiltinRenderTextureType.MotionVectors); + _dispatchDescription.Exposure = ResourceView.Unassigned; + _dispatchDescription.Reactive = ResourceView.Unassigned; + _dispatchDescription.TransparencyAndComposition = ResourceView.Unassigned; - if (!enableAutoExposure && exposure != null) _dispatchDescription.Exposure = new Fsr2.ResourceView(exposure); - if (reactiveMask != null) _dispatchDescription.Reactive = new Fsr2.ResourceView(reactiveMask); - if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new Fsr2.ResourceView(transparencyAndCompositionMask); + if (!enableAutoExposure && exposure != null) _dispatchDescription.Exposure = new ResourceView(exposure); + if (reactiveMask != null) _dispatchDescription.Reactive = new ResourceView(reactiveMask); + if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new ResourceView(transparencyAndCompositionMask); var scaledRenderSize = GetScaledRenderSize(); - _dispatchDescription.Output = new Fsr2.ResourceView(Fsr2ShaderIDs.UavUpscaledOutput); + _dispatchDescription.Output = new ResourceView(Fsr3ShaderIDs.UavUpscaledOutput); _dispatchDescription.PreExposure = preExposure; _dispatchDescription.EnableSharpening = performSharpenPass; _dispatchDescription.Sharpness = sharpness; @@ -333,7 +338,7 @@ namespace FidelityFX _dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition; if (autoGenerateTransparencyAndComposition) { - _dispatchDescription.ColorOpaqueOnly = new Fsr2.ResourceView(_colorOpaqueOnly); + _dispatchDescription.ColorOpaqueOnly = new ResourceView(_colorOpaqueOnly); _dispatchDescription.AutoTcThreshold = generateTransparencyAndCompositionParameters.autoTcThreshold; _dispatchDescription.AutoTcScale = generateTransparencyAndCompositionParameters.autoTcScale; _dispatchDescription.AutoReactiveScale = generateTransparencyAndCompositionParameters.autoReactiveScale; @@ -342,7 +347,7 @@ namespace FidelityFX if (SystemInfo.usesReversedZBuffer) { - // Swap the near and far clip plane distances as FSR2 expects this when using inverted depth + // Swap the near and far clip plane distances as FSR3 expects this when using inverted depth (_dispatchDescription.CameraNear, _dispatchDescription.CameraFar) = (_dispatchDescription.CameraFar, _dispatchDescription.CameraNear); } } @@ -350,9 +355,9 @@ namespace FidelityFX private void SetupAutoReactiveDescription() { // Set up the parameters to auto-generate a reactive mask - _genReactiveDescription.ColorOpaqueOnly = new Fsr2.ResourceView(_colorOpaqueOnly); - _genReactiveDescription.ColorPreUpscale = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); - _genReactiveDescription.OutReactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); + _genReactiveDescription.ColorOpaqueOnly = new ResourceView(_colorOpaqueOnly); + _genReactiveDescription.ColorPreUpscale = new ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Color); + _genReactiveDescription.OutReactive = new ResourceView(Fsr3ShaderIDs.UavAutoReactive); _genReactiveDescription.RenderSize = GetScaledRenderSize(); _genReactiveDescription.Scale = generateReactiveParameters.scale; _genReactiveDescription.CutoffThreshold = generateReactiveParameters.cutoffThreshold; @@ -364,9 +369,9 @@ namespace FidelityFX { var scaledRenderSize = GetScaledRenderSize(); - // Perform custom jittering of the camera's projection matrix according to FSR2's recipe - int jitterPhaseCount = Fsr2.GetJitterPhaseCount(scaledRenderSize.x, _displaySize.x); - Fsr2.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount); + // Perform custom jittering of the camera's projection matrix according to FSR3's recipe + int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(scaledRenderSize.x, _displaySize.x); + Fsr3Upscaler.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount); _dispatchDescription.JitterOffset = new Vector2(jitterX, jitterY); @@ -392,38 +397,36 @@ namespace FidelityFX if (autoGenerateReactiveMask) { - // The auto-reactive mask pass is executed separately from the main FSR2 passes + // The auto-reactive mask pass is executed separately from the main FSR3 Upscaler passes var scaledRenderSize = GetScaledRenderSize(); - _dispatchCommandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavAutoReactive, scaledRenderSize.x, scaledRenderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); + _dispatchCommandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavAutoReactive, scaledRenderSize.x, scaledRenderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); _context.GenerateReactiveMask(_genReactiveDescription, _dispatchCommandBuffer); - _dispatchDescription.Reactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); + _dispatchDescription.Reactive = new ResourceView(Fsr3ShaderIDs.UavAutoReactive); } - // The backbuffer is not set up to allow random-write access, so we need a temporary render texture for FSR2 to output to - _dispatchCommandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput, _displaySize.x, _displaySize.y, 0, default, GetDefaultFormat(), default, 1, true); + // The backbuffer is not set up to allow random-write access, so we need a temporary render texture for FSR3 to output to + _dispatchCommandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavUpscaledOutput, _displaySize.x, _displaySize.y, 0, default, GetDefaultFormat(), default, 1, true); _context.Dispatch(_dispatchDescription, _dispatchCommandBuffer); // Output the upscaled image if (_originalRenderTarget != null) { - // Output to the camera target texture, passing through depth and motion vectors + // Output to the camera target texture, passing through depth as well _dispatchCommandBuffer.SetGlobalTexture("_DepthTex", BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); - _dispatchCommandBuffer.Blit(Fsr2ShaderIDs.UavUpscaledOutput, _originalRenderTarget, _copyWithDepthMaterial); - if (outputMotionVectors != null) - _dispatchCommandBuffer.Blit(BuiltinRenderTextureType.MotionVectors, outputMotionVectors); + _dispatchCommandBuffer.Blit(Fsr3ShaderIDs.UavUpscaledOutput, _originalRenderTarget, _copyWithDepthMaterial); } else { // Output directly to the backbuffer - _dispatchCommandBuffer.Blit(Fsr2ShaderIDs.UavUpscaledOutput, dest); + _dispatchCommandBuffer.Blit(Fsr3ShaderIDs.UavUpscaledOutput, dest); } - _dispatchCommandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput); - _dispatchCommandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavAutoReactive); + _dispatchCommandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavUpscaledOutput); + _dispatchCommandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavAutoReactive); Graphics.ExecuteCommandBuffer(_dispatchCommandBuffer); - + if (_colorOpaqueOnly != null) { RenderTexture.ReleaseTemporary(_colorOpaqueOnly); @@ -462,5 +465,20 @@ namespace FidelityFX return _maxRenderSize; } + + #if UNITY_EDITOR + private void Reset() + { + if (assets != null) + return; + + string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:{nameof(Fsr3UpscalerAssets)}"); + if (assetGuids == null || assetGuids.Length == 0) + return; + + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); + assets = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); + } + #endif } } diff --git a/Assets/Scripts/Fsr2ImageEffect.cs.meta b/Assets/Scripts/Fsr3UpscalerImageEffect.cs.meta similarity index 100% rename from Assets/Scripts/Fsr2ImageEffect.cs.meta rename to Assets/Scripts/Fsr3UpscalerImageEffect.cs.meta diff --git a/Assets/Scripts/Fsr2ImageEffectHelper.cs b/Assets/Scripts/Fsr3UpscalerImageEffectHelper.cs similarity index 75% rename from Assets/Scripts/Fsr2ImageEffectHelper.cs rename to Assets/Scripts/Fsr3UpscalerImageEffectHelper.cs index 25b2902..785ab8c 100644 --- a/Assets/Scripts/Fsr2ImageEffectHelper.cs +++ b/Assets/Scripts/Fsr3UpscalerImageEffectHelper.cs @@ -24,23 +24,23 @@ using UnityEngine; namespace FidelityFX { /// - /// Small helper script to be used in conjunction with the Fsr2ImageEffect script. - /// The FSR2 image effect needs to be the last effect in the post-processing chain but for render scaling to work properly, it also needs to be the first to execute OnPreCull. + /// Small helper script to be used in conjunction with the Fsr3UpscalerImageEffect script. + /// The FSR3 Upscaler image effect needs to be the last effect in the post-processing chain but for render scaling to work properly, it also needs to be the first to execute OnPreCull. /// Unfortunately altering the script execution order does not affect the order in which OnPreCull is executed. Only the order of scripts on the same game object matters. /// - /// When combining FSR2 upscaling with other post-processing effects (most notably Unity's Post-Processing Stack V2), + /// When combining FSR3 upscaling with other post-processing effects (most notably Unity's Post-Processing Stack V2), /// this script should be added to the same camera and moved up above any other scripts that have an OnPreCull method. /// - [RequireComponent(typeof(Camera), typeof(Fsr2ImageEffect))] - public class Fsr2ImageEffectHelper : MonoBehaviour + [RequireComponent(typeof(Camera), typeof(Fsr3UpscalerImageEffect))] + public class Fsr3UpscalerImageEffectHelper : MonoBehaviour { private Camera _renderCamera; - private Fsr2ImageEffect _imageEffect; + private Fsr3UpscalerImageEffect _imageEffect; private void OnEnable() { _renderCamera = GetComponent(); - _imageEffect = GetComponent(); + _imageEffect = GetComponent(); } private void OnPreCull() @@ -49,10 +49,10 @@ namespace FidelityFX return; var originalRect = _renderCamera.rect; - float upscaleRatio = Fsr2.GetUpscaleRatioFromQualityMode(_imageEffect.qualityMode); + float upscaleRatio = Fsr3Upscaler.GetUpscaleRatioFromQualityMode(_imageEffect.qualityMode); // Render to a smaller portion of the screen by manipulating the camera's viewport rect - _renderCamera.aspect = (_renderCamera.pixelWidth * originalRect.width) / (_renderCamera.pixelHeight * originalRect.height); + _renderCamera.aspect = (float)_renderCamera.pixelWidth / _renderCamera.pixelHeight; _renderCamera.rect = new Rect(0, 0, originalRect.width / upscaleRatio, originalRect.height / upscaleRatio); } } diff --git a/Assets/Scripts/Fsr2ImageEffectHelper.cs.meta b/Assets/Scripts/Fsr3UpscalerImageEffectHelper.cs.meta similarity index 100% rename from Assets/Scripts/Fsr2ImageEffectHelper.cs.meta rename to Assets/Scripts/Fsr3UpscalerImageEffectHelper.cs.meta diff --git a/Assets/Resources.meta b/Assets/Shaders.meta similarity index 100% rename from Assets/Resources.meta rename to Assets/Shaders.meta diff --git a/Assets/Resources/FSR2.meta b/Assets/Shaders/FSR3.meta similarity index 77% rename from Assets/Resources/FSR2.meta rename to Assets/Shaders/FSR3.meta index 6d47067..ca8a4cc 100644 --- a/Assets/Resources/FSR2.meta +++ b/Assets/Shaders/FSR3.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cad7d53fa2166a0449bec7a9b4f17d69 +guid: 661ffc6dbd7389b4da99fb9f749745de folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute similarity index 61% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute index a359485..5cbfb80 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute @@ -21,21 +21,21 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#pragma multi_compile_local __ FFX_FSR2_OPTION_HDR_COLOR_INPUT -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ FFX_FSR2_OPTION_APPLY_SHARPENING +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" // Ensure the correct value is defined for this keyword, as it is used to select one of multiple sampler functions -#ifdef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#undef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 1 +#ifdef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#undef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE 1 #endif -#include "shaders/ffx_fsr2_accumulate_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_accumulate_pass.hlsl" diff --git a/Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta similarity index 79% rename from Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta index 49033cb..dbe5282 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0894ebeefb6aa7d4680c71dffbda3fee +guid: c9b45f0ae7673694ba57a4aadfe212e9 ComputeShaderImporter: externalObjects: {} preprocessorOverride: 0 diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute new file mode 100644 index 0000000..e13c001 --- /dev/null +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Nico de Poel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// 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. + +#pragma kernel CS + +#pragma multi_compile_local __ FFX_HALF +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH + +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP + +#include "ffx_fsr3upscaler_unity_common.cginc" + +#include "shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl" diff --git a/Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta similarity index 79% rename from Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute.meta rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta index 26fb9ba..1df041b 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute.meta +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8026d9d8542eab6499c32d5d46beb2b6 +guid: 5716b91fdaa4e9e439df6b96a796fe6e ComputeShaderImporter: externalObjects: {} preprocessorOverride: 0 diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute similarity index 76% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute index 385dfe4..d5903c0 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute @@ -20,14 +20,14 @@ #pragma kernel CS -//#pragma multi_compile_local __ FFX_HALF // causes a hard-coded error message from the shader include ¯\_(ツ)_/¯ -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_HALF +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" // Wave operations require shader model 6.0; this can only be enabled when using DXC on D3D12 // These pragmas are commented out by default as Unity will sometimes ignore the #if's and try to enable these features anyway. @@ -36,7 +36,7 @@ //#pragma require WaveBasic // Required for WaveGetLaneIndex //#pragma require WaveBallot // Required for WaveReadLaneAt //#else -#define SPD_NO_WAVE_OPERATIONS +#define FFX_SPD_NO_WAVE_OPERATIONS //#endif -#include "shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl" diff --git a/Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta similarity index 79% rename from Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta index 19d1df3..9e002c0 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d18fb8811ca4753469c439784546104e +guid: d253be05abcdc80428503d3e4cce3a36 ComputeShaderImporter: externalObjects: {} preprocessorOverride: 0 diff --git a/Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute similarity index 74% rename from Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute index d27a02d..0ccd388 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_autogen_reactive_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute @@ -21,12 +21,12 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_autogen_reactive_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl" diff --git a/Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta similarity index 79% rename from Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute.meta rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta index 3864379..d695f48 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute.meta +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 702560780e923c84394c9b22ba460a9c +guid: 20e44016ed34b0d4b8de499d1b566c69 ComputeShaderImporter: externalObjects: {} preprocessorOverride: 0 diff --git a/Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute similarity index 77% rename from Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute index 5f8c13d..e38ad99 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_lock_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute @@ -21,10 +21,10 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_lock_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_lock_pass.hlsl" diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta new file mode 100644 index 0000000..c01e009 --- /dev/null +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a135306e6d1857e43a86ef20db2a47fe +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute similarity index 77% rename from Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute index 6d97414..04c2fe4 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_rcas_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute @@ -20,10 +20,10 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_rcas_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_rcas_pass.hlsl" diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta new file mode 100644 index 0000000..cd12641 --- /dev/null +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7aaf5cfff022de2499e9b0412f947f6c +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute similarity index 70% rename from Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute index c6cc99f..ee2f276 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute @@ -21,13 +21,13 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_HDR_COLOR_INPUT -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl" diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta new file mode 100644 index 0000000..1053c34 --- /dev/null +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f59e5b9179d74844ae06a30ae1e0629 +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute b/Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute similarity index 74% rename from Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute index 62d386b..6338918 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_tcr_autogen_pass.compute +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute @@ -21,12 +21,12 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_tcr_autogen_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl" diff --git a/Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta new file mode 100644 index 0000000..ad42fbb --- /dev/null +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75cdc6ef23f08ed498d4da511923fcea +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc similarity index 92% rename from Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc index 98c5b17..758bb0c 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Nico de Poel +// Copyright (c) 2023 Nico de Poel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,7 @@ // Workaround for HDRP using texture arrays for its camera buffers on some platforms // The below defines are copied from: Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl -#if defined(UNITY_FSR2_HDRP) +#if defined(UNITY_FSR3UPSCALER_HDRP) // Must be in sync with C# with property useTexArray in TextureXR.cs #if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) #define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED @@ -73,9 +73,10 @@ #endif // Declare and sample camera buffers as texture arrays - #define UNITY_FSR2_TEX2D(type) Texture2DArray - #define UNITY_FSR2_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) - #define UNITY_FSR2_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) + #define UNITY_FSR3_TEX2D(type) Texture2DArray + #define UNITY_FSR3_RWTEX2D(type) RWTexture2DArray + #define UNITY_FSR3_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) + #define UNITY_FSR3_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) #endif #endif diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta similarity index 75% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta rename to Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta index 2e93435..5a68b6c 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta +++ b/Assets/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cc76bd6f46792f3418a56b79eb5c959b +guid: 3ce00ba677bb7e14bb91772fd68bfe6b ShaderIncludeImporter: externalObjects: {} userData: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders.meta b/Assets/Shaders/FSR3/shaders.meta similarity index 77% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders.meta rename to Assets/Shaders/FSR3/shaders.meta index 676ff9a..8a4ff2b 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders.meta +++ b/Assets/Shaders/FSR3/shaders.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4a24e63edc822264a871f58397325d51 +guid: 8364d4f86c613ec4d999d062f5f773b8 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl new file mode 100644 index 0000000..d2f1b32 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl @@ -0,0 +1,79 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0 +#define FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS 1 +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 2 +#else +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2 +#endif +#define FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED 3 +#define FSR3UPSCALER_BIND_SRV_LOCK_STATUS 4 +#define FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR 5 +#define FSR3UPSCALER_BIND_SRV_LANCZOS_LUT 6 +#define FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7 +#define FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS 8 +#define FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE 9 +#define FSR3UPSCALER_BIND_SRV_LUMA_HISTORY 10 + +#define FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED 0 +#define FSR3UPSCALER_BIND_UAV_LOCK_STATUS 1 +#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 2 +#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 3 +#define FSR3UPSCALER_BIND_UAV_LUMA_HISTORY 4 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_upsample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h" +#include "fsr3upscaler/ffx_fsr3upscaler_reproject.h" +#include "fsr3upscaler/ffx_fsr3upscaler_accumulate.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT - 1) / FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT; + uGroupId.y = GroupRows - uGroupId.y - 1; + + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + Accumulate(uDispatchThreadId); +} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta similarity index 75% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta rename to Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta index ac39806..80f209e 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 19dfb00afb70c3144b43ec2dc05ecdd9 +guid: 507ab779c38eddb429cdcedf9c108d1b ShaderIncludeImporter: externalObjects: {} userData: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl new file mode 100644 index 0000000..0d6e2eb --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl @@ -0,0 +1,77 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1 + +#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_REACTIVE 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + float3 ColorPreAlpha = LoadOpaqueOnly( FFX_MIN16_I2(uDispatchThreadId) ).rgb; + float3 ColorPostAlpha = LoadInputColor(uDispatchThreadId).rgb; + + if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP) + { + ColorPreAlpha = Tonemap(ColorPreAlpha); + ColorPostAlpha = Tonemap(ColorPostAlpha); + } + + if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP) + { + ColorPreAlpha = InverseTonemap(ColorPreAlpha); + ColorPostAlpha = InverseTonemap(ColorPostAlpha); + } + + float out_reactive_value = 0.f; + float3 delta = abs(ColorPostAlpha - ColorPreAlpha); + + out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta); + out_reactive_value *= GenReactiveScale(); + + out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < GenReactiveThreshold() ? 0 : GenReactiveBinaryValue()) : out_reactive_value; + + rw_output_autoreactive[uDispatchThreadId] = out_reactive_value; +} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta similarity index 75% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta rename to Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta index d7ce66d..c55f004 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7981b48622ddaa944909ebf209284d83 +guid: 52cdb7a7c30cb614984908593ed19082 ShaderIncludeImporter: externalObjects: {} userData: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl new file mode 100644 index 0000000..93b7332 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl @@ -0,0 +1,55 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 0 + +#define FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC 0 +#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 1 +#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 2 +#define FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_SPD 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 256 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +void CS(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex) +{ + ComputeAutoExposure(WorkGroupId, LocalThreadIndex); +} diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta similarity index 75% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta rename to Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta index cad5022..508b43e 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 356ec46d3f01672428b5a7a0de727548 +guid: 2d149b52ba0f5bb468a94a71dbbcb66f ShaderIncludeImporter: externalObjects: {} userData: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl new file mode 100644 index 0000000..70cc7ba --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl @@ -0,0 +1,67 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 +#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 1 +#define FSR3UPSCALER_BIND_SRV_DILATED_DEPTH 2 +#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 3 +#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 4 +#define FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS 5 +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 6 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 7 +#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 8 +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 9 + +#define FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS 0 +#define FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR 1 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_depth_clip.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS( + int2 iGroupId : SV_GroupID, + int2 iDispatchThreadId : SV_DispatchThreadID, + int2 iGroupThreadId : SV_GroupThreadID, + int iGroupIndex : SV_GroupIndex) +{ + DepthClip(iDispatchThreadId); +} diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta new file mode 100644 index 0000000..cde3a5e --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: da435b71cf57e2247b80ae0f0f86d1f8 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl new file mode 100644 index 0000000..26b28f0 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl @@ -0,0 +1,56 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA 0 + +#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 0 +#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 1 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_lock.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + ComputeLock(uDispatchThreadId); +} diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta new file mode 100644 index 0000000..45c99dc --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 98d2cbbda5e90dd4ebd1d70abbb63a09 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl new file mode 100644 index 0000000..bebdeb3 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl @@ -0,0 +1,53 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0 +#define FSR3UPSCALER_BIND_SRV_RCAS_INPUT 1 + +#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 0 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_RCAS 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_rcas.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 64 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID) +{ + RCAS(LocalThreadId, WorkGroupId, Dtid); +} diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta new file mode 100644 index 0000000..fb9bfe2 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9a15fc73170a9bc478801c8fa4d8d574 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl new file mode 100644 index 0000000..f277fd1 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl @@ -0,0 +1,64 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 1 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 2 +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 3 + +#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 +#define FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS 1 +#define FSR3UPSCALER_BIND_UAV_DILATED_DEPTH 2 +#define FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS( + int2 iGroupId : SV_GroupID, + int2 iDispatchThreadId : SV_DispatchThreadID, + int2 iGroupThreadId : SV_GroupThreadID, + int iGroupIndex : SV_GroupIndex +) +{ + ReconstructAndDilate(iDispatchThreadId); +} diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta new file mode 100644 index 0000000..6489d6d --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bafb3726a76b97a49bb343d8a4323754 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl similarity index 56% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl rename to Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl index 8e635d1..6180885 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl @@ -19,68 +19,44 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#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 4 -#define FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 5 - -#define FSR2_BIND_UAV_AUTOREACTIVE 0 -#define FSR2_BIND_UAV_AUTOCOMPOSITION 1 -#define FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR 2 -#define FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR 3 - -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_AUTOREACTIVE 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -#if defined(FSR2_BIND_CB_AUTOREACTIVE) - cbuffer cbGenerateReactive : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_AUTOREACTIVE) - { - float fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels - float fTcScale; - float fReactiveScale; - float fReactiveMax; - }; - float getTcThreshold() - { - return fTcThreshold; - } -#else - #define fTcThreshold 0.05f - #define fTcScale 1.00f - #define fReactiveScale 10.0f - #define fReactiveMax 0.90f - float getTcThreshold() - { - return fTcThreshold; - } -#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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT +#define FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1 +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2 +#define FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR 3 +#define FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR 4 +#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 4 +#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 5 + +#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0 +#define FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION 1 +#define FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR 2 +#define FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_AUTOREACTIVE 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) { - FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId); + FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId); // 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 diff --git a/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta new file mode 100644 index 0000000..02c5f46 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 712d171118b59fc4fb28d0d487060d42 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler.meta similarity index 77% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2.meta rename to Assets/Shaders/FSR3/shaders/fsr3upscaler.meta index 1579387..2626a2e 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2.meta +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9e2d87f36f288024cb500a20acaae11e +guid: ae9c6d015ae76544f9e8117e79ea862b folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Resources/FSR2/shaders/ffx_common_types.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h similarity index 83% rename from Assets/Resources/FSR2/shaders/ffx_common_types.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h index 4594dc1..f0b62ab 100644 --- a/Assets/Resources/FSR2/shaders/ffx_common_types.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -18,6 +18,8 @@ // 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. + + #ifndef FFX_COMMON_TYPES_H #define FFX_COMMON_TYPES_H @@ -25,127 +27,200 @@ #define FFX_PARAMETER_IN #define FFX_PARAMETER_OUT #define FFX_PARAMETER_INOUT +#define FFX_PARAMETER_UNIFORM #elif defined(FFX_HLSL) #define FFX_PARAMETER_IN in #define FFX_PARAMETER_OUT out #define FFX_PARAMETER_INOUT inout +#define FFX_PARAMETER_UNIFORM uniform #elif defined(FFX_GLSL) #define FFX_PARAMETER_IN in #define FFX_PARAMETER_OUT out #define FFX_PARAMETER_INOUT inout +#define FFX_PARAMETER_UNIFORM const //[cacao_placeholder] until a better fit is found! #endif // #if defined(FFX_CPU) #if defined(FFX_CPU) /// A typedef for a boolean value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef bool FfxBoolean; /// A typedef for a unsigned 8bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint8_t FfxUInt8; /// A typedef for a unsigned 16bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint16_t FfxUInt16; /// A typedef for a unsigned 32bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32; /// A typedef for a unsigned 64bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint64_t FfxUInt64; /// A typedef for a signed 8bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int8_t FfxInt8; /// A typedef for a signed 16bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int16_t FfxInt16; /// A typedef for a signed 32bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int32_t FfxInt32; /// A typedef for a signed 64bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int64_t FfxInt64; /// A typedef for a floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32; /// A typedef for a 2-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x2[2]; /// A typedef for a 3-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x3[3]; /// A typedef for a 4-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x4[4]; /// A typedef for a 2-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x2[2]; /// A typedef for a 3-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x3[3]; /// A typedef for a 4-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x4[4]; #endif // #if defined(FFX_CPU) #if defined(FFX_HLSL) + +#define FfxFloat32Mat4 matrix +#define FfxFloat32Mat3 matrix + /// A typedef for a boolean value. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef bool FfxBoolean; -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM>=62 + +/// @defgroup HLSL62Types HLSL 6.2 And Above Types +/// HLSL 6.2 and above type defines for all commonly used variables +/// +/// @ingroup HLSLTypes + +/// A typedef for a floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t FfxFloat32; + +/// A typedef for a 2-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t2 FfxFloat32x2; + +/// A typedef for a 3-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t3 FfxFloat32x3; + +/// A typedef for a 4-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t4 FfxFloat32x4; +/// A [cacao_placeholder] typedef for matrix type until confirmed. +typedef float4x4 FfxFloat32x4x4; +typedef float3x3 FfxFloat32x3x3; +typedef float2x2 FfxFloat32x2x2; + /// A typedef for a unsigned 32bit integer. /// -/// @ingroup GPU +/// @ingroup HLSL62Types typedef uint32_t FfxUInt32; + +/// A typedef for a 2-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t2 FfxUInt32x2; + +/// A typedef for a 3-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t3 FfxUInt32x3; + +/// A typedef for a 4-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t4 FfxUInt32x4; + +/// A typedef for a signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t FfxInt32; + +/// A typedef for a 2-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t2 FfxInt32x2; + +/// A typedef for a 3-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t3 FfxInt32x3; + +/// A typedef for a 4-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t4 FfxInt32x4; -#else + +#else // #if FFX_HLSL_SM>=62 + +/// @defgroup HLSLBaseTypes HLSL 6.1 And Below Types +/// HLSL 6.1 and below type defines for all commonly used variables +/// +/// @ingroup HLSLTypes + #define FfxFloat32 float #define FfxFloat32x2 float2 #define FfxFloat32x3 float3 #define FfxFloat32x4 float4 +/// A [cacao_placeholder] typedef for matrix type until confirmed. +#define FfxFloat32x4x4 float4x4 +#define FfxFloat32x3x3 float3x3 +#define FfxFloat32x2x2 float2x2 + /// A typedef for a unsigned 32bit integer. /// /// @ingroup GPU @@ -153,14 +228,18 @@ typedef uint FfxUInt32; typedef uint2 FfxUInt32x2; typedef uint3 FfxUInt32x3; typedef uint4 FfxUInt32x4; + typedef int FfxInt32; typedef int2 FfxInt32x2; typedef int3 FfxInt32x3; typedef int4 FfxInt32x4; -#endif // #if defined(FFX_HLSL_6_2) + +#endif // #if FFX_HLSL_SM>=62 #if FFX_HALF -#if FFX_HLSL_6_2 + +#if FFX_HLSL_SM >= 62 + typedef float16_t FfxFloat16; typedef float16_t2 FfxFloat16x2; typedef float16_t3 FfxFloat16x3; @@ -168,7 +247,7 @@ typedef float16_t4 FfxFloat16x4; /// A typedef for an unsigned 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef uint16_t FfxUInt16; typedef uint16_t2 FfxUInt16x2; typedef uint16_t3 FfxUInt16x3; @@ -176,7 +255,7 @@ typedef uint16_t4 FfxUInt16x4; /// A typedef for a signed 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef int16_t FfxInt16; typedef int16_t2 FfxInt16x2; typedef int16_t3 FfxInt16x3; @@ -204,7 +283,7 @@ typedef short FfxInt16; typedef short2 FfxInt16x2; typedef short3 FfxInt16x3; typedef short4 FfxInt16x4; -#else +#else // #if FFX_HLSL_SM>=62 typedef min16float FfxFloat16; typedef min16float2 FfxFloat16x2; typedef min16float3 FfxFloat16x3; @@ -212,7 +291,7 @@ typedef min16float4 FfxFloat16x4; /// A typedef for an unsigned 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef min16uint FfxUInt16; typedef min16uint2 FfxUInt16x2; typedef min16uint3 FfxUInt16x3; @@ -220,19 +299,25 @@ typedef min16uint4 FfxUInt16x4; /// A typedef for a signed 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef min16int FfxInt16; typedef min16int2 FfxInt16x2; typedef min16int3 FfxInt16x3; typedef min16int4 FfxInt16x4; -#endif // FFX_HLSL_6_2 +#endif // #if FFX_HLSL_SM>=62 + #endif // FFX_HALF + #endif // #if defined(FFX_HLSL) #if defined(FFX_GLSL) + +#define FfxFloat32Mat4 mat4 +#define FfxFloat32Mat3 mat3 + /// A typedef for a boolean value. /// -/// @ingroup GPU +/// @ingroup GLSLTypes #define FfxBoolean bool #define FfxFloat32 float #define FfxFloat32x2 vec2 @@ -246,6 +331,12 @@ typedef min16int4 FfxInt16x4; #define FfxInt32x2 ivec2 #define FfxInt32x3 ivec3 #define FfxInt32x4 ivec4 + +/// A [cacao_placeholder] typedef for matrix type until confirmed. +#define FfxFloat32x4x4 mat4 +#define FfxFloat32x3x3 mat3 +#define FfxFloat32x2x2 mat2 + #if FFX_HALF #define FfxFloat16 float16_t #define FfxFloat16x2 f16vec2 @@ -264,11 +355,11 @@ typedef min16int4 FfxInt16x4; // Global toggles: // #define FFX_HALF (1) -// #define FFX_HLSL_6_2 (1) +// #define FFX_HLSL_SM (62) -#if defined(FFX_HALF) && !defined(SHADER_API_PSSL) +#if FFX_HALF && !defined(SHADER_API_PSSL) -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM >= 62 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName; #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; @@ -278,7 +369,7 @@ typedef min16int4 FfxInt16x4; #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix TypeName; -#else //FFX_HLSL_6_2 +#else //FFX_HLSL_SM>=62 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef min16##BaseComponentType TypeName; #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; @@ -288,7 +379,7 @@ typedef min16int4 FfxInt16x4; #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ); #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ); -#endif //FFX_HLSL_6_2 +#endif //FFX_HLSL_SM>=62 #else //FFX_HALF diff --git a/Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta similarity index 92% rename from Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc.meta rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta index 8393144..8d9b15f 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_unity_common.cginc.meta +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bb2d4d4671c448698877526c29f2fc99 +guid: 7974b728d5c1b6d4a8a8e3965d03f96d PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h similarity index 66% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h index 4e687d6..02f6b3f 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,17 +19,40 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -/// @defgroup Core -/// @defgroup HLSL -/// @defgroup GLSL -/// @defgroup GPU -/// @defgroup CPU -/// @defgroup CAS -/// @defgroup FSR1 + +/// @defgroup FfxGPU GPU +/// The FidelityFX SDK GPU References +/// +/// @ingroup ffxSDK + +/// @defgroup FfxHLSL HLSL References +/// FidelityFX SDK HLSL GPU References +/// +/// @ingroup FfxGPU + +/// @defgroup FfxGLSL GLSL References +/// FidelityFX SDK GLSL GPU References +/// +/// @ingroup FfxGPU + +/// @defgroup FfxGPUEffects FidelityFX GPU References +/// FidelityFX Effect GPU Reference Documentation +/// +/// @ingroup FfxGPU + +/// @defgroup GPUCore GPU Core +/// GPU defines and functions +/// +/// @ingroup FfxGPU #if !defined(FFX_CORE_H) #define FFX_CORE_H +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic push +#pragma dxc diagnostic ignored "-Wambig-lit-shift" +#endif //__hlsl_dx_compiler + #include "ffx_common_types.h" #if defined(FFX_CPU) @@ -49,4 +72,9 @@ #include "ffx_core_gpu_common_half.h" #include "ffx_core_portability.h" #endif // #if defined(FFX_GPU) -#endif // #if !defined(FFX_CORE_H) \ No newline at end of file + +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic pop +#endif //__hlsl_dx_compiler + +#endif // #if !defined(FFX_CORE_H) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta similarity index 92% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc.meta rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta index 8393144..562741a 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc.meta +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bb2d4d4671c448698877526c29f2fc99 +guid: b91c5f52b89ff554dacb51045a802ed8 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Resources/FSR2/shaders/ffx_core_cpu.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h similarity index 93% rename from Assets/Resources/FSR2/shaders/ffx_core_cpu.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h index 3bf0295..865258d 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core_cpu.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,23 +19,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + /// A define for a true value in a boolean expression. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_TRUE (1) /// A define for a false value in a boolean expression. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_FALSE (0) #if !defined(FFX_STATIC) /// A define to abstract declaration of static variables and functions. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_STATIC static #endif // #if !defined(FFX_STATIC) +/// @defgroup CPUCore CPU Core +/// Core CPU-side defines and functions +/// +/// @ingroup ffxHost + #ifdef __clang__ #pragma clang diagnostic ignored "-Wunused-variable" #endif @@ -47,7 +53,7 @@ /// @returns /// An unsigned 32bit integer value containing the bit pattern of x. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxUInt32 ffxAsUInt32(FfxFloat32 x) { union @@ -89,7 +95,7 @@ FFX_STATIC FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) { return y * t + (-x * t + x); @@ -102,10 +108,10 @@ FFX_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) /// @returns /// The reciprocal value of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 x) { - return 1.0f / a; + return 1.0f / x; } /// Compute the square root of a value. @@ -115,7 +121,7 @@ FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 a) /// @returns /// The the square root of x. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxFloat32 ffxSqrt(FfxFloat32 x) { return sqrt(x); @@ -135,10 +141,10 @@ FFX_STATIC FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b) /// @returns /// The fractional part of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 x) { - return a - floor(a); + return x - floor(x); } /// Compute the reciprocal square root of a value. @@ -148,10 +154,10 @@ FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 a) /// @returns /// The reciprocal square root value of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 rsqrt(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 rsqrt(FfxFloat32 x) { - return ffxReciprocal(ffxSqrt(a)); + return ffxReciprocal(ffxSqrt(x)); } FFX_STATIC FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) @@ -181,10 +187,10 @@ FFX_STATIC FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) /// @returns /// The clamped version of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxSaturate(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxSaturate(FfxFloat32 x) { - return ffxMin(1.0f, ffxMax(0.0f, a)); + return ffxMin(1.0f, ffxMax(0.0f, x)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -245,7 +251,7 @@ FFX_STATIC void opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a) /// @returns /// The closest 16bit floating point value to f. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxUInt32 f32tof16(FfxFloat32 f) { static FfxUInt16 base[512] = { @@ -320,13 +326,13 @@ FFX_STATIC FfxUInt32 f32tof16(FfxFloat32 f) /// point representation, and then stores the X and Y components in the lower and upper 16 bits of the /// 32bit unsigned integer respectively. /// -/// @param [in] value A 2-dimensional floating point value to convert and pack. +/// @param [in] x A 2-dimensional floating point value to convert and pack. /// /// @returns /// A packed 32bit value containing 2 16bit floating point values. /// -/// @ingroup CPU -FFX_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 a) +/// @ingroup CPUCore +FFX_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 x) { - return f32tof16(a[0]) + (f32tof16(a[1]) << 16); + return f32tof16(x[0]) + (f32tof16(x[1]) << 16); } diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta new file mode 100644 index 0000000..9aed874 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 4c88c0b7a4dec1e479272449c19ca981 +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_core_gpu_common.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h similarity index 91% rename from Assets/Resources/FSR2/shaders/ffx_core_gpu_common.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h index ae07642..2f687df 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,31 +19,35 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + /// A define for a true value in a boolean expression. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_TRUE (true) /// A define for a false value in a boolean expression. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_FALSE (false) /// A define value for positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_FLOAT ffxAsFloat(0x7f800000u) /// A define value for negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_FLOAT ffxAsFloat(0xff800000u) /// A define value for PI. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_PI (3.14159) +FFX_STATIC const FfxFloat32 FFX_FP16_MIN = 6.10e-05f; +FFX_STATIC const FfxFloat32 FFX_FP16_MAX = 65504.0f; +FFX_STATIC const FfxFloat32 FFX_TONEMAP_EPSILON = 1.0f / FFX_FP16_MAX; /// Compute the reciprocal of value. /// @@ -52,7 +56,7 @@ /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxReciprocal(FfxFloat32 value) { return rcp(value); @@ -65,7 +69,7 @@ FfxFloat32 ffxReciprocal(FfxFloat32 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxReciprocal(FfxFloat32x2 value) { return rcp(value); @@ -78,7 +82,7 @@ FfxFloat32x2 ffxReciprocal(FfxFloat32x2 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxReciprocal(FfxFloat32x3 value) { return rcp(value); @@ -91,7 +95,7 @@ FfxFloat32x3 ffxReciprocal(FfxFloat32x3 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxReciprocal(FfxFloat32x4 value) { return rcp(value); @@ -105,7 +109,7 @@ FfxFloat32x4 ffxReciprocal(FfxFloat32x4 value) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) { return min(x, y); @@ -119,7 +123,7 @@ FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxMin(FfxFloat32x2 x, FfxFloat32x2 y) { return min(x, y); @@ -133,7 +137,7 @@ FfxFloat32x2 ffxMin(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxMin(FfxFloat32x3 x, FfxFloat32x3 y) { return min(x, y); @@ -147,7 +151,7 @@ FfxFloat32x3 ffxMin(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxMin(FfxFloat32x4 x, FfxFloat32x4 y) { return min(x, y); @@ -161,7 +165,7 @@ FfxFloat32x4 ffxMin(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32 ffxMin(FfxInt32 x, FfxInt32 y) { return min(x, y); @@ -175,7 +179,7 @@ FfxInt32 ffxMin(FfxInt32 x, FfxInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x2 ffxMin(FfxInt32x2 x, FfxInt32x2 y) { return min(x, y); @@ -189,7 +193,7 @@ FfxInt32x2 ffxMin(FfxInt32x2 x, FfxInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x3 ffxMin(FfxInt32x3 x, FfxInt32x3 y) { return min(x, y); @@ -203,7 +207,7 @@ FfxInt32x3 ffxMin(FfxInt32x3 x, FfxInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x4 ffxMin(FfxInt32x4 x, FfxInt32x4 y) { return min(x, y); @@ -217,7 +221,7 @@ FfxInt32x4 ffxMin(FfxInt32x4 x, FfxInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y) { return min(x, y); @@ -231,7 +235,7 @@ FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxMin(FfxUInt32x2 x, FfxUInt32x2 y) { return min(x, y); @@ -245,7 +249,7 @@ FfxUInt32x2 ffxMin(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxMin(FfxUInt32x3 x, FfxUInt32x3 y) { return min(x, y); @@ -259,7 +263,7 @@ FfxUInt32x3 ffxMin(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxMin(FfxUInt32x4 x, FfxUInt32x4 y) { return min(x, y); @@ -273,7 +277,7 @@ FfxUInt32x4 ffxMin(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y) { return max(x, y); @@ -287,7 +291,7 @@ FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxMax(FfxFloat32x2 x, FfxFloat32x2 y) { return max(x, y); @@ -301,7 +305,7 @@ FfxFloat32x2 ffxMax(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxMax(FfxFloat32x3 x, FfxFloat32x3 y) { return max(x, y); @@ -315,7 +319,7 @@ FfxFloat32x3 ffxMax(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxMax(FfxFloat32x4 x, FfxFloat32x4 y) { return max(x, y); @@ -329,7 +333,7 @@ FfxFloat32x4 ffxMax(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32 ffxMax(FfxInt32 x, FfxInt32 y) { return max(x, y); @@ -343,7 +347,7 @@ FfxInt32 ffxMax(FfxInt32 x, FfxInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x2 ffxMax(FfxInt32x2 x, FfxInt32x2 y) { return max(x, y); @@ -357,7 +361,7 @@ FfxInt32x2 ffxMax(FfxInt32x2 x, FfxInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x3 ffxMax(FfxInt32x3 x, FfxInt32x3 y) { return max(x, y); @@ -371,7 +375,7 @@ FfxInt32x3 ffxMax(FfxInt32x3 x, FfxInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x4 ffxMax(FfxInt32x4 x, FfxInt32x4 y) { return max(x, y); @@ -385,7 +389,7 @@ FfxInt32x4 ffxMax(FfxInt32x4 x, FfxInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) { return max(x, y); @@ -399,7 +403,7 @@ FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxMax(FfxUInt32x2 x, FfxUInt32x2 y) { return max(x, y); @@ -413,7 +417,7 @@ FfxUInt32x2 ffxMax(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxMax(FfxUInt32x3 x, FfxUInt32x3 y) { return max(x, y); @@ -427,7 +431,7 @@ FfxUInt32x3 ffxMax(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxMax(FfxUInt32x4 x, FfxUInt32x4 y) { return max(x, y); @@ -441,7 +445,7 @@ FfxUInt32x4 ffxMax(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxPow(FfxFloat32 x, FfxFloat32 y) { return pow(x, y); @@ -455,7 +459,7 @@ FfxFloat32 ffxPow(FfxFloat32 x, FfxFloat32 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxPow(FfxFloat32x2 x, FfxFloat32x2 y) { return pow(x, y); @@ -469,7 +473,7 @@ FfxFloat32x2 ffxPow(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxPow(FfxFloat32x3 x, FfxFloat32x3 y) { return pow(x, y); @@ -483,7 +487,7 @@ FfxFloat32x3 ffxPow(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxPow(FfxFloat32x4 x, FfxFloat32x4 y) { return pow(x, y); @@ -496,7 +500,7 @@ FfxFloat32x4 ffxPow(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxSqrt(FfxFloat32 x) { return sqrt(x); @@ -509,7 +513,7 @@ FfxFloat32 ffxSqrt(FfxFloat32 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxSqrt(FfxFloat32x2 x) { return sqrt(x); @@ -522,7 +526,7 @@ FfxFloat32x2 ffxSqrt(FfxFloat32x2 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxSqrt(FfxFloat32x3 x) { return sqrt(x); @@ -535,7 +539,7 @@ FfxFloat32x3 ffxSqrt(FfxFloat32x3 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxSqrt(FfxFloat32x4 x) { return sqrt(x); @@ -549,7 +553,7 @@ FfxFloat32x4 ffxSqrt(FfxFloat32x4 x) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxCopySignBit(FfxFloat32 d, FfxFloat32 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & FfxUInt32(0x80000000u))); @@ -563,7 +567,7 @@ FfxFloat32 ffxCopySignBit(FfxFloat32 d, FfxFloat32 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxCopySignBit(FfxFloat32x2 d, FfxFloat32x2 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast2(0x80000000u))); @@ -577,7 +581,7 @@ FfxFloat32x2 ffxCopySignBit(FfxFloat32x2 d, FfxFloat32x2 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxCopySignBit(FfxFloat32x3 d, FfxFloat32x3 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast3(0x80000000u))); @@ -591,7 +595,7 @@ FfxFloat32x3 ffxCopySignBit(FfxFloat32x3 d, FfxFloat32x3 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxCopySignBit(FfxFloat32x4 d, FfxFloat32x4 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast4(0x80000000u))); @@ -614,7 +618,7 @@ FfxFloat32x4 ffxCopySignBit(FfxFloat32x4 d, FfxFloat32x4 s) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxIsSigned(FfxFloat32 m) { return ffxSaturate(m * FfxFloat32(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -637,7 +641,7 @@ FfxFloat32 ffxIsSigned(FfxFloat32 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxIsSigned(FfxFloat32x2 m) { return ffxSaturate(m * ffxBroadcast2(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -660,7 +664,7 @@ FfxFloat32x2 ffxIsSigned(FfxFloat32x2 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxIsSigned(FfxFloat32x3 m) { return ffxSaturate(m * ffxBroadcast3(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -683,7 +687,7 @@ FfxFloat32x3 ffxIsSigned(FfxFloat32x3 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or positive. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxIsSigned(FfxFloat32x4 m) { return ffxSaturate(m * ffxBroadcast4(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -701,7 +705,7 @@ FfxFloat32x4 ffxIsSigned(FfxFloat32x4 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxIsGreaterThanZero(FfxFloat32 m) { return ffxSaturate(m * FfxFloat32(FFX_POSITIVE_INFINITY_FLOAT)); @@ -719,7 +723,7 @@ FfxFloat32 ffxIsGreaterThanZero(FfxFloat32 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxIsGreaterThanZero(FfxFloat32x2 m) { return ffxSaturate(m * ffxBroadcast2(FFX_POSITIVE_INFINITY_FLOAT)); @@ -737,7 +741,7 @@ FfxFloat32x2 ffxIsGreaterThanZero(FfxFloat32x2 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxIsGreaterThanZero(FfxFloat32x3 m) { return ffxSaturate(m * ffxBroadcast3(FFX_POSITIVE_INFINITY_FLOAT)); @@ -755,7 +759,7 @@ FfxFloat32x3 ffxIsGreaterThanZero(FfxFloat32x3 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxIsGreaterThanZero(FfxFloat32x4 m) { return ffxSaturate(m * ffxBroadcast4(FFX_POSITIVE_INFINITY_FLOAT)); @@ -775,7 +779,7 @@ FfxFloat32x4 ffxIsGreaterThanZero(FfxFloat32x4 m) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxFloatToSortableInteger(FfxUInt32 value) { return value ^ ((AShrSU1(value, FfxUInt32(31))) | FfxUInt32(0x80000000)); @@ -792,7 +796,7 @@ FfxUInt32 ffxFloatToSortableInteger(FfxUInt32 value) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxSortableIntegerToFloat(FfxUInt32 value) { return value ^ ((~AShrSU1(value, FfxUInt32(31))) | FfxUInt32(0x80000000)); @@ -811,10 +815,10 @@ FfxUInt32 ffxSortableIntegerToFloat(FfxUInt32 value) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateSqrt(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateSqrt(FfxFloat32 value) { - return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(1)) + FfxUInt32(0x1fbc4639)); + return ffxAsFloat((ffxAsUInt32(value) >> FfxUInt32(1)) + FfxUInt32(0x1fbc4639)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -830,10 +834,10 @@ FfxFloat32 ffxApproximateSqrt(FfxFloat32 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateReciprocal(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateReciprocal(FfxFloat32 value) { - return ffxAsFloat(FfxUInt32(0x7ef07ebb) - ffxAsUInt32(a)); + return ffxAsFloat(FfxUInt32(0x7ef07ebb) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -849,7 +853,7 @@ FfxFloat32 ffxApproximateReciprocal(FfxFloat32 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateReciprocalMedium(FfxFloat32 value) { FfxFloat32 b = ffxAsFloat(FfxUInt32(0x7ef19fff) - ffxAsUInt32(value)); @@ -869,10 +873,10 @@ FfxFloat32 ffxApproximateReciprocalMedium(FfxFloat32 value) /// @returns /// An approximation of the reciprocal square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 value) { - return ffxAsFloat(FfxUInt32(0x5f347d74) - (ffxAsUInt32(a) >> FfxUInt32(1))); + return ffxAsFloat(FfxUInt32(0x5f347d74) - (ffxAsUInt32(value) >> FfxUInt32(1))); } /// Calculate a low-quality approximation for the square root of a value. @@ -888,10 +892,10 @@ FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(1u)) + ffxBroadcast2(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast2(1u)) + ffxBroadcast2(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -907,10 +911,10 @@ FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 value) { - return ffxAsFloat(ffxBroadcast2(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast2(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -926,11 +930,11 @@ FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 value) { - FfxFloat32x2 b = ffxAsFloat(ffxBroadcast2(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast2(2.0f)); + FfxFloat32x2 b = ffxAsFloat(ffxBroadcast2(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast2(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -946,10 +950,10 @@ FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 value) { - return ffxAsFloat(ffxBroadcast2(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast2(1u))); + return ffxAsFloat(ffxBroadcast2(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast2(1u))); } /// Calculate a low-quality approximation for the square root of a value. @@ -965,10 +969,10 @@ FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(1u)) + ffxBroadcast3(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast3(1u)) + ffxBroadcast3(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -984,10 +988,10 @@ FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 value) { - return ffxAsFloat(ffxBroadcast3(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast3(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -1003,11 +1007,11 @@ FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 value) { - FfxFloat32x3 b = ffxAsFloat(ffxBroadcast3(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast3(2.0f)); + FfxFloat32x3 b = ffxAsFloat(ffxBroadcast3(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast3(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -1023,10 +1027,10 @@ FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 value) { - return ffxAsFloat(ffxBroadcast3(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast3(1u))); + return ffxAsFloat(ffxBroadcast3(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast3(1u))); } /// Calculate a low-quality approximation for the square root of a value. @@ -1042,10 +1046,10 @@ FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(1u)) + ffxBroadcast4(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast4(1u)) + ffxBroadcast4(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -1061,10 +1065,10 @@ FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 value) { - return ffxAsFloat(ffxBroadcast4(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast4(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -1080,11 +1084,11 @@ FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 value) { - FfxFloat32x4 b = ffxAsFloat(ffxBroadcast4(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast4(2.0f)); + FfxFloat32x4 b = ffxAsFloat(ffxBroadcast4(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast4(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -1100,10 +1104,10 @@ FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 value) { - return ffxAsFloat(ffxBroadcast4(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast4(1u))); + return ffxAsFloat(ffxBroadcast4(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast4(1u))); } /// Calculate dot product of 'a' and 'b'. @@ -1114,7 +1118,7 @@ FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 a) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b) { return dot(a, b); @@ -1128,7 +1132,7 @@ FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b) { return dot(a, b); @@ -1142,7 +1146,7 @@ FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) { return dot(a, b); @@ -1160,7 +1164,7 @@ FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximatePQToGamma2Medium(FfxFloat32 a) { return a * a * a * a; @@ -1177,7 +1181,7 @@ FfxFloat32 ffxApproximatePQToGamma2Medium(FfxFloat32 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximatePQToLinear(FfxFloat32 a) { return a * a * a * a * a * a * a * a; @@ -1194,7 +1198,7 @@ FfxFloat32 ffxApproximatePQToLinear(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQ(FfxFloat32 a) { return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(2)) + FfxUInt32(0x2F9A4E46)); @@ -1211,7 +1215,7 @@ FfxFloat32 ffxApproximateGamma2ToPQ(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQMedium(FfxFloat32 a) { FfxFloat32 b = ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(2)) + FfxUInt32(0x2F9A4E46)); @@ -1230,7 +1234,7 @@ FfxFloat32 ffxApproximateGamma2ToPQMedium(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQHigh(FfxFloat32 a) { return ffxSqrt(ffxSqrt(a)); @@ -1247,7 +1251,7 @@ FfxFloat32 ffxApproximateGamma2ToPQHigh(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQ(FfxFloat32 a) { return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(3)) + FfxUInt32(0x378D8723)); @@ -1264,7 +1268,7 @@ FfxFloat32 ffxApproximateLinearToPQ(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQMedium(FfxFloat32 a) { FfxFloat32 b = ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(3)) + FfxUInt32(0x378D8723)); @@ -1283,7 +1287,7 @@ FfxFloat32 ffxApproximateLinearToPQMedium(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQHigh(FfxFloat32 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1300,7 +1304,7 @@ FfxFloat32 ffxApproximateLinearToPQHigh(FfxFloat32 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximatePQToGamma2Medium(FfxFloat32x2 a) { return a * a * a * a; @@ -1317,7 +1321,7 @@ FfxFloat32x2 ffxApproximatePQToGamma2Medium(FfxFloat32x2 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximatePQToLinear(FfxFloat32x2 a) { return a * a * a * a * a * a * a * a; @@ -1334,7 +1338,7 @@ FfxFloat32x2 ffxApproximatePQToLinear(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQ(FfxFloat32x2 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(2u)) + ffxBroadcast2(0x2F9A4E46u)); @@ -1351,7 +1355,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQ(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQMedium(FfxFloat32x2 a) { FfxFloat32x2 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(2u)) + ffxBroadcast2(0x2F9A4E46u)); @@ -1370,7 +1374,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQMedium(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQHigh(FfxFloat32x2 a) { return ffxSqrt(ffxSqrt(a)); @@ -1387,7 +1391,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQHigh(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQ(FfxFloat32x2 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(3u)) + ffxBroadcast2(0x378D8723u)); @@ -1404,7 +1408,7 @@ FfxFloat32x2 ffxApproximateLinearToPQ(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQMedium(FfxFloat32x2 a) { FfxFloat32x2 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(3u)) + ffxBroadcast2(0x378D8723u)); @@ -1423,7 +1427,7 @@ FfxFloat32x2 ffxApproximateLinearToPQMedium(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQHigh(FfxFloat32x2 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1440,7 +1444,7 @@ FfxFloat32x2 ffxApproximateLinearToPQHigh(FfxFloat32x2 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximatePQToGamma2Medium(FfxFloat32x3 a) { return a * a * a * a; @@ -1457,7 +1461,7 @@ FfxFloat32x3 ffxApproximatePQToGamma2Medium(FfxFloat32x3 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximatePQToLinear(FfxFloat32x3 a) { return a * a * a * a * a * a * a * a; @@ -1474,7 +1478,7 @@ FfxFloat32x3 ffxApproximatePQToLinear(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQ(FfxFloat32x3 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(2u)) + ffxBroadcast3(0x2F9A4E46u)); @@ -1491,7 +1495,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQ(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQMedium(FfxFloat32x3 a) { FfxFloat32x3 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(2u)) + ffxBroadcast3(0x2F9A4E46u)); @@ -1510,7 +1514,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQMedium(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQHigh(FfxFloat32x3 a) { return ffxSqrt(ffxSqrt(a)); @@ -1527,7 +1531,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQHigh(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQ(FfxFloat32x3 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(3u)) + ffxBroadcast3(0x378D8723u)); @@ -1544,7 +1548,7 @@ FfxFloat32x3 ffxApproximateLinearToPQ(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQMedium(FfxFloat32x3 a) { FfxFloat32x3 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(3u)) + ffxBroadcast3(0x378D8723u)); @@ -1563,7 +1567,7 @@ FfxFloat32x3 ffxApproximateLinearToPQMedium(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQHigh(FfxFloat32x3 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1580,7 +1584,7 @@ FfxFloat32x3 ffxApproximateLinearToPQHigh(FfxFloat32x3 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximatePQToGamma2Medium(FfxFloat32x4 a) { return a * a * a * a; @@ -1597,7 +1601,7 @@ FfxFloat32x4 ffxApproximatePQToGamma2Medium(FfxFloat32x4 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximatePQToLinear(FfxFloat32x4 a) { return a * a * a * a * a * a * a * a; @@ -1614,7 +1618,7 @@ FfxFloat32x4 ffxApproximatePQToLinear(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQ(FfxFloat32x4 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(2u)) + ffxBroadcast4(0x2F9A4E46u)); @@ -1631,7 +1635,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQ(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQMedium(FfxFloat32x4 a) { FfxFloat32x4 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(2u)) + ffxBroadcast4(0x2F9A4E46u)); @@ -1650,7 +1654,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQMedium(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQHigh(FfxFloat32x4 a) { return ffxSqrt(ffxSqrt(a)); @@ -1667,7 +1671,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQHigh(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQ(FfxFloat32x4 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(3u)) + ffxBroadcast4(0x378D8723u)); @@ -1684,7 +1688,7 @@ FfxFloat32x4 ffxApproximateLinearToPQ(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQMedium(FfxFloat32x4 a) { FfxFloat32x4 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(3u)) + ffxBroadcast4(0x378D8723u)); @@ -1703,7 +1707,7 @@ FfxFloat32x4 ffxApproximateLinearToPQMedium(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQHigh(FfxFloat32x4 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1793,7 +1797,7 @@ FfxFloat32x2 ffxParabolicSinCos(FfxFloat32 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAnd(FfxUInt32 x, FfxUInt32 y) { return min(x, y); @@ -1807,7 +1811,7 @@ FfxUInt32 ffxZeroOneAnd(FfxUInt32 x, FfxUInt32 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x, FfxUInt32x2 y) { return min(x, y); @@ -1821,7 +1825,7 @@ FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x, FfxUInt32x3 y) { return min(x, y); @@ -1835,7 +1839,7 @@ FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x, FfxUInt32x4 y) { return min(x, y); @@ -1844,12 +1848,11 @@ FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x, FfxUInt32x4 y) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAnd(FfxUInt32 x) { return x ^ FfxUInt32(1); @@ -1858,12 +1861,11 @@ FfxUInt32 ffxZeroOneAnd(FfxUInt32 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x) { return x ^ ffxBroadcast2(1u); @@ -1872,12 +1874,11 @@ FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x) { return x ^ ffxBroadcast3(1u); @@ -1886,12 +1887,11 @@ FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x) { return x ^ ffxBroadcast4(1u); @@ -1905,7 +1905,7 @@ FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneOr(FfxUInt32 x, FfxUInt32 y) { return max(x, y); @@ -1919,7 +1919,7 @@ FfxUInt32 ffxZeroOneOr(FfxUInt32 x, FfxUInt32 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneOr(FfxUInt32x2 x, FfxUInt32x2 y) { return max(x, y); @@ -1933,7 +1933,7 @@ FfxUInt32x2 ffxZeroOneOr(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneOr(FfxUInt32x3 x, FfxUInt32x3 y) { return max(x, y); @@ -1947,7 +1947,7 @@ FfxUInt32x3 ffxZeroOneOr(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneOr(FfxUInt32x4 x, FfxUInt32x4 y) { return max(x, y); @@ -1960,7 +1960,7 @@ FfxUInt32x4 ffxZeroOneOr(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAndToU1(FfxFloat32 x) { return FfxUInt32(FfxFloat32(1.0) - x); @@ -1973,7 +1973,7 @@ FfxUInt32 ffxZeroOneAndToU1(FfxFloat32 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAndToU2(FfxFloat32x2 x) { return FfxUInt32x2(ffxBroadcast2(1.0) - x); @@ -1986,7 +1986,7 @@ FfxUInt32x2 ffxZeroOneAndToU2(FfxFloat32x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAndToU3(FfxFloat32x3 x) { return FfxUInt32x3(ffxBroadcast3(1.0) - x); @@ -1999,7 +1999,7 @@ FfxUInt32x3 ffxZeroOneAndToU3(FfxFloat32x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAndToU4(FfxFloat32x4 x) { return FfxUInt32x4(ffxBroadcast4(1.0) - x); @@ -2015,7 +2015,7 @@ FfxUInt32x4 ffxZeroOneAndToU4(FfxFloat32x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneAndOr(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return ffxSaturate(x * y + z); @@ -2031,7 +2031,7 @@ FfxFloat32 ffxZeroOneAndOr(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneAndOr(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return ffxSaturate(x * y + z); @@ -2047,7 +2047,7 @@ FfxFloat32x2 ffxZeroOneAndOr(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneAndOr(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return ffxSaturate(x * y + z); @@ -2063,7 +2063,7 @@ FfxFloat32x3 ffxZeroOneAndOr(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneAndOr(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return ffxSaturate(x * y + z); @@ -2076,7 +2076,7 @@ FfxFloat32x4 ffxZeroOneAndOr(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneIsGreaterThanZero(FfxFloat32 x) { return ffxSaturate(x * FfxFloat32(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2089,7 +2089,7 @@ FfxFloat32 ffxZeroOneIsGreaterThanZero(FfxFloat32 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneIsGreaterThanZero(FfxFloat32x2 x) { return ffxSaturate(x * ffxBroadcast2(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2102,7 +2102,7 @@ FfxFloat32x2 ffxZeroOneIsGreaterThanZero(FfxFloat32x2 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneIsGreaterThanZero(FfxFloat32x3 x) { return ffxSaturate(x * ffxBroadcast3(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2115,7 +2115,7 @@ FfxFloat32x3 ffxZeroOneIsGreaterThanZero(FfxFloat32x3 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneIsGreaterThanZero(FfxFloat32x4 x) { return ffxSaturate(x * ffxBroadcast4(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2128,7 +2128,7 @@ FfxFloat32x4 ffxZeroOneIsGreaterThanZero(FfxFloat32x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneAnd(FfxFloat32 x) { return FfxFloat32(1.0) - x; @@ -2141,7 +2141,7 @@ FfxFloat32 ffxZeroOneAnd(FfxFloat32 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneAnd(FfxFloat32x2 x) { return ffxBroadcast2(1.0) - x; @@ -2154,7 +2154,7 @@ FfxFloat32x2 ffxZeroOneAnd(FfxFloat32x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneAnd(FfxFloat32x3 x) { return ffxBroadcast3(1.0) - x; @@ -2167,7 +2167,7 @@ FfxFloat32x3 ffxZeroOneAnd(FfxFloat32x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneAnd(FfxFloat32x4 x) { return ffxBroadcast4(1.0) - x; @@ -2181,7 +2181,7 @@ FfxFloat32x4 ffxZeroOneAnd(FfxFloat32x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneOr(FfxFloat32 x, FfxFloat32 y) { return max(x, y); @@ -2195,7 +2195,7 @@ FfxFloat32 ffxZeroOneOr(FfxFloat32 x, FfxFloat32 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneOr(FfxFloat32x2 x, FfxFloat32x2 y) { return max(x, y); @@ -2209,7 +2209,7 @@ FfxFloat32x2 ffxZeroOneOr(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneOr(FfxFloat32x3 x, FfxFloat32x3 y) { return max(x, y); @@ -2223,7 +2223,7 @@ FfxFloat32x3 ffxZeroOneOr(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneOr(FfxFloat32x4 x, FfxFloat32x4 y) { return max(x, y); @@ -2238,7 +2238,7 @@ FfxFloat32x4 ffxZeroOneOr(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneSelect(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { FfxFloat32 r = (-x) * z + z; @@ -2254,7 +2254,7 @@ FfxFloat32 ffxZeroOneSelect(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneSelect(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { FfxFloat32x2 r = (-x) * z + z; @@ -2270,7 +2270,7 @@ FfxFloat32x2 ffxZeroOneSelect(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneSelect(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { FfxFloat32x3 r = (-x) * z + z; @@ -2286,7 +2286,7 @@ FfxFloat32x3 ffxZeroOneSelect(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneSelect(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { FfxFloat32x4 r = (-x) * z + z; @@ -2300,7 +2300,7 @@ FfxFloat32x4 ffxZeroOneSelect(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneIsSigned(FfxFloat32 x) { return ffxSaturate(x * FfxFloat32(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2313,7 +2313,7 @@ FfxFloat32 ffxZeroOneIsSigned(FfxFloat32 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneIsSigned(FfxFloat32x2 x) { return ffxSaturate(x * ffxBroadcast2(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2326,7 +2326,7 @@ FfxFloat32x2 ffxZeroOneIsSigned(FfxFloat32x2 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneIsSigned(FfxFloat32x3 x) { return ffxSaturate(x * ffxBroadcast3(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2339,7 +2339,7 @@ FfxFloat32x3 ffxZeroOneIsSigned(FfxFloat32x3 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneIsSigned(FfxFloat32x4 x) { return ffxSaturate(x * ffxBroadcast4(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2358,7 +2358,7 @@ FfxFloat32x4 ffxZeroOneIsSigned(FfxFloat32x4 x) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxRec709FromLinear(FfxFloat32 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2379,7 +2379,7 @@ FfxFloat32 ffxRec709FromLinear(FfxFloat32 color) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxRec709FromLinear(FfxFloat32x2 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2400,7 +2400,7 @@ FfxFloat32x2 ffxRec709FromLinear(FfxFloat32x2 color) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxRec709FromLinear(FfxFloat32x3 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2420,10 +2420,10 @@ FfxFloat32x3 ffxRec709FromLinear(FfxFloat32x3 color) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32 ffxGammaFromLinear(FfxFloat32 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32 ffxGammaFromLinear(FfxFloat32 value, FfxFloat32 power) { - return pow(color, FfxFloat32(rcpX)); + return pow(value, FfxFloat32(power)); } /// Compute a gamma value from a linear value. @@ -2438,10 +2438,10 @@ FfxFloat32 ffxGammaFromLinear(FfxFloat32 color, FfxFloat32 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 value, FfxFloat32 power) { - return pow(color, ffxBroadcast2(rcpX)); + return pow(value, ffxBroadcast2(power)); } /// Compute a gamma value from a linear value. @@ -2456,10 +2456,10 @@ FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 color, FfxFloat32 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 value, FfxFloat32 power) { - return pow(color, ffxBroadcast3(rcpX)); + return pow(value, ffxBroadcast3(power)); } /// Compute a PQ value from a linear value. @@ -2469,10 +2469,10 @@ FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 color, FfxFloat32 rcpX) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxPQToLinear(FfxFloat32 x) +/// @ingroup GPUCore +FfxFloat32 ffxPQToLinear(FfxFloat32 value) { - FfxFloat32 p = pow(x, FfxFloat32(0.159302)); + FfxFloat32 p = pow(value, FfxFloat32(0.159302)); return pow((FfxFloat32(0.835938) + FfxFloat32(18.8516) * p) / (FfxFloat32(1.0) + FfxFloat32(18.6875) * p), FfxFloat32(78.8438)); } @@ -2483,10 +2483,10 @@ FfxFloat32 ffxPQToLinear(FfxFloat32 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 x) +/// @ingroup GPUCore +FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 value) { - FfxFloat32x2 p = pow(x, ffxBroadcast2(0.159302)); + FfxFloat32x2 p = pow(value, ffxBroadcast2(0.159302)); return pow((ffxBroadcast2(0.835938) + ffxBroadcast2(18.8516) * p) / (ffxBroadcast2(1.0) + ffxBroadcast2(18.6875) * p), ffxBroadcast2(78.8438)); } @@ -2497,10 +2497,10 @@ FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 x) +/// @ingroup GPUCore +FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 value) { - FfxFloat32x3 p = pow(x, ffxBroadcast3(0.159302)); + FfxFloat32x3 p = pow(value, ffxBroadcast3(0.159302)); return pow((ffxBroadcast3(0.835938) + ffxBroadcast3(18.8516) * p) / (ffxBroadcast3(1.0) + ffxBroadcast3(18.6875) * p), ffxBroadcast3(78.8438)); } @@ -2511,12 +2511,12 @@ FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 x) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32 ffxSrgbToLinear(FfxFloat32 color) +/// @ingroup GPUCore +FfxFloat32 ffxSrgbToLinear(FfxFloat32 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.x, color * j.y, pow(color, j.z) * k.x + k.y); + return clamp(j.x, value * j.y, pow(value, j.z) * k.x + k.y); } /// Compute a linear value from a SRGB value. @@ -2526,12 +2526,12 @@ FfxFloat32 ffxSrgbToLinear(FfxFloat32 color) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 color) +/// @ingroup GPUCore +FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.xx, color * j.yy, pow(color, j.zz) * k.xx + k.yy); + return clamp(j.xx, value * j.yy, pow(value, j.zz) * k.xx + k.yy); } /// Compute a linear value from a SRGB value. @@ -2541,12 +2541,12 @@ FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 color) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 color) +/// @ingroup GPUCore +FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.xxx, color * j.yyy, pow(color, j.zzz) * k.xxx + k.yyy); + return clamp(j.xxx, value * j.yyy, pow(value, j.zzz) * k.xxx + k.yyy); } /// Compute a linear value from a REC.709 value. @@ -2556,7 +2556,7 @@ FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxLinearFromRec709(FfxFloat32 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2571,7 +2571,7 @@ FfxFloat32 ffxLinearFromRec709(FfxFloat32 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxLinearFromRec709(FfxFloat32x2 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2586,7 +2586,7 @@ FfxFloat32x2 ffxLinearFromRec709(FfxFloat32x2 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxLinearFromRec709(FfxFloat32x3 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2604,7 +2604,7 @@ FfxFloat32x3 ffxLinearFromRec709(FfxFloat32x3 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxLinearFromGamma(FfxFloat32 color, FfxFloat32 power) { return pow(color, FfxFloat32(power)); @@ -2620,7 +2620,7 @@ FfxFloat32 ffxLinearFromGamma(FfxFloat32 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxLinearFromGamma(FfxFloat32x2 color, FfxFloat32 power) { return pow(color, ffxBroadcast2(power)); @@ -2636,7 +2636,7 @@ FfxFloat32x2 ffxLinearFromGamma(FfxFloat32x2 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxLinearFromGamma(FfxFloat32x3 color, FfxFloat32 power) { return pow(color, ffxBroadcast3(power)); @@ -2651,10 +2651,10 @@ FfxFloat32x3 ffxLinearFromGamma(FfxFloat32x3 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxLinearFromPQ(FfxFloat32 x) +/// @ingroup GPUCore +FfxFloat32 ffxLinearFromPQ(FfxFloat32 value) { - FfxFloat32 p = pow(x, FfxFloat32(0.0126833)); + FfxFloat32 p = pow(value, FfxFloat32(0.0126833)); return pow(ffxSaturate(p - FfxFloat32(0.835938)) / (FfxFloat32(18.8516) - FfxFloat32(18.6875) * p), FfxFloat32(6.27739)); } @@ -2667,10 +2667,10 @@ FfxFloat32 ffxLinearFromPQ(FfxFloat32 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 x) +/// @ingroup GPUCore +FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 value) { - FfxFloat32x2 p = pow(x, ffxBroadcast2(0.0126833)); + FfxFloat32x2 p = pow(value, ffxBroadcast2(0.0126833)); return pow(ffxSaturate(p - ffxBroadcast2(0.835938)) / (ffxBroadcast2(18.8516) - ffxBroadcast2(18.6875) * p), ffxBroadcast2(6.27739)); } @@ -2683,10 +2683,10 @@ FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 x) +/// @ingroup GPUCore +FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 value) { - FfxFloat32x3 p = pow(x, ffxBroadcast3(0.0126833)); + FfxFloat32x3 p = pow(value, ffxBroadcast3(0.0126833)); return pow(ffxSaturate(p - ffxBroadcast3(0.835938)) / (ffxBroadcast3(18.8516) - ffxBroadcast3(18.6875) * p), ffxBroadcast3(6.27739)); } @@ -2699,12 +2699,12 @@ FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxLinearFromSrgb(FfxFloat32 color) +/// @ingroup GPUCore +FfxFloat32 ffxLinearFromSrgb(FfxFloat32 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.x), color * j.y, pow(color * k.x + k.y, j.z)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.x), value * j.y, pow(value * k.x + k.y, j.z)); } /// Compute a linear value from a value in a SRGB space. @@ -2716,12 +2716,12 @@ FfxFloat32 ffxLinearFromSrgb(FfxFloat32 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 color) +/// @ingroup GPUCore +FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.xx), color * j.yy, pow(color * k.xx + k.yy, j.zz)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.xx), value * j.yy, pow(value * k.xx + k.yy, j.zz)); } /// Compute a linear value from a value in a SRGB space. @@ -2733,12 +2733,12 @@ FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 color) +/// @ingroup GPUCore +FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.xxx), color * j.yyy, pow(color * k.xxx + k.yyy, j.zzz)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.xxx), value * j.yyy, pow(value * k.xxx + k.yyy, j.zzz)); } /// A remapping of 64x1 to 8x8 imposing rotated 2x2 pixel quads in quad linear. @@ -2753,7 +2753,7 @@ FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 color) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxRemapForQuad(FfxUInt32 a) { return FfxUInt32x2(bitfieldExtract(a, 1u, 3u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), a, 1u)); @@ -2777,7 +2777,7 @@ FfxUInt32x2 ffxRemapForQuad(FfxUInt32 a) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxRemapForWaveReduction(FfxUInt32 a) { return FfxUInt32x2(bitfieldInsertMask(bitfieldExtract(a, 2u, 3u), a, 1u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), bitfieldExtract(a, 1u, 2u), 2u)); diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta new file mode 100644 index 0000000..ec380d2 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 05b921699d1374a429e32afca13137e2 +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_core_gpu_common_half.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h similarity index 94% rename from Assets/Resources/FSR2/shaders/ffx_core_gpu_common_half.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h index c46ccb3..4c73daf 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core_gpu_common_half.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,28 +19,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + #if FFX_HALF -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM >= 62 /// A define value for 16bit positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0x7c00u) /// A define value for 16bit negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0xfc00u) #else /// A define value for 16bit positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16(0x7c00u) /// A define value for 16bit negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16(0xfc00u) -#endif // FFX_HLSL_6_2 +#endif // #if FFX_HLSL_SM>=62 /// Compute the min of two values. /// @@ -50,7 +51,7 @@ /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxMin(FfxFloat16 x, FfxFloat16 y) { return min(x, y); @@ -64,7 +65,7 @@ FfxFloat16 ffxMin(FfxFloat16 x, FfxFloat16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxMin(FfxFloat16x2 x, FfxFloat16x2 y) { return min(x, y); @@ -78,7 +79,7 @@ FfxFloat16x2 ffxMin(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxMin(FfxFloat16x3 x, FfxFloat16x3 y) { return min(x, y); @@ -92,7 +93,7 @@ FfxFloat16x3 ffxMin(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxMin(FfxFloat16x4 x, FfxFloat16x4 y) { return min(x, y); @@ -106,7 +107,7 @@ FfxFloat16x4 ffxMin(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16 ffxMin(FfxInt16 x, FfxInt16 y) { return min(x, y); @@ -120,7 +121,7 @@ FfxInt16 ffxMin(FfxInt16 x, FfxInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x2 ffxMin(FfxInt16x2 x, FfxInt16x2 y) { return min(x, y); @@ -134,7 +135,7 @@ FfxInt16x2 ffxMin(FfxInt16x2 x, FfxInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x3 ffxMin(FfxInt16x3 x, FfxInt16x3 y) { return min(x, y); @@ -148,7 +149,7 @@ FfxInt16x3 ffxMin(FfxInt16x3 x, FfxInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x4 ffxMin(FfxInt16x4 x, FfxInt16x4 y) { return min(x, y); @@ -162,7 +163,7 @@ FfxInt16x4 ffxMin(FfxInt16x4 x, FfxInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxMin(FfxUInt16 x, FfxUInt16 y) { return min(x, y); @@ -176,7 +177,7 @@ FfxUInt16 ffxMin(FfxUInt16 x, FfxUInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxMin(FfxUInt16x2 x, FfxUInt16x2 y) { return min(x, y); @@ -190,7 +191,7 @@ FfxUInt16x2 ffxMin(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxMin(FfxUInt16x3 x, FfxUInt16x3 y) { return min(x, y); @@ -204,7 +205,7 @@ FfxUInt16x3 ffxMin(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxMin(FfxUInt16x4 x, FfxUInt16x4 y) { return min(x, y); @@ -218,7 +219,7 @@ FfxUInt16x4 ffxMin(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxMax(FfxFloat16 x, FfxFloat16 y) { return max(x, y); @@ -232,7 +233,7 @@ FfxFloat16 ffxMax(FfxFloat16 x, FfxFloat16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxMax(FfxFloat16x2 x, FfxFloat16x2 y) { return max(x, y); @@ -246,7 +247,7 @@ FfxFloat16x2 ffxMax(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxMax(FfxFloat16x3 x, FfxFloat16x3 y) { return max(x, y); @@ -260,7 +261,7 @@ FfxFloat16x3 ffxMax(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxMax(FfxFloat16x4 x, FfxFloat16x4 y) { return max(x, y); @@ -274,7 +275,7 @@ FfxFloat16x4 ffxMax(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16 ffxMax(FfxInt16 x, FfxInt16 y) { return max(x, y); @@ -288,7 +289,7 @@ FfxInt16 ffxMax(FfxInt16 x, FfxInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x2 ffxMax(FfxInt16x2 x, FfxInt16x2 y) { return max(x, y); @@ -302,7 +303,7 @@ FfxInt16x2 ffxMax(FfxInt16x2 x, FfxInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x3 ffxMax(FfxInt16x3 x, FfxInt16x3 y) { return max(x, y); @@ -316,7 +317,7 @@ FfxInt16x3 ffxMax(FfxInt16x3 x, FfxInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x4 ffxMax(FfxInt16x4 x, FfxInt16x4 y) { return max(x, y); @@ -330,7 +331,7 @@ FfxInt16x4 ffxMax(FfxInt16x4 x, FfxInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxMax(FfxUInt16 x, FfxUInt16 y) { return max(x, y); @@ -344,7 +345,7 @@ FfxUInt16 ffxMax(FfxUInt16 x, FfxUInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxMax(FfxUInt16x2 x, FfxUInt16x2 y) { return max(x, y); @@ -358,7 +359,7 @@ FfxUInt16x2 ffxMax(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxMax(FfxUInt16x3 x, FfxUInt16x3 y) { return max(x, y); @@ -372,7 +373,7 @@ FfxUInt16x3 ffxMax(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxMax(FfxUInt16x4 x, FfxUInt16x4 y) { return max(x, y); @@ -386,7 +387,7 @@ FfxUInt16x4 ffxMax(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxPow(FfxFloat16 x, FfxFloat16 y) { return pow(x, y); @@ -400,7 +401,7 @@ FfxFloat16 ffxPow(FfxFloat16 x, FfxFloat16 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPow(FfxFloat16x2 x, FfxFloat16x2 y) { return pow(x, y); @@ -414,7 +415,7 @@ FfxFloat16x2 ffxPow(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxPow(FfxFloat16x3 x, FfxFloat16x3 y) { return pow(x, y); @@ -428,7 +429,7 @@ FfxFloat16x3 ffxPow(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxPow(FfxFloat16x4 x, FfxFloat16x4 y) { return pow(x, y); @@ -441,7 +442,7 @@ FfxFloat16x4 ffxPow(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSqrt(FfxFloat16 x) { return sqrt(x); @@ -454,7 +455,7 @@ FfxFloat16 ffxSqrt(FfxFloat16 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSqrt(FfxFloat16x2 x) { return sqrt(x); @@ -467,7 +468,7 @@ FfxFloat16x2 ffxSqrt(FfxFloat16x2 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSqrt(FfxFloat16x3 x) { return sqrt(x); @@ -480,7 +481,7 @@ FfxFloat16x3 ffxSqrt(FfxFloat16x3 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxSqrt(FfxFloat16x4 x) { return sqrt(x); @@ -494,7 +495,7 @@ FfxFloat16x4 ffxSqrt(FfxFloat16x4 x) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxCopySignBitHalf(FfxFloat16 d, FfxFloat16 s) { return FFX_TO_FLOAT16(FFX_TO_UINT16(d) | (FFX_TO_UINT16(s) & FFX_BROADCAST_UINT16(0x8000u))); @@ -508,7 +509,7 @@ FfxFloat16 ffxCopySignBitHalf(FfxFloat16 d, FfxFloat16 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxCopySignBitHalf(FfxFloat16x2 d, FfxFloat16x2 s) { return FFX_TO_FLOAT16X2(FFX_TO_UINT16X2(d) | (FFX_TO_UINT16X2(s) & FFX_BROADCAST_UINT16X2(0x8000u))); @@ -522,7 +523,7 @@ FfxFloat16x2 ffxCopySignBitHalf(FfxFloat16x2 d, FfxFloat16x2 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxCopySignBitHalf(FfxFloat16x3 d, FfxFloat16x3 s) { return FFX_TO_FLOAT16X3(FFX_TO_UINT16X3(d) | (FFX_TO_UINT16X3(s) & FFX_BROADCAST_UINT16X3(0x8000u))); @@ -536,7 +537,7 @@ FfxFloat16x3 ffxCopySignBitHalf(FfxFloat16x3 d, FfxFloat16x3 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxCopySignBitHalf(FfxFloat16x4 d, FfxFloat16x4 s) { return FFX_TO_FLOAT16X4(FFX_TO_UINT16X4(d) | (FFX_TO_UINT16X4(s) & FFX_BROADCAST_UINT16X4(0x8000u))); @@ -559,10 +560,10 @@ FfxFloat16x4 ffxCopySignBitHalf(FfxFloat16x4 d, FfxFloat16x4 s) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxIsSignedHalf(FfxFloat16 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -582,10 +583,10 @@ FfxFloat16 ffxIsSignedHalf(FfxFloat16 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxIsSignedHalf(FfxFloat16x2 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -605,10 +606,10 @@ FfxFloat16x2 ffxIsSignedHalf(FfxFloat16x2 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxIsSignedHalf(FfxFloat16x3 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -628,10 +629,10 @@ FfxFloat16x3 ffxIsSignedHalf(FfxFloat16x3 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxIsSignedHalf(FfxFloat16x4 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -646,10 +647,10 @@ FfxFloat16x4 ffxIsSignedHalf(FfxFloat16x4 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxIsGreaterThanZeroHalf(FfxFloat16 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -664,10 +665,10 @@ FfxFloat16 ffxIsGreaterThanZeroHalf(FfxFloat16 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxIsGreaterThanZeroHalf(FfxFloat16x2 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -682,10 +683,10 @@ FfxFloat16x2 ffxIsGreaterThanZeroHalf(FfxFloat16x2 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxIsGreaterThanZeroHalf(FfxFloat16x3 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -700,10 +701,10 @@ FfxFloat16x3 ffxIsGreaterThanZeroHalf(FfxFloat16x3 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxIsGreaterThanZeroHalf(FfxFloat16x4 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF))); } /// Convert a 16bit floating point value to sortable integer. @@ -720,7 +721,7 @@ FfxFloat16x4 ffxIsGreaterThanZeroHalf(FfxFloat16x4 m) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxFloatToSortableIntegerHalf(FfxUInt16 x) { return x ^ ((ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16(15))) | FFX_BROADCAST_UINT16(0x8000)); @@ -737,7 +738,7 @@ FfxUInt16 ffxFloatToSortableIntegerHalf(FfxUInt16 x) /// @returns /// The floating point value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxSortableIntegerToFloatHalf(FfxUInt16 x) { return x ^ ((~ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16(15))) | FFX_BROADCAST_UINT16(0x8000)); @@ -757,7 +758,7 @@ FfxUInt16 ffxSortableIntegerToFloatHalf(FfxUInt16 x) /// @returns /// The sortable integer values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxFloatToSortableIntegerHalf(FfxUInt16x2 x) { return x ^ ((ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16X2(15))) | FFX_BROADCAST_UINT16X2(0x8000)); @@ -774,7 +775,7 @@ FfxUInt16x2 ffxFloatToSortableIntegerHalf(FfxUInt16x2 x) /// @returns /// The floating point values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxSortableIntegerToFloatHalf(FfxUInt16x2 x) { return x ^ ((~ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16X2(15))) | FFX_BROADCAST_UINT16X2(0x8000)); @@ -790,7 +791,7 @@ FfxUInt16x2 ffxSortableIntegerToFloatHalf(FfxUInt16x2 x) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY0ZeroX0(FfxUInt32x2 i) { return ((i.x) & 0xffu) | ((i.y << 16) & 0xff0000u); @@ -806,7 +807,7 @@ FfxUInt32 ffxPackBytesZeroY0ZeroX0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY1ZeroX1(FfxUInt32x2 i) { return ((i.x >> 8) & 0xffu) | ((i.y << 8) & 0xff0000u); @@ -822,7 +823,7 @@ FfxUInt32 ffxPackBytesZeroY1ZeroX1(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY2ZeroX2(FfxUInt32x2 i) { return ((i.x >> 16) & 0xffu) | ((i.y) & 0xff0000u); @@ -838,7 +839,7 @@ FfxUInt32 ffxPackBytesZeroY2ZeroX2(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY3ZeroX3(FfxUInt32x2 i) { return ((i.x >> 24) & 0xffu) | ((i.y >> 8) & 0xff0000u); @@ -854,7 +855,7 @@ FfxUInt32 ffxPackBytesZeroY3ZeroX3(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2Y1X0(FfxUInt32x2 i) { return ((i.x) & 0x000000ffu) | (i.y & 0xffffff00u); @@ -870,7 +871,7 @@ FfxUInt32 ffxPackBytesY3Y2Y1X0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2Y1X2(FfxUInt32x2 i) { return ((i.x >> 16) & 0x000000ffu) | (i.y & 0xffffff00u); @@ -886,7 +887,7 @@ FfxUInt32 ffxPackBytesY3Y2Y1X2(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2X0Y0(FfxUInt32x2 i) { return ((i.x << 8) & 0x0000ff00u) | (i.y & 0xffff00ffu); @@ -902,7 +903,7 @@ FfxUInt32 ffxPackBytesY3Y2X0Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2X2Y0(FfxUInt32x2 i) { return ((i.x >> 8) & 0x0000ff00u) | (i.y & 0xffff00ffu); @@ -918,7 +919,7 @@ FfxUInt32 ffxPackBytesY3Y2X2Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3X0Y1Y0(FfxUInt32x2 i) { return ((i.x << 16) & 0x00ff0000u) | (i.y & 0xff00ffffu); @@ -934,7 +935,7 @@ FfxUInt32 ffxPackBytesY3X0Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3X2Y1Y0(FfxUInt32x2 i) { return ((i.x) & 0x00ff0000u) | (i.y & 0xff00ffffu); @@ -950,7 +951,7 @@ FfxUInt32 ffxPackBytesY3X2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesX0Y2Y1Y0(FfxUInt32x2 i) { return ((i.x << 24) & 0xff000000u) | (i.y & 0x00ffffffu); @@ -966,7 +967,7 @@ FfxUInt32 ffxPackBytesX0Y2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesX2Y2Y1Y0(FfxUInt32x2 i) { return ((i.x << 8) & 0xff000000u) | (i.y & 0x00ffffffu); @@ -982,7 +983,7 @@ FfxUInt32 ffxPackBytesX2Y2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY2X2Y0X0(FfxUInt32x2 i) { return ((i.x) & 0x00ff00ffu) | ((i.y << 8) & 0xff00ff00u); @@ -998,7 +999,7 @@ FfxUInt32 ffxPackBytesY2X2Y0X0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY2Y0X2X0(FfxUInt32x2 i) { return (((i.x) & 0xffu) | ((i.x >> 8) & 0xff00u) | ((i.y << 16) & 0xff0000u) | ((i.y << 8) & 0xff000000u)); @@ -1012,7 +1013,7 @@ FfxUInt32 ffxPackBytesY2Y0X2X0(FfxUInt32x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxPackX0Y0X1Y1UnsignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) { x *= FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0); @@ -1037,7 +1038,7 @@ FfxUInt16x2 ffxPackX0Y0X1Y1UnsignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1061,7 +1062,7 @@ FfxUInt32x2 ffxPermuteUByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1085,7 +1086,7 @@ FfxUInt32x2 ffxPermuteUByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1109,7 +1110,7 @@ FfxUInt32x2 ffxPermuteUByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1123,7 +1124,7 @@ FfxUInt32x2 ffxPermuteUByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1136,7 +1137,7 @@ FfxFloat16x2 ffxPermuteUByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1149,7 +1150,7 @@ FfxFloat16x2 ffxPermuteUByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1162,7 +1163,7 @@ FfxFloat16x2 ffxPermuteUByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1176,7 +1177,7 @@ FfxFloat16x2 ffxPermuteUByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxPackX0Y0X1Y1SignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) { x = x * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0); @@ -1195,7 +1196,7 @@ FfxUInt16x2 ffxPackX0Y0X1Y1SignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1213,7 +1214,7 @@ FfxUInt32x2 ffxPermuteSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1231,7 +1232,7 @@ FfxUInt32x2 ffxPermuteSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1249,7 +1250,7 @@ FfxUInt32x2 ffxPermuteSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1270,7 +1271,7 @@ FfxUInt32x2 ffxPermuteSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1291,7 +1292,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1312,7 +1313,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1333,7 +1334,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1349,7 +1350,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1364,7 +1365,7 @@ FfxFloat16x2 ffxPermuteSByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1379,7 +1380,7 @@ FfxFloat16x2 ffxPermuteSByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1394,7 +1395,7 @@ FfxFloat16x2 ffxPermuteSByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1409,7 +1410,7 @@ FfxFloat16x2 ffxPermuteSByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1424,7 +1425,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1439,7 +1440,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1454,7 +1455,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1473,7 +1474,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateSqrtHalf(FfxFloat16 a) { return FFX_TO_FLOAT16((FFX_TO_UINT16(a) >> FFX_BROADCAST_UINT16(1)) + FFX_BROADCAST_UINT16(0x1de2)); @@ -1492,7 +1493,7 @@ FfxFloat16 ffxApproximateSqrtHalf(FfxFloat16 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateSqrtHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2((FFX_TO_UINT16X2(a) >> FFX_BROADCAST_UINT16X2(1)) + FFX_BROADCAST_UINT16X2(0x1de2)); @@ -1511,7 +1512,7 @@ FfxFloat16x2 ffxApproximateSqrtHalf(FfxFloat16x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateSqrtHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3((FFX_TO_UINT16X3(a) >> FFX_BROADCAST_UINT16X3(1)) + FFX_BROADCAST_UINT16X3(0x1de2)); @@ -1530,7 +1531,7 @@ FfxFloat16x3 ffxApproximateSqrtHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalHalf(FfxFloat16 a) { return FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x7784) - FFX_TO_UINT16(a)); @@ -1549,7 +1550,7 @@ FfxFloat16 ffxApproximateReciprocalHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x7784) - FFX_TO_UINT16X2(a)); @@ -1568,7 +1569,7 @@ FfxFloat16x2 ffxApproximateReciprocalHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x7784) - FFX_TO_UINT16X3(a)); @@ -1587,7 +1588,7 @@ FfxFloat16x3 ffxApproximateReciprocalHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalHalf(FfxFloat16x4 a) { return FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x7784) - FFX_TO_UINT16X4(a)); @@ -1606,7 +1607,7 @@ FfxFloat16x4 ffxApproximateReciprocalHalf(FfxFloat16x4 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalMediumHalf(FfxFloat16 a) { FfxFloat16 b = FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x778d) - FFX_TO_UINT16(a)); @@ -1626,7 +1627,7 @@ FfxFloat16 ffxApproximateReciprocalMediumHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalMediumHalf(FfxFloat16x2 a) { FfxFloat16x2 b = FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x778d) - FFX_TO_UINT16X2(a)); @@ -1646,7 +1647,7 @@ FfxFloat16x2 ffxApproximateReciprocalMediumHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalMediumHalf(FfxFloat16x3 a) { FfxFloat16x3 b = FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x778d) - FFX_TO_UINT16X3(a)); @@ -1666,7 +1667,7 @@ FfxFloat16x3 ffxApproximateReciprocalMediumHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalMediumHalf(FfxFloat16x4 a) { FfxFloat16x4 b = FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x778d) - FFX_TO_UINT16X4(a)); @@ -1686,7 +1687,7 @@ FfxFloat16x4 ffxApproximateReciprocalMediumHalf(FfxFloat16x4 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalSquareRootHalf(FfxFloat16 a) { return FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x59a3) - (FFX_TO_UINT16(a) >> FFX_BROADCAST_UINT16(1))); @@ -1705,7 +1706,7 @@ FfxFloat16 ffxApproximateReciprocalSquareRootHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x59a3) - (FFX_TO_UINT16X2(a) >> FFX_BROADCAST_UINT16X2(1))); @@ -1724,7 +1725,7 @@ FfxFloat16x2 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x59a3) - (FFX_TO_UINT16X3(a) >> FFX_BROADCAST_UINT16X3(1))); @@ -1743,7 +1744,7 @@ FfxFloat16x3 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x4 a) { return FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x59a3) - (FFX_TO_UINT16X4(a) >> FFX_BROADCAST_UINT16X4(1))); @@ -1833,7 +1834,7 @@ FfxFloat16x2 ffxParabolicSinCosHalf(FfxFloat16 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneAndHalf(FfxUInt16 x, FfxUInt16 y) { return min(x, y); @@ -1847,7 +1848,7 @@ FfxUInt16 ffxZeroOneAndHalf(FfxUInt16 x, FfxUInt16 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneAndHalf(FfxUInt16x2 x, FfxUInt16x2 y) { return min(x, y); @@ -1861,7 +1862,7 @@ FfxUInt16x2 ffxZeroOneAndHalf(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneAndHalf(FfxUInt16x3 x, FfxUInt16x3 y) { return min(x, y); @@ -1875,7 +1876,7 @@ FfxUInt16x3 ffxZeroOneAndHalf(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneAndHalf(FfxUInt16x4 x, FfxUInt16x4 y) { return min(x, y); @@ -1889,7 +1890,7 @@ FfxUInt16x4 ffxZeroOneAndHalf(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneNotHalf(FfxUInt16 x) { return x ^ FFX_BROADCAST_UINT16(1); @@ -1903,7 +1904,7 @@ FfxUInt16 ffxZeroOneNotHalf(FfxUInt16 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneNotHalf(FfxUInt16x2 x) { return x ^ FFX_BROADCAST_UINT16X2(1); @@ -1917,7 +1918,7 @@ FfxUInt16x2 ffxZeroOneNotHalf(FfxUInt16x2 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneNotHalf(FfxUInt16x3 x) { return x ^ FFX_BROADCAST_UINT16X3(1); @@ -1931,7 +1932,7 @@ FfxUInt16x3 ffxZeroOneNotHalf(FfxUInt16x3 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneNotHalf(FfxUInt16x4 x) { return x ^ FFX_BROADCAST_UINT16X4(1); @@ -1945,7 +1946,7 @@ FfxUInt16x4 ffxZeroOneNotHalf(FfxUInt16x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneOrHalf(FfxUInt16 x, FfxUInt16 y) { return max(x, y); @@ -1959,7 +1960,7 @@ FfxUInt16 ffxZeroOneOrHalf(FfxUInt16 x, FfxUInt16 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneOrHalf(FfxUInt16x2 x, FfxUInt16x2 y) { return max(x, y); @@ -1973,7 +1974,7 @@ FfxUInt16x2 ffxZeroOneOrHalf(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneOrHalf(FfxUInt16x3 x, FfxUInt16x3 y) { return max(x, y); @@ -1987,7 +1988,7 @@ FfxUInt16x3 ffxZeroOneOrHalf(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneOrHalf(FfxUInt16x4 x, FfxUInt16x4 y) { return max(x, y); @@ -2000,7 +2001,7 @@ FfxUInt16x4 ffxZeroOneOrHalf(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneFloat16ToUint16(FfxFloat16 x) { return FFX_TO_UINT16(x * FFX_TO_FLOAT16(FFX_TO_UINT16(1))); @@ -2013,7 +2014,7 @@ FfxUInt16 ffxZeroOneFloat16ToUint16(FfxFloat16 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneFloat16x2ToUint16x2(FfxFloat16x2 x) { return FFX_TO_UINT16X2(x * FFX_TO_FLOAT16X2(FfxUInt16x2(1, 1))); @@ -2026,7 +2027,7 @@ FfxUInt16x2 ffxZeroOneFloat16x2ToUint16x2(FfxFloat16x2 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneFloat16x3ToUint16x3(FfxFloat16x3 x) { return FFX_TO_UINT16X3(x * FFX_TO_FLOAT16X3(FfxUInt16x3(1, 1, 1))); @@ -2039,7 +2040,7 @@ FfxUInt16x3 ffxZeroOneFloat16x3ToUint16x3(FfxFloat16x3 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneFloat16x4ToUint16x4(FfxFloat16x4 x) { return FFX_TO_UINT16X4(x * FFX_TO_FLOAT16X4(FfxUInt16x4(1, 1, 1, 1))); @@ -2052,7 +2053,7 @@ FfxUInt16x4 ffxZeroOneFloat16x4ToUint16x4(FfxFloat16x4 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneUint16ToFloat16(FfxUInt16 x) { return FFX_TO_FLOAT16(x * FFX_TO_UINT16(FFX_TO_FLOAT16(1.0))); @@ -2065,7 +2066,7 @@ FfxFloat16 ffxZeroOneUint16ToFloat16(FfxUInt16 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneUint16x2ToFloat16x2(FfxUInt16x2 x) { return FFX_TO_FLOAT16X2(x * FFX_TO_UINT16X2(FfxUInt16x2(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2078,7 +2079,7 @@ FfxFloat16x2 ffxZeroOneUint16x2ToFloat16x2(FfxUInt16x2 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneUint16x3ToFloat16x3(FfxUInt16x3 x) { return FFX_TO_FLOAT16X3(x * FFX_TO_UINT16X3(FfxUInt16x3(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2091,7 +2092,7 @@ FfxFloat16x3 ffxZeroOneUint16x3ToFloat16x3(FfxUInt16x3 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneUint16x4ToFloat16x4(FfxUInt16x4 x) { return FFX_TO_FLOAT16X4(x * FFX_TO_UINT16X4(FfxUInt16x4(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2105,7 +2106,7 @@ FfxFloat16x4 ffxZeroOneUint16x4ToFloat16x4(FfxUInt16x4 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneAndHalf(FfxFloat16 x, FfxFloat16 y) { return min(x, y); @@ -2119,7 +2120,7 @@ FfxFloat16 ffxZeroOneAndHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneAndHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return min(x, y); @@ -2133,7 +2134,7 @@ FfxFloat16x2 ffxZeroOneAndHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneAndHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return min(x, y); @@ -2147,7 +2148,7 @@ FfxFloat16x3 ffxZeroOneAndHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneAndHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return min(x, y); @@ -2161,7 +2162,7 @@ FfxFloat16x4 ffxZeroOneAndHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSignedZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y) { return (-x) * y + FFX_BROADCAST_FLOAT16(1.0); @@ -2175,7 +2176,7 @@ FfxFloat16 ffxSignedZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSignedZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X2(1.0); @@ -2189,7 +2190,7 @@ FfxFloat16x2 ffxSignedZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSignedZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X3(1.0); @@ -2203,7 +2204,7 @@ FfxFloat16x3 ffxSignedZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxSignedZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X4(1.0); @@ -2219,10 +2220,10 @@ FfxFloat16x4 ffxSignedZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) { - return ffxSaturate(x * y + z); + return FfxFloat16(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2235,10 +2236,10 @@ FfxFloat16 ffxZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x2(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2251,10 +2252,10 @@ FfxFloat16x2 ffxZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x3(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2267,10 +2268,10 @@ FfxFloat16x3 ffxZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x4(ffxSaturate(x * y + z)); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2280,10 +2281,10 @@ FfxFloat16x4 ffxZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2293,10 +2294,10 @@ FfxFloat16 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x2 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2306,10 +2307,10 @@ FfxFloat16x2 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x2 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x3 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2319,10 +2320,10 @@ FfxFloat16x3 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x3 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x4 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF))); } /// Conditional free logic signed NOT operation using two half-precision FfxFloat32 values. @@ -2332,7 +2333,7 @@ FfxFloat16x4 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneNotHalf(FfxFloat16 x) { return FFX_BROADCAST_FLOAT16(1.0) - x; @@ -2345,7 +2346,7 @@ FfxFloat16 ffxZeroOneNotHalf(FfxFloat16 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneNotHalf(FfxFloat16x2 x) { return FFX_BROADCAST_FLOAT16X2(1.0) - x; @@ -2358,7 +2359,7 @@ FfxFloat16x2 ffxZeroOneNotHalf(FfxFloat16x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneNotHalf(FfxFloat16x3 x) { return FFX_BROADCAST_FLOAT16X3(1.0) - x; @@ -2371,7 +2372,7 @@ FfxFloat16x3 ffxZeroOneNotHalf(FfxFloat16x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneNotHalf(FfxFloat16x4 x) { return FFX_BROADCAST_FLOAT16X4(1.0) - x; @@ -2385,7 +2386,7 @@ FfxFloat16x4 ffxZeroOneNotHalf(FfxFloat16x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneOrHalf(FfxFloat16 x, FfxFloat16 y) { return max(x, y); @@ -2399,7 +2400,7 @@ FfxFloat16 ffxZeroOneOrHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return max(x, y); @@ -2413,7 +2414,7 @@ FfxFloat16x2 ffxZeroOneOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return max(x, y); @@ -2427,7 +2428,7 @@ FfxFloat16x3 ffxZeroOneOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return max(x, y); @@ -2442,7 +2443,7 @@ FfxFloat16x4 ffxZeroOneOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneSelectHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) { FfxFloat16 r = (-x) * z + z; @@ -2458,7 +2459,7 @@ FfxFloat16 ffxZeroOneSelectHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneSelectHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) { FfxFloat16x2 r = (-x) * z + z; @@ -2474,7 +2475,7 @@ FfxFloat16x2 ffxZeroOneSelectHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneSelectHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) { FfxFloat16x3 r = (-x) * z + z; @@ -2490,7 +2491,7 @@ FfxFloat16x3 ffxZeroOneSelectHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneSelectHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) { FfxFloat16x4 r = (-x) * z + z; @@ -2504,10 +2505,10 @@ FfxFloat16x4 ffxZeroOneSelectHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneIsSignedHalf(FfxFloat16 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2517,10 +2518,10 @@ FfxFloat16 ffxZeroOneIsSignedHalf(FfxFloat16 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneIsSignedHalf(FfxFloat16x2 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2530,10 +2531,10 @@ FfxFloat16x2 ffxZeroOneIsSignedHalf(FfxFloat16x2 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneIsSignedHalf(FfxFloat16x3 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2543,10 +2544,10 @@ FfxFloat16x3 ffxZeroOneIsSignedHalf(FfxFloat16x3 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneIsSignedHalf(FfxFloat16x4 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF))); } /// Compute a Rec.709 color space. @@ -2562,7 +2563,7 @@ FfxFloat16x4 ffxZeroOneIsSignedHalf(FfxFloat16x4 x) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxRec709FromLinearHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2583,7 +2584,7 @@ FfxFloat16 ffxRec709FromLinearHalf(FfxFloat16 c) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxRec709FromLinearHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2604,7 +2605,7 @@ FfxFloat16x2 ffxRec709FromLinearHalf(FfxFloat16x2 c) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxRec709FromLinearHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2624,7 +2625,7 @@ FfxFloat16x3 ffxRec709FromLinearHalf(FfxFloat16x3 c) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxGammaFromLinearHalf(FfxFloat16 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16(rcpX)); @@ -2642,7 +2643,7 @@ FfxFloat16 ffxGammaFromLinearHalf(FfxFloat16 c, FfxFloat16 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxGammaFromLinearHalf(FfxFloat16x2 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16X2(rcpX)); @@ -2660,7 +2661,7 @@ FfxFloat16x2 ffxGammaFromLinearHalf(FfxFloat16x2 c, FfxFloat16 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxGammaFromLinearHalf(FfxFloat16x3 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16X3(rcpX)); @@ -2673,7 +2674,7 @@ FfxFloat16x3 ffxGammaFromLinearHalf(FfxFloat16x3 c, FfxFloat16 rcpX) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSrgbFromLinearHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2688,7 +2689,7 @@ FfxFloat16 ffxSrgbFromLinearHalf(FfxFloat16 c) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSrgbFromLinearHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2703,7 +2704,7 @@ FfxFloat16x2 ffxSrgbFromLinearHalf(FfxFloat16x2 c) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSrgbFromLinearHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2718,7 +2719,7 @@ FfxFloat16x3 ffxSrgbFromLinearHalf(FfxFloat16x3 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSquareRootHalf(FfxFloat16 c) { return sqrt(c); @@ -2731,7 +2732,7 @@ FfxFloat16 ffxSquareRootHalf(FfxFloat16 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSquareRootHalf(FfxFloat16x2 c) { return sqrt(c); @@ -2744,7 +2745,7 @@ FfxFloat16x2 ffxSquareRootHalf(FfxFloat16x2 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSquareRootHalf(FfxFloat16x3 c) { return sqrt(c); @@ -2757,7 +2758,7 @@ FfxFloat16x3 ffxSquareRootHalf(FfxFloat16x3 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxCubeRootHalf(FfxFloat16 c) { return pow(c, FFX_BROADCAST_FLOAT16(1.0 / 3.0)); @@ -2770,7 +2771,7 @@ FfxFloat16 ffxCubeRootHalf(FfxFloat16 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxCubeRootHalf(FfxFloat16x2 c) { return pow(c, FFX_BROADCAST_FLOAT16X2(1.0 / 3.0)); @@ -2783,7 +2784,7 @@ FfxFloat16x2 ffxCubeRootHalf(FfxFloat16x2 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxCubeRootHalf(FfxFloat16x3 c) { return pow(c, FFX_BROADCAST_FLOAT16X3(1.0 / 3.0)); @@ -2796,7 +2797,7 @@ FfxFloat16x3 ffxCubeRootHalf(FfxFloat16x3 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromRec709Half(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2811,7 +2812,7 @@ FfxFloat16 ffxLinearFromRec709Half(FfxFloat16 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromRec709Half(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2826,7 +2827,7 @@ FfxFloat16x2 ffxLinearFromRec709Half(FfxFloat16x2 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromRec709Half(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2844,7 +2845,7 @@ FfxFloat16x3 ffxLinearFromRec709Half(FfxFloat16x3 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromGammaHalf(FfxFloat16 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16(x)); @@ -2860,7 +2861,7 @@ FfxFloat16 ffxLinearFromGammaHalf(FfxFloat16 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromGammaHalf(FfxFloat16x2 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16X2(x)); @@ -2876,7 +2877,7 @@ FfxFloat16x2 ffxLinearFromGammaHalf(FfxFloat16x2 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromGammaHalf(FfxFloat16x3 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16X3(x)); @@ -2891,7 +2892,7 @@ FfxFloat16x3 ffxLinearFromGammaHalf(FfxFloat16x3 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromSrgbHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2908,7 +2909,7 @@ FfxFloat16 ffxLinearFromSrgbHalf(FfxFloat16 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromSrgbHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2925,7 +2926,7 @@ FfxFloat16x2 ffxLinearFromSrgbHalf(FfxFloat16x2 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromSrgbHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2945,7 +2946,7 @@ FfxFloat16x3 ffxLinearFromSrgbHalf(FfxFloat16x3 c) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxRemapForQuadHalf(FfxUInt32 a) { return FfxUInt16x2(bitfieldExtract(a, 1u, 3u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), a, 1u)); @@ -2969,7 +2970,7 @@ FfxUInt16x2 ffxRemapForQuadHalf(FfxUInt32 a) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxRemapForWaveReductionHalf(FfxUInt32 a) { return FfxUInt16x2(bitfieldInsertMask(bitfieldExtract(a, 2u, 3u), a, 1u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), bitfieldExtract(a, 1u, 2u), 2u)); diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta new file mode 100644 index 0000000..e78eec4 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 1bdb323791a91a5438ee8e1e63187840 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h similarity index 86% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h index ad4ff65..337eb06 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,188 +19,221 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + +/// @defgroup HLSLCore HLSL Core +/// HLSL core defines and functions +/// +/// @ingroup FfxHLSL + +#define DECLARE_SRV_REGISTER(regIndex) t##regIndex +#define DECLARE_UAV_REGISTER(regIndex) u##regIndex +#define DECLARE_CB_REGISTER(regIndex) b##regIndex +#define FFX_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) +#define FFX_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) +#define FFX_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) + /// A define for abstracting shared memory between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GROUPSHARED groupshared /// A define for abstracting compute memory barriers between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GROUP_MEMORY_BARRIER GroupMemoryBarrierWithGroupSync +/// A define for abstracting compute atomic additions between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_ATOMIC_ADD(x, y) InterlockedAdd(x, y) + /// A define added to accept static markup on functions to aid CPU/GPU portability of code. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_STATIC static /// A define for abstracting loop unrolling between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_UNROLL [unroll] /// A define for abstracting a 'greater than' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GREATER_THAN(x, y) x > y /// A define for abstracting a 'greater than or equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GREATER_THAN_EQUAL(x, y) x >= y /// A define for abstracting a 'less than' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_LESS_THAN(x, y) x < y /// A define for abstracting a 'less than or equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_LESS_THAN_EQUAL(x, y) x <= y /// A define for abstracting an 'equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_EQUAL(x, y) x == y /// A define for abstracting a 'not equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_NOT_EQUAL(x, y) x != y +/// A define for abstracting matrix multiply operations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_MATRIX_MULTIPLY(a, b) mul(a, b) + +/// A define for abstracting vector transformations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_TRANSFORM_VECTOR(a, b) mul(a, b) + +/// A define for abstracting modulo operations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_MODULO(a, b) (fmod(a, b)) + /// Broadcast a scalar value to a 1-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32(x) FfxFloat32(x) /// Broadcast a scalar value to a 2-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X2(x) FfxFloat32(x) /// Broadcast a scalar value to a 3-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X3(x) FfxFloat32(x) /// Broadcast a scalar value to a 4-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X4(x) FfxFloat32(x) /// Broadcast a scalar value to a 1-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32(x) FfxUInt32(x) /// Broadcast a scalar value to a 2-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X2(x) FfxUInt32(x) /// Broadcast a scalar value to a 4-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X3(x) FfxUInt32(x) /// Broadcast a scalar value to a 4-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X4(x) FfxUInt32(x) /// Broadcast a scalar value to a 1-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32(x) FfxInt32(x) /// Broadcast a scalar value to a 2-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X2(x) FfxInt32(x) /// Broadcast a scalar value to a 3-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X3(x) FfxInt32(x) /// Broadcast a scalar value to a 4-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X4(x) FfxInt32(x) /// Broadcast a scalar value to a 1-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 2-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X2(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 3-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X3(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 4-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X4(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 1-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 2-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X2(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 3-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X3(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 4-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X4(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 1-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 2-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X2(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 3-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X3(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 4-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X4(a) FFX_MIN16_I(a) /// Pack 2x32-bit floating point values in a single 32bit value. -/// +/// /// This function first converts each component of value into their nearest 16-bit floating /// point representation, and then stores the X and Y components in the lower and upper 16 bits of the /// 32bit unsigned integer respectively. /// /// @param [in] value A 2-dimensional floating point value to convert and pack. -/// +/// /// @returns /// A packed 32bit value containing 2 16bit floating point values. -/// -/// @ingroup HLSL +/// +/// @ingroup HLSLCore FfxUInt32 packHalf2x16(FfxFloat32x2 value) { return f32tof16(value.x) | (f32tof16(value.y) << 16); @@ -213,7 +246,7 @@ FfxUInt32 packHalf2x16(FfxFloat32x2 value) /// @returns /// A 2-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxBroadcast2(FfxFloat32 value) { return FfxFloat32x2(value, value); @@ -226,7 +259,7 @@ FfxFloat32x2 ffxBroadcast2(FfxFloat32 value) /// @returns /// A 3-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxBroadcast3(FfxFloat32 value) { return FfxFloat32x3(value, value, value); @@ -239,7 +272,7 @@ FfxFloat32x3 ffxBroadcast3(FfxFloat32 value) /// @returns /// A 4-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxBroadcast4(FfxFloat32 value) { return FfxFloat32x4(value, value, value, value); @@ -252,7 +285,7 @@ FfxFloat32x4 ffxBroadcast4(FfxFloat32 value) /// @returns /// A 2-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxInt32x2 ffxBroadcast2(FfxInt32 value) { return FfxInt32x2(value, value); @@ -265,7 +298,7 @@ FfxInt32x2 ffxBroadcast2(FfxInt32 value) /// @returns /// A 3-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxBroadcast3(FfxInt32 value) { return FfxUInt32x3(value, value, value); @@ -278,7 +311,7 @@ FfxUInt32x3 ffxBroadcast3(FfxInt32 value) /// @returns /// A 4-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxInt32x4 ffxBroadcast4(FfxInt32 value) { return FfxInt32x4(value, value, value, value); @@ -291,7 +324,7 @@ FfxInt32x4 ffxBroadcast4(FfxInt32 value) /// @returns /// A 2-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxBroadcast2(FfxUInt32 value) { return FfxUInt32x2(value, value); @@ -304,7 +337,7 @@ FfxUInt32x2 ffxBroadcast2(FfxUInt32 value) /// @returns /// A 3-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxBroadcast3(FfxUInt32 value) { return FfxUInt32x3(value, value, value); @@ -317,7 +350,7 @@ FfxUInt32x3 ffxBroadcast3(FfxUInt32 value) /// @returns /// A 4-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxBroadcast4(FfxUInt32 value) { return FfxUInt32x4(value, value, value, value); @@ -342,12 +375,12 @@ FfxUInt32 bitfieldInsertMask(FfxUInt32 src, FfxUInt32 ins, FfxUInt32 bits) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxAsUInt32(FfxFloat32 x) { return asuint(x); @@ -355,12 +388,12 @@ FfxUInt32 ffxAsUInt32(FfxFloat32 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x) { return asuint(x); @@ -368,12 +401,12 @@ FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x) { return asuint(x); @@ -381,12 +414,12 @@ FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x) { return asuint(x); @@ -394,12 +427,12 @@ FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxAsFloat(FfxUInt32 x) { return asfloat(x); @@ -407,12 +440,12 @@ FfxFloat32 ffxAsFloat(FfxUInt32 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x) { return asfloat(x); @@ -420,12 +453,12 @@ FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x) { return asfloat(x); @@ -433,12 +466,12 @@ FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x) { return asfloat(x); @@ -458,7 +491,7 @@ FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) { return lerp(x, y, t); @@ -478,7 +511,7 @@ FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32 t) { return lerp(x, y, t); @@ -498,7 +531,7 @@ FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 t) { return lerp(x, y, t); @@ -518,7 +551,7 @@ FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32 t) { return lerp(x, y, t); @@ -538,7 +571,7 @@ FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 t) { return lerp(x, y, t); @@ -558,7 +591,7 @@ FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32 t) { return lerp(x, y, t); @@ -578,7 +611,7 @@ FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 t) { return lerp(x, y, t); @@ -591,7 +624,7 @@ FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 t) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxSaturate(FfxFloat32 x) { return saturate(x); @@ -604,7 +637,7 @@ FfxFloat32 ffxSaturate(FfxFloat32 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxSaturate(FfxFloat32x2 x) { return saturate(x); @@ -617,7 +650,7 @@ FfxFloat32x2 ffxSaturate(FfxFloat32x2 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxSaturate(FfxFloat32x3 x) { return saturate(x); @@ -630,7 +663,7 @@ FfxFloat32x3 ffxSaturate(FfxFloat32x3 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxSaturate(FfxFloat32x4 x) { return saturate(x); @@ -645,11 +678,11 @@ FfxFloat32x4 ffxSaturate(FfxFloat32x4 x) /// function. /// /// @param [in] x The value to compute the fractional part from. -/// +/// /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxFract(FfxFloat32 x) { return x - floor(x); @@ -668,7 +701,7 @@ FfxFloat32 ffxFract(FfxFloat32 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxFract(FfxFloat32x2 x) { return x - floor(x); @@ -687,7 +720,7 @@ FfxFloat32x2 ffxFract(FfxFloat32x2 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxFract(FfxFloat32x3 x) { return x - floor(x); @@ -698,7 +731,7 @@ FfxFloat32x3 ffxFract(FfxFloat32x3 x) /// 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 +/// 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. @@ -706,7 +739,7 @@ FfxFloat32x3 ffxFract(FfxFloat32x3 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxFract(FfxFloat32x4 x) { return x - floor(x); @@ -715,15 +748,15 @@ FfxFloat32x4 ffxFract(FfxFloat32x4 x) /// 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 HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return max(x, max(y, z)); @@ -732,7 +765,7 @@ FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 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. @@ -740,7 +773,7 @@ FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return max(x, max(y, z)); @@ -749,7 +782,7 @@ FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 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. @@ -757,7 +790,7 @@ FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return max(x, max(y, z)); @@ -774,7 +807,7 @@ FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return max(x, max(y, z)); @@ -791,7 +824,7 @@ FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) { return max(x, max(y, z)); @@ -808,7 +841,7 @@ FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) { return max(x, max(y, z)); @@ -825,7 +858,7 @@ FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) { return max(x, max(y, z)); @@ -842,7 +875,7 @@ FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) { return max(x, max(y, z)); @@ -859,7 +892,7 @@ FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMed3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return max(min(x, y), min(max(x, y), z)); @@ -876,7 +909,7 @@ FfxFloat32 ffxMed3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMed3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return max(min(x, y), min(max(x, y), z)); @@ -893,7 +926,7 @@ FfxFloat32x2 ffxMed3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMed3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return max(min(x, y), min(max(x, y), z)); @@ -910,7 +943,7 @@ FfxFloat32x3 ffxMed3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMed3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return max(min(x, y), min(max(x, y), z)); @@ -990,7 +1023,7 @@ FfxInt32x4 ffxMed3(FfxInt32x4 x, FfxInt32x4 y, FfxInt32x4 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -999,7 +1032,7 @@ FfxInt32x4 ffxMed3(FfxInt32x4 x, FfxInt32x4 y, FfxInt32x4 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return min(x, min(y, z)); @@ -1007,7 +1040,7 @@ FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -1016,7 +1049,7 @@ FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return min(x, min(y, z)); @@ -1024,7 +1057,7 @@ FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -1033,7 +1066,7 @@ FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return min(x, min(y, z)); @@ -1041,7 +1074,7 @@ FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1050,7 +1083,7 @@ FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return min(x, min(y, z)); @@ -1058,7 +1091,7 @@ FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1067,7 +1100,7 @@ FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) { return min(x, min(y, z)); @@ -1075,7 +1108,7 @@ FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1084,7 +1117,7 @@ FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) { return min(x, min(y, z)); @@ -1092,16 +1125,16 @@ FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. +/// @param [in] y The second value to include in the min calculation. +/// @param [in] z The third value to include in the min calculation. /// /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) { return min(x, min(y, z)); @@ -1109,7 +1142,7 @@ FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1118,7 +1151,7 @@ FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxMin3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) { return min(x, min(y, z)); @@ -1130,11 +1163,18 @@ FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b) return FfxUInt32(FfxInt32(a) >> FfxInt32(b)); } +FfxUInt32 ffxPackF32(FfxFloat32x2 v){ + FfxUInt32x2 p = FfxUInt32x2(f32tof16(FfxFloat32x2(v).x), f32tof16(FfxFloat32x2(v).y)); + return p.x | (p.y << 16); +} + +FfxFloat32x2 ffxUnpackF32(FfxUInt32 a){ + return f16tof32(FfxUInt32x2(a & 0xFFFF, a >> 16)); +} + //============================================================================================================================== // HLSL HALF //============================================================================================================================== -#if FFX_HALF - //============================================================================================================================== // Need to use manual unpack to get optimal execution (don't use packed types in buffers directly). // Unpack requires this pattern: https://gpuopen.com/first-steps-implementing-fp16/ @@ -1156,10 +1196,59 @@ FFX_MIN16_U4 ffxUint32x2ToUint16x4(FfxUInt32x2 x) { return FFX_MIN16_U4(ffxUint32ToUint16x2(x.x), ffxUint32ToUint16x2(x.y)); } + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32 ffxInvertSafe(FfxFloat32 v){ + FfxFloat32 s = sign(v); + FfxFloat32 s2 = s*s; + return s2/(v + s2 - 1.0); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x2 ffxInvertSafe(FfxFloat32x2 v){ + FfxFloat32x2 s = sign(v); + FfxFloat32x2 s2 = s*s; + return s2/(v + s2 - FfxFloat32x2(1.0, 1.0)); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x3 ffxInvertSafe(FfxFloat32x3 v){ + FfxFloat32x3 s = sign(v); + FfxFloat32x3 s2 = s*s; + return s2/(v + s2 - FfxFloat32x3(1.0, 1.0, 1.0)); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x4 ffxInvertSafe(FfxFloat32x4 v){ + FfxFloat32x4 s = sign(v); + FfxFloat32x4 s2 = s*s; + return s2/(v + s2 - FfxFloat32x4(1.0, 1.0, 1.0, 1.0)); +} + #define FFX_UINT32_TO_FLOAT16X2(x) ffxUint32ToFloat16x2(FfxUInt32(x)) +#if FFX_HALF + #define FFX_UINT32X2_TO_FLOAT16X4(x) ffxUint32x2ToFloat16x4(FfxUInt32x2(x)) #define FFX_UINT32_TO_UINT16X2(x) ffxUint32ToUint16x2(FfxUInt32(x)) #define FFX_UINT32X2_TO_UINT16X4(x) ffxUint32x2ToUint16x4(FfxUInt32x2(x)) + +FfxUInt32 ffxPackF16(FfxFloat16x2 v){ + FfxUInt32x2 p = FfxUInt32x2(f32tof16(FfxFloat32x2(v).x), f32tof16(FfxFloat32x2(v).y)); + return p.x | (p.y << 16); +} + +FfxFloat16x2 ffxUnpackF16(FfxUInt32 a){ + return FfxFloat16x2(f16tof32(FfxUInt32x2(a & 0xFFFF, a >> 16))); +} + //------------------------------------------------------------------------------------------------------------------------------ FfxUInt32 FFX_MIN16_F2ToUint32(FFX_MIN16_F2 x) { @@ -1182,7 +1271,7 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_UINT16X2_TO_UINT32(x) FFX_MIN16_U2ToUint32(FFX_MIN16_U2(x)) #define FFX_UINT16X4_TO_UINT32X2(x) FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4(x)) -#if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#if (FFX_HLSL_SM >= 62) && !defined(FFX_NO_16_BIT_CAST) #define FFX_TO_UINT16(x) asuint16(x) #define FFX_TO_UINT16X2(x) asuint16(x) #define FFX_TO_UINT16X3(x) asuint16(x) @@ -1192,9 +1281,9 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_TO_UINT16X2(a) FFX_MIN16_U2(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y)) #define FFX_TO_UINT16X3(a) FFX_MIN16_U3(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y), FFX_TO_UINT16((a).z)) #define FFX_TO_UINT16X4(a) FFX_MIN16_U4(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y), FFX_TO_UINT16((a).z), FFX_TO_UINT16((a).w)) -#endif // #if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#endif // #if (FFX_HLSL_SM>=62) && !defined(FFX_NO_16_BIT_CAST) -#if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#if (FFX_HLSL_SM >= 62) && !defined(FFX_NO_16_BIT_CAST) #define FFX_TO_FLOAT16(x) asfloat16(x) #define FFX_TO_FLOAT16X2(x) asfloat16(x) #define FFX_TO_FLOAT16X3(x) asfloat16(x) @@ -1204,7 +1293,7 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_TO_FLOAT16X2(a) FFX_MIN16_F2(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y)) #define FFX_TO_FLOAT16X3(a) FFX_MIN16_F3(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y), FFX_TO_FLOAT16((a).z)) #define FFX_TO_FLOAT16X4(a) FFX_MIN16_F4(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y), FFX_TO_FLOAT16((a).z), FFX_TO_FLOAT16((a).w)) -#endif // #if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#endif // #if (FFX_HLSL_SM>=62) && !defined(FFX_NO_16_BIT_CAST) //============================================================================================================================== #define FFX_BROADCAST_FLOAT16(a) FFX_MIN16_F(a) @@ -1480,6 +1569,66 @@ FfxUInt32x4 AWaveXorU1(FfxUInt32x4 v, FfxUInt32 x) { return WaveReadLaneAt(v, WaveGetLaneIndex() ^ x); } +FfxBoolean AWaveIsFirstLane() +{ + return WaveIsFirstLane(); +} +FfxUInt32 AWaveLaneIndex() +{ + return WaveGetLaneIndex(); +} +FfxBoolean AWaveReadAtLaneIndexB1(FfxBoolean v, FfxUInt32 x) +{ + return WaveReadLaneAt(v, x); +} +FfxUInt32 AWavePrefixCountBits(FfxBoolean v) +{ + return WavePrefixCountBits(v); +} +FfxUInt32 AWaveActiveCountBits(FfxBoolean v) +{ + return WaveActiveCountBits(v); +} +FfxUInt32 AWaveReadLaneFirstU1(FfxUInt32 v) +{ + return WaveReadLaneFirst(v); +} +FfxUInt32 WaveOr(FfxUInt32 a) +{ + return WaveActiveBitOr(a); +} +FfxFloat32 WaveMin(FfxFloat32 a) +{ + return WaveActiveMin(a); +} +FfxFloat32 WaveMax(FfxFloat32 a) +{ + return WaveActiveMax(a); +} +FfxUInt32 WaveLaneCount() +{ + return WaveGetLaneCount(); +} +FfxBoolean WaveAllTrue(FfxBoolean v) +{ + return WaveActiveAllTrue(v); +} +FfxFloat32 QuadReadX(FfxFloat32 v) +{ + return QuadReadAcrossX(v); +} +FfxFloat32x2 QuadReadX(FfxFloat32x2 v) +{ + return QuadReadAcrossX(v); +} +FfxFloat32 QuadReadY(FfxFloat32 v) +{ + return QuadReadAcrossY(v); +} +FfxFloat32x2 QuadReadY(FfxFloat32x2 v) +{ + return QuadReadAcrossY(v); +} #if FFX_HALF FfxFloat16x2 ffxWaveXorFloat16x2(FfxFloat16x2 v, FfxUInt32 x) @@ -1496,7 +1645,7 @@ FfxUInt16x2 ffxWaveXorUint16x2(FfxUInt16x2 v, FfxUInt32 x) } FfxUInt16x4 ffxWaveXorUint16x4(FfxUInt16x4 v, FfxUInt32 x) { - return AW4_FFX_UINT32(WaveReadLaneAt(FFX_UINT32_AW4(v), WaveGetLaneIndex() ^ x)); + return FFX_UINT32X2_TO_UINT16X4(WaveReadLaneAt(FFX_UINT16X4_TO_UINT32X2(v), WaveGetLaneIndex() ^ x)); } #endif // FFX_HALF #endif // #if defined(FFX_WAVE) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta new file mode 100644 index 0000000..ff56bee --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 299f67e8b7e1d1a48a577bf8b328ac92 +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_core_portability.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h similarity index 94% rename from Assets/Resources/FSR2/shaders/ffx_core_portability.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h index 45be059..84a62d6 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core_portability.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,6 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + FfxFloat32x3 opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b) { d = a + ffxBroadcast3(b); diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta new file mode 100644 index 0000000..25ff64b --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 8d2ace0bd52e0e1438e08ddaccd3ba24 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h similarity index 90% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h index 7bd5892..c425de7 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_ACCUMULATE_H -#define FFX_FSR2_ACCUMULATE_H + +#ifndef FFX_FSR3UPSCALER_ACCUMULATE_H +#define FFX_FSR3UPSCALER_ACCUMULATE_H FfxFloat32 GetPxHrVelocity(FfxFloat32x2 fMotionVector) { @@ -36,9 +37,9 @@ FFX_MIN16_F GetPxHrVelocity(FFX_MIN16_F2 fMotionVector) void Accumulate(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT FfxFloat32x3 fHistoryColor, FfxFloat32x3 fAccumulation, FFX_PARAMETER_IN FfxFloat32x4 fUpsampledColorAndWeight) { // Aviod invalid values when accumulation and upsampled weight is 0 - fAccumulation = ffxMax(FSR2_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www); + fAccumulation = ffxMax(FSR3UPSCALER_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT //YCoCg -> RGB -> Tonemap -> YCoCg (Use RGB tonemapper to avoid color desaturation) fUpsampledColorAndWeight.xyz = RGBToYCoCg(Tonemap(YCoCgToRGB(fUpsampledColorAndWeight.xyz))); fHistoryColor = RGBToYCoCg(Tonemap(YCoCgToRGB(fHistoryColor))); @@ -49,7 +50,7 @@ void Accumulate(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT F fHistoryColor = YCoCgToRGB(fHistoryColor); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fHistoryColor = InverseTonemap(fHistoryColor); #endif } @@ -63,20 +64,13 @@ void RectifyHistory( FfxFloat32 fTemporalReactiveFactor, FfxFloat32 fLumaInstabilityFactor) { - FfxFloat32 fScaleFactorInfluence = ffxMin(20.0f, ffxPow(FfxFloat32(1.0f / length(DownscaleFactor().x * DownscaleFactor().y)), 3.0f)); - const FfxFloat32 fVecolityFactor = ffxSaturate(params.fHrVelocity / 20.0f); const FfxFloat32 fBoxScaleT = ffxMax(params.fDepthClipFactor, ffxMax(params.fAccumulationMask, fVecolityFactor)); - FfxFloat32 fBoxScale = ffxLerp(fScaleFactorInfluence, 1.0f, fBoxScaleT); - - FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale; - FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec; - FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec; - FfxFloat32x3 boxCenter = clippingBox.boxCenter; - FfxFloat32 boxVecSize = length(clippingBox.boxVec); + const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT); - boxMin = ffxMax(clippingBox.aabbMin, boxMin); - boxMax = ffxMin(clippingBox.aabbMax, boxMax); + const FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale; + const FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec; + const FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec; if (any(FFX_GREATER_THAN(boxMin, fHistoryColor)) || any(FFX_GREATER_THAN(fHistoryColor, boxMax))) { @@ -143,7 +137,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param FfxFloat32 fCurrentFrameLuma = clippingBox.boxCenter.x; -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fCurrentFrameLuma = fCurrentFrameLuma / (1.0f + ffxMax(0.0f, fCurrentFrameLuma)); #endif @@ -157,8 +151,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param FfxFloat32 fMin = abs(fDiffs0); - if (fMin >= fUnormThreshold) - { + if (fMin >= fUnormThreshold) { for (int i = N_MINUS_2; i <= N_MINUS_4; i++) { FfxFloat32 fDiffs1 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[i]); @@ -170,7 +163,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param } } - const FfxFloat32 fBoxSize = clippingBox.boxVec.x; + const FfxFloat32 fBoxSize = clippingBox.boxVec.x; const FfxFloat32 fBoxSizeFactor = ffxPow(ffxSaturate(fBoxSize / 0.1f), 6.0f); fLumaInstability = FfxFloat32(fMin != abs(fDiffs0)) * fBoxSizeFactor; @@ -202,7 +195,7 @@ FfxFloat32 ComputeTemporalReactiveFactor(const AccumulationPassCommonParams para fNewFactor = params.bIsNewSample ? 1.0f : fNewFactor; if (ffxSaturate(params.fHrVelocity * 10.0f) >= 1.0f) { - fNewFactor = ffxMax(FSR2_EPSILON, fNewFactor) * -1.0f; + fNewFactor = ffxMax(FSR3UPSCALER_EPSILON, fNewFactor) * -1.0f; } return fNewFactor; @@ -286,10 +279,10 @@ void Accumulate(FfxInt32x2 iPxHrPos) StoreInternalColorAndWeight(iPxHrPos, FfxFloat32x4(fHistoryColor, fTemporalReactiveFactor)); // Output final color when RCAS is disabled -#if FFX_FSR2_OPTION_APPLY_SHARPENING == 0 +#if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0 WriteUpscaledOutput(iPxHrPos, fHistoryColor); #endif StoreNewLocks(iPxHrPos, 0); } -#endif // FFX_FSR2_ACCUMULATE_H +#endif // FFX_FSR3UPSCALER_ACCUMULATE_H diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta new file mode 100644 index 0000000..08c98e7 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 3fc2f7a2c8c31324a949e1761bf599cc +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/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h new file mode 100644 index 0000000..c70bc1d --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h @@ -0,0 +1,928 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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_fsr3upscaler_resources.h" + +#if defined(FFX_GPU) +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic push +#pragma dxc diagnostic ignored "-Wambig-lit-shift" +#endif //__hlsl_dx_compiler +#include "ffx_core.h" +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic pop +#endif //__hlsl_dx_compiler +#endif // #if defined(FFX_GPU) + +#if defined(FFX_GPU) +#ifndef FFX_PREFER_WAVE64 +#define FFX_PREFER_WAVE64 +#endif // FFX_PREFER_WAVE64 + +#if defined(FFX_GPU) +#pragma warning(disable: 3205) // conversion from larger type to smaller +#endif // #if defined(FFX_GPU) + +#define DECLARE_SRV_REGISTER(regIndex) t##regIndex +#define DECLARE_UAV_REGISTER(regIndex) u##regIndex +#define DECLARE_CB_REGISTER(regIndex) b##regIndex +#define FFX_FSR3UPSCALER_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) +#define FFX_FSR3UPSCALER_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) +#define FFX_FSR3UPSCALER_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) + +#if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + cbuffer cbFSR3Upscaler : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + { + 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; + + FfxInt32 iDummy; + }; + +#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR3Upscaler) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR3Upscaler size. + +/* Define getter functions in the order they are defined in the CB! */ +FfxInt32x2 RenderSize() +{ + return iRenderSize; +} + +FfxInt32x2 MaxRenderSize() +{ + return iMaxRenderSize; +} + +FfxInt32x2 DisplaySize() +{ + return iDisplaySize; +} + +FfxInt32x2 InputColorResourceDimensions() +{ + return iInputColorResourceDimensions; +} + +FfxInt32x2 LumaMipDimensions() +{ + return iLumaMipDimensions; +} + +FfxInt32 LumaMipLevelToUse() +{ + return iLumaMipLevelToUse; +} + +FfxInt32 FrameIndex() +{ + return iFrameIndex; +} + +FfxFloat32x2 Jitter() +{ + return fJitter; +} + +FfxFloat32x4 DeviceToViewSpaceTransformFactors() +{ + return fDeviceToViewDepth; +} + +FfxFloat32x2 MotionVectorScale() +{ + return fMotionVectorScale; +} + +FfxFloat32x2 DownscaleFactor() +{ + return fDownscaleFactor; +} + +FfxFloat32x2 MotionVectorJitterCancellation() +{ + return fMotionVectorJitterCancellation; +} + +FfxFloat32 PreExposure() +{ + return fPreExposure; +} + +FfxFloat32 PreviousFramePreExposure() +{ + return fPreviousFramePreExposure; +} + +FfxFloat32 TanHalfFoV() +{ + return fTanHalfFOV; +} + +FfxFloat32 JitterSequenceLength() +{ + return fJitterSequenceLength; +} + +FfxFloat32 DeltaTime() +{ + return fDeltaTime; +} + +FfxFloat32 DynamicResChangeFactor() +{ + return fDynamicResChangeFactor; +} + +FfxFloat32 ViewSpaceToMetersFactor() +{ + return fViewSpaceToMetersFactor; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + +#define FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(p) FFX_FSR3UPSCALER_ROOTSIG_STR(p) +#define FFX_FSR3UPSCALER_ROOTSIG_STR(p) #p +#define FFX_FSR3UPSCALER_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", b0), " \ + "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ + "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] + +#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE 6 // Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size. + +#define FFX_FSR3UPSCALER_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", b0), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE) ", b1), " \ + "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ + "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] +#if defined(FFX_FSR3UPSCALER_EMBED_ROOTSIG) +#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT FFX_FSR3UPSCALER_ROOTSIG +#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT FFX_FSR3UPSCALER_CB2_ROOTSIG +#else +#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +#endif // #if FFX_FSR3UPSCALER_EMBED_ROOTSIG + +#if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) +cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) +{ + FfxFloat32 fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels + FfxFloat32 fTcScale; + FfxFloat32 fReactiveScale; + FfxFloat32 fReactiveMax; +}; + +FfxFloat32 TcThreshold() +{ + return fTcThreshold; +} + +FfxFloat32 TcScale() +{ + return fTcScale; +} + +FfxFloat32 ReactiveScale() +{ + return fReactiveScale; +} + +FfxFloat32 ReactiveMax() +{ + return fReactiveMax; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) + +#if defined(FSR3UPSCALER_BIND_CB_RCAS) +cbuffer cbRCAS : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_RCAS) +{ + FfxUInt32x4 rcasConfig; +}; + +FfxUInt32x4 RCASConfig() +{ + return rcasConfig; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_RCAS) + + +#if defined(FSR3UPSCALER_BIND_CB_REACTIVE) +cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_REACTIVE) +{ + FfxFloat32 gen_reactive_scale; + FfxFloat32 gen_reactive_threshold; + FfxFloat32 gen_reactive_binaryValue; + FfxUInt32 gen_reactive_flags; +}; + +FfxFloat32 GenReactiveScale() +{ + return gen_reactive_scale; +} + +FfxFloat32 GenReactiveThreshold() +{ + return gen_reactive_threshold; +} + +FfxFloat32 GenReactiveBinaryValue() +{ + return gen_reactive_binaryValue; +} + +FfxUInt32 GenReactiveFlags() +{ + return gen_reactive_flags; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_REACTIVE) + +#if defined(FSR3UPSCALER_BIND_CB_SPD) +cbuffer cbSPD : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_SPD) { + + FfxUInt32 mips; + FfxUInt32 numWorkGroups; + FfxUInt32x2 workGroupOffset; + FfxUInt32x2 renderSize; +}; + +FfxUInt32 MipCount() +{ + return mips; +} + +FfxUInt32 NumWorkGroups() +{ + return numWorkGroups; +} + +FfxUInt32x2 WorkGroupOffset() +{ + return workGroupOffset; +} + +FfxUInt32x2 SPD_RenderSize() +{ + return renderSize; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_SPD) + +// Declare and sample camera buffers as regular textures, unless overridden +#if !defined(UNITY_FSR3_TEX2D) +#define UNITY_FSR3_TEX2D(type) Texture2D +#endif +#if !defined(UNITY_FSR3_RWTEX2D) +#define UNITY_FSR3_RWTEX2D(type) RWTexture2D +#endif +#if !defined(UNITY_FSR3_POS) +#define UNITY_FSR3_POS(pxPos) (pxPos) +#endif +#if !defined(UNITY_FSR3_UV) +#define UNITY_FSR3_UV(uv) (uv) +#endif + +SamplerState s_PointClamp : register(s0); +SamplerState s_LinearClamp : register(s1); + + // SRVs + #if defined FSR3UPSCALER_BIND_SRV_INPUT_COLOR + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_DEPTH + UNITY_FSR3_TEX2D(FfxFloat32) r_input_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE + Texture2D r_input_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE + Texture2D r_auto_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_SRV_REACTIVE_MASK + Texture2D r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK); + #endif + #if defined FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK + Texture2D r_transparency_and_composition_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); + #endif + #if defined FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH + Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS + Texture2D r_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS + Texture2D r_previous_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_DEPTH + Texture2D r_dilated_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED + Texture2D r_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LOCK_STATUS + Texture2D r_lock_status : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_STATUS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA + Texture2D r_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA); + #endif + #if defined FSR3UPSCALER_BIND_SRV_NEW_LOCKS + Texture2D r_new_locks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_NEW_LOCKS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR + Texture2D r_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LUMA_HISTORY + Texture2D r_luma_history : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY); + #endif + #if defined FSR3UPSCALER_BIND_SRV_RCAS_INPUT + Texture2D r_rcas_input : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RCAS_INPUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LANCZOS_LUT + Texture2D r_lanczos_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS + Texture2D r_imgMips : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT + Texture2D r_upsample_maximum_bias_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS + Texture2D r_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS); + #endif + + #if defined FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR + Texture2D r_input_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR + Texture2D r_input_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); + #endif + + // UAV declarations + #if defined FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH + RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS + RWTexture2D rw_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_DEPTH + RWTexture2D rw_dilated_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED + RWTexture2D rw_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LOCK_STATUS + RWTexture2D rw_lock_status : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_STATUS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA + RWTexture2D rw_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA); + #endif + #if defined FSR3UPSCALER_BIND_UAV_NEW_LOCKS + RWTexture2D rw_new_locks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_NEW_LOCKS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR + RWTexture2D rw_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LUMA_HISTORY + RWTexture2D rw_luma_history : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY); + #endif + #if defined FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT + UNITY_FSR3_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS + RWTexture2D rw_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE + RWTexture2D rw_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + RWTexture2D rw_auto_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC); + #endif + + #if defined FSR3UPSCALER_BIND_UAV_AUTOREACTIVE + RWTexture2D rw_output_autoreactive : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION + RWTexture2D rw_output_autocomposition : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR + RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR + RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR); + #endif + +#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS) +FfxFloat32 LoadMipLuma(FfxUInt32x2 iPxPos, FfxUInt32 mipLevel) +{ + return r_imgMips.mips[mipLevel][iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS) +FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) +{ + return r_imgMips.SampleLevel(s_LinearClamp, fUV, mipLevel); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) +FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) +{ + return r_input_depth[UNITY_FSR3_POS(iPxPos)]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) +FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) +{ + return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).x; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK) +FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) +{ + return r_reactive_mask[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) +FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) +{ + return r_transparency_and_composition_mask[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) +FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) +{ + return r_input_color_jittered[UNITY_FSR3_POS(iPxPos)].rgb; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) +FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) +{ + return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).rgb; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR) +FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos) +{ + return r_prepared_input_color[iPxPos].xyz; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS) +FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) +{ + FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR3_POS(iPxDilatedMotionVectorPos)].xy; + + FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); + +#if FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS + fUvMotionVector -= MotionVectorJitterCancellation(); +#endif + + return fUvMotionVector; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED) +FfxFloat32x4 LoadHistory(FfxUInt32x2 iPxHistory) +{ + return r_internal_upscaled_color[iPxHistory]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY) +void StoreLumaHistory(FfxUInt32x2 iPxPos, FfxFloat32x4 fLumaHistory) +{ + rw_luma_history[iPxPos] = fLumaHistory; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY) +FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV) +{ + return r_luma_history.SampleLevel(s_LinearClamp, fUV, 0); +} +#endif + +FfxFloat32x4 LoadRCAS_Input(FfxInt32x2 iPxPos) +{ +#if defined(FSR3UPSCALER_BIND_SRV_RCAS_INPUT) + return r_rcas_input[iPxPos]; +#else + return 0.0; +#endif +} + +#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED) +void StoreReprojectedHistory(FfxUInt32x2 iPxHistory, FfxFloat32x4 fHistory) +{ + rw_internal_upscaled_color[iPxHistory] = fHistory; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED) +void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight) +{ + rw_internal_upscaled_color[iPxPos] = fColorAndWeight; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT) +void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) +{ + rw_upscaled_output[UNITY_FSR3_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); +} +#endif + +//LOCK_LIFETIME_REMAINING == 0 +//Should make LockInitialLifetime() return a const 1.0f later +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS) +FfxFloat32x2 LoadLockStatus(FfxUInt32x2 iPxPos) +{ + return r_lock_status[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LOCK_STATUS) +void StoreLockStatus(FfxUInt32x2 iPxPos, FfxFloat32x2 fLockStatus) +{ + rw_lock_status[iPxPos] = fLockStatus; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA) +FfxFloat32 LoadLockInputLuma(FfxUInt32x2 iPxPos) +{ + return r_lock_input_luma[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA) +void StoreLockInputLuma(FfxUInt32x2 iPxPos, FfxFloat32 fLuma) +{ + rw_lock_input_luma[iPxPos] = fLuma; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_NEW_LOCKS) +FfxFloat32 LoadNewLocks(FfxUInt32x2 iPxPos) +{ + return r_new_locks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS) +FfxFloat32 LoadRwNewLocks(FfxUInt32x2 iPxPos) +{ + return rw_new_locks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS) +void StoreNewLocks(FfxUInt32x2 iPxPos, FfxFloat32 newLock) +{ + rw_new_locks[iPxPos] = newLock; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR) +void StorePreparedInputColor(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped) +{ + rw_prepared_input_color[iPxPos] = fTonemapped; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR) +FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV) +{ + return r_prepared_input_color.SampleLevel(s_LinearClamp, fUV, 0).w; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS) +FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV) +{ + FfxFloat32x2 fLockStatus = r_lock_status.SampleLevel(s_LinearClamp, fUV, 0); + return fLockStatus; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +FfxFloat32 LoadReconstructedPrevDepth(FfxUInt32x2 iPxPos) +{ + return asfloat(r_reconstructed_previous_nearest_depth[iPxPos]); +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +void StoreReconstructedDepth(FfxUInt32x2 iPxSample, FfxFloat32 fDepth) +{ + FfxUInt32 uDepth = asuint(fDepth); + + #if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH + InterlockedMax(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); + #else + InterlockedMin(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); // min for standard, max for inverted depth + #endif +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +void SetReconstructedDepth(FfxUInt32x2 iPxSample, const FfxUInt32 uValue) +{ + rw_reconstructed_previous_nearest_depth[iPxSample] = uValue; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH) +void StoreDilatedDepth(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth) +{ + rw_dilated_depth[iPxPos] = fDepth; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS) +void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector) +{ + rw_dilated_motion_vectors[iPxPos] = fMotionVector; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS) +FfxFloat32x2 LoadDilatedMotionVector(FfxUInt32x2 iPxInput) +{ + return r_dilated_motion_vectors[iPxInput].xy; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) +FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxUInt32x2 iPxInput) +{ + return r_previous_dilated_motion_vectors[iPxInput].xy; +} + +FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 uv) +{ + return r_previous_dilated_motion_vectors.SampleLevel(s_LinearClamp, uv, 0).xy; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH) +FfxFloat32 LoadDilatedDepth(FfxUInt32x2 iPxInput) +{ + return r_dilated_depth[iPxInput]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE) +FfxFloat32 Exposure() +{ + FfxFloat32 exposure = r_input_exposure[FfxUInt32x2(0, 0)].x; + + if (exposure == 0.0f) { + exposure = 1.0f; + } + + return exposure; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE) +FfxFloat32 AutoExposure() +{ + FfxFloat32 exposure = r_auto_exposure[FfxUInt32x2(0, 0)].x; + + if (exposure == 0.0f) { + exposure = 1.0f; + } + + return exposure; +} +#endif + +FfxFloat32 SampleLanczos2Weight(FfxFloat32 x) +{ +#if defined(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT) + return r_lanczos_lut.SampleLevel(s_LinearClamp, FfxFloat32x2(x / 2, 0.5f), 0); +#else + return 0.f; +#endif +} + +#if defined(FSR3UPSCALER_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.0) * r_upsample_maximum_bias_lut.SampleLevel(s_LinearClamp, abs(uv) * 2.0, 0); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS) +FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV) +{ + return r_dilated_reactive_masks.SampleLevel(s_LinearClamp, fUV, 0); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS) +FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos) +{ + return r_dilated_reactive_masks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS) +void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks) +{ + rw_dilated_reactive_masks[iPxPos] = fDilatedReactiveMasks; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY) +FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_opaque_only[UNITY_FSR3_POS(iPxPos)].xyz; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR) +FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_prev_color_pre_alpha[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR) +FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_prev_color_post_alpha[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE) +#if defined(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION) +void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive) +{ + rw_output_autoreactive[iPxPos] = fReactive.x; + + rw_output_autocomposition[iPxPos] = fReactive.y; +} +#endif +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR) +void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) +{ + rw_output_prev_color_pre_alpha[iPxPos] = color; + +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR) +void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) +{ + rw_output_prev_color_post_alpha[iPxPos] = color; +} +#endif + +FfxFloat32x2 SPD_LoadExposureBuffer() +{ +#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + return rw_auto_exposure[FfxInt32x2(0, 0)]; +#else + return FfxFloat32x2(0.f, 0.f); +#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE +} + +void SPD_SetExposureBuffer(FfxFloat32x2 value) +{ +#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + rw_auto_exposure[FfxInt32x2(0, 0)] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE +} + +FfxFloat32x4 SPD_LoadMipmap5(FfxInt32x2 iPxPos) +{ +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + return FfxFloat32x4(rw_img_mip_5[iPxPos], 0, 0, 0); +#else + return FfxFloat32x4(0.f, 0.f, 0.f, 0.f); +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 +} + +void SPD_SetMipmap(FfxInt32x2 iPxPos, FfxUInt32 slice, FfxFloat32 value) +{ + switch (slice) + { + case FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL: +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + rw_img_mip_shading_change[iPxPos] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + break; + case 5: +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + rw_img_mip_5[iPxPos] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + break; + default: + + // avoid flattened side effect +#if defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE) + rw_img_mip_shading_change[iPxPos] = rw_img_mip_shading_change[iPxPos]; +#elif defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5) + rw_img_mip_5[iPxPos] = rw_img_mip_5[iPxPos]; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + break; + } +} + +void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter) +{ +#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + InterlockedAdd(rw_spd_global_atomic[FfxInt32x2(0, 0)], 1, spdCounter); +#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC +} + +void SPD_ResetAtomicCounter() +{ +#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + rw_spd_global_atomic[FfxInt32x2(0, 0)] = 0; +#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC +} + +#endif // #if defined(FFX_GPU) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta new file mode 100644 index 0000000..e060d2c --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: ba849fdeb042e7f458c81408414db834 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h similarity index 91% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h index 0c72aa8..1f78a29 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if !defined(FFX_FSR2_COMMON_H) -#define FFX_FSR2_COMMON_H + +#if !defined(FFX_FSR3UPSCALER_COMMON_H) +#define FFX_FSR3UPSCALER_COMMON_H #if defined(FFX_CPU) || defined(FFX_GPU) //Locks @@ -29,12 +30,12 @@ #endif // #if defined(FFX_CPU) || defined(FFX_GPU) #if defined(FFX_GPU) -FFX_STATIC const FfxFloat32 FSR2_FP16_MIN = 6.10e-05f; -FFX_STATIC const FfxFloat32 FSR2_FP16_MAX = 65504.0f; -FFX_STATIC const FfxFloat32 FSR2_EPSILON = 1e-03f; -FFX_STATIC const FfxFloat32 FSR2_TONEMAP_EPSILON = 1.0f / FSR2_FP16_MAX; -FFX_STATIC const FfxFloat32 FSR2_FLT_MAX = 3.402823466e+38f; -FFX_STATIC const FfxFloat32 FSR2_FLT_MIN = 1.175494351e-38f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MIN = 6.10e-05f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MAX = 65504.0f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_EPSILON = 1e-03f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_TONEMAP_EPSILON = 1.0f / FSR3UPSCALER_FP16_MAX; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MAX = 3.402823466e+38f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MIN = 1.175494351e-38f; // treat vector truncation warnings as errors #pragma warning(error: 3206) @@ -128,8 +129,8 @@ void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBox rectificationBox rectificationBox.boxCenter = FfxFloat32x3(0, 0, 0); rectificationBox.boxVec = FfxFloat32x3(0, 0, 0); - rectificationBox.aabbMin = FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX); - rectificationBox.aabbMax = -FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX); + rectificationBox.aabbMin = FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX); + rectificationBox.aabbMax = -FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX); } #if FFX_HALF void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox) @@ -138,8 +139,8 @@ void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificati rectificationBox.boxCenter = FFX_MIN16_F3(0, 0, 0); rectificationBox.boxVec = FFX_MIN16_F3(0, 0, 0); - rectificationBox.aabbMin = FFX_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX); - rectificationBox.aabbMax = -FFX_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX); + rectificationBox.aabbMin = FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX); + rectificationBox.aabbMax = -FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX); } #endif @@ -198,7 +199,7 @@ void RectificationBoxAddSample(FfxBoolean bInitialSample, FFX_PARAMETER_INOUT Re void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBox rectificationBox) { - rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f)); + rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f)); rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight; rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight; FfxFloat32x3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter)); @@ -207,7 +208,7 @@ void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBox #if FFX_HALF void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox) { - rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFX_MIN16_F(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FFX_MIN16_F(1.f)); + rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFX_MIN16_F(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FFX_MIN16_F(1.f)); rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight; rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight; FFX_MIN16_F3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter)); @@ -339,7 +340,7 @@ FfxFloat32x3 Tonemap(FfxFloat32x3 fRgb) FfxFloat32x3 InverseTonemap(FfxFloat32x3 fRgb) { - return fRgb / ffxMax(FSR2_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; + return fRgb / ffxMax(FSR3UPSCALER_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; } #if FFX_HALF @@ -350,7 +351,7 @@ FFX_MIN16_F3 Tonemap(FFX_MIN16_F3 fRgb) FFX_MIN16_F3 InverseTonemap(FFX_MIN16_F3 fRgb) { - return fRgb / ffxMax(FFX_MIN16_F(FSR2_TONEMAP_EPSILON), FFX_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; + return fRgb / ffxMax(FFX_MIN16_F(FSR3UPSCALER_TONEMAP_EPSILON), FFX_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; } #endif @@ -454,7 +455,7 @@ FfxFloat32 GetViewSpaceDepth(FfxFloat32 fDeviceDepth) { const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors(); - // fDeviceToViewDepth details found in ffx_fsr2.cpp + // fDeviceToViewDepth details found in ffx_fsr3upscaler.cpp return (fDeviceToViewDepth[1] / (fDeviceDepth - fDeviceToViewDepth[0])); } @@ -483,7 +484,7 @@ FfxFloat32x3 GetViewSpacePositionInMeters(FfxInt32x2 iViewportPos, FfxInt32x2 iV FfxFloat32 GetMaxDistanceInMeters() { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH return GetViewSpaceDepth(0.0f) * ViewSpaceToMetersFactor(); #else return GetViewSpaceDepth(1.0f) * ViewSpaceToMetersFactor(); @@ -495,7 +496,7 @@ FfxFloat32x3 PrepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure, FfxFloat32 fPre fRgb /= fPreExposure; fRgb *= fExposure; - fRgb = clamp(fRgb, 0.0f, FSR2_FP16_MAX); + fRgb = clamp(fRgb, 0.0f, FSR3UPSCALER_FP16_MAX); return fRgb; } @@ -562,4 +563,4 @@ FfxFloat32 PointToPlaneDistance(PlaneData plane, FfxFloat32x3 fPoint) #endif // #if defined(FFX_GPU) -#endif //!defined(FFX_FSR2_COMMON_H) +#endif //!defined(FFX_FSR3UPSCALER_COMMON_H) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta new file mode 100644 index 0000000..2ebe2aa --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 6a638bec681caac4fa8e2ca198726694 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h similarity index 85% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h index c63f182..d26cf23 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,24 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + FFX_GROUPSHARED FfxUInt32 spdCounter; +void SpdIncreaseAtomicCounter(FfxUInt32 slice) +{ + SPD_IncreaseAtomicCounter(spdCounter); +} + +FfxUInt32 SpdGetAtomicCounter() +{ + return spdCounter; +} + +void SpdResetAtomicCounter(FfxUInt32 slice) +{ + SPD_ResetAtomicCounter(); +} + #ifndef SPD_PACKED_ONLY FFX_GROUPSHARED FfxFloat32 spdIntermediateR[16][16]; FFX_GROUPSHARED FfxFloat32 spdIntermediateG[16][16]; @@ -36,7 +52,7 @@ FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 tex, FfxUInt32 slice) fRgb /= PreExposure(); //compute log luma - const FfxFloat32 fLogLuma = log(ffxMax(FSR2_EPSILON, RGBToLuma(fRgb))); + const FfxFloat32 fLogLuma = log(ffxMax(FSR3UPSCALER_EPSILON, RGBToLuma(fRgb))); // Make sure out of screen pixels contribute no value to the end result const FfxFloat32 result = all(FFX_LESS_THAN(tex, RenderSize())) ? fLogLuma : 0.0f; @@ -74,21 +90,6 @@ void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 } } -void SpdIncreaseAtomicCounter(FfxUInt32 slice) -{ - SPD_IncreaseAtomicCounter(spdCounter); -} - -FfxUInt32 SpdGetAtomicCounter() -{ - return spdCounter; -} - -void SpdResetAtomicCounter(FfxUInt32 slice) -{ - SPD_ResetAtomicCounter(); -} - FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) { return FfxFloat32x4( @@ -112,40 +113,24 @@ FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFl // define fetch and store functions Packed #if FFX_HALF -#error Callback must be implemented FFX_GROUPSHARED FfxFloat16x2 spdIntermediateRG[16][16]; FFX_GROUPSHARED FfxFloat16x2 spdIntermediateBA[16][16]; FfxFloat16x4 SpdLoadSourceImageH(FfxFloat32x2 tex, FfxUInt32 slice) { - return FfxFloat16x4(imgDst[0][FfxFloat32x3(tex, slice)]); + return FfxFloat16x4(0, 0, 0, 0); } + FfxFloat16x4 SpdLoadH(FfxInt32x2 p, FfxUInt32 slice) { - return FfxFloat16x4(imgDst6[FfxUInt32x3(p, slice)]); + return FfxFloat16x4(0, 0, 0, 0); } + void SpdStoreH(FfxInt32x2 p, FfxFloat16x4 value, FfxUInt32 mip, FfxUInt32 slice) { - if (index == LumaMipLevelToUse() || index == 5) - { - imgDst6[FfxUInt32x3(p, slice)] = FfxFloat32x4(value); - return; - } - imgDst[mip + 1][FfxUInt32x3(p, slice)] = FfxFloat32x4(value); -} -void SpdIncreaseAtomicCounter(FfxUInt32 slice) -{ - InterlockedAdd(rw_spd_global_atomic[FfxInt16x2(0, 0)].counter[slice], 1, spdCounter); -} -FfxUInt32 SpdGetAtomicCounter() -{ - return spdCounter; -} -void SpdResetAtomicCounter(FfxUInt32 slice) -{ - rw_spd_global_atomic[FfxInt16x2(0, 0)].counter[slice] = 0; } + FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y) { return FfxFloat16x4( @@ -154,18 +139,20 @@ FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y) spdIntermediateBA[x][y].x, spdIntermediateBA[x][y].y); } + void SpdStoreIntermediateH(FfxUInt32 x, FfxUInt32 y, FfxFloat16x4 value) { spdIntermediateRG[x][y] = value.xy; spdIntermediateBA[x][y] = value.zw; } + FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxFloat16x4 v3) { return (v0 + v1 + v2 + v3) * FfxFloat16(0.25); } #endif -#include "ffx_spd.h" +#include "spd/ffx_spd.h" void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex) { @@ -186,4 +173,4 @@ void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex) FfxUInt32(WorkGroupId.z), FfxUInt32x2(WorkGroupOffset())); #endif -} \ No newline at end of file +} diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta new file mode 100644 index 0000000..9f1d2ab --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 61bd10363d44ee2478461c9e9efbcb67 +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_depth_clip.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h similarity index 97% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h index fa4c975..53763c8 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_depth_clip.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_DEPTH_CLIP_H -#define FFX_FSR2_DEPTH_CLIP_H + +#ifndef FFX_FSR3UPSCALER_DEPTH_CLIP_H +#define FFX_FSR3UPSCALER_DEPTH_CLIP_H FFX_STATIC const FfxFloat32 DepthClipBaseScale = 4.0f; @@ -48,7 +49,7 @@ FfxFloat32 ComputeDepthClip(FfxFloat32x2 fUvSample, FfxFloat32 fCurrentDepthSamp if (fDepthDiff > 0.0f) { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH const FfxFloat32 fPlaneDepth = ffxMin(fPrevDepthSample, fCurrentDepthSample); #else const FfxFloat32 fPlaneDepth = ffxMax(fPrevDepthSample, fCurrentDepthSample); @@ -243,7 +244,7 @@ void DepthClip(FfxInt32x2 iPxPos) StorePreparedInputColor(iPxPos, FfxFloat32x4(fPreparedYCoCg, fDepthClip)); // Compute dilated reactive mask -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxInt32x2 iSamplePos = iPxPos; #else FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxPos); @@ -255,4 +256,4 @@ void DepthClip(FfxInt32x2 iPxPos) PreProcessReactiveMasks(iPxPos, ffxMax(fTemporalMotionDifference, fMotionDivergence)); } -#endif //!defined( FFX_FSR2_DEPTH_CLIPH ) \ No newline at end of file +#endif //!defined( FFX_FSR3UPSCALER_DEPTH_CLIPH ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta new file mode 100644 index 0000000..21fe627 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 7c662249d70c4434da4f2da00e432c38 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h similarity index 91% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h index 8347fa8..e1a0d06 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,14 +19,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_LOCK_H -#define FFX_FSR2_LOCK_H + +#ifndef FFX_FSR3UPSCALER_LOCK_H +#define FFX_FSR3UPSCALER_LOCK_H void ClearResourcesForNextFrame(in FfxInt32x2 iPxHrPos) { if (all(FFX_LESS_THAN(iPxHrPos, FfxInt32x2(RenderSize())))) { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH const FfxUInt32 farZ = 0x0; #else const FfxUInt32 farZ = 0x3f800000; @@ -42,7 +43,7 @@ FfxBoolean ComputeThinFeatureConfidence(FfxInt32x2 pos) FfxFloat32 fNucleus = LoadLockInputLuma(pos); FfxFloat32 similar_threshold = 1.05f; - FfxFloat32 dissimilarLumaMin = FSR2_FLT_MAX; + FfxFloat32 dissimilarLumaMin = FSR3UPSCALER_FLT_MAX; FfxFloat32 dissimilarLumaMax = 0; /* @@ -109,7 +110,7 @@ void ComputeLock(FfxInt32x2 iPxLrPos) StoreNewLocks(ComputeHrPosFromLrPos(iPxLrPos), 1.f); } - ClearResourcesForNextFrame(iPxLrPos); + // ClearResourcesForNextFrame(iPxLrPos); } -#endif // FFX_FSR2_LOCK_H +#endif // FFX_FSR3UPSCALER_LOCK_H diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta new file mode 100644 index 0000000..38a5a57 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: c7e9f53dd040b2645af5ccd936a94b0e +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_postprocess_lock_status.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h similarity index 91% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h index cee9e14..3709113 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_POSTPROCESS_LOCK_STATUS_H -#define FFX_FSR2_POSTPROCESS_LOCK_STATUS_H + +#ifndef FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H +#define FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H FfxFloat32x4 WrapShadingChangeLuma(FfxInt32x2 iPxSample) { @@ -34,7 +35,7 @@ FFX_MIN16_F4 WrapShadingChangeLuma(FFX_MIN16_I2 iPxSample) } #endif -#if FFX_FSR2_OPTION_POSTPROCESSLOCKSTATUS_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_POSTPROCESSLOCKSTATUS_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBilinearSamplesMin16(FetchShadingChangeLumaSamples, WrapShadingChangeLuma) #else DeclareCustomFetchBicubicSamples(FetchShadingChangeLumaSamples, WrapShadingChangeLuma) @@ -49,7 +50,7 @@ FfxFloat32 GetShadingChangeLuma(FfxInt32x2 iPxHrPos, FfxFloat32x2 fUvCoord) fShadingChangeLuma = Exposure() * exp(ShadingChangeLumaSample(fUvCoord, LumaMipDimensions()).x); #else - const FfxFloat32 fDiv = FfxFloat32(2 << LumaMipLevelToUse()); + const FfxFloat32 fDiv = FfxFloat32(2u << LumaMipLevelToUse()); FfxInt32x2 iMipRenderSize = FfxInt32x2(RenderSize() / fDiv); fUvCoord = ClampUv(fUvCoord, iMipRenderSize, LumaMipDimensions()); @@ -103,4 +104,4 @@ void UpdateLockStatus(AccumulationPassCommonParams params, fLockContributionThisFrame = ffxSaturate(ffxSaturate(fLifetimeContribution * 4.0f) * fShadingChangeContribution); } -#endif //!defined( FFX_FSR2_POSTPROCESS_LOCK_STATUS_H ) +#endif //!defined( FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta new file mode 100644 index 0000000..f8b5616 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 67a8b72ceb93d634f883b086fdccb348 +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_rcas.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h similarity index 93% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_rcas.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h index d9006cd..77619a5 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_rcas.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,16 +19,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#define GROUP_SIZE 8 +#define GROUP_SIZE 8 #define FSR_RCAS_DENOISE 1 +#include "ffx_core.h" + void WriteUpscaledOutput(FFX_MIN16_U2 iPxHrPos, FfxFloat32x3 fUpscaledColor) { StoreUpscaledOutput(FFX_MIN16_I2(iPxHrPos), fUpscaledColor); } -#define FSR_RCAS_F +#define FSR_RCAS_F 1 FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p) { FfxFloat32x4 fColor = LoadRCAS_Input(p); @@ -37,11 +39,9 @@ FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p) return fColor; } - void FsrRcasInputF(inout FfxFloat32 r, inout FfxFloat32 g, inout FfxFloat32 b) {} -#include "ffx_fsr1.h" - +#include "fsr1/ffx_fsr1.h" void CurrFilter(FFX_MIN16_U2 pos) { diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta new file mode 100644 index 0000000..7a53a1f --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 692efb7cec0df67408a583a7ff34146a +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_reconstruct_dilated_velocity_and_previous_depth.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h similarity index 91% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h index e9ccc4b..a822dfc 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H -#define FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H + +#ifndef FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H +#define FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H void ReconstructPrevDepth(FfxInt32x2 iPxPos, FfxFloat32 fDepth, FfxFloat32x2 fMotionVector, FfxInt32x2 iPxDepthSize) { @@ -83,7 +84,7 @@ void FindNearestDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxIn if (IsOnScreen(iPos, iPxSize)) { FfxFloat32 fNdDepth = depth[iSampleIndex]; -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH if (fNdDepth > fNearestDepth) { #else if (fNdDepth < fNearestDepth) { @@ -105,7 +106,7 @@ FfxFloat32 ComputeLockInputLuma(FfxInt32x2 iPxLrPos) fRgb /= PreExposure(); fRgb *= Exposure(); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fRgb = Tonemap(fRgb); #endif @@ -122,7 +123,7 @@ void ReconstructAndDilate(FfxInt32x2 iPxLrPos) FindNearestDepth(iPxLrPos, RenderSize(), fDilatedDepth, iNearestDepthCoord); -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxInt32x2 iSamplePos = iPxLrPos; FfxInt32x2 iMotionVectorPos = iNearestDepthCoord; #else @@ -142,4 +143,4 @@ void ReconstructAndDilate(FfxInt32x2 iPxLrPos) } -#endif //!defined( FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H ) +#endif //!defined( FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta new file mode 100644 index 0000000..78ced0d --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: c8b3854bad30a8b40babc5a9805f294e +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h similarity index 77% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h index f7f3961..29b7584 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,11 +19,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_REPROJECT_H -#define FFX_FSR2_REPROJECT_H -#ifndef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 0 // Reference +#ifndef FFX_FSR3UPSCALER_REPROJECT_H +#define FFX_FSR3UPSCALER_REPROJECT_H + +#ifndef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE 0 // Reference #endif FfxFloat32x4 WrapHistory(FfxInt32x2 iPxSample) @@ -39,12 +40,12 @@ FFX_MIN16_F4 WrapHistory(FFX_MIN16_I2 iPxSample) #endif -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBicubicSamplesMin16(FetchHistorySamples, WrapHistory) -DeclareCustomTextureSampleMin16(HistorySample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) +DeclareCustomTextureSampleMin16(HistorySample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) #else DeclareCustomFetchBicubicSamples(FetchHistorySamples, WrapHistory) -DeclareCustomTextureSample(HistorySample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) +DeclareCustomTextureSample(HistorySample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) #endif FfxFloat32x4 WrapLockStatus(FfxInt32x2 iPxSample) @@ -63,7 +64,7 @@ FFX_MIN16_F4 WrapLockStatus(FFX_MIN16_I2 iPxSample) #endif #if 1 -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBilinearSamplesMin16(FetchLockStatusSamples, WrapLockStatus) DeclareCustomTextureSampleMin16(LockStatusSample, Bilinear, FetchLockStatusSamples) #else @@ -71,18 +72,18 @@ DeclareCustomFetchBilinearSamples(FetchLockStatusSamples, WrapLockStatus) DeclareCustomTextureSample(LockStatusSample, Bilinear, FetchLockStatusSamples) #endif #else -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBicubicSamplesMin16(FetchLockStatusSamples, WrapLockStatus) -DeclareCustomTextureSampleMin16(LockStatusSample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) +DeclareCustomTextureSampleMin16(LockStatusSample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) #else DeclareCustomFetchBicubicSamples(FetchLockStatusSamples, WrapLockStatus) -DeclareCustomTextureSample(LockStatusSample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) +DeclareCustomTextureSample(LockStatusSample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) #endif #endif FfxFloat32x2 GetMotionVector(FfxInt32x2 iPxHrPos, FfxFloat32x2 fHrUv) { -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxFloat32x2 fDilatedMotionVector = LoadDilatedMotionVector(FFX_MIN16_I2(fHrUv * RenderSize())); #else FfxFloat32x2 fDilatedMotionVector = LoadInputMotionVector(iPxHrPos); @@ -133,4 +134,4 @@ LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, return state; } -#endif //!defined( FFX_FSR2_REPROJECT_H ) +#endif //!defined( FFX_FSR3UPSCALER_REPROJECT_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta new file mode 100644 index 0000000..ea2e14d --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 9d893016eebb2564f9a66b80afb0849f +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/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h new file mode 100644 index 0000000..d98cfcc --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h @@ -0,0 +1,104 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#ifndef FFX_FSR3UPSCALER_RESOURCES_H +#define FFX_FSR3UPSCALER_RESOURCES_H + +#if defined(FFX_CPU) || defined(FFX_GPU) +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL 0 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_COLOR 2 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_DEPTH 4 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_DEPTH 10 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS 12 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NEW_LOCKS 13 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY 15 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LANCZOS_LUT 17 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RCAS_INPUT 20 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOREACTIVE 44 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOCOMPOSITION_DEPRECATED 45 + +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR 46 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR 47 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_1 48 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_1 49 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_2 50 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_2 51 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 52 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 53 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 54 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 55 + +// Shading change detection mip level setting, value must be in the range [FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12] +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 +#define FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL (FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE) + +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT 56 + +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_FSR3UPSCALER 0 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_SPD 1 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_RCAS 2 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3 + +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8 + +#endif // #if defined(FFX_CPU) || defined(FFX_GPU) + +#endif //!defined( FFX_FSR3UPSCALER_RESOURCES_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta new file mode 100644 index 0000000..24cdbd2 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: b5a95a38dcfaf3946a5095bbbc42939a +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h similarity index 96% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h index f94f40a..d33f70c 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_SAMPLE_H -#define FFX_FSR2_SAMPLE_H + +#ifndef FFX_FSR3UPSCALER_SAMPLE_H +#define FFX_FSR3UPSCALER_SAMPLE_H // suppress warnings #ifdef FFX_HLSL @@ -127,7 +128,7 @@ FFX_MIN16_F4 Bilinear(FetchedBilinearSamplesMin16 BilinearSamples, FFX_MIN16_F2 FfxFloat32 Lanczos2NoClamp(FfxFloat32 x) { const FfxFloat32 PI = 3.141592653589793f; // TODO: share SDK constants - return abs(x) < FSR2_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); + return abs(x) < FSR3UPSCALER_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); } FfxFloat32 Lanczos2(FfxFloat32 x) @@ -142,7 +143,7 @@ FfxFloat32 Lanczos2(FfxFloat32 x) FFX_MIN16_F Lanczos2NoClamp(FFX_MIN16_F x) { const FFX_MIN16_F PI = FFX_MIN16_F(3.141592653589793f); // TODO: share SDK constants - return abs(x) < FFX_MIN16_F(FSR2_EPSILON) ? FFX_MIN16_F(1.f) : (sin(PI * x) / (PI * x)) * (sin(FFX_MIN16_F(0.5f) * PI * x) / (FFX_MIN16_F(0.5f) * PI * x)); + return abs(x) < FFX_MIN16_F(FSR3UPSCALER_EPSILON) ? FFX_MIN16_F(1.f) : (sin(PI * x) / (PI * x)) * (sin(FFX_MIN16_F(0.5f) * PI * x) / (FFX_MIN16_F(0.5f) * PI * x)); } #endif @@ -594,12 +595,12 @@ FFX_MIN16_I2 ClampCoord(FFX_MIN16_I2 iPxSample, FFX_MIN16_I2 iPxOffset, FFX_MIN1 return fColorXY; \ } -#define FFX_FSR2_CONCAT_ID(x, y) x ## y -#define FFX_FSR2_CONCAT(x, y) FFX_FSR2_CONCAT_ID(x, y) -#define FFX_FSR2_SAMPLER_1D_0 Lanczos2 -#define FFX_FSR2_SAMPLER_1D_1 Lanczos2LUT -#define FFX_FSR2_SAMPLER_1D_2 Lanczos2Approx +#define FFX_FSR3UPSCALER_CONCAT_ID(x, y) x ## y +#define FFX_FSR3UPSCALER_CONCAT(x, y) FFX_FSR3UPSCALER_CONCAT_ID(x, y) +#define FFX_FSR3UPSCALER_SAMPLER_1D_0 Lanczos2 +#define FFX_FSR3UPSCALER_SAMPLER_1D_1 Lanczos2LUT +#define FFX_FSR3UPSCALER_SAMPLER_1D_2 Lanczos2Approx -#define FFX_FSR2_GET_LANCZOS_SAMPLER1D(x) FFX_FSR2_CONCAT(FFX_FSR2_SAMPLER_1D_, x) +#define FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(x) FFX_FSR3UPSCALER_CONCAT(FFX_FSR3UPSCALER_SAMPLER_1D_, x) -#endif //!defined( FFX_FSR2_SAMPLE_H ) +#endif //!defined( FFX_FSR3UPSCALER_SAMPLE_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta new file mode 100644 index 0000000..1a46376 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: dcb900c9deecd06419a8a4c10c305890 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h similarity index 99% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h index 101b75d..2d446bb 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h @@ -52,7 +52,7 @@ FFX_MIN16_F ComputeAutoTC_01(FFX_MIN16_I2 uDispatchThreadId, FFX_MIN16_I2 iPrevI FFX_MIN16_F retVal = FFX_MIN16_F(ffxSaturate(dot(abs(abs(Y - X) - abs(W - Z)), FfxFloat32x3(1, 1, 1)))); // cleanup very small values - retVal = (retVal < getTcThreshold()) ? FFX_MIN16_F(0.0f) : FFX_MIN16_F(1.f); + retVal = (retVal < TcThreshold()) ? FFX_MIN16_F(0.0f) : FFX_MIN16_F(1.f); return retVal; } diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta new file mode 100644 index 0000000..99d54e7 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: f01d5a8fbd1f34a4ea8d971755a21b6c +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_upsample.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h similarity index 85% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_upsample.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h index abdb888..47e7ccf 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_upsample.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_UPSAMPLE_H -#define FFX_FSR2_UPSAMPLE_H + +#ifndef FFX_FSR3UPSCALER_UPSAMPLE_H +#define FFX_FSR3UPSCALER_UPSAMPLE_H FFX_STATIC const FfxUInt32 iLanczos2SampleCount = 16; @@ -35,18 +36,18 @@ void Deringing(RectificationBoxMin16 clippingBox, FFX_PARAMETER_INOUT FFX_MIN16_ } #endif -#ifndef FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE 2 // Approximate +#ifndef FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE 2 // Approximate #endif FfxFloat32 GetUpsampleLanczosWeight(FfxFloat32x2 fSrcSampleOffset, FfxFloat32 fKernelWeight) { FfxFloat32x2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx; -#if FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE +#if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE FfxFloat32 fSampleWeight = Lanczos2(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT FfxFloat32 fSampleWeight = Lanczos2_UseLUT(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE FfxFloat32 fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased)); #else #error "Invalid Lanczos type" @@ -58,11 +59,11 @@ FfxFloat32 GetUpsampleLanczosWeight(FfxFloat32x2 fSrcSampleOffset, FfxFloat32 fK FFX_MIN16_F GetUpsampleLanczosWeight(FFX_MIN16_F2 fSrcSampleOffset, FFX_MIN16_F fKernelWeight) { FFX_MIN16_F2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx; -#if FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE +#if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE FFX_MIN16_F fSampleWeight = Lanczos2(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT FFX_MIN16_F fSampleWeight = Lanczos2_UseLUT(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE FFX_MIN16_F fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased)); // To Test: Save reciproqual sqrt compute @@ -85,16 +86,16 @@ FfxFloat32 ComputeMaxKernelWeight() { FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT RectificationBox clippingBox, FfxFloat32 fReactiveFactor) { - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_begin.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_begin.h" #endif // We compute a sliced lanczos filter with 2 lobes (other slices are accumulated temporaly) FfxFloat32x2 fDstOutputPos = FfxFloat32x2(params.iPxHrPos) + FFX_BROADCAST_FLOAT32X2(0.5f); // Destination resolution output pixel center position FfxFloat32x2 fSrcOutputPos = fDstOutputPos * DownscaleFactor(); // Source resolution output pixel center position FfxInt32x2 iSrcInputPos = FfxInt32x2(floor(fSrcOutputPos)); // TODO: what about weird upscale factors... - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_end.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_end.h" #endif FfxFloat32x3 fSamples[iLanczos2SampleCount]; @@ -174,9 +175,9 @@ FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams p RectificationBoxComputeVarianceBoxData(clippingBox); - fColorAndWeight.w *= FfxFloat32(fColorAndWeight.w > FSR2_EPSILON); + fColorAndWeight.w *= FfxFloat32(fColorAndWeight.w > FSR3UPSCALER_EPSILON); - if (fColorAndWeight.w > FSR2_EPSILON) { + if (fColorAndWeight.w > FSR3UPSCALER_EPSILON) { // Normalize for deringing (we need to compare colors) fColorAndWeight.xyz = fColorAndWeight.xyz / fColorAndWeight.w; fColorAndWeight.w *= fUpsampleLanczosWeightScale; @@ -184,11 +185,11 @@ FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams p Deringing(clippingBox, fColorAndWeight.xyz); } - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_end.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_end.h" #endif return fColorAndWeight; } -#endif //!defined( FFX_FSR2_UPSAMPLE_H ) +#endif //!defined( FFX_FSR3UPSCALER_UPSAMPLE_H ) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta new file mode 100644 index 0000000..e4153a0 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 3e7832c4a9154414f9eaa125acfe6cd5 +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/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta new file mode 100644 index 0000000..731c94f --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09438bc445e66204f970dc99ca8dae5a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h similarity index 97% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h index 1ac23cf..e780995 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,9 +19,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wunused-variable" -#endif + +/// @defgroup FfxGPUFsr1 FidelityFX FSR1 +/// FidelityFX Super Resolution 1 GPU documentation +/// +/// @ingroup FfxGPUEffects /// Setup required constant values for EASU (works on CPU or GPU). /// @@ -36,7 +38,7 @@ /// @param [in] outputSizeInPixelsX The display resolution which the input image gets upscaled to in X dimension. /// @param [in] outputSizeInPixelsY The display resolution which the input image gets upscaled to in Y dimension. /// -/// @ingroup FSR1 +/// @ingroup FfxGPUFsr1 FFX_STATIC void ffxFsrPopulateEasuConstants( FFX_PARAMETER_INOUT FfxUInt32x4 con0, FFX_PARAMETER_INOUT FfxUInt32x4 con1, @@ -102,7 +104,7 @@ FFX_STATIC void ffxFsrPopulateEasuConstants( /// @param [in] inputOffsetInPixelsX The input image offset in the X dimension into the resource containing it (useful for dynamic resolution). /// @param [in] inputOffsetInPixelsY The input image offset in the Y dimension into the resource containing it (useful for dynamic resolution). /// -/// @ingroup FSR1 +/// @ingroup FfxGPUFsr1 FFX_STATIC void ffxFsrPopulateEasuConstantsOffset( FFX_PARAMETER_INOUT FfxUInt32x4 con0, FFX_PARAMETER_INOUT FfxUInt32x4 con1, @@ -329,7 +331,7 @@ void ffxFsrEasuFloat( // Normalize with approximation, and cleanup close to zero. FfxFloat32x2 dir2 = dir * dir; FfxFloat32 dirR = dir2.x + dir2.y; - FfxUInt32 zro = dirR < FfxFloat32(1.0 / 32768.0); + FfxBoolean zro = dirR < FfxFloat32(1.0 / 32768.0); dirR = ffxApproximateReciprocalSquareRoot(dirR); dirR = zro ? FfxFloat32(1.0) : dirR; dir.x = zro ? FfxFloat32(1.0) : dir.x; @@ -457,7 +459,7 @@ void FsrEasuSetH( FfxFloat16x2 dirX = lD - lB; dirPX += dirX * w; - lenX = ffxSaturate(abs(dirX) * lenX); + lenX = FfxFloat16x2(ffxSaturate(abs(dirX) * lenX)); lenX *= lenX; lenP += lenX * w; FfxFloat16x2 ec = lE - lC; @@ -466,7 +468,7 @@ void FsrEasuSetH( lenY = ffxReciprocalHalf(lenY); FfxFloat16x2 dirY = lE - lA; dirPY += dirY * w; - lenY = ffxSaturate(abs(dirY) * lenY); + lenY = FfxFloat16x2(ffxSaturate(abs(dirY) * lenY)); lenY *= lenY; lenP += lenY * w; } @@ -526,8 +528,8 @@ void FsrEasuH( dirPY, lenP, ppp, - FfxUInt32(true), - FfxUInt32(false), + FfxBoolean(true), + FfxBoolean(false), FfxFloat16x2(bL, cL), FfxFloat16x2(eL, fL), FfxFloat16x2(fL, gL), @@ -537,8 +539,8 @@ void FsrEasuH( dirPY, lenP, ppp, - FfxUInt32(false), - FfxUInt32(true), + FfxBoolean(false), + FfxBoolean(true), FfxFloat16x2(fL, gL), FfxFloat16x2(iL, jL), FfxFloat16x2(jL, kL), @@ -549,7 +551,7 @@ void FsrEasuH( FfxFloat16x2 dir2 = dir * dir; FfxFloat16 dirR = dir2.x + dir2.y; - FfxBoolean zro = FfxBoolean(dirR < FFX_BROADCAST_FLOAT16(1.0 / 32768.0)); + FfxUInt32 zro = FfxUInt32(dirR < FFX_BROADCAST_FLOAT16(1.0 / 32768.0)); dirR = ffxApproximateReciprocalSquareRootHalf(dirR); dirR = (zro > 0) ? FFX_BROADCAST_FLOAT16(1.0) : dirR; dir.x = (zro > 0) ? FFX_BROADCAST_FLOAT16(1.0) : dir.x; @@ -834,7 +836,7 @@ void FsrEasuH( FfxFloat16 hL=hB*FFX_BROADCAST_FLOAT16(0.5)+(hR*FFX_BROADCAST_FLOAT16(0.5)+hG); // Noise detection. FfxFloat16 nz=FFX_BROADCAST_FLOAT16(0.25)*bL+FFX_BROADCAST_FLOAT16(0.25)*dL+FFX_BROADCAST_FLOAT16(0.25)*fL+FFX_BROADCAST_FLOAT16(0.25)*hL-eL; - nz=ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL))); + nz=FfxFloat16(ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL)))); nz=FFX_BROADCAST_FLOAT16(-0.5)*nz+FFX_BROADCAST_FLOAT16(1.0); // Min and max of ring. FfxFloat16 mn4R=min(ffxMin3Half(bR,dR,fR),hR); @@ -1175,7 +1177,7 @@ void FsrEasuH( FfxFloat16x3 b = n + FFX_BROADCAST_FLOAT16X3(1.0 / 255.0); b = b * b; FfxFloat16x3 r = (c - b) * ffxApproximateReciprocalMediumHalf(a - b); - c = ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 255.0)); + c = FfxFloat16x3(ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 255.0))); } //------------------------------------------------------------------------------------------------------------------------------ void FsrTepdC10H(inout FfxFloat16x3 c, FfxFloat16 dit) @@ -1186,7 +1188,7 @@ void FsrEasuH( FfxFloat16x3 b = n + FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0); b = b * b; FfxFloat16x3 r = (c - b) * ffxApproximateReciprocalMediumHalf(a - b); - c = ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0)); + c = FfxFloat16x3(ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0))); } //============================================================================================================================== // This computes dither for positions 'p' and 'p+{8,0}'. @@ -1222,9 +1224,9 @@ void FsrEasuH( FfxFloat16x2 rR = (cR - bR) * ffxApproximateReciprocalMediumHalf(aR - bR); FfxFloat16x2 rG = (cG - bG) * ffxApproximateReciprocalMediumHalf(aG - bG); FfxFloat16x2 rB = (cB - bB) * ffxApproximateReciprocalMediumHalf(aB - bB); - cR = ffxSaturate(nR + ffxIsGreaterThanZeroHalf(dit - rR) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); - cG = ffxSaturate(nG + ffxIsGreaterThanZeroHalf(dit - rG) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); - cB = ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); + cR = FfxFloat16x2(ffxSaturate(nR + ffxIsGreaterThanZeroHalf(dit - rR) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); + cG = FfxFloat16x2(ffxSaturate(nG + ffxIsGreaterThanZeroHalf(dit - rG) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); + cB = FfxFloat16x2(ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); } //------------------------------------------------------------------------------------------------------------------------------ void FsrTepdC10Hx2(inout FfxFloat16x2 cR,inout FfxFloat16x2 cG,inout FfxFloat16x2 cB,FfxFloat16x2 dit){ @@ -1243,8 +1245,8 @@ void FsrEasuH( FfxFloat16x2 rR=(cR-bR)*ffxApproximateReciprocalMediumHalf(aR-bR); FfxFloat16x2 rG=(cG-bG)*ffxApproximateReciprocalMediumHalf(aG-bG); FfxFloat16x2 rB=(cB-bB)*ffxApproximateReciprocalMediumHalf(aB-bB); - cR=ffxSaturate(nR+ffxIsGreaterThanZeroHalf(dit-rR)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0)); - cG=ffxSaturate(nG+ffxIsGreaterThanZeroHalf(dit-rG)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0)); - cB = ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 1023.0)); + cR=FfxFloat16x2(ffxSaturate(nR+ffxIsGreaterThanZeroHalf(dit-rR)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0))); + cG=FfxFloat16x2(ffxSaturate(nG+ffxIsGreaterThanZeroHalf(dit-rG)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0))); + cB=FfxFloat16x2(ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 1023.0))); } #endif diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta new file mode 100644 index 0000000..64e4ffa --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 628e23510f46ef44bbf0035ce9a63be0 +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/Shaders/FSR3/shaders/fsr3upscaler/spd.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd.meta new file mode 100644 index 0000000..0b775af --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f03de1579ac3294595ae4f40106b7a2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_spd.h b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h similarity index 82% rename from Assets/Resources/FSR2/shaders/ffx_spd.h rename to Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h index b94f46f..6441419 100644 --- a/Assets/Resources/FSR2/shaders/ffx_spd.h +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,22 +19,42 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifdef FFX_CPU -FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side: dispatch thread group count xy - FfxUInt32x2 workGroupOffset, // GPU side: pass in as constant - FfxUInt32x2 numWorkGroupsAndMips, // GPU side: pass in as constant - FfxUInt32x4 rectInfo, // left, top, width, height - FfxInt32 mips) // optional: if -1, calculate based on rect width and height -{ - workGroupOffset[0] = rectInfo[0] / 64; // rectInfo[0] = left - workGroupOffset[1] = rectInfo[1] / 64; // rectInfo[1] = top + +/// @defgroup FfxGPUSpd FidelityFX SPD +/// FidelityFX Single Pass Downsampler 2.0 GPU documentation +/// +/// @ingroup FfxGPUEffects + +/// Setup required constant values for SPD (CPU). +/// +/// @param [out] dispatchThreadGroupCountXY CPU side: dispatch thread group count xy. z is number of slices of the input texture +/// @param [out] workGroupOffset GPU side: pass in as constant +/// @param [out] numWorkGroupsAndMips GPU side: pass in as constant +/// @param [in] rectInfo left, top, width, height +/// @param [in] mips optional: if -1, calculate based on rect width and height +/// +/// @ingroup FfxGPUSpd +#if defined(FFX_CPU) +FFX_STATIC void ffxSpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, + FfxUInt32x2 workGroupOffset, + FfxUInt32x2 numWorkGroupsAndMips, + FfxUInt32x4 rectInfo, + FfxInt32 mips) +{ + // determines the offset of the first tile to downsample based on + // left (rectInfo[0]) and top (rectInfo[1]) of the subregion. + workGroupOffset[0] = rectInfo[0] / 64; + workGroupOffset[1] = rectInfo[1] / 64; FfxUInt32 endIndexX = (rectInfo[0] + rectInfo[2] - 1) / 64; // rectInfo[0] = left, rectInfo[2] = width FfxUInt32 endIndexY = (rectInfo[1] + rectInfo[3] - 1) / 64; // rectInfo[1] = top, rectInfo[3] = height + // we only need to dispatch as many thread groups as tiles we need to downsample + // number of tiles per slice depends on the subregion to downsample dispatchThreadGroupCountXY[0] = endIndexX + 1 - workGroupOffset[0]; dispatchThreadGroupCountXY[1] = endIndexY + 1 - workGroupOffset[1]; + // number of thread groups per slice numWorkGroupsAndMips[0] = (dispatchThreadGroupCountXY[0]) * (dispatchThreadGroupCountXY[1]); if (mips >= 0) @@ -42,29 +62,37 @@ FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side numWorkGroupsAndMips[1] = FfxUInt32(mips); } else - { + { // calculate based on rect width and height FfxUInt32 resolution = ffxMax(rectInfo[2], rectInfo[3]); numWorkGroupsAndMips[1] = FfxUInt32((ffxMin(floor(log2(FfxFloat32(resolution))), FfxFloat32(12)))); } } -FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side: dispatch thread group count xy - FfxUInt32x2 workGroupOffset, // GPU side: pass in as constant - FfxUInt32x2 numWorkGroupsAndMips, // GPU side: pass in as constant - FfxUInt32x4 rectInfo) // left, top, width, height +/// Setup required constant values for SPD (CPU). +/// +/// @param [out] dispatchThreadGroupCountXY CPU side: dispatch thread group count xy. z is number of slices of the input texture +/// @param [out] workGroupOffset GPU side: pass in as constant +/// @param [out] numWorkGroupsAndMips GPU side: pass in as constant +/// @param [in] rectInfo left, top, width, height +/// +/// @ingroup FfxGPUSpd +FFX_STATIC void ffxSpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, + FfxUInt32x2 workGroupOffset, + FfxUInt32x2 numWorkGroupsAndMips, + FfxUInt32x4 rectInfo) { - SpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo, -1); + ffxSpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo, -1); } -#endif // #ifdef FFX_CPU +#endif // #if defined(FFX_CPU) //============================================================================================================================== // NON-PACKED VERSION //============================================================================================================================== -#ifdef FFX_GPU -#ifdef SPD_PACKED_ONLY -// Avoid compiler error +#if defined(FFX_GPU) +#if defined(FFX_SPD_PACKED_ONLY) +// Avoid compiler errors by including default implementations of these callbacks. FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 p, FfxUInt32 slice) { return FfxFloat32x4(0.0, 0.0, 0.0, 0.0); @@ -88,18 +116,13 @@ FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFl { return FfxFloat32x4(0.0, 0.0, 0.0, 0.0); } -#endif // #ifdef SPD_PACKED_ONLY +#endif // #if FFX_SPD_PACKED_ONLY //_____________________________________________________________/\_______________________________________________________________ -void SpdWorkgroupShuffleBarrier() +void ffxSpdWorkgroupShuffleBarrier() { -#ifdef FFX_GLSL - barrier(); -#endif -#ifdef FFX_HLSL - GroupMemoryBarrierWithGroupSync(); -#endif + FFX_GROUP_MEMORY_BARRIER(); } // Only last active workgroup should proceed @@ -111,14 +134,14 @@ bool SpdExitWorkgroup(FfxUInt32 numWorkGroups, FfxUInt32 localInvocationIndex, F SpdIncreaseAtomicCounter(slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); return (SpdGetAtomicCounter() != (numWorkGroups - 1)); } // User defined: FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3); FfxFloat32x4 SpdReduceQuad(FfxFloat32x4 v) { -#if defined(FFX_GLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#if defined(FFX_GLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) FfxFloat32x4 v0 = v; FfxFloat32x4 v1 = subgroupQuadSwapHorizontal(v); @@ -126,7 +149,7 @@ FfxFloat32x4 SpdReduceQuad(FfxFloat32x4 v) FfxFloat32x4 v3 = subgroupQuadSwapDiagonal(v); return SpdReduce4(v0, v1, v2, v3); -#elif defined(FFX_HLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#elif defined(FFX_HLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) // requires SM6.0 FfxUInt32 quad = WaveGetLaneIndex() & (~0x3); @@ -196,7 +219,7 @@ FfxFloat32x4 SpdReduceLoadSourceImage4(FfxUInt32x2 i0, FfxUInt32x2 i1, FfxUInt32 FfxFloat32x4 SpdReduceLoadSourceImage(FfxUInt32x2 base, FfxUInt32 slice) { -#ifdef SPD_LINEAR_SAMPLER +#if defined(SPD_LINEAR_SAMPLER) return SpdLoadSourceImage(FfxInt32x2(base), slice); #else return SpdReduceLoadSourceImage4(FfxUInt32x2(base + FfxUInt32x2(0, 0)), FfxUInt32x2(base + FfxUInt32x2(0, 1)), FfxUInt32x2(base + FfxUInt32x2(1, 0)), FfxUInt32x2(base + FfxUInt32x2(1, 1)), slice); @@ -281,13 +304,13 @@ void SpdDownsampleMips_0_1_LDS(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID for (FfxUInt32 i = 0; i < 4; i++) { SpdStoreIntermediate(x, y, v[i]); - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); if (localInvocationIndex < 64) { v[i] = SpdReduceIntermediate(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); SpdStore(FfxInt32x2(workGroupID.xy * 16) + FfxInt32x2(x + (i % 2) * 8, y + (i / 2) * 8), v[i], 1, slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); } if (localInvocationIndex < 64) @@ -301,7 +324,7 @@ void SpdDownsampleMips_0_1_LDS(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID void SpdDownsampleMips_0_1(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) SpdDownsampleMips_0_1_LDS(x, y, workGroupID, localInvocationIndex, mip, slice); #else SpdDownsampleMips_0_1_Intrinsics(x, y, workGroupID, localInvocationIndex, mip, slice); @@ -311,7 +334,7 @@ void SpdDownsampleMips_0_1(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, Ff void SpdDownsampleMip_2(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 64) { FfxFloat32x4 v = SpdReduceIntermediate(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); @@ -340,7 +363,7 @@ void SpdDownsampleMip_2(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_3(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 16) { // x 0 x 0 @@ -380,7 +403,7 @@ void SpdDownsampleMip_3(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_4(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 4) { // x 0 0 0 x 0 0 0 @@ -413,7 +436,7 @@ void SpdDownsampleMip_4(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_5(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 1) { // x x x x 0 ... @@ -470,48 +493,75 @@ void SpdDownsampleNextFour(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, Ff { if (mips <= baseMip) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_2(x, y, workGroupID, localInvocationIndex, baseMip, slice); if (mips <= baseMip + 1) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_3(x, y, workGroupID, localInvocationIndex, baseMip + 1, slice); if (mips <= baseMip + 2) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_4(x, y, workGroupID, localInvocationIndex, baseMip + 2, slice); if (mips <= baseMip + 3) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_5(workGroupID, localInvocationIndex, baseMip + 3, slice); } +/// Downsamples a 64x64 tile based on the work group id. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// +/// @ingroup FfxGPUSpd void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice) { + // compute MIP level 0 and 1 FfxUInt32x2 sub_xy = ffxRemapForWaveReduction(localInvocationIndex % 64); FfxUInt32 x = sub_xy.x + 8 * ((localInvocationIndex >> 6) % 2); FfxUInt32 y = sub_xy.y + 8 * ((localInvocationIndex >> 7)); SpdDownsampleMips_0_1(x, y, workGroupID, localInvocationIndex, mips, slice); + // compute MIP level 2, 3, 4, 5 SpdDownsampleNextFour(x, y, workGroupID, localInvocationIndex, 2, mips, slice); if (mips <= 6) return; + // increase the global atomic counter for the given slice and check if it's the last remaining thread group: + // terminate if not, continue if yes. if (SpdExitWorkgroup(numWorkGroups, localInvocationIndex, slice)) return; + // reset the global atomic counter back to 0 for the next spd dispatch SpdResetAtomicCounter(slice); - // After mip 6 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // After mip 5 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // compute MIP level 6 and 7 SpdDownsampleMips_6_7(x, y, mips, slice); + // compute MIP level 8, 9, 10, 11 SpdDownsampleNextFour(x, y, FfxUInt32x2(0, 0), localInvocationIndex, 8, mips, slice); } - +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// @param [in] workGroupOffset the work group offset. it's (0,0) in case the entire input texture is downsampled. +/// +/// @ingroup FfxGPUSpd void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice, FfxUInt32x2 workGroupOffset) { SpdDownsample(workGroupID + workGroupOffset, localInvocationIndex, mips, numWorkGroups, slice); @@ -528,13 +578,13 @@ void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxU FfxFloat16x4 SpdReduceQuadH(FfxFloat16x4 v) { -#if defined(FFX_GLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#if defined(FFX_GLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) FfxFloat16x4 v0 = v; FfxFloat16x4 v1 = subgroupQuadSwapHorizontal(v); FfxFloat16x4 v2 = subgroupQuadSwapVertical(v); FfxFloat16x4 v3 = subgroupQuadSwapDiagonal(v); return SpdReduce4H(v0, v1, v2, v3); -#elif defined(FFX_HLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#elif defined(FFX_HLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) // requires SM6.0 FfxUInt32 quad = WaveGetLaneIndex() & (~0x3); FfxFloat16x4 v0 = v; @@ -603,7 +653,7 @@ FfxFloat16x4 SpdReduceLoadSourceImage4H(FfxUInt32x2 i0, FfxUInt32x2 i1, FfxUInt3 FfxFloat16x4 SpdReduceLoadSourceImageH(FfxUInt32x2 base, FfxUInt32 slice) { -#ifdef SPD_LINEAR_SAMPLER +#if defined(SPD_LINEAR_SAMPLER) return SpdLoadSourceImageH(FfxInt32x2(base), slice); #else return SpdReduceLoadSourceImage4H(FfxUInt32x2(base + FfxUInt32x2(0, 0)), FfxUInt32x2(base + FfxUInt32x2(0, 1)), FfxUInt32x2(base + FfxUInt32x2(1, 0)), FfxUInt32x2(base + FfxUInt32x2(1, 1)), slice); @@ -685,16 +735,16 @@ void SpdDownsampleMips_0_1_LDSH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupI if (mips <= 1) return; - for (FfxInt32 i = 0; i < 4; i++) + for (FfxUInt32 i = 0; i < 4; i++) { SpdStoreIntermediateH(x, y, v[i]); - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); if (localInvocationIndex < 64) { v[i] = SpdReduceIntermediateH(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); SpdStoreH(FfxInt32x2(workGroupID.xy * 16) + FfxInt32x2(x + (i % 2) * 8, y + (i / 2) * 8), v[i], 1, slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); } if (localInvocationIndex < 64) @@ -708,7 +758,7 @@ void SpdDownsampleMips_0_1_LDSH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupI void SpdDownsampleMips_0_1H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) SpdDownsampleMips_0_1_LDSH(x, y, workGroupID, localInvocationIndex, mips, slice); #else SpdDownsampleMips_0_1_IntrinsicsH(x, y, workGroupID, localInvocationIndex, mips, slice); @@ -718,7 +768,7 @@ void SpdDownsampleMips_0_1H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, F void SpdDownsampleMip_2H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 64) { FfxFloat16x4 v = SpdReduceIntermediateH(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); @@ -747,7 +797,7 @@ void SpdDownsampleMip_2H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_3H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 16) { // x 0 x 0 @@ -787,7 +837,7 @@ void SpdDownsampleMip_3H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_4H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 4) { // x 0 0 0 x 0 0 0 @@ -820,7 +870,7 @@ void SpdDownsampleMip_4H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_5H(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 1) { // x x x x 0 ... @@ -877,53 +927,83 @@ void SpdDownsampleNextFourH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, F { if (mips <= baseMip) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_2H(x, y, workGroupID, localInvocationIndex, baseMip, slice); if (mips <= baseMip + 1) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_3H(x, y, workGroupID, localInvocationIndex, baseMip + 1, slice); if (mips <= baseMip + 2) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_4H(x, y, workGroupID, localInvocationIndex, baseMip + 2, slice); if (mips <= baseMip + 3) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_5H(workGroupID, localInvocationIndex, baseMip + 3, slice); } +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// Uses half types. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// +/// @ingroup FfxGPUSpd void SpdDownsampleH(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice) { FfxUInt32x2 sub_xy = ffxRemapForWaveReduction(localInvocationIndex % 64); FfxUInt32 x = sub_xy.x + 8 * ((localInvocationIndex >> 6) % 2); FfxUInt32 y = sub_xy.y + 8 * ((localInvocationIndex >> 7)); + // compute MIP level 0 and 1 SpdDownsampleMips_0_1H(x, y, workGroupID, localInvocationIndex, mips, slice); + // compute MIP level 2, 3, 4, 5 SpdDownsampleNextFourH(x, y, workGroupID, localInvocationIndex, 2, mips, slice); if (mips < 7) return; + // increase the global atomic counter for the given slice and check if it's the last remaining thread group: + // terminate if not, continue if yes. if (SpdExitWorkgroup(numWorkGroups, localInvocationIndex, slice)) return; + // reset the global atomic counter back to 0 for the next spd dispatch SpdResetAtomicCounter(slice); - // After mip 6 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // After mip 5 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // compute MIP level 6 and 7 SpdDownsampleMips_6_7H(x, y, mips, slice); + // compute MIP level 8, 9, 10, 11 SpdDownsampleNextFourH(x, y, FfxUInt32x2(0, 0), localInvocationIndex, 8, mips, slice); } +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// Uses half types. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// @param [in] workGroupOffset the work group offset. it's (0,0) in case the entire input texture is downsampled. +/// +/// @ingroup FfxGPUSpd void SpdDownsampleH(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice, FfxUInt32x2 workGroupOffset) { SpdDownsampleH(workGroupID + workGroupOffset, localInvocationIndex, mips, numWorkGroups, slice); } #endif // #if FFX_HALF -#endif // #ifdef FFX_GPU +#endif // #if defined(FFX_GPU) diff --git a/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta new file mode 100644 index 0000000..8d4e716 --- /dev/null +++ b/Assets/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: face65176ee3b82498bd0b8fed0ddacd +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/README.md b/README.md index dcc6597..5cb4f7d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# FSR 2.2 for Unity +# FSR 3.0 Upscaler for Unity -FidelityFX Super Resolution 2 (FSR2) is an advanced image upscaling and temporal reconstruction technique developed by AMD and [released as open source](https://github.com/GPUOpen-Effects/FidelityFX-FSR2). It provides both high-quality anti-aliasing and the ability for games to output at high resolutions while rendering at a lower internal resolution, improving performance. +FidelityFX Super Resolution 3 (FSR3) Upscaler is an advanced image upscaling and temporal reconstruction technique developed by AMD and [released as open source](https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/release-FSR3-3.0.3) through the GPUOpen initiative. It provides both high-quality anti-aliasing and the ability for games to output at high resolutions while rendering at a lower internal resolution, improving performance. -This project aims to bring FSR2 to Unity, as an alternative to Unity's existing FXAA, SMAA and TAA anti-aliasing solutions. Compared to Unity's TAA implementation, FSR2 offers a sharper and more stable image, with a better sub-pixel detail resolve and better performance due to its reliance on upscaling. +This project aims to bring FSR3 upscaling to Unity as an alternative to Unity's existing FXAA, SMAA and TAA anti-aliasing solutions. Compared to Unity's TAA implementation, FSR3 Upscaler offers a sharper and more stable image, with a better sub-pixel detail resolve and better performance due to its reliance on upscaling. ![Comparison](images/comparison.png) -Rather than attempting to integrate AMD's open source C++ libraries for FSR2, this project instead reimplements the C++ backend in C# while adapting FSR2's HLSL shader code to work within Unity. This allows for maximum compatibility with the platforms and graphics APIs that Unity supports, including ones that normally wouldn't be supported by FSR2. +Rather than attempting to integrate AMD's open source C++ libraries for FSR3, this project instead reimplements the C++ backend in C# while adapting FSR3's HLSL shader code to work within Unity. This allows for maximum compatibility with the platforms and graphics APIs that Unity supports, including ones that normally wouldn't be supported by FSR3. -Focus of this project lies initially on making FSR2 work with the traditional Unity built-in render pipeline. However the core FSR2 classes are render pipeline-agnostic, so there is every possibility for URP and HDRP to be supported as well in the future. +Focus of this project lies initially on making FSR3 Upscaler work with the traditional Unity built-in render pipeline. However the core FSR3 Upscaler classes are render pipeline-agnostic, so there is every possibility for URP and HDRP to be supported as well in the future. ## Table of Contents @@ -31,9 +31,9 @@ Focus of this project lies initially on making FSR2 work with the traditional Un ## Requirements -FSR2 for Unity requires Unity 2020.1 or higher. This version of Unity added support for the `multi_compile` keyword in compute shaders, which the FSR2 implementation makes use of. +FSR3 Upscaler for Unity requires Unity 2020.1 or higher. This version of Unity added support for the `multi_compile` keyword in compute shaders, which the FSR3 Upscaler implementation makes use of. -Other than the above, requirements are no different from normal FSR2: it requires a GPU with compute shader support, typed UAV load and R16G16B16A16_UNORM support. In practice, almost every GPU made in the past decade will be able to run it. +Other than the above, requirements are no different from standard FSR3 Upscaler: it requires a GPU with compute shader support, typed UAV load and R16G16B16A16_UNORM support. In practice, almost every GPU made in the past decade will be able to run it. Platforms tested and confirmed working: - Windows @@ -60,57 +60,53 @@ Platforms tested and confirmed working: The exact hardware requirements for mobile devices (Android and iOS) are still to be determined. -Note that OpenGL on MacOS does not support compute shaders, so it will never be able to run FSR2. +Note that OpenGL on MacOS does not support compute shaders, so it will never be able to run FSR3 Upscaler. ## Integration -Integration generally follows the same guidelines as the [FSR2 documentation on Github](https://github.com/GPUOpen-Effects/FidelityFX-FSR2#integration-guidelines), with a few specifics for the Unity implementation. +Integration generally follows the same guidelines as the [FSR3 Upscaler documentation by GPUOpen](https://gpuopen.com/manuals/fidelityfx_sdk/fidelityfx_sdk-page_techniques_super-resolution-upscaler/#integration-guidelines), with a few specifics for the Unity implementation. ### Built-in Render Pipeline -To apply FSR2 to a camera, simply add the `Fsr2ImageEffect` script to your camera game object. It should be placed at the bottom of the components list, to ensure that it's the last image effect in the chain. +To apply FSR3 Upscaler to a camera, simply add the `Fsr3UpscalerImageEffect` script to your camera game object. It should be placed at the bottom of the components list, to ensure that it's the last image effect in the chain. ![Simple Camera Setup](images/camera-simple.png) -This component contains settings for changing the scaling factor (Quality Mode), enabling or disabling various features, and for providing certain optional inputs that are further explained below. +This component contains settings for changing the scaling factor (Quality Mode), enabling or disabling various features, and for providing certain optional inputs that are further explained below. Be sure that the Assets field contains a valid reference to an `Fsr3UpscalerAssets` object. This should get filled in automatically when creating the component. -If you have any other post-processing effects on your camera that make use of the `OnPreCull` method, then also add the `Fsr2ImageEffectHelper` script to the camera and move it up, above those other post-processing effects. Specifically: it needs to be above any script that queries the camera's viewport size properties (i.e. `rect`, `pixelRect`, `pixelWidth`/`Height`) in `OnPreCull`. Unity's `PostProcessLayer` script is a particularly good example of this. +If you have any other post-processing effects on your camera that make use of the `OnPreCull` method, then also add the `Fsr3UpscalerImageEffectHelper` script to the camera and move it up, above those other post-processing effects. Specifically: it needs to be above any script that queries the camera's viewport size properties (i.e. `rect`, `pixelRect`, `pixelWidth`/`Height`) in `OnPreCull`. Unity's `PostProcessLayer` script is a particularly good example of this. ![PPV2 Camera Setup](images/camera-ppv2.png) -Also make sure that any other anti-aliasing methods (MSAA, FXAA, SMAA, TAA) are disabled when enabling FSR2. +Also make sure that any other anti-aliasing methods (MSAA, FXAA, SMAA, TAA) are disabled when enabling FSR3 Upscaler. ### Post-Processing Stack V2 -FSR2 for Unity is also available as a full integration into the Post-Processing Stack V2 (PPV2) from Unity. This integration gets closer to the ideal placement in the render pipeline [as recommended by the FSR2 documentation](https://github.com/GPUOpen-Effects/FidelityFX-FSR2#placement-in-the-frame). The post-processing effects from PPV2 are split into groups before and after upscaling, meaning that effects that should be applied at full resolution (e.g. film grain, bloom, depth of field, motion blur) are indeed applied on the full resolution upscaled image. +FSR3 Upscaler for Unity is also available as a full integration into the Post-Processing Stack V2 (PPV2) from Unity. This integration gets closer to the ideal placement in the render pipeline [as recommended by the FSR3 Upscaler documentation](https://gpuopen.com/manuals/fidelityfx_sdk/fidelityfx_sdk-page_techniques_super-resolution-upscaler/#placement-in-the-frame). The post-processing effects from PPV2 are split into groups before and after upscaling, meaning that effects that should be applied at full resolution (e.g. film grain, bloom, depth of field, motion blur) are indeed applied on the full resolution upscaled image. -Post-Processing Stack V2 with FSR2 is intended to be used as a drop-in replacement package for the official PPV2 package from Unity. It can be [downloaded from the Releases page](https://github.com/ndepoel/FSR2Unity/releases/latest) and should be extracted into the `Packages` directory of your project. From there it will automatically get picked up by Unity when you refresh your project. +Post-Processing Stack V2 with FSR3 Upscaler is intended to be used as a drop-in replacement package for the official PPV2 package from Unity. It can be [downloaded from the Releases page](https://github.com/ndepoel/FSR2Unity/releases/latest) and should be extracted into the `Packages` directory of your project. From there it will automatically get picked up by Unity when you refresh your project. -When the package is installed correctly, FSR2 should appear as an Anti-aliasing Mode on the Post-process Layer component: +When the package is installed correctly, 'FidelityFX Super Resolution 3 (FSR3) Upscaler' should appear as an Anti-aliasing Mode on the Post-process Layer component: -![FSR2 Anti-aliasing Mode](images/ppv2layer.png) +![FSR3 Upscaler Anti-aliasing Mode](images/ppv2layer.png) -From here you can configure the usual FSR2 settings, including quality mode, sharpness, exposure and reactive mask. +From here you can configure the usual FSR3 Upscaler settings, including quality mode, sharpness, exposure and reactive mask. ### Callbacks -FSR2 for Unity requires the application to provide a few services that it can't make any assumptions about itself. For this purpose, it exposes an `IFsr2Callbacks` interface with a default implementation `Fsr2CallbacksBase`. The application can provide these callbacks by either implementing the `IFsr2Callbacks` interface or inheriting the `Fsr2CallbacksBase` class and overriding one or more methods. Assign these callbacks to the `Callbacks` property on the `Fsr2ImageEffect` script component, before the script is enabled. - -#### Resource management - -By default, FSR2 for Unity loads its shaders directly from a Resources folder. This is not recommended behavior and many applications choose to manage shaders in a different way. To accomodate this, FSR2 for Unity makes it possible to override the methods by which shaders are loaded and unloaded. For example, they may be loaded from an asset bundle instead. +FSR3 Upscaler for Unity requires the application to provide a few services that it can't make any assumptions about itself. For this purpose, it exposes an `IFsr3UpscalerCallbacks` interface with a default implementation `Fsr3UpscalerCallbacksBase`. The application can provide these callbacks by either implementing the `IFsr3UpscalerCallbacks` interface or inheriting the `Fsr3UpscalerCallbacksBase` class and overriding one or more methods. Assign these callbacks to the `Callbacks` property on the `Fsr3UpscalerImageEffect` script component, before the script is enabled. #### Mipmap biasing -One key part of FSR2 is adjusting the mipmap bias of textures. Normally when lowering the rendering resolution, Unity will also sample textures at lower mipmap levels to prevent texture aliasing. When upscaling is in use, this will result in noticeably blurry textures. To combat this, FSR2 suggests that applications adjust the mipmap bias for texture content in the scene that is to be upscaled. This is [further explained in the FSR2 documentation](https://github.com/GPUOpen-Effects/FidelityFX-FSR2#mipmap-biasing). +One key part of FSR3 Upscaler is adjusting the mipmap bias of textures. Normally when lowering the rendering resolution, Unity will also sample textures at lower mipmap levels to prevent texture aliasing. When upscaling is in use, this will result in noticeably blurry textures. To combat this, FSR3 suggests that applications adjust the mipmap bias for texture content in the scene that is to be upscaled. This is [further explained in the FSR3 Upscaler documentation](https://gpuopen.com/manuals/fidelityfx_sdk/fidelityfx_sdk-page_techniques_super-resolution-upscaler/#mipmap-biasing). Unfortunately Unity has no single unified way to identify textures that are part of the 3D scene, nor does it offer a way to set a global mipmap bias at run-time. There are also many different ways in which textures may be applied to a scene, depending on which third-party asset packages the application chooses to use. This makes the implementation of texture mipmap biasing a highly application-specific thing. -The default implementation in `Fsr2CallbackBase` will very naively look up every `Texture2D` object in the current scene and apply the mipmap bias offset to it. This generally works fine but it will also include textures that shouldn't have the mipmap bias applied (e.g. UI textures) and potentially misses textures that should have the mipmap bias applied (e.g. texture arrays for terrain rendering). You will want to override this callback to more selectively specify the textures that need to have this mipmap bias applied, and possibly store the current mipmap bias value to retroactively apply it to assets that are loaded on demand. +The default implementation in `Fsr3UpscalerCallbacksBase` will very naively look up every `Texture2D` object in the current scene and apply the mipmap bias offset to it. This generally works fine but it will also include textures that shouldn't have the mipmap bias applied (e.g. UI textures) and potentially misses textures that should have the mipmap bias applied (e.g. texture arrays for terrain rendering). You will want to override this callback to more selectively specify the textures that need to have this mipmap bias applied, and possibly store the current mipmap bias value to retroactively apply it to assets that are loaded on demand. ### Motion vectors -FSR2 relies on depth and motion vector data to track pixels across frames and to detect areas that 'became visible' on the current frame and therefore should not be reconstructed using historical data. For all of this to work properly, it is very important that the application renders correct motion vector data for all moving objects in the scene, in addition to camera motion vectors. +FSR3 Upscaler relies on depth and motion vector data to track pixels across frames and to detect areas that 'became visible' on the current frame and therefore should not be reconstructed using historical data. For all of this to work properly, it is very important that the application renders correct motion vector data for all moving objects in the scene, in addition to camera motion vectors. Unfortunately not all community-made Unity asset packages have gotten the message that temporal image techniques are here to stay, and either don't output motion vectors from their shaders or poorly document how this is enabled. This is not helped by Unity itself being rather obscure in how motion vectors are to be rendered and accessed. @@ -124,9 +120,9 @@ Again, make sure that all of your moving objects render motion vectors and compl ### Reactive mask -The reactive mask is a special input texture that tells FSR2 how much of the current frame should be taken into account when reconstructing each pixel. This is important when reconstructing pixels containing transparency effects, such as glass, water or particles. Transparencies are usually not rendered to motion vectors (and even if they did it wouldn't match the opaque content behind the transparent object), so FSR2 has no way to track these pixels across frames. +The reactive mask is a special input texture that tells the FSR3 Upscaler how much of the current frame should be taken into account when reconstructing each pixel. This is important when reconstructing pixels containing transparency effects, such as glass, water or particles. Transparencies are usually not rendered to motion vectors (and even if they did it wouldn't match the opaque content behind the transparent object), so FSR3 Upscaler has no way to track these pixels across frames. -Here is an example of a transparent particle effect upscaled by FSR2 without a reactive mask applied: +Here is an example of a transparent particle effect upscaled by FSR3 Upscaler without a reactive mask applied: ![No Reactive Mask](images/reactive-none.png) @@ -138,9 +134,9 @@ A reactive mask can be provided in two different ways. The easiest way is to mak The artifacting is mostly gone but the particles remain somewhat blurry and streaky. -Enabling the auto-generate reactive mask feature is as simple as ticking the corresponding checkbox on the `Fsr2ImageEffect` script. This will automatically capture the opaque-only image on the `BeforeForwardAlpha` camera event and dispatch the relevant compute shader when it's time to apply FSR2 upscaling. There are various parameters available for tweaking the auto-generate process, however what these values do is rather poorly documented. The defaults should give decent results in most cases. +Enabling the auto-generate reactive mask feature is as simple as ticking the corresponding checkbox on the `Fsr3UpscalerImageEffect` script. This will automatically capture the opaque-only image on the `BeforeForwardAlpha` camera event and dispatch the relevant compute shader when it's time to apply the FSR3 Upscaler. There are various parameters available for tweaking the auto-generate process, however what these values do is rather poorly documented. The defaults should give decent results in most cases. -The other way to provide a reactive mask is by generating one yourself. Essentially, you need to have your transparent shaders output directly to a reactive mask texture with a value representing both the pixel's luminance and opacity values. The FSR2 sample does this as follows: +The other way to provide a reactive mask is by generating one yourself. Essentially, you need to have your transparent shaders output directly to a reactive mask texture with a value representing both the pixel's luminance and opacity values. The FSR3 Upscaler sample does this as follows: output.reactiveMask = max( output.color.r, max( output.color.g, output.color.b ) ) * albedo.a; @@ -148,29 +144,29 @@ Of course this means that you have to modify your application's shaders to outpu ![Manual Reactive Mask](images/reactive-manual.png) -The manually generated reactive mask can be supplied to the `Fsr2ImageEffect` script through its Reactive Mask texture parameter. +The manually generated reactive mask can be supplied to the `Fsr3UpscalerImageEffect` script through its Reactive Mask texture parameter. ### Exposure -FSR2 accepts a 1x1 input texture containing an exposure value for the current frame. Typically this exposure value is output by an eye adaptation shader, as is the case with PPV2's Auto Exposure effect. The need for this exposure value in FSR2 isn't immediately obvious, so I'll try to explain. +FSR3 Upscaler accepts a 1x1 input texture containing an exposure value for the current frame. Typically this exposure value is output by an eye adaptation shader, as is the case with PPV2's Auto Exposure effect. The need for this exposure value by the FSR3 Upscaler isn't immediately obvious, so I'll try to explain. -Imagine walking from a bright outdoors area into a dark tunnel and standing still while the camera adjusts to the darkness. Without any additional information, FSR2 will see the pixels changing as the picture becomes brighter and will attempt to temporally reconstruct the intended image. This reconstruction is visible as a slight fizzling effect, especially on lower resolutions, lower framerates and lower quality modes. In a situation like this, FSR2 needs to be told that it's not the geometry that is changing but rather the light level. +Imagine walking from a bright outdoors area into a dark tunnel and standing still while the camera adjusts to the darkness. Without any additional information, the FSR3 Upscaler will see the pixels changing as the picture becomes brighter and will attempt to temporally reconstruct the intended image. This reconstruction is visible as a slight fizzling effect, especially on lower resolutions, lower framerates and lower quality modes. In a situation like this, FSR3 Upscaler needs to be told that it's not the geometry that is changing but rather the light level. -By providing FSR2 with the image's current exposure value, it can derive each pixel's original unadjusted color value and will be able to tell that the pixels are not actually changing. This results in a sharper and more stable image, without any temporal fizzling artifacts. +By providing the FSR3 Upscaler with the image's current exposure value, it can derive each pixel's original unadjusted color value and will be able to tell that the pixels are not actually changing. This results in a sharper and more stable image, without any temporal fizzling artifacts. -The exposure value can be supplied to the `Fsr2ImageEffect` script through its Exposure texture parameter. PPV2's Auto Exposure effect outputs a compatible texture, however this value is kept internal by PPV2 so it'll require some trickery to plug this into FSR2. It's also possible to allow FSR2 to compute an exposure value by itself by enabling the Auto Exposure feature, however results may vary and this feature has some issues on a couple of platforms. +The exposure value can be supplied to the `Fsr3UpscalerImageEffect` script through its Exposure texture parameter. PPV2's Auto Exposure effect outputs a compatible texture, however this value is kept internal by PPV2 so it'll require some trickery to plug this into the FSR3 Upscaler. It's also possible to allow FSR3 Upscaler to compute an exposure value by itself by enabling the Auto Exposure feature, however results may vary and this feature has some issues on a couple of platforms. ### Dynamic resolution -FSR2 for Unity supports dynamic resolution through Unity's `ScalableBufferManager` class. This is distinct from FSR2's own internal upscaling mechanism, which works by manipulating the camera's viewport size (see [Built-in Render Pipeline upscaling](#built-in-render-pipeline-upscaling)). The selected FSR2 quality mode determines the maximum render size that will be used by FSR2's upscaling; the dynamic resolution from `ScalableBufferManager` can be added on top of that to further reduce the actual render size on a frame-by-frame basis. +FSR3 Upscaler for Unity supports dynamic resolution through Unity's `ScalableBufferManager` class. This is distinct from FSR3 Upscaler's own internal resolution scaling mechanism, which works by manipulating the camera's viewport size (see [Built-in Render Pipeline upscaling](#built-in-render-pipeline-upscaling)). The selected quality mode determines the maximum render size that will be used by FSR3's upscaling; the dynamic resolution from `ScalableBufferManager` can be added on top of that to further reduce the actual render size on a frame-by-frame basis. -The use of `ScalableBufferManager` is not mandatory in any way, as this form of dynamic resolution is not supported by all graphics APIs in Unity. All that FSR2 does with it is: if `ScalableBufferManager` is supported, and the camera or render target has dynamic scaling enabled, then FSR2 will respect the width and height scale factors set by the application to reduce its internal render size. It is up to the application to control the dynamic resolution scale, for example by measuring GPU times using `FrameTimingManager` and adjusting the resolution according to a target framerate. +The use of `ScalableBufferManager` is not mandatory in any way, as this form of dynamic resolution is not supported by all graphics APIs in Unity. All that FSR3 Upscaler does with it is: if `ScalableBufferManager` is supported, and the camera or render target has dynamic scaling enabled, then FSR3 Upscaler will respect the width and height scale factors set by the application to reduce its internal render size. It is up to the application to control the dynamic resolution scale, for example by measuring GPU times using `FrameTimingManager` and adjusting the resolution according to a target framerate. -Dynamic resolution works really well in combination with FSR2. Any run-time change in resolution is barely noticeable due to FSR2's robust upscaling and image reconstruction, with only a small drop in texture sharpness that can be observed. It is recommended not to scale dynamic resolution below 50%, as the image reconstruction has trouble drawing a stable image below that figure. Typically scaling down to 70% provides the best balance between performance gain and maintaining image quality. +Dynamic resolution works really well in combination with FSR3 Upscaler. Any run-time change in resolution is barely noticeable due to FSR3's robust upscaling and image reconstruction, with only a small drop in texture sharpness that can be observed. It is recommended not to scale dynamic resolution below 50%, as the image reconstruction has trouble drawing a stable image below that figure. Typically scaling down to 70% provides the best balance between performance gain and maintaining image quality. ## Known issues -- Enabling Auto Exposure causes artifacting on OpenGL Core. +- Enabling Auto Exposure causes artifacting in OpenGL Core on Nvidia GPUs. It's uncertain what is causing this. Further investigation is required. Workaround: disable Auto Exposure on affected platforms. - Texture mipmap bias adjustment is not working on MacOS Metal. @@ -179,23 +175,23 @@ Dynamic resolution works really well in combination with FSR2. Any run-time chan ## Details on implementation -This section goes more in-depth on how the implementation of FSR2 into Unity was accomplished, as well as the rationale behind some of its design decisions. For more information on how the FSR2 algorithm itself works, see the [official documentation on Github](https://github.com/GPUOpen-Effects/FidelityFX-FSR2#the-technique). +This section goes more in-depth on how the implementation of FSR3 Upscaler into Unity was accomplished, as well as the rationale behind some of its design decisions. For more information on how the FSR3 Upscaler algorithm itself works, see the [official documentation on GPUOpen](https://gpuopen.com/manuals/fidelityfx_sdk/fidelityfx_sdk-page_techniques_super-resolution-upscaler/#the-technique). ### Supporting unsupported platforms -Officially, FSR2 only offers support for DX12 and Vulkan, with DX11 and Xbox implementations available at request for licensed developers. So how did we manage to get FSR2 working on OpenGL, MacOS and PlayStation? +Officially, FSR3 Upscaler only offers support for DX12 and Vulkan, with DX11 and Xbox implementations available at request for licensed developers. So how did we manage to get FSR3 upscaling working on OpenGL, MacOS and PlayStation? -FSR2 for Unity relies heavily on Unity's ability to cross-compile HLSL and translate code to other shader languages. As it turns out, FSR2's shader codebase consists largely of very straightforward and portable HLSL code. Only a few shader keywords were necessary to make these shaders compile for DX11 and OpenGL Core in Unity, with a couple of additional patches and hacks required to make them work in Metal and PSSL as well. Additionally by translating FSR2's C++ backend code to C# code using Unity's APIs, we take advantage of Unity's platform abstractions to implement compute shader dispatch and resource management for all the platforms that we want to support. +FSR3 Upscaler for Unity relies heavily on Unity's ability to cross-compile HLSL and translate code to other shader languages. As it turns out, FSR3's shader codebase consists largely of very straightforward and portable HLSL code. Only a few shader keywords were necessary to make these shaders compile for DX11 and OpenGL Core in Unity, with a couple of additional patches and hacks required to make them work in Metal and PSSL as well. Additionally by translating FSR3's C++ backend code to C# code using Unity's APIs, we take advantage of Unity's platform abstractions to implement compute shader dispatch and resource management for all the platforms that we want to support. -With Metal, the biggest limitation is the lack of support for atomic texture operations in Unity. FSR2's HLSL code uses three such operations: `InterlockedAdd`, `InterlockedMin` and `InterlockedMax`. These allow values to be accumulated between multiple threads, without the risk of one thread overwriting another thread's write actions. In order to "just make it compile" I redefined these functions as simple, non-atomic code blocks. This was already enough to make FSR2 work on Metal and there were no obvious visual issues caused by this hack. It should be possible to properly reimplement these atomic functions by using a compare-and-swap technique, but I've decided to leave well enough alone for now. +With Metal, the biggest limitation is the lack of support for atomic texture operations in Unity. FSR3 Upscaler's HLSL code uses three such operations: `InterlockedAdd`, `InterlockedMin` and `InterlockedMax`. These allow values to be accumulated between multiple threads, without the risk of one thread overwriting another thread's write actions. In order to "just make it compile" I redefined these functions as simple, non-atomic code blocks. This was already enough to make FSR3 Upscaler work on Metal and there were no obvious visual issues caused by this hack. It should be possible to properly reimplement these atomic functions by using a compare-and-swap technique, but I've decided to leave well enough alone for now. -For PSSL, the main missing element were type definitions for the various float and vector types that FSR2 uses. These are all defined in a single common header file (`ffx_common_types.h`) and are primarily aimed at HLSL and GLSL as expected. PSSL uses different type names so in order to make the FSR2 shaders compile for PS4/5, I added the required type definitions to this header file. Additionally, the FSR2 shader code uses two type qualifiers (`unorm` and `globallycoherent`) that PSSL doesn't understand. I simply defined these keywords as blanks, which was enough to make the shaders work. Again there is probably a proper way to redefine these keywords using PSSL equivalents, but I haven't found the correct ones yet. +For PSSL, the main missing element were type definitions for the various float and vector types that FSR3 uses. These are all defined in a single common header file (`ffx_common_types.h`) and are primarily aimed at HLSL and GLSL as expected. PSSL uses different type names so in order to make the FSR3 shaders compile for PS4/5, I added the required type definitions to this header file. Additionally, the FSR3 Upscaler shader code uses two type qualifiers (`unorm` and `globallycoherent`) that PSSL doesn't understand. I simply defined these keywords as blanks, which was enough to make the shaders work. Again there is probably a proper way to redefine these keywords using PSSL equivalents, but I haven't found the correct ones yet. -These hacks mean that technically speaking, the FSR2 shaders are not 'correct' on Metal and PSSL. However during my testing I have not seen any problems or visual artifacts caused by these modifications, and the results look as good as they do on any other platform. It's certainly possible that there are issues that I haven't seen yet, particularly in applications with heavy use of high contrast colors and HDR lighting, but until I see a clear example of this I'm going to leave things as-is. +These hacks mean that technically speaking, the FSR3 Upscaler shaders are not 'correct' on Metal and PSSL. However during my testing I have not seen any problems or visual artifacts caused by these modifications, and the results look as good as they do on any other platform. It's certainly possible that there are issues that I haven't seen yet, particularly in applications with heavy use of high contrast colors and HDR lighting, but until I see a clear example of this I'm going to leave things as-is. ### Built-in Render Pipeline upscaling -FSR2 for Unity performs upscaling by manipulating the camera's viewport parameters ahead of rendering, then restoring them during the post-processing phase and outputting the upscaled image directly to the camera's backbuffer. This approach has several advantages and drawbacks: +FSR3 Upscaler for Unity performs upscaling by manipulating the camera's viewport parameters ahead of rendering, then restoring them during the post-processing phase and outputting the upscaled image directly to the camera's backbuffer. This approach has several advantages and drawbacks: Advantages: - It's very simple and works well together with most other rendering effects. @@ -205,26 +201,26 @@ Advantages: Drawbacks: - The upscaled output cannot be blitted back to the camera's target texture, it can only be blitted directly to the backbuffer. -- Consequently, FSR2 upscaling has to be the last image effect in the camera's post-processing chain. -- This makes it difficult to apply additional post-processing effects after FSR2 upscaling. +- Consequently, FSR3 Upscaler has to be the last image effect in the camera's post-processing chain. +- This makes it difficult to apply additional post-processing effects after FSR3 upscaling. -It is now possible to have FSR2 output to a camera target texture, but this is accomplished by taking over control of the target texture and removing it from the camera. This allows the upscaled output to be used as a render texture on a different camera (e.g. for UI usage), but it does not remove the limitation of FSR2 having to be the last image effect on its camera. +It is possible to have FSR3 Upscaler output to a camera target texture, but this is accomplished by taking over control of the target texture and removing it from the camera. This allows the upscaled output to be used as a render texture on a different camera (e.g. for UI usage), but it does not remove the limitation of FSR3 Upscaler having to be the last image effect on its camera. Initial prototypes of the upscaler used a two-camera setup with an intermediate render texture created at runtime. This approach worked, but it had several problems: - It added a lot of complexity of having to create and manage an additional camera. - It added extra rendering overhead; Unity cameras will always render *something* even if you tell it not to draw anything (Clear Flags set to Don't Clear, Culling Mask set to Nothing, etc) and that had a visible performance impact in the GPU profiler. -- It doesn't work well on all platforms. Particularly on Xbox One, Unity has some unsolved issues with render texture blitting when ESRAM usage is enabled. This was causing jittering artifacts when FSR2 upscaling was in use. Disabling ESRAM solved the problem, but at the cost of measurably worse rendering performance. +- It doesn't work well on all platforms. Particularly on Xbox One, Unity has some unsolved issues with render texture blitting when ESRAM usage is enabled. This was causing jittering artifacts when FSR3 Upscaler was in use. Disabling ESRAM solved the problem, but at the cost of measurably worse rendering performance. -Unity also offers a dynamic resolution system (through `ScalableBufferManager`) which would be a good fit for upscaling techniques, but the problem there is that it's not supported on every platform. In particular DirectX 11 on Windows does not support `ScalableBufferManager`, which is a deal breaker. Additionally `ScalableBufferManager` has a long-standing issue where UI gets scaled as well, even if the UI camera is set not to allow dynamic resolution. +Unity also offers a dynamic resolution system (through `ScalableBufferManager`) which would be a good fit for upscaling techniques, but the problem there is that it's not supported on every platform. In particular DirectX 11 on Windows does not support `ScalableBufferManager`, which is a deal breaker. Additionally `ScalableBufferManager` has a long-standing issue where UI gets scaled as well, even if the UI camera is set not to allow dynamic resolution scaling. After looking around for alternative solutions, I came across this discussion: https://answers.unity.com/questions/1322637/best-way-to-downsample-camera-viewport.html. Using camera viewport rect manipulation turned out to be an easy, unassuming and unintrusive solution offering the best balance of platform support, performance and simplicity. ### 16-bit Floating Point support -FSR2 supports the use of half-precision floating point calculations (or FP16) by enabling the `FFX_HALF` keyword on its shaders. This allows FSR2 to take advantage of double-rate floating point operations on modern graphics cards to improve performance. +FSR3 Upscaler supports the use of half-precision floating point calculations (or FP16) by enabling the `FFX_HALF` keyword on its shaders. This allows FSR3 Upscaler to take advantage of double-rate floating point operations on modern graphics cards to improve performance. -FSR2 for Unity supports enabling FP16 too, however the feature is rendered practically useless by how Unity compiles shaders. By default on most non-mobile platforms, any half-precision variables and operations are compiled as 32-bit floating point anyway by Unity's shader compiler. This means on those platforms, FSR2's shaders will behave the same regardless of whether the `FFX_HALF` keyword is enabled or not. +FSR3 Upscaler for Unity supports enabling FP16 too, however the feature is rendered practically useless by how Unity compiles shaders. By default on most non-mobile platforms, any half-precision variables and operations are compiled as 32-bit floating point anyway by Unity's shader compiler. This means on those platforms, FSR3's shaders will behave the same regardless of whether the `FFX_HALF` keyword is enabled or not. There are some exceptions however. First of all, mobile platforms should see an improvement from enabling FP16. Secondly, because the PlayStation platforms received their own custom floating point type definitions, these are not automatically detected and translated to 32-bit floating point types by Unity. This means that on PS4 Pro and PS5, enabling FP16 may have an effect and indeed, on PS5 a measurable performance improvement was observed. -Thirdly, FSR2 for Unity includes experimental support for the DXC shader compiler. Using this alternative shader compiler allows use of certain advanced shader features, such as wave operations and 16-bit floating point operations. The downside of using this compiler is that platform support is very limited; for instance DXC completely breaks DirectX 11 support, which makes it impossible to endorse the use of it. If you're not worried about this and only target platforms covered by the DXC compiler, then it may be worth enabling it in the `ffx_fsr2_unity_common.cginc` shader source file, enabling FP16 support in the inspector and measuring what the effect on performance is. +Thirdly, FSR3 Upscaler for Unity includes experimental support for the DXC shader compiler. Using this alternative shader compiler allows use of certain advanced shader features, such as wave operations and 16-bit floating point operations. The downside of using this compiler is that platform support is very limited; for instance DXC completely breaks DirectX 11 support, which makes it impossible to endorse the use of it. If you're not worried about this and only target platforms covered by the DXC compiler, then it may be worth enabling it in the `ffx_fsr3upscaler_unity_common.cginc` shader source file, enabling FP16 support in the inspector and measuring what the effect on performance is. diff --git a/com.unity.postprocessing/CHANGELOG.md b/com.unity.postprocessing/CHANGELOG.md index 12023f3..10b262d 100644 --- a/com.unity.postprocessing/CHANGELOG.md +++ b/com.unity.postprocessing/CHANGELOG.md @@ -4,10 +4,18 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [3.3.1] - 2023-06-02 +## [3.4.0] - 2023-12-11 + +### Added +- Added WebGPU support ### Fixed -- Fixed obsolete FormatUsage bug +- Fixed obsolete FormatUsage error +- Fixed non-scalar logical operation error +- Fixed MSVO to support platforms with limited storage texture support +- Fixed compute based effects not supported on WebGL and Android OpenGL (IN-2999) +- Fixed grid gizmo is visible through geometry when Post Process Layer is enabled (IN-10318) +- Fixed transparent objects rendering incorrectly when TAA is disabled (IN-31494) ## [3.3.0] - 2023-05-11 diff --git a/com.unity.postprocessing/LICENSE.md b/com.unity.postprocessing/LICENSE.md index bab8330..0ceebee 100644 --- a/com.unity.postprocessing/LICENSE.md +++ b/com.unity.postprocessing/LICENSE.md @@ -1,4 +1,4 @@ -com.unity.postprocessing copyright © 2020 Unity Technologies ApS +com.unity.postprocessing copyright © 2023 Unity Technologies Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License). diff --git a/com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs b/com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs index ecb253d..e329c3f 100644 --- a/com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs +++ b/com.unity.postprocessing/PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs @@ -49,10 +49,14 @@ namespace UnityEditor.Rendering.PostProcessing } else if (aoMode == (int)AmbientOcclusionMode.MultiScaleVolumetricObscurance) { - if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL) + if (!SystemInfo.supportsComputeShaders) { EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support which is not available on this platform.", MessageType.Error); } + else if (EditorUtilities.isTargetingWebGL) + { + EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (WebGPU) when running on Web.", MessageType.Warning); + } else if(EditorUtilities.isTargetingAndroid) { EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (Vulkan) when running on Android.", MessageType.Warning); diff --git a/com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs b/com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs index 559cf51..ae2e1bd 100644 --- a/com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs +++ b/com.unity.postprocessing/PostProcessing/Editor/Effects/AutoExposureEditor.cs @@ -31,10 +31,14 @@ namespace UnityEditor.Rendering.PostProcessing public override void OnInspectorGUI() { - if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL) + if (!SystemInfo.supportsComputeShaders) { EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available on this platform.", MessageType.Error); } + else if (EditorUtilities.isTargetingWebGL) + { + EditorGUILayout.HelpBox("Auto exposure requires compute shader support (WebGPU) when running on Web.", MessageType.Warning); + } else if (EditorUtilities.isTargetingAndroid) { EditorGUILayout.HelpBox("Auto exposure requires compute shader support (Vulkan) when running on Android.", MessageType.Warning); diff --git a/com.unity.postprocessing/PostProcessing/Editor/PostProcessLayerEditor.cs b/com.unity.postprocessing/PostProcessing/Editor/PostProcessLayerEditor.cs index 20f363c..691483d 100644 --- a/com.unity.postprocessing/PostProcessing/Editor/PostProcessLayerEditor.cs +++ b/com.unity.postprocessing/PostProcessing/Editor/PostProcessLayerEditor.cs @@ -62,7 +62,7 @@ namespace UnityEditor.Rendering.PostProcessing new GUIContent("Fast Approximate Anti-aliasing (FXAA)"), new GUIContent("Subpixel Morphological Anti-aliasing (SMAA)"), new GUIContent("Temporal Anti-aliasing (TAA)"), - new GUIContent("FidelityFX Super Resolution 2 (FSR2)") + new GUIContent("FidelityFX Super Resolution 3 (FSR3) Upscaler") }; enum ExportMode diff --git a/com.unity.postprocessing/PostProcessing/PostProcessResources.asset b/com.unity.postprocessing/PostProcessing/PostProcessResources.asset index ae78db2..835a2eb 100644 --- a/com.unity.postprocessing/PostProcessing/PostProcessResources.asset +++ b/com.unity.postprocessing/PostProcessing/PostProcessResources.asset @@ -3,8 +3,9 @@ --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 @@ -92,19 +93,15 @@ MonoBehaviour: bloom: {fileID: 4800000, guid: c1e1d3119c6fd4646aea0b4b74cacc1a, type: 3} copy: {fileID: 4800000, guid: cdbdb71de5f9c454b980f6d0e87f0afb, type: 3} copyStd: {fileID: 4800000, guid: 4bf4cff0d0bac3d43894e2e8839feb40, type: 3} - copyStdFromTexArray: {fileID: 4800000, guid: 02d2da9bc88d25c4d878c1ed4e0b3854, - type: 3} - copyStdFromDoubleWide: {fileID: 4800000, guid: e8ce9961912f3214586fe8709b9012c1, - type: 3} + copyStdFromTexArray: {fileID: 4800000, guid: 02d2da9bc88d25c4d878c1ed4e0b3854, type: 3} + copyStdFromDoubleWide: {fileID: 4800000, guid: e8ce9961912f3214586fe8709b9012c1, type: 3} discardAlpha: {fileID: 4800000, guid: 5ab0816423f0dfe45841cab3b05ec9ef, type: 3} depthOfField: {fileID: 4800000, guid: 0ef78d24e85a44f4da9d5b5eaa00e50b, type: 3} finalPass: {fileID: 4800000, guid: f75014305794b3948a3c6d5ccd550e05, type: 3} grainBaker: {fileID: 4800000, guid: 0d8afcb51cc9f0349a6d190da929b838, type: 3} motionBlur: {fileID: 4800000, guid: 2c459b89a7c8b1a4fbefe0d81341651c, type: 3} - temporalAntialiasing: {fileID: 4800000, guid: 51bcf79c50dc92e47ba87821b61100c3, - type: 3} - subpixelMorphologicalAntialiasing: {fileID: 4800000, guid: 81af42a93ade3dd46a9b583d4eec76d6, - type: 3} + temporalAntialiasing: {fileID: 4800000, guid: 51bcf79c50dc92e47ba87821b61100c3, type: 3} + subpixelMorphologicalAntialiasing: {fileID: 4800000, guid: 81af42a93ade3dd46a9b583d4eec76d6, type: 3} texture2dLerp: {fileID: 4800000, guid: 34a819c9e33402547a81619693adc8d5, type: 3} uber: {fileID: 4800000, guid: 382151503e2a43a4ebb7366d1632731d, type: 3} lut2DBaker: {fileID: 4800000, guid: 7ad194cbe7d006f4bace915156972026, type: 3} @@ -116,8 +113,7 @@ MonoBehaviour: deferredFog: {fileID: 4800000, guid: 4117fce9491711c4094d33a048e36e73, type: 3} scalableAO: {fileID: 4800000, guid: d7640629310e79646af0f46eb55ae466, type: 3} multiScaleAO: {fileID: 4800000, guid: 67f9497810829eb4791ec19e95781e51, type: 3} - screenSpaceReflections: {fileID: 4800000, guid: f997a3dc9254c44459323cced085150c, - type: 3} + screenSpaceReflections: {fileID: 4800000, guid: f997a3dc9254c44459323cced085150c, type: 3} computeShaders: autoExposure: {fileID: 7200000, guid: 34845e0ca016b7448842e965db5890a5, type: 3} exposureHistogram: {fileID: 7200000, guid: 8c2fcbdf9bc58664f89917f7b9d79501, type: 3} @@ -126,30 +122,17 @@ MonoBehaviour: gammaHistogram: {fileID: 7200000, guid: 18183ebfeeab97749b43e38b928604a7, type: 3} waveform: {fileID: 7200000, guid: 92c63830cd50c0b4fbb8233613839958, type: 3} vectorscope: {fileID: 7200000, guid: e1efca7c36fd01840aae0dd10378de5c, type: 3} - multiScaleAODownsample1: {fileID: 7200000, guid: 4c63bc487e6c29a4a99f85a6c47b292b, - type: 3} - multiScaleAODownsample2: {fileID: 7200000, guid: e4d3e4779e48a374f91d48d4c0aedb7b, - type: 3} - multiScaleAORender: {fileID: 7200000, guid: 34a460e8a2e66c243a9c12024e5a798d, - type: 3} - multiScaleAOUpsample: {fileID: 7200000, guid: 600d6212b59bb40409d19d750b5fd1e9, - type: 3} - gaussianDownsample: {fileID: 7200000, guid: 6dba4103d23a7904fbc49099355aff3e, - type: 3} - namedShaders: - - name: FSR2/ffx_fsr2_compute_luminance_pyramid_pass - shader: {fileID: 7200000, guid: 0894ebeefb6aa7d4680c71dffbda3fee, type: 3} - - name: FSR2/ffx_fsr2_reconstruct_previous_depth_pass - shader: {fileID: 7200000, guid: 6ef1b4c25874e334dad5ba3ac6345e32, type: 3} - - name: FSR2/ffx_fsr2_depth_clip_pass - shader: {fileID: 7200000, guid: 8026d9d8542eab6499c32d5d46beb2b6, type: 3} - - name: FSR2/ffx_fsr2_lock_pass - shader: {fileID: 7200000, guid: 3c96d72b39a840c428c901628dab92c0, type: 3} - - name: FSR2/ffx_fsr2_accumulate_pass - shader: {fileID: 7200000, guid: 702560780e923c84394c9b22ba460a9c, type: 3} - - name: FSR2/ffx_fsr2_rcas_pass - shader: {fileID: 7200000, guid: 5a82801f160ff6a4eb47db567216e592, type: 3} - - name: FSR2/ffx_fsr2_autogen_reactive_pass - shader: {fileID: 7200000, guid: d18fb8811ca4753469c439784546104e, type: 3} - - name: FSR2/ffx_fsr2_tcr_autogen_pass - shader: {fileID: 7200000, guid: b478fba0a6a87b44b8be7c35deb5f0dc, type: 3} + multiScaleAODownsample1: {fileID: 7200000, guid: 4c63bc487e6c29a4a99f85a6c47b292b, type: 3} + multiScaleAODownsample2: {fileID: 7200000, guid: e4d3e4779e48a374f91d48d4c0aedb7b, type: 3} + multiScaleAORender: {fileID: 7200000, guid: 34a460e8a2e66c243a9c12024e5a798d, type: 3} + multiScaleAOUpsample: {fileID: 7200000, guid: 600d6212b59bb40409d19d750b5fd1e9, type: 3} + gaussianDownsample: {fileID: 7200000, guid: 6dba4103d23a7904fbc49099355aff3e, type: 3} + superResolution: + computeLuminancePyramidPass: {fileID: 7200000, guid: d253be05abcdc80428503d3e4cce3a36, type: 3} + reconstructPreviousDepthPass: {fileID: 7200000, guid: 4f59e5b9179d74844ae06a30ae1e0629, type: 3} + depthClipPass: {fileID: 7200000, guid: 20e44016ed34b0d4b8de499d1b566c69, type: 3} + lockPass: {fileID: 7200000, guid: a135306e6d1857e43a86ef20db2a47fe, type: 3} + accumulatePass: {fileID: 7200000, guid: c9b45f0ae7673694ba57a4aadfe212e9, type: 3} + sharpenPass: {fileID: 7200000, guid: 7aaf5cfff022de2499e9b0412f947f6c, type: 3} + autoGenReactivePass: {fileID: 7200000, guid: 5716b91fdaa4e9e439df6b96a796fe6e, type: 3} + tcrAutoGenPass: {fileID: 7200000, guid: 75cdc6ef23f08ed498d4da511923fcea, type: 3} diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs b/com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs index afffab9..ae5d00e 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Effects/AmbientOcclusion.cs @@ -196,7 +196,7 @@ namespace UnityEngine.Rendering.PostProcessing state &= SystemInfo.supportsComputeShaders && !RuntimeUtilities.isAndroidOpenGL - && !RuntimeUtilities.isWebGL + && !RuntimeUtilities.isWebNonWebGPU #if UNITY_2023_2_OR_NEWER && SystemInfo.IsFormatSupported(GraphicsFormat.R32_SFloat, GraphicsFormatUsage.Render) && SystemInfo.IsFormatSupported(GraphicsFormat.R16_SFloat, GraphicsFormatUsage.Render) diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs b/com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs index 7a0e933..7995cdc 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Effects/AutoExposure.cs @@ -85,7 +85,7 @@ namespace UnityEngine.Rendering.PostProcessing return enabled.value && SystemInfo.supportsComputeShaders && !RuntimeUtilities.isAndroidOpenGL - && !RuntimeUtilities.isWebGL + && !RuntimeUtilities.isWebNonWebGPU && RenderTextureFormat.RFloat.IsSupported() && context.resources.computeShaders.autoExposure && context.resources.computeShaders.exposureHistogram; diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Effects/MultiScaleVO.cs b/com.unity.postprocessing/PostProcessing/Runtime/Effects/MultiScaleVO.cs index a1af379..42719df 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Effects/MultiScaleVO.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Effects/MultiScaleVO.cs @@ -1,4 +1,5 @@ using System; +using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.PostProcessing { @@ -53,6 +54,10 @@ namespace UnityEngine.Rendering.PostProcessing // command buffer warning RenderTexture m_AmbientOnlyAO; + RenderTextureFormat m_R8Format; + RenderTextureFormat m_R16Format; + bool float4Texture = false; + readonly RenderTargetIdentifier[] m_MRT = { BuiltinRenderTextureType.GBuffer0, // Albedo, Occ @@ -62,6 +67,46 @@ namespace UnityEngine.Rendering.PostProcessing public MultiScaleVO(AmbientOcclusion settings) { m_Settings = settings; + // R16 is not supported on all platforms as a storage texture format + // R8 is not supported on all platforms as a storage texture format + m_R8Format = RenderTextureFormat.R8; + m_R16Format = RenderTextureFormat.RHalf; +#if UNITY_2023_2_OR_NEWER + if (!SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(m_R8Format, false), GraphicsFormatUsage.LoadStore)) + { + if (SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(RenderTextureFormat.ARGB32, false), GraphicsFormatUsage.LoadStore)) + { + m_R8Format = RenderTextureFormat.ARGB32; + float4Texture = true; + } + } + + if (!SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(m_R16Format, false), GraphicsFormatUsage.LoadStore)) + { + if (SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(RenderTextureFormat.RFloat, false), GraphicsFormatUsage.LoadStore)) + { + m_R16Format = RenderTextureFormat.RFloat; + } + } + +#else + if (!SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(m_R8Format, false), FormatUsage.LoadStore)) + { + if (SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(RenderTextureFormat.ARGB32, false), FormatUsage.LoadStore)) + { + m_R8Format = RenderTextureFormat.ARGB32; + float4Texture = true; + } + } + + if (!SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(m_R16Format, false), FormatUsage.LoadStore)) + { + if (SystemInfo.IsFormatSupported(GraphicsFormatUtility.GetGraphicsFormat(RenderTextureFormat.RFloat, false), FormatUsage.LoadStore)) + { + m_R16Format = RenderTextureFormat.RFloat; + } + } +#endif } public DepthTextureMode GetCameraFlags() @@ -237,26 +282,26 @@ namespace UnityEngine.Rendering.PostProcessing } else { - Alloc(cmd, ShaderIDs.LinearDepth, MipLevel.Original, RenderTextureFormat.RHalf, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.LinearDepth, MipLevel.Original, m_R16Format, true, dynamicResolutionEnabled); Alloc(cmd, ShaderIDs.LowDepth1, MipLevel.L1, RenderTextureFormat.RFloat, true, dynamicResolutionEnabled); Alloc(cmd, ShaderIDs.LowDepth2, MipLevel.L2, RenderTextureFormat.RFloat, true, dynamicResolutionEnabled); Alloc(cmd, ShaderIDs.LowDepth3, MipLevel.L3, RenderTextureFormat.RFloat, true, dynamicResolutionEnabled); Alloc(cmd, ShaderIDs.LowDepth4, MipLevel.L4, RenderTextureFormat.RFloat, true, dynamicResolutionEnabled); - AllocArray(cmd, ShaderIDs.TiledDepth1, MipLevel.L3, RenderTextureFormat.RHalf, true, dynamicResolutionEnabled); - AllocArray(cmd, ShaderIDs.TiledDepth2, MipLevel.L4, RenderTextureFormat.RHalf, true, dynamicResolutionEnabled); - AllocArray(cmd, ShaderIDs.TiledDepth3, MipLevel.L5, RenderTextureFormat.RHalf, true, dynamicResolutionEnabled); - AllocArray(cmd, ShaderIDs.TiledDepth4, MipLevel.L6, RenderTextureFormat.RHalf, true, dynamicResolutionEnabled); + AllocArray(cmd, ShaderIDs.TiledDepth1, MipLevel.L3, m_R16Format, true, dynamicResolutionEnabled); + AllocArray(cmd, ShaderIDs.TiledDepth2, MipLevel.L4, m_R16Format, true, dynamicResolutionEnabled); + AllocArray(cmd, ShaderIDs.TiledDepth3, MipLevel.L5, m_R16Format, true, dynamicResolutionEnabled); + AllocArray(cmd, ShaderIDs.TiledDepth4, MipLevel.L6, m_R16Format, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Occlusion1, MipLevel.L1, RenderTextureFormat.R8, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Occlusion2, MipLevel.L2, RenderTextureFormat.R8, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Occlusion3, MipLevel.L3, RenderTextureFormat.R8, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Occlusion4, MipLevel.L4, RenderTextureFormat.R8, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Occlusion1, MipLevel.L1, m_R8Format, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Occlusion2, MipLevel.L2, m_R8Format, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Occlusion3, MipLevel.L3, m_R8Format, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Occlusion4, MipLevel.L4, m_R8Format, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Combined1, MipLevel.L1, RenderTextureFormat.R8, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Combined2, MipLevel.L2, RenderTextureFormat.R8, true, dynamicResolutionEnabled); - Alloc(cmd, ShaderIDs.Combined3, MipLevel.L3, RenderTextureFormat.R8, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Combined1, MipLevel.L1, m_R8Format, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Combined2, MipLevel.L2, m_R8Format, true, dynamicResolutionEnabled); + Alloc(cmd, ShaderIDs.Combined3, MipLevel.L3, m_R8Format, true, dynamicResolutionEnabled); } } @@ -292,12 +337,11 @@ namespace UnityEngine.Rendering.PostProcessing cmd.SetComputeTextureParam(cs, kernel, "LinearZ", ShaderIDs.LinearDepth); cmd.SetComputeTextureParam(cs, kernel, "DS2x", ShaderIDs.LowDepth1); - cmd.SetComputeTextureParam(cs, kernel, "DS4x", ShaderIDs.LowDepth2); cmd.SetComputeTextureParam(cs, kernel, "DS2xAtlas", ShaderIDs.TiledDepth1); - cmd.SetComputeTextureParam(cs, kernel, "DS4xAtlas", ShaderIDs.TiledDepth2); cmd.SetComputeVectorParam(cs, "ZBufferParams", CalculateZBufferParams(camera)); cmd.SetComputeTextureParam(cs, kernel, "Depth", depthMapId); - + cmd.SetComputeTextureParam(cs, kernel, "DS4x", ShaderIDs.LowDepth2); + cmd.SetComputeTextureParam(cs, kernel, "DS4xAtlas", ShaderIDs.TiledDepth2); cmd.DispatchCompute(cs, kernel, m_ScaledWidths[(int)MipLevel.L4], m_ScaledHeights[(int)MipLevel.L4], 1); if (needDepthMapRelease) @@ -384,7 +428,9 @@ namespace UnityEngine.Rendering.PostProcessing // Set the arguments for the render kernel. var cs = m_Resources.computeShaders.multiScaleAORender; - int kernel = isMSAA ? cs.FindKernel("MultiScaleVORender_MSAA_interleaved") : cs.FindKernel("MultiScaleVORender_interleaved"); + string kernelName = isMSAA ? "MultiScaleVORender_MSAA_interleaved" : "MultiScaleVORender_interleaved"; + if (float4Texture) kernelName += "_Float4"; + int kernel = cs.FindKernel(kernelName); cmd.SetComputeFloatParams(cs, "gInvThicknessTable", m_InvThicknessTable); cmd.SetComputeFloatParams(cs, "gSampleWeightTable", m_SampleWeightTable); @@ -411,17 +457,27 @@ namespace UnityEngine.Rendering.PostProcessing int kernel = 0; if (!isMSAA) { - kernel = cs.FindKernel(highResAO == null ? invert + string kernelName = highResAO == null ? invert ? "MultiScaleVOUpSample_invert" : "MultiScaleVOUpSample" - : "MultiScaleVOUpSample_blendout"); + : "MultiScaleVOUpSample_blendout"; + if (float4Texture) + { + kernelName += "_Float4"; + } + kernel = cs.FindKernel(kernelName); } else { - kernel = cs.FindKernel(highResAO == null ? invert + string kernelName = highResAO == null ? invert ? "MultiScaleVOUpSample_MSAA_invert" : "MultiScaleVOUpSample_MSAA" - : "MultiScaleVOUpSample_MSAA_blendout"); + : "MultiScaleVOUpSample_MSAA_blendout"; + if (float4Texture) + { + kernelName += "_Float4"; + } + kernel = cs.FindKernel(kernelName); } @@ -491,8 +547,7 @@ namespace UnityEngine.Rendering.PostProcessing if (AOUpdateNeeded) { RuntimeUtilities.Destroy(m_AmbientOnlyAO); - - m_AmbientOnlyAO = new RenderTexture(context.width, context.height, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear) + m_AmbientOnlyAO = new RenderTexture(context.width, context.height, 0, m_R8Format, RenderTextureReadWrite.Linear) { hideFlags = HideFlags.DontSave, filterMode = FilterMode.Point, diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Effects/SuperResolution.cs b/com.unity.postprocessing/PostProcessing/Runtime/Effects/SuperResolution.cs index e7ff440..1148403 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Effects/SuperResolution.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Effects/SuperResolution.cs @@ -31,10 +31,10 @@ namespace UnityEngine.Rendering.PostProcessing [Serializable] public class SuperResolution { - public Func callbacksFactory { get; set; } = (context) => new Callbacks(context.resources); + public Func callbacksFactory { get; set; } = (context) => new Fsr3UpscalerCallbacksBase(); [Tooltip("Standard scaling ratio presets.")] - public Fsr2.QualityMode qualityMode = Fsr2.QualityMode.Quality; + public Fsr3Upscaler.QualityMode qualityMode = Fsr3Upscaler.QualityMode.Quality; [Tooltip("Apply RCAS sharpening to the image after upscaling.")] public bool performSharpenPass = true; @@ -44,7 +44,7 @@ namespace UnityEngine.Rendering.PostProcessing [Tooltip("Allow the use of half precision compute operations, potentially improving performance if the platform supports it.")] public bool enableFP16 = false; - [Tooltip("Choose where to get the exposure value from. Use auto-exposure from either FSR2 or Unity, provide a manual exposure texture, or use a default value.")] + [Tooltip("Choose where to get the exposure value from. Use auto-exposure from either FSR3 or Unity, provide a manual exposure texture, or use a default value.")] public ExposureSource exposureSource = ExposureSource.Auto; [Tooltip("Value by which the input signal will be divided, to get back to the original signal produced by the game.")] public float preExposure = 1.0f; @@ -78,7 +78,7 @@ namespace UnityEngine.Rendering.PostProcessing [Tooltip("A value to set for the binary reactive mask")] [Range(0, 1)] public float binaryValue = 0.9f; [Tooltip("Flags to determine how to generate the reactive mask")] - public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax; + public Fsr3Upscaler.GenerateReactiveFlags flags = Fsr3Upscaler.GenerateReactiveFlags.ApplyTonemap | Fsr3Upscaler.GenerateReactiveFlags.ApplyThreshold | Fsr3Upscaler.GenerateReactiveFlags.UseComponentsMax; } [Tooltip("(Experimental) Automatically generate and use Reactive mask and Transparency & composition mask internally.")] @@ -104,17 +104,17 @@ namespace UnityEngine.Rendering.PostProcessing public Vector2Int displaySize => _displaySize; public RenderTargetIdentifier colorOpaqueOnly { get; set; } - private Fsr2Context _fsrContext; + private Fsr3UpscalerContext _fsrContext; private Vector2Int _maxRenderSize; private Vector2Int _displaySize; private bool _resetHistory; - private IFsr2Callbacks _callbacks; + private IFsr3UpscalerCallbacks _callbacks; - private readonly Fsr2.DispatchDescription _dispatchDescription = new Fsr2.DispatchDescription(); - private readonly Fsr2.GenerateReactiveDescription _genReactiveDescription = new Fsr2.GenerateReactiveDescription(); + private readonly Fsr3Upscaler.DispatchDescription _dispatchDescription = new Fsr3Upscaler.DispatchDescription(); + private readonly Fsr3Upscaler.GenerateReactiveDescription _genReactiveDescription = new Fsr3Upscaler.GenerateReactiveDescription(); - private Fsr2.QualityMode _prevQualityMode; + private Fsr3Upscaler.QualityMode _prevQualityMode; private ExposureSource _prevExposureSource; private Vector2Int _prevDisplaySize; @@ -152,11 +152,11 @@ namespace UnityEngine.Rendering.PostProcessing // Determine the desired rendering and display resolutions _displaySize = new Vector2Int(camera.pixelWidth, camera.pixelHeight); - Fsr2.GetRenderResolutionFromQualityMode(out int maxRenderWidth, out int maxRenderHeight, _displaySize.x, _displaySize.y, qualityMode); + Fsr3Upscaler.GetRenderResolutionFromQualityMode(out int maxRenderWidth, out int maxRenderHeight, _displaySize.x, _displaySize.y, qualityMode); _maxRenderSize = new Vector2Int(maxRenderWidth, maxRenderHeight); // Render to a smaller portion of the screen by manipulating the camera's viewport rect - camera.aspect = (_displaySize.x * _originalRect.width) / (_displaySize.y * _originalRect.height); + camera.aspect = (float)_displaySize.x / _displaySize.y; camera.rect = new Rect(0, 0, _originalRect.width * _maxRenderSize.x / _displaySize.x, _originalRect.height * _maxRenderSize.y / _displaySize.y); } @@ -168,10 +168,10 @@ namespace UnityEngine.Rendering.PostProcessing public void Render(PostProcessRenderContext context) { var cmd = context.command; - cmd.BeginSample("FSR2"); + cmd.BeginSample("FSR3 Upscaler"); - // Monitor for any resolution changes and recreate the FSR2 context if necessary - // We can't create an FSR2 context without info from the post-processing context, so delay the initial setup until here + // Monitor for any resolution changes and recreate the FSR3 Upscaler context if necessary + // We can't create an FSR3 Upscaler context without info from the post-processing context, so delay the initial setup until here if (_fsrContext == null || _displaySize.x != _prevDisplaySize.x || _displaySize.y != _prevDisplaySize.y || qualityMode != _prevQualityMode || exposureSource != _prevExposureSource) { DestroyFsrContext(); @@ -185,14 +185,14 @@ namespace UnityEngine.Rendering.PostProcessing SetupAutoReactiveDescription(context); var scaledRenderSize = _genReactiveDescription.RenderSize; - cmd.GetTemporaryRT(Fsr2ShaderIDs.UavAutoReactive, scaledRenderSize.x, scaledRenderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); + cmd.GetTemporaryRT(Fsr3ShaderIDs.UavAutoReactive, scaledRenderSize.x, scaledRenderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); _fsrContext.GenerateReactiveMask(_genReactiveDescription, cmd); - _dispatchDescription.Reactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); + _dispatchDescription.Reactive = new ResourceView(Fsr3ShaderIDs.UavAutoReactive); } _fsrContext.Dispatch(_dispatchDescription, cmd); - cmd.EndSample("FSR2"); + cmd.EndSample("FSR3 Upscaler"); _resetHistory = false; } @@ -203,18 +203,18 @@ namespace UnityEngine.Rendering.PostProcessing _prevExposureSource = exposureSource; _prevDisplaySize = _displaySize; - // Initialize FSR2 context - Fsr2.InitializationFlags flags = 0; - if (context.camera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; - if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; - if (exposureSource == ExposureSource.Auto) flags |= Fsr2.InitializationFlags.EnableAutoExposure; - if (RuntimeUtilities.IsDynamicResolutionEnabled(context.camera)) flags |= Fsr2.InitializationFlags.EnableDynamicResolution; + // Initialize FSR3 Upscaler context + Fsr3Upscaler.InitializationFlags flags = 0; + if (context.camera.allowHDR) flags |= Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange; + if (enableFP16) flags |= Fsr3Upscaler.InitializationFlags.EnableFP16Usage; + if (exposureSource == ExposureSource.Auto) flags |= Fsr3Upscaler.InitializationFlags.EnableAutoExposure; + if (RuntimeUtilities.IsDynamicResolutionEnabled(context.camera)) flags |= Fsr3Upscaler.InitializationFlags.EnableDynamicResolution; _callbacks = callbacksFactory(context); - _fsrContext = Fsr2.CreateContext(_displaySize, _maxRenderSize, _callbacks, flags); + _fsrContext = Fsr3Upscaler.CreateContext(_displaySize, _maxRenderSize, context.resources.computeShaders.superResolution, flags); // Apply a mipmap bias so that textures retain their sharpness - float biasOffset = Fsr2.GetMipmapBiasOffset(_maxRenderSize.x, _displaySize.x); + float biasOffset = Fsr3Upscaler.GetMipmapBiasOffset(_maxRenderSize.x, _displaySize.x); if (!float.IsNaN(biasOffset) && !float.IsInfinity(biasOffset)) { _callbacks.ApplyMipmapBias(biasOffset); @@ -241,9 +241,9 @@ namespace UnityEngine.Rendering.PostProcessing { var scaledRenderSize = GetScaledRenderSize(camera); - // Perform custom jittering of the camera's projection matrix according to FSR2's recipe - int jitterPhaseCount = Fsr2.GetJitterPhaseCount(scaledRenderSize.x, _displaySize.x); - Fsr2.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount); + // Perform custom jittering of the camera's projection matrix according to FSR3's recipe + int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(scaledRenderSize.x, _displaySize.x); + Fsr3Upscaler.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount); _dispatchDescription.JitterOffset = new Vector2(jitterX, jitterY); @@ -262,22 +262,22 @@ namespace UnityEngine.Rendering.PostProcessing { var camera = context.camera; - // Set up the main FSR2 dispatch parameters - _dispatchDescription.Color = new Fsr2.ResourceView(context.source); - _dispatchDescription.Depth = new Fsr2.ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); - _dispatchDescription.MotionVectors = new Fsr2.ResourceView(BuiltinRenderTextureType.MotionVectors); - _dispatchDescription.Exposure = Fsr2.ResourceView.Unassigned; - _dispatchDescription.Reactive = Fsr2.ResourceView.Unassigned; - _dispatchDescription.TransparencyAndComposition = Fsr2.ResourceView.Unassigned; - - if (exposureSource == ExposureSource.Manual && exposure != null) _dispatchDescription.Exposure = new Fsr2.ResourceView(exposure); - if (exposureSource == ExposureSource.Unity) _dispatchDescription.Exposure = new Fsr2.ResourceView(context.autoExposureTexture); - if (reactiveMask != null) _dispatchDescription.Reactive = new Fsr2.ResourceView(reactiveMask); - if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new Fsr2.ResourceView(transparencyAndCompositionMask); + // Set up the main FSR3 Upscaler dispatch parameters + _dispatchDescription.Color = new ResourceView(context.source); + _dispatchDescription.Depth = new ResourceView(BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); + _dispatchDescription.MotionVectors = new ResourceView(BuiltinRenderTextureType.MotionVectors); + _dispatchDescription.Exposure = ResourceView.Unassigned; + _dispatchDescription.Reactive = ResourceView.Unassigned; + _dispatchDescription.TransparencyAndComposition = ResourceView.Unassigned; + + if (exposureSource == ExposureSource.Manual && exposure != null) _dispatchDescription.Exposure = new ResourceView(exposure); + if (exposureSource == ExposureSource.Unity) _dispatchDescription.Exposure = new ResourceView(context.autoExposureTexture); + if (reactiveMask != null) _dispatchDescription.Reactive = new ResourceView(reactiveMask); + if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = new ResourceView(transparencyAndCompositionMask); var scaledRenderSize = GetScaledRenderSize(context.camera); - _dispatchDescription.Output = new Fsr2.ResourceView(context.destination); + _dispatchDescription.Output = new ResourceView(context.destination); _dispatchDescription.PreExposure = preExposure; _dispatchDescription.EnableSharpening = performSharpenPass; _dispatchDescription.Sharpness = sharpness; @@ -296,7 +296,7 @@ namespace UnityEngine.Rendering.PostProcessing _dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition; if (autoGenerateTransparencyAndComposition) { - _dispatchDescription.ColorOpaqueOnly = new Fsr2.ResourceView(colorOpaqueOnly); + _dispatchDescription.ColorOpaqueOnly = new ResourceView(colorOpaqueOnly); _dispatchDescription.AutoTcThreshold = generateTransparencyAndCompositionParameters.autoTcThreshold; _dispatchDescription.AutoTcScale = generateTransparencyAndCompositionParameters.autoTcScale; _dispatchDescription.AutoReactiveScale = generateTransparencyAndCompositionParameters.autoReactiveScale; @@ -305,7 +305,7 @@ namespace UnityEngine.Rendering.PostProcessing if (SystemInfo.usesReversedZBuffer) { - // Swap the near and far clip plane distances as FSR2 expects this when using inverted depth + // Swap the near and far clip plane distances as FSR3 expects this when using inverted depth (_dispatchDescription.CameraNear, _dispatchDescription.CameraFar) = (_dispatchDescription.CameraFar, _dispatchDescription.CameraNear); } } @@ -313,9 +313,9 @@ namespace UnityEngine.Rendering.PostProcessing private void SetupAutoReactiveDescription(PostProcessRenderContext context) { // Set up the parameters to auto-generate a reactive mask - _genReactiveDescription.ColorOpaqueOnly = new Fsr2.ResourceView(colorOpaqueOnly); - _genReactiveDescription.ColorPreUpscale = new Fsr2.ResourceView(context.source); - _genReactiveDescription.OutReactive = new Fsr2.ResourceView(Fsr2ShaderIDs.UavAutoReactive); + _genReactiveDescription.ColorOpaqueOnly = new ResourceView(colorOpaqueOnly); + _genReactiveDescription.ColorPreUpscale = new ResourceView(context.source); + _genReactiveDescription.OutReactive = new ResourceView(Fsr3ShaderIDs.UavAutoReactive); _genReactiveDescription.RenderSize = GetScaledRenderSize(context.camera); _genReactiveDescription.Scale = generateReactiveParameters.scale; _genReactiveDescription.CutoffThreshold = generateReactiveParameters.cutoffThreshold; @@ -330,24 +330,5 @@ namespace UnityEngine.Rendering.PostProcessing return new Vector2Int(Mathf.CeilToInt(_maxRenderSize.x * ScalableBufferManager.widthScaleFactor), Mathf.CeilToInt(_maxRenderSize.y * ScalableBufferManager.heightScaleFactor)); } - - private class Callbacks : Fsr2CallbacksBase - { - private readonly PostProcessResources _resources; - - public Callbacks(PostProcessResources resources) - { - _resources = resources; - } - - public override ComputeShader LoadComputeShader(string name) - { - return _resources.computeShaders.FindComputeShader(name); - } - - public override void UnloadComputeShader(ComputeShader shader) - { - } - } } } diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs.meta deleted file mode 100644 index 10fe120..0000000 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 742d52dc87714f0d93f3b59719859dff -timeCreated: 1673441954 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs.meta deleted file mode 100644 index ed50468..0000000 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2f00ea267c3443d88bbd0e9dd7c08b4a -timeCreated: 1673442225 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs.meta deleted file mode 100644 index 06ce7e4..0000000 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Pass.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 14234aed75ce454183019d2e20a44d24 -timeCreated: 1676885169 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs.meta deleted file mode 100644 index 0e993b4..0000000 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Resources.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 22ad49193f244ab4a36d0a1512f3015f -timeCreated: 1677236102 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs.meta deleted file mode 100644 index ef83135..0000000 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2ShaderIDs.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ad1eca9398174f6c85d8bc01d10993df -timeCreated: 1679060863 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3.meta new file mode 100644 index 0000000..e12cfa8 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfeca308812376e4a8e5e49e0d96c5c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Core/Fsr2ShaderIDs.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs similarity index 96% rename from Assets/Scripts/Core/Fsr2ShaderIDs.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs index b07c967..3a28843 100644 --- a/Assets/Scripts/Core/Fsr2ShaderIDs.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs @@ -22,7 +22,7 @@ using UnityEngine; namespace FidelityFX { - internal static class Fsr2ShaderIDs + internal static class Fsr3ShaderIDs { // Shader resource views, i.e. read-only bindings internal static readonly int SrvInputColor = Shader.PropertyToID("r_input_color_jittered"); @@ -36,7 +36,7 @@ namespace FidelityFX internal static readonly int SrvReconstructedPrevNearestDepth = Shader.PropertyToID("r_reconstructed_previous_nearest_depth"); internal static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors"); internal static readonly int SrvPrevDilatedMotionVectors = Shader.PropertyToID("r_previous_dilated_motion_vectors"); - internal static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilatedDepth"); + internal static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilated_depth"); internal static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color"); internal static readonly int SrvLockStatus = Shader.PropertyToID("r_lock_status"); internal static readonly int SrvLockInputLuma = Shader.PropertyToID("r_lock_input_luma"); @@ -53,7 +53,7 @@ namespace FidelityFX // Unordered access views, i.e. random read/write bindings internal static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth"); internal static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors"); - internal static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilatedDepth"); + internal static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilated_depth"); internal static readonly int UavInternalUpscaled = Shader.PropertyToID("rw_internal_upscaled_color"); internal static readonly int UavLockStatus = Shader.PropertyToID("rw_lock_status"); internal static readonly int UavLockInputLuma = Shader.PropertyToID("rw_lock_input_luma"); @@ -72,7 +72,7 @@ namespace FidelityFX internal static readonly int UavPrevColorPostAlpha = Shader.PropertyToID("rw_output_prev_color_post_alpha"); // Constant buffer bindings - internal static readonly int CbFsr2 = Shader.PropertyToID("cbFSR2"); + internal static readonly int CbFsr3Upscaler = Shader.PropertyToID("cbFSR3Upscaler"); internal static readonly int CbSpd = Shader.PropertyToID("cbSPD"); internal static readonly int CbRcas = Shader.PropertyToID("cbRCAS"); internal static readonly int CbGenReactive = Shader.PropertyToID("cbGenerateReactive"); diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs.meta new file mode 100644 index 0000000..9012617 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3ShaderIDs.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a0e0bcc2967836742b7864d1cafafbf0 +timeCreated: 1679060863 \ No newline at end of file diff --git a/Assets/Scripts/Core/Fsr2.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs similarity index 79% rename from Assets/Scripts/Core/Fsr2.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs index 1ba8192..c636c93 100644 --- a/Assets/Scripts/Core/Fsr2.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs @@ -26,14 +26,14 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// A collection of helper functions and data structures required by the FSR2 process. + /// A collection of helper functions and data structures required by the FSR3 Upscaler process. /// - public static class Fsr2 + public static class Fsr3Upscaler { /// - /// Creates a new FSR2 context with standard parameters that are appropriate for the current platform. + /// Creates a new FSR3 Upscaler context with standard parameters that are appropriate for the current platform. /// - public static Fsr2Context CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, IFsr2Callbacks callbacks, InitializationFlags flags = 0) + public static Fsr3UpscalerContext CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, Fsr3UpscalerShaders shaders, InitializationFlags flags = 0) { if (SystemInfo.usesReversedZBuffer) flags |= InitializationFlags.EnableDepthInverted; @@ -44,17 +44,17 @@ namespace FidelityFX flags |= InitializationFlags.EnableDebugChecking; #endif - Debug.Log($"Setting up FSR2 with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}"); + Debug.Log($"Setting up FSR3 Upscaler with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}"); var contextDescription = new ContextDescription { Flags = flags, DisplaySize = displaySize, MaxRenderSize = maxRenderSize, - Callbacks = callbacks, + Shaders = shaders, }; - var context = new Fsr2Context(); + var context = new Fsr3UpscalerContext(); context.Create(contextDescription); return context; } @@ -63,6 +63,8 @@ namespace FidelityFX { switch (qualityMode) { + case QualityMode.NativeAA: + return 1.0f; case QualityMode.UltraQuality: return 1.2f; case QualityMode.Quality: @@ -134,11 +136,12 @@ namespace FidelityFX public enum QualityMode { - UltraQuality = 0, - Quality = 1, - Balanced = 2, - Performance = 3, - UltraPerformance = 4, + NativeAA = 0, + UltraQuality = 1, + Quality = 2, + Balanced = 3, + Performance = 4, + UltraPerformance = 5, } [Flags] @@ -155,47 +158,19 @@ namespace FidelityFX EnableDebugChecking = 1 << 8, } + /// + /// A structure encapsulating the parameters required to initialize FidelityFX Super Resolution 3 upscaling. + /// public struct ContextDescription { public InitializationFlags Flags; public Vector2Int MaxRenderSize; public Vector2Int DisplaySize; - public IFsr2Callbacks Callbacks; - } - - /// - /// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader. - /// - public readonly struct ResourceView - { - /// - /// This value is the equivalent of not setting any value at all; all struct fields will have their default values. - /// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader. - /// - public static readonly ResourceView Unassigned = new ResourceView(default); - - /// - /// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture. - /// Binding this to a shader can be seen as setting the texture variable inside the shader to null. - /// - public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None); - - public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) - { - RenderTarget = renderTarget; - SubElement = subElement; - MipLevel = mipLevel; - } - - public bool IsValid => !RenderTarget.Equals(default); - - public readonly RenderTargetIdentifier RenderTarget; - public readonly RenderTextureSubElement SubElement; - public readonly int MipLevel; + public Fsr3UpscalerShaders Shaders; } /// - /// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 2. + /// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 3. /// public class DispatchDescription { @@ -231,7 +206,7 @@ namespace FidelityFX /// /// A structure encapsulating the parameters for automatic generation of a reactive mask. - /// The default values for Scale, CutoffThreshold, BinaryValue and Flags were taken from the FSR2 demo project. + /// The default values for Scale, CutoffThreshold, BinaryValue and Flags were taken from the FSR3 demo project. /// public class GenerateReactiveDescription { @@ -255,7 +230,7 @@ namespace FidelityFX } [Serializable, StructLayout(LayoutKind.Sequential)] - internal struct Fsr2Constants + internal struct UpscalerConstants { public Vector2Int renderSize; public Vector2Int maxRenderSize; @@ -324,4 +299,35 @@ namespace FidelityFX public readonly uint dummy1; } } + + /// + /// An immutable structure wrapping all of the necessary information to bind a specific buffer or attachment of a render target to a compute shader. + /// + public readonly struct ResourceView + { + /// + /// This value is the equivalent of not setting any value at all; all struct fields will have their default values. + /// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader. + /// + public static readonly ResourceView Unassigned = new ResourceView(default); + + /// + /// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture. + /// Binding this to a shader can be seen as setting the texture variable inside the shader to null. + /// + public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None); + + public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0) + { + RenderTarget = renderTarget; + SubElement = subElement; + MipLevel = mipLevel; + } + + public bool IsValid => !RenderTarget.Equals(default); + + public readonly RenderTargetIdentifier RenderTarget; + public readonly RenderTextureSubElement SubElement; + public readonly int MipLevel; + } } diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs.meta new file mode 100644 index 0000000..6717df4 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3Upscaler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: df8b18c192f2dc145b4b43e68fd3407d +timeCreated: 1673441954 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs new file mode 100644 index 0000000..3e4e24f --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs @@ -0,0 +1,151 @@ +// Copyright (c) 2023 Nico de Poel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// 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. + +using UnityEngine; + +namespace FidelityFX +{ + /// + /// Scriptable object containing all shader resources required by FidelityFX Super Resolution 3 (FSR3) Upscaler. + /// These can be stored in an asset file and referenced from a scene or prefab, avoiding the need to load the shaders from a Resources folder. + /// + public class Fsr3UpscalerAssets : ScriptableObject + { + public Fsr3UpscalerShaders shaders; + +#if UNITY_EDITOR + private void Reset() + { + shaders = new Fsr3UpscalerShaders + { + computeLuminancePyramidPass = FindComputeShader("ffx_fsr3upscaler_compute_luminance_pyramid_pass"), + reconstructPreviousDepthPass = FindComputeShader("ffx_fsr3upscaler_reconstruct_previous_depth_pass"), + depthClipPass = FindComputeShader("ffx_fsr3upscaler_depth_clip_pass"), + lockPass = FindComputeShader("ffx_fsr3upscaler_lock_pass"), + accumulatePass = FindComputeShader("ffx_fsr3upscaler_accumulate_pass"), + sharpenPass = FindComputeShader("ffx_fsr3upscaler_rcas_pass"), + autoGenReactivePass = FindComputeShader("ffx_fsr3upscaler_autogen_reactive_pass"), + tcrAutoGenPass = FindComputeShader("ffx_fsr3upscaler_tcr_autogen_pass"), + }; + } + + private static ComputeShader FindComputeShader(string name) + { + string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); + if (assetGuids == null || assetGuids.Length == 0) + return null; + + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); + return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); + } +#endif + } + + /// + /// All the compute shaders used by the FSR3 Upscaler. + /// + [System.Serializable] + public class Fsr3UpscalerShaders + { + /// + /// The compute shader used by the luminance pyramid computation pass. + /// + public ComputeShader computeLuminancePyramidPass; + + /// + /// The compute shader used by the previous depth reconstruction pass. + /// + public ComputeShader reconstructPreviousDepthPass; + + /// + /// The compute shader used by the depth clip pass. + /// + public ComputeShader depthClipPass; + + /// + /// The compute shader used by the lock pass. + /// + public ComputeShader lockPass; + + /// + /// The compute shader used by the accumulation pass. + /// + public ComputeShader accumulatePass; + + /// + /// The compute shader used by the RCAS sharpening pass. + /// + public ComputeShader sharpenPass; + + /// + /// The compute shader used to auto-generate a reactive mask. + /// + public ComputeShader autoGenReactivePass; + + /// + /// The compute shader used to auto-generate a transparency & composition mask. + /// + public ComputeShader tcrAutoGenPass; + + /// + /// Returns a copy of this class and its contents. + /// + public Fsr3UpscalerShaders Clone() + { + return (Fsr3UpscalerShaders)MemberwiseClone(); + } + + /// + /// Returns a copy of this class with clones of all its shaders. + /// This can be useful if you're running multiple FSR3 Upscaler instances with different shader configurations. + /// Be sure to clean up these clones through Dispose once you're done with them. + /// + public Fsr3UpscalerShaders DeepCopy() + { + return new Fsr3UpscalerShaders + { + computeLuminancePyramidPass = Object.Instantiate(computeLuminancePyramidPass), + reconstructPreviousDepthPass = Object.Instantiate(reconstructPreviousDepthPass), + depthClipPass = Object.Instantiate(depthClipPass), + lockPass = Object.Instantiate(lockPass), + accumulatePass = Object.Instantiate(accumulatePass), + sharpenPass = Object.Instantiate(sharpenPass), + autoGenReactivePass = Object.Instantiate(autoGenReactivePass), + tcrAutoGenPass = Object.Instantiate(tcrAutoGenPass), + }; + } + + /// + /// Destroy all the shaders within this instance. + /// Use this only on clones created through DeepCopy. + /// + public void Dispose() + { + Object.Destroy(computeLuminancePyramidPass); + Object.Destroy(reconstructPreviousDepthPass); + Object.Destroy(depthClipPass); + Object.Destroy(lockPass); + Object.Destroy(accumulatePass); + Object.Destroy(sharpenPass); + Object.Destroy(autoGenReactivePass); + Object.Destroy(tcrAutoGenPass); + } + } +} diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs.meta new file mode 100644 index 0000000..de48032 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerAssets.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aaeb3d821f826d44b84289a2dd23f90e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Core/Fsr2Callbacks.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs similarity index 76% rename from Assets/Scripts/Core/Fsr2Callbacks.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs index ad41d98..5b2c89c 100644 --- a/Assets/Scripts/Core/Fsr2Callbacks.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs @@ -23,16 +23,11 @@ using UnityEngine; namespace FidelityFX { /// - /// A collection of callbacks required by the FSR2 process. - /// This allows some customization by the game dev on how to integrate FSR2 into their own game setup. + /// A collection of callbacks required by the FSR3 Upscaler process. + /// This allows some customization by the game dev on how to integrate FSR3 upscaling into their own game setup. /// - public interface IFsr2Callbacks + public interface IFsr3UpscalerCallbacks { - Shader LoadShader(string name); - void UnloadShader(Shader shader); - ComputeShader LoadComputeShader(string name); - void UnloadComputeShader(ComputeShader shader); - /// /// Apply a mipmap bias to in-game textures to prevent them from becoming blurry as the internal rendering resolution lowers. /// This will need to be customized on a per-game basis, as there is no clear universal way to determine what are "in-game" textures. @@ -47,32 +42,12 @@ namespace FidelityFX } /// - /// Default implementation of IFsr2Callbacks using simple Resources calls. + /// Default implementation of IFsr3UpscalerCallbacks using simple Resources calls. /// These are fine for testing but a proper game will want to extend and override these methods. /// - public class Fsr2CallbacksBase: IFsr2Callbacks + public class Fsr3UpscalerCallbacksBase: IFsr3UpscalerCallbacks { protected float CurrentBiasOffset = 0; - - public virtual Shader LoadShader(string name) - { - return Resources.Load(name); - } - - public virtual void UnloadShader(Shader shader) - { - Resources.UnloadAsset(shader); - } - - public virtual ComputeShader LoadComputeShader(string name) - { - return Resources.Load(name); - } - - public virtual void UnloadComputeShader(ComputeShader shader) - { - Resources.UnloadAsset(shader); - } public virtual void ApplyMipmapBias(float biasOffset) { diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs.meta new file mode 100644 index 0000000..ae2ee1a --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerCallbacks.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1b555daa29ec3043a8cf89b4db31a26 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs similarity index 70% rename from com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs index 5c8975c..da02d9f 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/FSR2/Fsr2Context.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -19,7 +19,6 @@ // THE SOFTWARE. using System; -using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.Rendering; @@ -27,69 +26,69 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// This class loosely matches the FfxFsr2Context struct from the original FSR2 codebase. - /// It manages the various resources and compute passes required by the FSR2 process. + /// This class loosely matches the FfxFsr3UpscalerContext struct from the original FSR3 codebase. + /// It manages the various resources and compute passes required by the FSR3 Upscaler process. /// Note that this class does not know anything about Unity render pipelines; all it knows is CommandBuffers and RenderTargetIdentifiers. /// This should make it suitable for integration with any of the available Unity render pipelines. /// - public class Fsr2Context + public class Fsr3UpscalerContext { private const int MaxQueuedFrames = 16; - private Fsr2.ContextDescription _contextDescription; + private Fsr3Upscaler.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; - private Fsr2Pass _depthClipPass; - private Fsr2Pass _reconstructPreviousDepthPass; - private Fsr2Pass _lockPass; - private Fsr2Pass _accumulatePass; - private Fsr2Pass _rcasPass; - private Fsr2Pass _computeLuminancePyramidPass; - private Fsr2Pass _generateReactivePass; - private Fsr2Pass _tcrAutogeneratePass; + private Fsr3UpscalerPass _depthClipPass; + private Fsr3UpscalerPass _reconstructPreviousDepthPass; + private Fsr3UpscalerPass _lockPass; + private Fsr3UpscalerPass _accumulatePass; + private Fsr3UpscalerPass _sharpenPass; + private Fsr3UpscalerPass _computeLuminancePyramidPass; + private Fsr3UpscalerPass _generateReactivePass; + private Fsr3UpscalerPass _tcrAutogeneratePass; - private readonly Fsr2Resources _resources = new Fsr2Resources(); + private readonly Fsr3UpscalerResources _resources = new Fsr3UpscalerResources(); - private ComputeBuffer _fsr2ConstantsBuffer; - private readonly Fsr2.Fsr2Constants[] _fsr2ConstantsArray = { new Fsr2.Fsr2Constants() }; - private ref Fsr2.Fsr2Constants Constants => ref _fsr2ConstantsArray[0]; + private ComputeBuffer _upscalerConstantsBuffer; + private readonly Fsr3Upscaler.UpscalerConstants[] _upscalerConstantsArray = { new Fsr3Upscaler.UpscalerConstants() }; + private ref Fsr3Upscaler.UpscalerConstants UpscalerConsts => ref _upscalerConstantsArray[0]; private ComputeBuffer _spdConstantsBuffer; - private readonly Fsr2.SpdConstants[] _spdConstantsArray = { new Fsr2.SpdConstants() }; - private ref Fsr2.SpdConstants SpdConsts => ref _spdConstantsArray[0]; + private readonly Fsr3Upscaler.SpdConstants[] _spdConstantsArray = { new Fsr3Upscaler.SpdConstants() }; + private ref Fsr3Upscaler.SpdConstants SpdConsts => ref _spdConstantsArray[0]; private ComputeBuffer _rcasConstantsBuffer; - private readonly Fsr2.RcasConstants[] _rcasConstantsArray = new Fsr2.RcasConstants[1]; - private ref Fsr2.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; + private readonly Fsr3Upscaler.RcasConstants[] _rcasConstantsArray = new Fsr3Upscaler.RcasConstants[1]; + private ref Fsr3Upscaler.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; private ComputeBuffer _generateReactiveConstantsBuffer; - private readonly Fsr2.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Fsr2.GenerateReactiveConstants() }; - private ref Fsr2.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; + private readonly Fsr3Upscaler.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants() }; + private ref Fsr3Upscaler.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; private ComputeBuffer _tcrAutogenerateConstantsBuffer; - private readonly Fsr2.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = { new Fsr2.GenerateReactiveConstants2() }; - private ref Fsr2.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; + private readonly Fsr3Upscaler.GenerateReactiveConstants2[] _tcrAutogenerateConstantsArray = { new Fsr3Upscaler.GenerateReactiveConstants2() }; + private ref Fsr3Upscaler.GenerateReactiveConstants2 TcrAutoGenConsts => ref _tcrAutogenerateConstantsArray[0]; private bool _firstExecution; private Vector2 _previousJitterOffset; private int _resourceFrameIndex; - public void Create(Fsr2.ContextDescription contextDescription) + public void Create(Fsr3Upscaler.ContextDescription contextDescription) { _contextDescription = contextDescription; - _commandBuffer = new CommandBuffer { name = "FSR2" }; + _commandBuffer = new CommandBuffer { name = "FSR3 Upscaler" }; - _fsr2ConstantsBuffer = CreateConstantBuffer(); - _spdConstantsBuffer = CreateConstantBuffer(); - _rcasConstantsBuffer = CreateConstantBuffer(); - _generateReactiveConstantsBuffer = CreateConstantBuffer(); - _tcrAutogenerateConstantsBuffer = CreateConstantBuffer(); + _upscalerConstantsBuffer = CreateConstantBuffer(); + _spdConstantsBuffer = CreateConstantBuffer(); + _rcasConstantsBuffer = CreateConstantBuffer(); + _generateReactiveConstantsBuffer = CreateConstantBuffer(); + _tcrAutogenerateConstantsBuffer = CreateConstantBuffer(); // Set defaults _firstExecution = true; _resourceFrameIndex = 0; - Constants.displaySize = _contextDescription.DisplaySize; + UpscalerConsts.displaySize = _contextDescription.DisplaySize; _resources.Create(_contextDescription); CreatePasses(); @@ -97,14 +96,14 @@ namespace FidelityFX private void CreatePasses() { - _computeLuminancePyramidPass = new Fsr2ComputeLuminancePyramidPass(_contextDescription, _resources, _fsr2ConstantsBuffer, _spdConstantsBuffer); - _reconstructPreviousDepthPass = new Fsr2ReconstructPreviousDepthPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _depthClipPass = new Fsr2DepthClipPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _lockPass = new Fsr2LockPass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _accumulatePass = new Fsr2AccumulatePass(_contextDescription, _resources, _fsr2ConstantsBuffer); - _rcasPass = new Fsr2RcasPass(_contextDescription, _resources, _fsr2ConstantsBuffer, _rcasConstantsBuffer); - _generateReactivePass = new Fsr2GenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); - _tcrAutogeneratePass = new Fsr2TcrAutogeneratePass(_contextDescription, _resources, _fsr2ConstantsBuffer, _tcrAutogenerateConstantsBuffer); + _computeLuminancePyramidPass = new Fsr3UpscalerComputeLuminancePyramidPass(_contextDescription, _resources, _upscalerConstantsBuffer, _spdConstantsBuffer); + _reconstructPreviousDepthPass = new Fsr3UpscalerReconstructPreviousDepthPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _depthClipPass = new Fsr3UpscalerDepthClipPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _lockPass = new Fsr3UpscalerLockPass(_contextDescription, _resources, _upscalerConstantsBuffer); + _accumulatePass = new Fsr3UpscalerAccumulatePass(_contextDescription, _resources, _upscalerConstantsBuffer); + _sharpenPass = new Fsr3UpscalerSharpenPass(_contextDescription, _resources, _upscalerConstantsBuffer, _rcasConstantsBuffer); + _generateReactivePass = new Fsr3UpscalerGenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); + _tcrAutogeneratePass = new Fsr3UpscalerTcrAutogeneratePass(_contextDescription, _resources, _upscalerConstantsBuffer, _tcrAutogenerateConstantsBuffer); } public void Destroy() @@ -112,7 +111,7 @@ namespace FidelityFX DestroyPass(ref _tcrAutogeneratePass); DestroyPass(ref _generateReactivePass); DestroyPass(ref _computeLuminancePyramidPass); - DestroyPass(ref _rcasPass); + DestroyPass(ref _sharpenPass); DestroyPass(ref _accumulatePass); DestroyPass(ref _lockPass); DestroyPass(ref _reconstructPreviousDepthPass); @@ -124,22 +123,22 @@ namespace FidelityFX DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); DestroyConstantBuffer(ref _spdConstantsBuffer); - DestroyConstantBuffer(ref _fsr2ConstantsBuffer); + DestroyConstantBuffer(ref _upscalerConstantsBuffer); _commandBuffer.Dispose(); _commandBuffer = null; } - public void Dispatch(Fsr2.DispatchDescription dispatchParams) + public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { _commandBuffer.Clear(); Dispatch(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - public void Dispatch(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer) + public void Dispatch(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer) { - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableDebugChecking) != 0) + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDebugChecking) != 0) { DebugCheckDispatch(dispatchParams); } @@ -157,10 +156,10 @@ namespace FidelityFX _firstExecution = false; // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) - dispatchParams.Exposure = new Fsr2.ResourceView(_resources.AutoExposure); + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) + dispatchParams.Exposure = new ResourceView(_resources.AutoExposure); else if (!dispatchParams.Exposure.IsValid) - dispatchParams.Exposure = new Fsr2.ResourceView(_resources.DefaultExposure); + dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); if (dispatchParams.EnableAutoReactive) { @@ -170,7 +169,7 @@ namespace FidelityFX if (resetAccumulation) { - RenderTargetIdentifier opaqueOnly = dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : Fsr2ShaderIDs.SrvOpaqueOnly; + RenderTargetIdentifier opaqueOnly = dispatchParams.ColorOpaqueOnly.IsValid ? dispatchParams.ColorOpaqueOnly.RenderTarget : Fsr3ShaderIDs.SrvOpaqueOnly; commandBuffer.Blit(_resources.PrevPreAlpha[frameIndex ^ 1], opaqueOnly); } } @@ -180,16 +179,16 @@ namespace FidelityFX _resources.DestroyTcrAutogenResources(); } - if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new Fsr2.ResourceView(_resources.DefaultReactive); - if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.DefaultReactive); - Fsr2Resources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); + if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive); + if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive); + Fsr3UpscalerResources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); SetupConstants(dispatchParams, resetAccumulation); // Reactive mask bias const int threadGroupWorkRegionDim = 8; - int dispatchSrcX = (Constants.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; - int dispatchSrcY = (Constants.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstX = (_contextDescription.DisplaySize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstY = (_contextDescription.DisplaySize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -214,19 +213,24 @@ namespace FidelityFX commandBuffer.ClearRenderTarget(false, true, Color.clear); } + // FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option + bool depthInverted = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) == Fsr3Upscaler.InitializationFlags.EnableDepthInverted; + commandBuffer.SetRenderTarget(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); // Initialize constant buffers data - commandBuffer.SetBufferData(_fsr2ConstantsBuffer, _fsr2ConstantsArray); + commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); // Auto reactive if (dispatchParams.EnableAutoReactive) { GenerateTransparencyCompositionReactive(dispatchParams, commandBuffer, frameIndex); - dispatchParams.Reactive = new Fsr2.ResourceView(_resources.AutoReactive); - dispatchParams.TransparencyAndComposition = new Fsr2.ResourceView(_resources.AutoComposition); + dispatchParams.Reactive = new ResourceView(_resources.AutoReactive); + dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); } // Compute luminance pyramid @@ -254,22 +258,22 @@ namespace FidelityFX const int threadGroupWorkRegionDimRcas = 16; int threadGroupsX = (Screen.width + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; int threadGroupsY = (Screen.height + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; - _rcasPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); + _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); } _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; - Fsr2Resources.DestroyAliasableResources(commandBuffer); + Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); } - public void GenerateReactiveMask(Fsr2.GenerateReactiveDescription dispatchParams) + public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams) { _commandBuffer.Clear(); GenerateReactiveMask(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - public void GenerateReactiveMask(Fsr2.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) + public void GenerateReactiveMask(Fsr3Upscaler.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) { const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -281,10 +285,10 @@ namespace FidelityFX GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); - ((Fsr2GenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); + ((Fsr3UpscalerGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); } - private void GenerateTransparencyCompositionReactive(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) + private void GenerateTransparencyCompositionReactive(Fsr3Upscaler.DispatchDescription dispatchParams, CommandBuffer commandBuffer, int frameIndex) { const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -299,9 +303,9 @@ namespace FidelityFX _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); } - private void SetupConstants(Fsr2.DispatchDescription dispatchParams, bool resetAccumulation) + private void SetupConstants(Fsr3Upscaler.DispatchDescription dispatchParams, bool resetAccumulation) { - ref Fsr2.Fsr2Constants constants = ref Constants; + ref Fsr3Upscaler.UpscalerConstants constants = ref UpscalerConsts; constants.jitterOffset = dispatchParams.JitterOffset; constants.renderSize = dispatchParams.RenderSize; @@ -323,17 +327,17 @@ namespace FidelityFX constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f; // Motion vector data - Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; + Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; constants.motionVectorScale = dispatchParams.MotionVectorScale / motionVectorsTargetSize; // Compute jitter cancellation - if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) + if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { constants.motionVectorJitterCancellation = (_previousJitterOffset - constants.jitterOffset) / motionVectorsTargetSize; _previousJitterOffset = constants.jitterOffset; } - int jitterPhaseCount = Fsr2.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x); + int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x); if (resetAccumulation || constants.jitterPhaseCount == 0) { constants.jitterPhaseCount = jitterPhaseCount; @@ -356,17 +360,17 @@ namespace FidelityFX constants.frameIndex++; // Shading change usage of the SPD mip levels - constants.lumaMipLevelToUse = Fsr2Pass.ShadingChangeMipLevel; + constants.lumaMipLevelToUse = Fsr3UpscalerPass.ShadingChangeMipLevel; float mipDiv = 2 << constants.lumaMipLevelToUse; constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv); constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv); } - private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr2.DispatchDescription dispatchParams) + private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr3Upscaler.DispatchDescription dispatchParams) { - bool inverted = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; - bool infinite = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInfinite) != 0; + bool inverted = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0; + bool infinite = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; // make sure it has no impact if near and far plane values are swapped in dispatch params // the flags "inverted" and "infinite" will decide what transform to use @@ -396,19 +400,19 @@ namespace FidelityFX 1.0f / cotHalfFovY); } - private void SetupRcasConstants(Fsr2.DispatchDescription dispatchParams) + private void SetupRcasConstants(Fsr3Upscaler.DispatchDescription dispatchParams) { int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (RcasConfigs.Length - 1)); RcasConsts = RcasConfigs[sharpnessIndex]; } - private void SetupSpdConstants(Fsr2.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) + private void SetupSpdConstants(Fsr3Upscaler.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) { RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y); SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); // Downsample - ref Fsr2.SpdConstants spdConstants = ref SpdConsts; + ref Fsr3Upscaler.SpdConstants spdConstants = ref SpdConsts; spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; spdConstants.mips = (uint)numWorkGroupsAndMips.y; spdConstants.workGroupOffsetX = (uint)workGroupOffset.x; @@ -434,7 +438,7 @@ namespace FidelityFX } } - private void DebugCheckDispatch(Fsr2.DispatchDescription dispatchParams) + private void DebugCheckDispatch(Fsr3Upscaler.DispatchDescription dispatchParams) { if (!dispatchParams.Color.IsValid) { @@ -456,7 +460,7 @@ namespace FidelityFX Debug.LogError("Output resource is null"); } - if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) + if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) { Debug.LogWarning("Exposure resource provided, however auto exposure flag is present"); } @@ -496,8 +500,8 @@ namespace FidelityFX Debug.LogError("PreExposure provided as 0.0f which is invalid"); } - bool infiniteDepth = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInfinite) != 0; - bool inverseDepth = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; + bool infiniteDepth = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInfinite) != 0; + bool inverseDepth = (_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0; if (inverseDepth) { @@ -552,32 +556,32 @@ namespace FidelityFX } /// - /// The FSR2 C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the RCAS shader. + /// The FSR3 C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the RCAS shader. /// This is not possible in C# without enabling unsafe code compilation, so to avoid that we instead use a table of precomputed values. /// - private static readonly Fsr2.RcasConstants[] RcasConfigs = new [] + private static readonly Fsr3Upscaler.RcasConstants[] RcasConfigs = new [] { - new Fsr2.RcasConstants(1048576000u, 872428544u), - new Fsr2.RcasConstants(1049178080u, 877212745u), - new Fsr2.RcasConstants(1049823372u, 882390168u), - new Fsr2.RcasConstants(1050514979u, 887895276u), - new Fsr2.RcasConstants(1051256227u, 893859143u), - new Fsr2.RcasConstants(1052050675u, 900216232u), - new Fsr2.RcasConstants(1052902144u, 907032080u), - new Fsr2.RcasConstants(1053814727u, 914306687u), - new Fsr2.RcasConstants(1054792807u, 922105590u), - new Fsr2.RcasConstants(1055841087u, 930494326u), - new Fsr2.RcasConstants(1056964608u, 939538432u), - new Fsr2.RcasConstants(1057566688u, 944322633u), - new Fsr2.RcasConstants(1058211980u, 949500056u), - new Fsr2.RcasConstants(1058903587u, 955005164u), - new Fsr2.RcasConstants(1059644835u, 960969031u), - new Fsr2.RcasConstants(1060439283u, 967326120u), - new Fsr2.RcasConstants(1061290752u, 974141968u), - new Fsr2.RcasConstants(1062203335u, 981416575u), - new Fsr2.RcasConstants(1063181415u, 989215478u), - new Fsr2.RcasConstants(1064229695u, 997604214u), - new Fsr2.RcasConstants(1065353216u, 1006648320), + new Fsr3Upscaler.RcasConstants(1048576000u, 872428544u), + new Fsr3Upscaler.RcasConstants(1049178080u, 877212745u), + new Fsr3Upscaler.RcasConstants(1049823372u, 882390168u), + new Fsr3Upscaler.RcasConstants(1050514979u, 887895276u), + new Fsr3Upscaler.RcasConstants(1051256227u, 893859143u), + new Fsr3Upscaler.RcasConstants(1052050675u, 900216232u), + new Fsr3Upscaler.RcasConstants(1052902144u, 907032080u), + new Fsr3Upscaler.RcasConstants(1053814727u, 914306687u), + new Fsr3Upscaler.RcasConstants(1054792807u, 922105590u), + new Fsr3Upscaler.RcasConstants(1055841087u, 930494326u), + new Fsr3Upscaler.RcasConstants(1056964608u, 939538432u), + new Fsr3Upscaler.RcasConstants(1057566688u, 944322633u), + new Fsr3Upscaler.RcasConstants(1058211980u, 949500056u), + new Fsr3Upscaler.RcasConstants(1058903587u, 955005164u), + new Fsr3Upscaler.RcasConstants(1059644835u, 960969031u), + new Fsr3Upscaler.RcasConstants(1060439283u, 967326120u), + new Fsr3Upscaler.RcasConstants(1061290752u, 974141968u), + new Fsr3Upscaler.RcasConstants(1062203335u, 981416575u), + new Fsr3Upscaler.RcasConstants(1063181415u, 989215478u), + new Fsr3Upscaler.RcasConstants(1064229695u, 997604214u), + new Fsr3Upscaler.RcasConstants(1065353216u, 1006648320), }; private static ComputeBuffer CreateConstantBuffer() where TConstants: struct @@ -594,7 +598,7 @@ namespace FidelityFX bufferRef = null; } - private static void DestroyPass(ref Fsr2Pass pass) + private static void DestroyPass(ref Fsr3UpscalerPass pass) { if (pass == null) return; diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs.meta new file mode 100644 index 0000000..673b2ef --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerContext.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 14c8dc4c7c3e4ac418e50a859cec0b2f +timeCreated: 1673442225 \ No newline at end of file diff --git a/Assets/Scripts/Core/Fsr2Pass.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs similarity index 56% rename from Assets/Scripts/Core/Fsr2Pass.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs index 23b8e6c..e1dc225 100644 --- a/Assets/Scripts/Core/Fsr2Pass.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs @@ -26,24 +26,22 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// Base class for all of the compute passes that make up the FSR2 process. - /// This loosely matches the FfxPipelineState struct from the original FSR2 codebase, wrapped in an object-oriented blanket. + /// Base class for all of the compute passes that make up the FSR3 Upscaler process. + /// This loosely matches the FfxPipelineState struct from the original FSR3 codebase, wrapped in an object-oriented blanket. /// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders. /// - internal abstract class Fsr2Pass: IDisposable + internal abstract class Fsr3UpscalerPass: IDisposable { - internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define + internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL define - protected readonly Fsr2.ContextDescription ContextDescription; - protected readonly Fsr2Resources Resources; + protected readonly Fsr3Upscaler.ContextDescription ContextDescription; + protected readonly Fsr3UpscalerResources Resources; protected readonly ComputeBuffer Constants; protected ComputeShader ComputeShader; protected int KernelIndex; - protected virtual bool AllowFP16 => true; - - protected Fsr2Pass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + protected Fsr3UpscalerPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) { ContextDescription = contextDescription; Resources = resources; @@ -52,26 +50,24 @@ namespace FidelityFX public virtual void Dispose() { - UnloadComputeShader(); } - public abstract void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); + public abstract void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); - protected void LoadComputeShader(string name) + protected void InitComputeShader(string passName, ComputeShader shader) { - LoadComputeShader(name, ContextDescription.Flags, ref ComputeShader, out KernelIndex); + InitComputeShader(passName, shader, ContextDescription.Flags); } - private void LoadComputeShader(string name, Fsr2.InitializationFlags flags, ref ComputeShader shaderRef, out int kernelIndex) + private void InitComputeShader(string passName, ComputeShader shader, Fsr3Upscaler.InitializationFlags flags) { - if (shaderRef == null) + if (shader == null) { - shaderRef = ContextDescription.Callbacks.LoadComputeShader(name); - if (shaderRef == null) - throw new MissingReferenceException($"Shader '{name}' could not be loaded! Please ensure it is included in the project correctly."); + throw new MissingReferenceException($"Shader for FSR3 Upscaler '{passName}' could not be loaded! Please ensure it is included in the project correctly."); } - kernelIndex = shaderRef.FindKernel("CS"); + ComputeShader = shader; + KernelIndex = ComputeShader.FindKernel("CS"); bool useLut = false; #if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+ @@ -81,106 +77,89 @@ namespace FidelityFX } #endif - // Allow 16-bit floating point as a configuration option, except on passes that explicitly disable it - bool supportedFP16 = ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0 && AllowFP16); - // This matches the permutation rules from the CreatePipeline* functions - if ((flags & Fsr2.InitializationFlags.EnableHighDynamicRange) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_HDR_COLOR_INPUT"); - if ((flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); - if ((flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS"); - if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) shaderRef.EnableKeyword("FFX_FSR2_OPTION_INVERTED_DEPTH"); - if (useLut) shaderRef.EnableKeyword("FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); - if (supportedFP16) shaderRef.EnableKeyword("FFX_HALF"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableHighDynamicRange) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); + if (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); + if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); // Inform the shader which render pipeline we're currently using var pipeline = GraphicsSettings.currentRenderPipeline; if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline")) { - shaderRef.EnableKeyword("UNITY_FSR2_HDRP"); + ComputeShader.EnableKeyword("UNITY_FSR3UPSCALER_HDRP"); } } - - private void UnloadComputeShader() - { - UnloadComputeShader(ref ComputeShader); - } - - private void UnloadComputeShader(ref ComputeShader shaderRef) - { - if (shaderRef == null) - return; - - ContextDescription.Callbacks.UnloadComputeShader(shaderRef); - shaderRef = null; - } } - internal class Fsr2ComputeLuminancePyramidPass : Fsr2Pass + internal class Fsr3UpscalerComputeLuminancePyramidPass : Fsr3UpscalerPass { private readonly ComputeBuffer _spdConstants; - public Fsr2ComputeLuminancePyramidPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer spdConstants) + public Fsr3UpscalerComputeLuminancePyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) : base(contextDescription, resources, constants) { _spdConstants = spdConstants; - LoadComputeShader("FSR2/ffx_fsr2_compute_luminance_pyramid_pass"); + InitComputeShader("compute_luminance_pyramid_pass", contextDescription.Shaders.computeLuminancePyramidPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoExposure, Resources.AutoExposure); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoExposure, Resources.AutoExposure); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2ReconstructPreviousDepthPass : Fsr2Pass + internal class Fsr3UpscalerReconstructPreviousDepthPass : Fsr3UpscalerPass { - public Fsr2ReconstructPreviousDepthPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerReconstructPreviousDepthPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_reconstruct_previous_depth_pass"); + InitComputeShader("reconstruct_previous_depth_pass", contextDescription.Shaders.reconstructPreviousDepthPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var depth = ref dispatchParams.Depth; ref var motionVectors = ref dispatchParams.MotionVectors; ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2DepthClipPass : Fsr2Pass + internal class Fsr3UpscalerDepthClipPass : Fsr3UpscalerPass { - public Fsr2DepthClipPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerDepthClipPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_depth_clip_pass"); + InitComputeShader("depth_clip_pass", contextDescription.Shaders.depthClipPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var depth = ref dispatchParams.Depth; @@ -189,62 +168,59 @@ namespace FidelityFX ref var reactive = ref dispatchParams.Reactive; ref var tac = ref dispatchParams.TransparencyAndComposition; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReconstructedPrevNearestDepth, Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedDepth, Fsr2ShaderIDs.UavDilatedDepth); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReconstructedPrevNearestDepth, Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedDepth, Fsr3ShaderIDs.UavDilatedDepth); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); + + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2LockPass : Fsr2Pass + internal class Fsr3UpscalerLockPass : Fsr3UpscalerPass { - public Fsr2LockPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerLockPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_lock_pass"); + InitComputeShader("lock_pass", contextDescription.Shaders.lockPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockInputLuma, Fsr2ShaderIDs.UavLockInputLuma); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLockInputLuma, Fsr3ShaderIDs.UavLockInputLuma); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2AccumulatePass : Fsr2Pass + internal class Fsr3UpscalerAccumulatePass : Fsr3UpscalerPass { - private const string SharpeningKeyword = "FFX_FSR2_OPTION_APPLY_SHARPENING"; - - // Workaround: Disable FP16 path for the accumulate pass on NVIDIA due to reduced occupancy and high VRAM throughput. - protected override bool AllowFP16 => SystemInfo.graphicsDeviceVendorID != 0x10DE; + private const string SharpeningKeyword = "FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING"; #if UNITY_2021_2_OR_NEWER private readonly LocalKeyword _sharpeningKeyword; #endif - public Fsr2AccumulatePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr3UpscalerAccumulatePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { - LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass"); + InitComputeShader("accumulate_pass", contextDescription.Shaders.accumulatePass); #if UNITY_2021_2_OR_NEWER _sharpeningKeyword = new LocalKeyword(ComputeShader, SharpeningKeyword); #endif } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { #if UNITY_2021_2_OR_NEWER if (dispatchParams.EnableSharpening) @@ -258,115 +234,115 @@ namespace FidelityFX commandBuffer.DisableShaderKeyword(SharpeningKeyword); #endif - if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) + if ((ContextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) { - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); } else { ref var motionVectors = ref dispatchParams.MotionVectors; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); } ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedReactiveMasks, Fsr2ShaderIDs.UavDilatedReactiveMasks); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPreparedInputColor, Fsr2ShaderIDs.UavPreparedInputColor); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLanczosLut, Resources.LanczosLut); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvAutoExposure, Resources.AutoExposure); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreparedInputColor, Fsr3ShaderIDs.UavPreparedInputColor); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLanczosLut, Resources.LanczosLut); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvAutoExposure, Resources.AutoExposure); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); ref var output = ref dispatchParams.Output; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2RcasPass : Fsr2Pass + internal class Fsr3UpscalerSharpenPass : Fsr3UpscalerPass { private readonly ComputeBuffer _rcasConstants; - public Fsr2RcasPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) + public Fsr3UpscalerSharpenPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) : base(contextDescription, resources, constants) { _rcasConstants = rcasConstants; - LoadComputeShader("FSR2/ffx_fsr2_rcas_pass"); + InitComputeShader("rcas_pass", contextDescription.Shaders.sharpenPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var exposure = ref dispatchParams.Exposure; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]); ref var output = ref dispatchParams.Output; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavUpscaledOutput, output.RenderTarget, output.MipLevel, output.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2GenerateReactivePass : Fsr2Pass + internal class Fsr3UpscalerGenerateReactivePass : Fsr3UpscalerPass { private readonly ComputeBuffer _generateReactiveConstants; - public Fsr2GenerateReactivePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer generateReactiveConstants) + public Fsr3UpscalerGenerateReactivePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer generateReactiveConstants) : base(contextDescription, resources, null) { _generateReactiveConstants = generateReactiveConstants; - LoadComputeShader("FSR2/ffx_fsr2_autogen_reactive_pass"); + InitComputeShader("autogen_reactive_pass", contextDescription.Shaders.autoGenReactivePass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { } - public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) + public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; ref var color = ref dispatchParams.ColorPreUpscale; ref var reactive = ref dispatchParams.OutReactive; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } } - internal class Fsr2TcrAutogeneratePass : Fsr2Pass + internal class Fsr3UpscalerTcrAutogeneratePass : Fsr3UpscalerPass { private readonly ComputeBuffer _tcrAutogenerateConstants; - public Fsr2TcrAutogeneratePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) + public Fsr3UpscalerTcrAutogeneratePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) : base(contextDescription, resources, constants) { _tcrAutogenerateConstants = tcrAutogenerateConstants; - LoadComputeShader("FSR2/ffx_fsr2_tcr_autogen_pass"); + InitComputeShader("tcr_autogen_pass", contextDescription.Shaders.tcrAutoGenPass); } - public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) + public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) { ref var color = ref dispatchParams.Color; ref var motionVectors = ref dispatchParams.MotionVectors; @@ -374,21 +350,21 @@ namespace FidelityFX ref var reactive = ref dispatchParams.Reactive; ref var tac = ref dispatchParams.TransparencyAndComposition; - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex ^ 1]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); - - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, Resources.AutoReactive); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoComposition, Resources.AutoComposition); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex]); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, opaqueOnly.RenderTarget, opaqueOnly.MipLevel, opaqueOnly.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex ^ 1]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReactiveMask, reactive.RenderTarget, reactive.MipLevel, reactive.SubElement); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvTransparencyAndCompositionMask, tac.RenderTarget, tac.MipLevel, tac.SubElement); + + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, Resources.AutoReactive); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoComposition, Resources.AutoComposition); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPreAlpha, Resources.PrevPreAlpha[frameIndex]); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavPrevColorPostAlpha, Resources.PrevPostAlpha[frameIndex]); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf()); - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf()); + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _tcrAutogenerateConstants, 0, Marshal.SizeOf()); commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); } diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs.meta new file mode 100644 index 0000000..8ffd58e --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerPass.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cfd077da533b192458b0b548668776e7 +timeCreated: 1676885169 \ No newline at end of file diff --git a/Assets/Scripts/Core/Fsr2Resources.cs b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs similarity index 64% rename from Assets/Scripts/Core/Fsr2Resources.cs rename to com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs index a3e8e27..676867b 100644 --- a/Assets/Scripts/Core/Fsr2Resources.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs @@ -26,10 +26,10 @@ using UnityEngine.Rendering; namespace FidelityFX { /// - /// Helper class for bundling and managing persistent resources required by the FSR2 process. + /// Helper class for bundling and managing persistent resources required by the FSR3 Upscaler process. /// This includes lookup tables, default fallback resources and double-buffered resources that get swapped between frames. /// - internal class Fsr2Resources + internal class Fsr3UpscalerResources { public Texture2D DefaultExposure; public Texture2D DefaultReactive; @@ -47,7 +47,7 @@ namespace FidelityFX public readonly RenderTexture[] PrevPreAlpha = new RenderTexture[2]; public readonly RenderTexture[] PrevPostAlpha = new RenderTexture[2]; - public void Create(Fsr2.ContextDescription contextDescription) + public void Create(Fsr3Upscaler.ContextDescription contextDescription) { // Generate the data for the LUT const int lanczos2LutWidth = 128; @@ -55,7 +55,7 @@ namespace FidelityFX for (int currentLanczosWidthIndex = 0; currentLanczosWidthIndex < lanczos2LutWidth; ++currentLanczosWidthIndex) { float x = 2.0f * currentLanczosWidthIndex / (lanczos2LutWidth - 1); - float y = Fsr2.Lanczos2(x); + float y = Fsr3Upscaler.Lanczos2(x); lanczos2Weights[currentLanczosWidthIndex] = y; } @@ -65,108 +65,108 @@ namespace FidelityFX maximumBias[i] = MaximumBias[i] / 2.0f; } - // Resource FSR2_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE + // Resource FSR3UPSCALER_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE // R16_SNorm textures are not supported by Unity on most platforms, strangely enough. So instead we use R32_SFloat and upload pre-normalized float data. - LanczosLut = new Texture2D(lanczos2LutWidth, 1, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR2_LanczosLutData" }; + LanczosLut = new Texture2D(lanczos2LutWidth, 1, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_LanczosLutData" }; LanczosLut.SetPixelData(lanczos2Weights, 0); LanczosLut.Apply(); - // Resource FSR2_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE - MaximumBiasLut = new Texture2D(MaximumBiasTextureWidth, MaximumBiasTextureHeight, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR2_MaximumUpsampleBias" }; + // Resource FSR3UPSCALER_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE + MaximumBiasLut = new Texture2D(MaximumBiasTextureWidth, MaximumBiasTextureHeight, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_MaximumUpsampleBias" }; MaximumBiasLut.SetPixelData(maximumBias, 0); MaximumBiasLut.Apply(); - // Resource FSR2_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE - DefaultExposure = new Texture2D(1, 1, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None) { name = "FSR2_DefaultExposure" }; + // Resource FSR3UPSCALER_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE + DefaultExposure = new Texture2D(1, 1, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None) { name = "FSR3UPSCALER_DefaultExposure" }; DefaultExposure.SetPixel(0, 0, Color.clear); DefaultExposure.Apply(); - // Resource FSR2_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - DefaultReactive = new Texture2D(1, 1, GraphicsFormat.R8_UNorm, TextureCreationFlags.None) { name = "FSR2_DefaultReactivityMask" }; + // Resource FSR3UPSCALER_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + DefaultReactive = new Texture2D(1, 1, GraphicsFormat.R8_UNorm, TextureCreationFlags.None) { name = "FSR3UPSCALER_DefaultReactivityMask" }; DefaultReactive.SetPixel(0, 0, Color.clear); DefaultReactive.Apply(); - // Resource FSR2_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE - // Despite what the original FSR2 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal. - SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "FSR2_SpdAtomicCounter", enableRandomWrite = true }; + // Resource FSR3UPSCALER_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE + // Despite what the original FSR3 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal. + SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "FSR3UPSCALER_SpdAtomicCounter", enableRandomWrite = true }; SpdAtomicCounter.Create(); - // Resource FSR2_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE - AutoExposure = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32_SFloat) { name = "FSR2_AutoExposure", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE + AutoExposure = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32_SFloat) { name = "FSR3UPSCALER_AutoExposure", enableRandomWrite = true }; AutoExposure.Create(); - // Resource FSR2_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + // Resource FSR3UPSCALER_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE // This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this. int w = contextDescription.MaxRenderSize.x / 2, h = contextDescription.MaxRenderSize.y / 2; int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Math.Max(w, h), 2.0f)); - SceneLuminance = new RenderTexture(w, h, 0, GraphicsFormat.R16_SFloat, mipCount) { name = "FSR2_ExposureMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + SceneLuminance = new RenderTexture(w, h, 0, GraphicsFormat.R16_SFloat, mipCount) { name = "FSR3UPSCALER_ExposureMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; SceneLuminance.Create(); - // Resources FSR2_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(DilatedMotionVectors, "FSR2_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat); + // Resources FSR3UPSCALER_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(DilatedMotionVectors, "FSR3UPSCALER_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat); - // Resources FSR2_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(LockStatus, "FSR2_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat); + // Resources FSR3UPSCALER_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(LockStatus, "FSR3UPSCALER_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat); - // Resources FSR2_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(InternalUpscaled, "FSR2_InternalUpscaled", contextDescription.DisplaySize, GraphicsFormat.R16G16B16A16_SFloat); + // Resources FSR3UPSCALER_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(InternalUpscaled, "FSR3UPSCALER_InternalUpscaled", contextDescription.DisplaySize, GraphicsFormat.R16G16B16A16_SFloat); - // Resources FSR2_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(LumaHistory, "FSR2_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm); + // Resources FSR3UPSCALER_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(LumaHistory, "FSR3UPSCALER_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm); } - public void CreateTcrAutogenResources(Fsr2.ContextDescription contextDescription) + public void CreateTcrAutogenResources(Fsr3Upscaler.ContextDescription contextDescription) { - // Resource FSR2_AutoReactive: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - AutoReactive = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR2_AutoReactive", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoReactive: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + AutoReactive = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR3UPSCALER_AutoReactive", enableRandomWrite = true }; AutoReactive.Create(); - // Resource FSR2_AutoComposition: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE - AutoComposition = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR2_AutoComposition", enableRandomWrite = true }; + // Resource FSR3UPSCALER_AutoComposition: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE + AutoComposition = new RenderTexture(contextDescription.MaxRenderSize.x, contextDescription.MaxRenderSize.y, 0, GraphicsFormat.R8_UNorm) { name = "FSR3UPSCALER_AutoComposition", enableRandomWrite = true }; AutoComposition.Create(); - // Resources FSR2_PrevPreAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(PrevPreAlpha, "FSR2_PrevPreAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); + // Resources FSR3UPSCALER_PrevPreAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(PrevPreAlpha, "FSR3UPSCALER_PrevPreAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); - // Resources FSR2_PrevPostAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE - CreateDoubleBufferedResource(PrevPostAlpha, "FSR2_PrevPostAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); + // Resources FSR3UPSCALER_PrevPostAlpha0/1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R11G11B10_FLOAT, FFX_RESOURCE_FLAGS_NONE + CreateDoubleBufferedResource(PrevPostAlpha, "FSR3UPSCALER_PrevPostAlpha", contextDescription.MaxRenderSize, GraphicsFormat.B10G11R11_UFloatPack32); } // Set up shared aliasable resources, i.e. temporary render textures // These do not need to persist between frames, but they do need to be available between passes - public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr2.ContextDescription contextDescription, Fsr2.DispatchDescription dispatchParams) + public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr3Upscaler.ContextDescription contextDescription, Fsr3Upscaler.DispatchDescription dispatchParams) { Vector2Int displaySize = contextDescription.DisplaySize; Vector2Int maxRenderSize = contextDescription.MaxRenderSize; - // FSR2_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); + // FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); - // FSR2_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); + // FSR3UPSCALER_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); - // FSR2_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); + // FSR3UPSCALER_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); - // FSR2_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); + // FSR3UPSCALER_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); - // FSR2_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); + // FSR3UPSCALER_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); - // FSR2_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE - commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); + // FSR3UPSCALER_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE + commandBuffer.GetTemporaryRT(Fsr3ShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); } public static void DestroyAliasableResources(CommandBuffer commandBuffer) { // Release all of the aliasable resources used this frame - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor); - commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavNewLocks); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavReconstructedPrevNearestDepth); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavDilatedDepth); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavLockInputLuma); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavDilatedReactiveMasks); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavPreparedInputColor); + commandBuffer.ReleaseTemporaryRT(Fsr3ShaderIDs.UavNewLocks); } private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format) diff --git a/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs.meta b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs.meta new file mode 100644 index 0000000..bf03a07 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Runtime/FSR3/Fsr3UpscalerResources.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ec6c0c34c7b11f041885ddee4aa72818 +timeCreated: 1677236102 \ No newline at end of file diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs b/com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs index fbcbb21..0e5d1a8 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Monitors/Monitor.cs @@ -48,7 +48,7 @@ namespace UnityEngine.Rendering.PostProcessing return requested && SystemInfo.supportsComputeShaders && !RuntimeUtilities.isAndroidOpenGL - && !RuntimeUtilities.isWebGL + && !RuntimeUtilities.isWebNonWebGPU && ShaderResourcesAvailable(context); } diff --git a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessLayer.cs b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessLayer.cs index dc0b571..42e42df 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessLayer.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessLayer.cs @@ -51,7 +51,7 @@ namespace UnityEngine.Rendering.PostProcessing TemporalAntialiasing, /// - /// FidelityFX Super Resolution 2 (FSR2). + /// FidelityFX Super Resolution 3 (FSR3) Upscaler. /// SuperResolution, } @@ -97,7 +97,7 @@ namespace UnityEngine.Rendering.PostProcessing public TemporalAntialiasing temporalAntialiasing; /// - /// FSR2 upscaling & anti-aliasing settings for this camera. + /// FSR3 upscaling & anti-aliasing settings for this camera. /// public SuperResolution superResolution; @@ -282,7 +282,9 @@ namespace UnityEngine.Rendering.PostProcessing #if UNITY_2019_1_OR_NEWER // We always use a CommandBuffer to blit to the final render target // OnRenderImage is used only to avoid the automatic blit from the RenderTexture of Camera.forceIntoRenderTexture to the actual target +#if !UNITY_EDITOR [ImageEffectUsesCommandBuffer] +#endif void OnRenderImage(RenderTexture src, RenderTexture dst) { if (m_opaqueOnly != null) @@ -540,6 +542,10 @@ namespace UnityEngine.Rendering.PostProcessing #endif } } + else + { + m_Camera.nonJitteredProjectionMatrix = m_Camera.projectionMatrix; + } #if (ENABLE_VR_MODULE && ENABLE_VR) if (m_Camera.stereoEnabled) @@ -1191,7 +1197,7 @@ namespace UnityEngine.Rendering.PostProcessing // Set the upscaler's output to full display resolution, as well as for all following post-processing effects context.SetRenderSize(superResolution.displaySize); - + var fsrTarget = m_TargetPool.Get(); var finalDestination = context.destination; context.GetScreenSpaceTemporaryRT(cmd, fsrTarget, 0, context.sourceFormat, isUpscaleOutput: true); diff --git a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessRenderContext.cs b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessRenderContext.cs index 4cbf865..8a23e55 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessRenderContext.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessRenderContext.cs @@ -216,7 +216,7 @@ namespace UnityEngine.Rendering.PostProcessing public TemporalAntialiasing temporalAntialiasing { get; internal set; } /// - /// A reference to the FSR2 settings for the rendering layer. + /// A reference to the FSR3 Upscaler settings for the rendering layer. /// public SuperResolution superResolution { get; internal set; } diff --git a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessResources.cs b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessResources.cs index fb9e469..35293ef 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/PostProcessResources.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/PostProcessResources.cs @@ -1,4 +1,5 @@ using System; +using FidelityFX; namespace UnityEngine.Rendering.PostProcessing { @@ -214,9 +215,9 @@ namespace UnityEngine.Rendering.PostProcessing public ComputeShader gaussianDownsample; /// - /// Compute shaders that need to be looked up by name. + /// Compute shaders used by the FidelityFX Super Resolution 3 (FSR3) Upscaler. /// - public NamedComputeShader[] namedShaders; + public Fsr3UpscalerShaders superResolution; /// /// Returns a copy of this class and its content. @@ -226,24 +227,6 @@ namespace UnityEngine.Rendering.PostProcessing { return (ComputeShaders)MemberwiseClone(); } - - public ComputeShader FindComputeShader(string name) - { - for (int i = 0; i < namedShaders.Length; ++i) - { - if (namedShaders[i].name == name) - return namedShaders[i].shader; - } - - return null; - } - } - - [Serializable] - public class NamedComputeShader - { - public string name; - public ComputeShader shader; } /// diff --git a/com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs b/com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs index a1d9154..7fd24a1 100644 --- a/com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs +++ b/com.unity.postprocessing/PostProcessing/Runtime/Utils/RuntimeUtilities.cs @@ -862,14 +862,28 @@ namespace UnityEngine.Rendering.PostProcessing /// Returns true if the target platform is WebGL, /// false otherwise. /// - public static bool isWebGL + public static bool isWebNonWebGPU { - get { -#if UNITY_WEBGL + get + { +#if UNITY_EDITOR + #if UNITY_WEBGL + #if UNITY_2023_2_OR_NEWER + return PlayerSettings.GetGraphicsAPIs(BuildTarget.WebGL).First() != GraphicsDeviceType.WebGPU; + #else return true; -#else + #endif + #else return false; + #endif +#else + return Application.platform == RuntimePlatform.WebGLPlayer + #if UNITY_2023_2_OR_NEWER + && SystemInfo.graphicsDeviceType != GraphicsDeviceType.WebGPU + #endif + ; #endif + } } diff --git a/com.unity.postprocessing/PostProcessing/Shaders/ACES.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/ACES.hlsl index 9f77efe..1405bb9 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/ACES.hlsl +++ b/com.unity.postprocessing/PostProcessing/Shaders/ACES.hlsl @@ -220,7 +220,9 @@ half3 ACES_to_ACEScc(half3 x) x = clamp(x, 0.0, HALF_MAX); // x is clamped to [0, HALF_MAX], skip the <= 0 check - return (x < 0.00003051757) ? (log2(0.00001525878 + x * 0.5) + 9.72) / 17.52 : (log2(x) + 9.72) / 17.52; + return half3((x.x < 0.00003051757) ? (log2(0.00001525878 + x.x * 0.5) + 9.72) / 17.52 : (log2(x.x) + 9.72) / 17.52, + (x.y < 0.00003051757) ? (log2(0.00001525878 + x.y * 0.5) + 9.72) / 17.52 : (log2(x.y) + 9.72) / 17.52, + (x.z < 0.00003051757) ? (log2(0.00001525878 + x.z * 0.5) + 9.72) / 17.52 : (log2(x.z) + 9.72) / 17.52); /* return half3( @@ -678,7 +680,9 @@ half roll_white_fwd( half3 linear_to_sRGB(half3 x) { - return (x <= 0.0031308 ? (x * 12.9232102) : 1.055 * pow(x, 1.0 / 2.4) - 0.055); + return half3(x.x <= 0.0031308 ? (x.x * 12.9232102) : 1.055 * pow(x.x, 1.0 / 2.4) - 0.055, + x.y <= 0.0031308 ? (x.y * 12.9232102) : 1.055 * pow(x.y, 1.0 / 2.4) - 0.055, + x.z <= 0.0031308 ? (x.z * 12.9232102) : 1.055 * pow(x.z, 1.0 / 2.4) - 0.055); } half3 linear_to_bt1886(half3 x, half gamma, half Lw, half Lb) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl new file mode 100644 index 0000000..1982bcb --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl @@ -0,0 +1,52 @@ +#define UNITY_UV_STARTS_AT_TOP 1 +#define UNITY_REVERSED_Z 1 +#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50) +#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1 + +#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName +#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName + +#define TEXTURE2D(textureName) Texture2D textureName +#define SAMPLER2D(samplerName) SamplerState samplerName + +#define TEXTURE3D(textureName) Texture3D textureName +#define SAMPLER3D(samplerName) SamplerState samplerName + +#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName +#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName + +#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName +#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName + +#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2) +#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod) + +#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3) + +#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0)) +#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod)) + +#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2) +#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2) +#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2) +#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2) + +#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r +#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r + +#define UNITY_BRANCH [branch] +#define UNITY_FLATTEN [flatten] +#define UNITY_UNROLL [unroll] +#define UNITY_LOOP [loop] +#define UNITY_FASTOPT [fastopt] + +#define CBUFFER_START(name) cbuffer name { +#define CBUFFER_END }; + +#if UNITY_GATHER_SUPPORTED + #define FXAA_HLSL_5 1 + #define SMAA_HLSL_4_1 1 +#else + #define FXAA_HLSL_4 1 + #define SMAA_HLSL_4 1 +#endif diff --git a/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl.meta new file mode 100644 index 0000000..e4d7e2c --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/API/WebGPU.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9597bf0cd70376447ace14a366b40fe8 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/FinalPass.shader b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/FinalPass.shader index 879b7f7..17c9853 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/FinalPass.shader +++ b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/FinalPass.shader @@ -99,7 +99,7 @@ Shader "Hidden/PostProcessing/FinalPass" Pass { HLSLPROGRAM - #pragma exclude_renderers gles vulkan switch + #pragma exclude_renderers gles vulkan webgpu switch #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET #pragma target 5.0 @@ -115,7 +115,7 @@ Shader "Hidden/PostProcessing/FinalPass" Pass { HLSLPROGRAM - #pragma exclude_renderers gles vulkan switch + #pragma exclude_renderers gles vulkan webgpu switch #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET #pragma target 3.0 @@ -147,7 +147,7 @@ Shader "Hidden/PostProcessing/FinalPass" Pass { HLSLPROGRAM - #pragma only_renderers gles vulkan switch + #pragma only_renderers gles vulkan webgpu switch #pragma multi_compile __ STEREO_DOUBLEWIDE_TARGET //not supporting STEREO_INSTANCING_ENABLED ENDHLSL diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVODownsample1.compute b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVODownsample1.compute index 2fdb6c7..4e63737 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVODownsample1.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVODownsample1.compute @@ -29,11 +29,11 @@ #ifdef MSAA // Output textures +RWTexture2D DS4x; +RWTexture2DArray DS4xAtlas; RWTexture2D LinearZ; RWTexture2D DS2x; RWTexture2DArray DS2xAtlas; -RWTexture2D DS4x; -RWTexture2DArray DS4xAtlas; // Input textures Texture2D Depth; @@ -42,11 +42,11 @@ Texture2D Depth; groupshared float2 g_CacheW[256]; #else // Output textures +RWTexture2D DS4x; +RWTexture2DArray DS4xAtlas; RWTexture2D LinearZ; RWTexture2D DS2x; RWTexture2DArray DS2xAtlas; -RWTexture2D DS4x; -RWTexture2DArray DS4xAtlas; // Input textures Texture2D Depth; @@ -122,7 +122,6 @@ void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group uint slice = ((st.x & 3) | (st.y << 2)) & 15; DS2x[st] = w1; DS2xAtlas[uint3(st >> 2, slice)] = w1; - if ((GI & 011) == 0) { st = DTid.xy >> 1; @@ -130,7 +129,6 @@ void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group DS4x[st] = w1; DS4xAtlas[uint3(st >> 2, slice)] = w1; } - } #endif diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVORender.compute b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVORender.compute index f4cab26..033941d 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVORender.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVORender.compute @@ -27,6 +27,12 @@ #pragma kernel MultiScaleVORender_MSAA MAIN=MultiScaleVORender_MSAA MSAA #pragma kernel MultiScaleVORender_MSAA_interleaved MAIN=MultiScaleVORender_MSAA_interleaved MSAA INTERLEAVE_RESULT +#pragma kernel MultiScaleVORender_Float4 MAIN=MultiScaleVORender_Float4 FLOAT4 +#pragma kernel MultiScaleVORender_interleaved_Float4 MAIN=MultiScaleVORender_interleaved_Float4 INTERLEAVE_RESULT FLOAT4 +#pragma kernel MultiScaleVORender_MSAA_Float4 MAIN=MultiScaleVORender_MSAA_Float4 MSAA FLOAT4 +#pragma kernel MultiScaleVORender_MSAA_interleaved_Float4 MAIN=MultiScaleVORender_MSAA_interleaved_Float4 MSAA INTERLEAVE_RESULT FLOAT4 + + #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl" #ifndef INTERLEAVE_RESULT @@ -68,7 +74,11 @@ #endif // Output texture +#ifdef FLOAT4 + RWTexture2D Occlusion; +#else RWTexture2D Occlusion; +#endif // Shared memory groupshared float DepthSamples[TILE_DIM * TILE_DIM]; diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVOUpsample.compute b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVOUpsample.compute index 6835f4e..2d29efa 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVOUpsample.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/MultiScaleVOUpsample.compute @@ -34,6 +34,19 @@ #pragma kernel MultiScaleVOUpSample_MSAA_blendout MAIN=MultiScaleVOUpSample_MSAA_blendout MSAA BLEND_WITH_HIGHER_RESOLUTION #pragma kernel MultiScaleVOUpSample_MSAA_premin_blendout MAIN=MultiScaleVOUpSample_MSAA_premin_blendout MSAA COMBINE_LOWER_RESOLUTIONS BLEND_WITH_HIGHER_RESOLUTION +#pragma kernel MultiScaleVOUpSample_Float4 MAIN=MultiScaleVOUpSample_Float4 FLOAT4 +#pragma kernel MultiScaleVOUpSample_invert_Float4 MAIN=MultiScaleVOUpSample_invert_Float4 INVERT FLOAT4 +#pragma kernel MultiScaleVOUpSample_premin_Float4 MAIN=MultiScaleVOUpSample_premin_Float4 COMBINE_LOWER_RESOLUTIONS FLOAT4 +#pragma kernel MultiScaleVOUpSample_blendout_Float4 MAIN=MultiScaleVOUpSample_blendout_Float4 BLEND_WITH_HIGHER_RESOLUTION FLOAT4 +#pragma kernel MultiScaleVOUpSample_premin_blendout_Float4 MAIN=MultiScaleVOUpSample_premin_blendout_Float4 COMBINE_LOWER_RESOLUTIONS BLEND_WITH_HIGHER_RESOLUTION FLOAT4 + +#pragma kernel MultiScaleVOUpSample_MSAA_Float4 MAIN=MultiScaleVOUpSample_MSAA_Float4 FLOAT4 +#pragma kernel MultiScaleVOUpSample_MSAA_invert_Float4 MAIN=MultiScaleVOUpSample_MSAA_invert_Float4 MSAA INVERT FLOAT4 +#pragma kernel MultiScaleVOUpSample_MSAA_premin_Float4 MAIN=MultiScaleVOUpSample_MSAA_premin_Float4 MSAA COMBINE_LOWER_RESOLUTIONS FLOAT4 +#pragma kernel MultiScaleVOUpSample_MSAA_blendout_Float4 MAIN=MultiScaleVOUpSample_MSAA_blendout_Float4 MSAA BLEND_WITH_HIGHER_RESOLUTION FLOAT4 +#pragma kernel MultiScaleVOUpSample_MSAA_premin_blendout_Float4 MAIN=MultiScaleVOUpSample_MSAA_premin_blendout_Float4 MSAA COMBINE_LOWER_RESOLUTIONS BLEND_WITH_HIGHER_RESOLUTION FLOAT4 + + #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl" @@ -67,7 +80,11 @@ #endif // Ouput textures + #ifdef FLOAT4 + RWTexture2D AoResult; + #else RWTexture2D AoResult; + #endif // Shared memory groupshared float DepthCache[256]; @@ -416,15 +433,41 @@ void MAIN(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_Group int2 OutST = DTid.xy << 1; #ifdef INVERT - AoResult[OutST + int2(-1, 0)] = 1.0 - BilateralUpsample(HiDepths.x, HiSSAOs.x, LoDepths.xyzw, LoSSAOs.xyzw); - AoResult[OutST + int2( 0, 0)] = 1.0 - BilateralUpsample(HiDepths.y, HiSSAOs.y, LoDepths.yzwx, LoSSAOs.yzwx); - AoResult[OutST + int2( 0, -1)] = 1.0 - BilateralUpsample(HiDepths.z, HiSSAOs.z, LoDepths.zwxy, LoSSAOs.zwxy); - AoResult[OutST + int2(-1, -1)] = 1.0 - BilateralUpsample(HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz); + float x = 1.0 - BilateralUpsample(HiDepths.x, HiSSAOs.x, LoDepths.xyzw, LoSSAOs.xyzw); + float y = 1.0 - BilateralUpsample(HiDepths.y, HiSSAOs.y, LoDepths.yzwx, LoSSAOs.yzwx); + float z = 1.0 - BilateralUpsample(HiDepths.z, HiSSAOs.z, LoDepths.zwxy, LoSSAOs.zwxy); + float w = 1.0 - BilateralUpsample(HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz); + + #ifdef FLOAT4 + AoResult[OutST + int2(-1, 0)] = float4(x, x, x, x); + AoResult[OutST + int2(0, 0)] = float4(y, y, y, y); + AoResult[OutST + int2(0, -1)] = float4(z, z, z, z); + AoResult[OutST + int2(-1, -1)] = float4(w, w, w, w); + #else + AoResult[OutST + int2(-1, 0)] = x; + AoResult[OutST + int2(0, 0)] = y; + AoResult[OutST + int2(0, -1)] = z; + AoResult[OutST + int2(-1, -1)] = w; + #endif + #else - AoResult[OutST + int2(-1, 0)] = BilateralUpsample(HiDepths.x, HiSSAOs.x, LoDepths.xyzw, LoSSAOs.xyzw); - AoResult[OutST + int2( 0, 0)] = BilateralUpsample(HiDepths.y, HiSSAOs.y, LoDepths.yzwx, LoSSAOs.yzwx); - AoResult[OutST + int2( 0, -1)] = BilateralUpsample(HiDepths.z, HiSSAOs.z, LoDepths.zwxy, LoSSAOs.zwxy); - AoResult[OutST + int2(-1, -1)] = BilateralUpsample(HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz); + float x = BilateralUpsample(HiDepths.x, HiSSAOs.x, LoDepths.xyzw, LoSSAOs.xyzw); + float y = BilateralUpsample(HiDepths.y, HiSSAOs.y, LoDepths.yzwx, LoSSAOs.yzwx); + float z = BilateralUpsample(HiDepths.z, HiSSAOs.z, LoDepths.zwxy, LoSSAOs.zwxy); + float w = BilateralUpsample(HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz); + + #ifdef FLOAT4 + AoResult[OutST + int2(-1, 0)] = float4(x, x, x, x); + AoResult[OutST + int2(0, 0)] = float4(y, y, y, y); + AoResult[OutST + int2(0, -1)] = float4(z, z, z, z); + AoResult[OutST + int2(-1, -1)] = float4(w, w, w, w); + #else + AoResult[OutST + int2(-1, 0)] = x; + AoResult[OutST + int2(0, 0)] = y; + AoResult[OutST + int2(0, -1)] = z; + AoResult[OutST + int2(-1, -1)] = w; + #endif + #endif #endif } diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Uber.shader b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Uber.shader index 8da2f91..2a0191e 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Uber.shader +++ b/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Uber.shader @@ -275,7 +275,7 @@ Shader "Hidden/PostProcessing/Uber" Pass { HLSLPROGRAM - #pragma exclude_renderers gles vulkan switch + #pragma exclude_renderers gles vulkan webgpu switch #pragma multi_compile __ COLOR_GRADING_LDR_2D COLOR_GRADING_HDR_2D COLOR_GRADING_HDR_3D #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET @@ -290,7 +290,7 @@ Shader "Hidden/PostProcessing/Uber" Pass { HLSLPROGRAM - #pragma only_renderers vulkan switch + #pragma only_renderers vulkan webgpu switch #pragma multi_compile __ COLOR_GRADING_LDR_2D COLOR_GRADING_HDR_2D COLOR_GRADING_HDR_3D #pragma multi_compile __ STEREO_DOUBLEWIDE_TARGET // disabled for Vulkan because of shader compiler issues in older Unity versions: STEREO_INSTANCING_ENABLED diff --git a/com.unity.postprocessing/PostProcessing/Shaders/Colors.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/Colors.hlsl index 5a25c30..8990830 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/Colors.hlsl +++ b/com.unity.postprocessing/PostProcessing/Shaders/Colors.hlsl @@ -179,7 +179,7 @@ half3 SRGBToLinear(half3 c) #else half3 linearRGBLo = c / 12.92; half3 linearRGBHi = PositivePow((c + 0.055) / 1.055, half3(2.4, 2.4, 2.4)); - half3 linearRGB = (c <= 0.04045) ? linearRGBLo : linearRGBHi; + half3 linearRGB = half3((c.x <= 0.04045) ? linearRGBLo.x : linearRGBHi.x, (c.y <= 0.04045) ? linearRGBLo.y : linearRGBHi.y, (c.z <= 0.04045) ? linearRGBLo.z : linearRGBHi.z); return linearRGB; #endif } @@ -212,7 +212,7 @@ half3 LinearToSRGB(half3 c) #else half3 sRGBLo = c * 12.92; half3 sRGBHi = (PositivePow(c, half3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055; - half3 sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi; + half3 sRGB = half3((c.x <= 0.0031308) ? sRGBLo.x : sRGBHi.x, (c.y <= 0.0031308) ? sRGBLo.y : sRGBHi.y, (c.z <= 0.0031308) ? sRGBLo.z : sRGBHi.z); return sRGB; #endif } diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2.meta deleted file mode 100644 index 6d47067..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cad7d53fa2166a0449bec7a9b4f17d69 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute.meta deleted file mode 100644 index 3864379..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_accumulate_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 702560780e923c84394c9b22ba460a9c -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta deleted file mode 100644 index 19d1df3..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d18fb8811ca4753469c439784546104e -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta deleted file mode 100644 index 49033cb..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0894ebeefb6aa7d4680c71dffbda3fee -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute deleted file mode 100644 index 4e41933..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2023 Nico de Poel -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// 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. - -#pragma kernel CS - -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH - -#pragma multi_compile_local __ UNITY_FSR2_HDRP - -#include "ffx_fsr2_unity_common.cginc" - -#include "shaders/ffx_fsr2_depth_clip_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute.meta deleted file mode 100644 index 26fb9ba..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_depth_clip_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8026d9d8542eab6499c32d5d46beb2b6 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute.meta deleted file mode 100644 index a197b49..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3c96d72b39a840c428c901628dab92c0 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute.meta deleted file mode 100644 index ea6c978..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5a82801f160ff6a4eb47db567216e592 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute deleted file mode 100644 index c6cc99f..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2023 Nico de Poel -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// 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. - -#pragma kernel CS - -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_HDR_COLOR_INPUT -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH - -#pragma multi_compile_local __ UNITY_FSR2_HDRP - -#include "ffx_fsr2_unity_common.cginc" - -#include "shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta deleted file mode 100644 index 6396b86..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_reconstruct_previous_depth_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6ef1b4c25874e334dad5ba3ac6345e32 -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute deleted file mode 100644 index 62d386b..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2023 Nico de Poel -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// 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. - -#pragma kernel CS - -#pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH - -#pragma multi_compile_local __ UNITY_FSR2_HDRP - -#include "ffx_fsr2_unity_common.cginc" - -#include "shaders/ffx_fsr2_tcr_autogen_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta deleted file mode 100644 index 0002090..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_tcr_autogen_pass.compute.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b478fba0a6a87b44b8be7c35deb5f0dc -ComputeShaderImporter: - externalObjects: {} - preprocessorOverride: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h.meta deleted file mode 100644 index f2cc805..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: c6da07d8aae05f04f87e4db20f84c73e -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h.meta deleted file mode 100644 index a5f80a7..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: b37eb663a0ae01b469b0b5a54365b301 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h.meta deleted file mode 100644 index 7edf590..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 9d1d6ed5c9da0c64b882f3ebc2bac307 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h.meta deleted file mode 100644 index 8f9711f..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 402c509393f5bf647b41a962a48ed8e2 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h.meta deleted file mode 100644 index 1d826e4..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 142bf3947ada43541a0f31a328fdec07 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h.meta deleted file mode 100644 index 5a91c43..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_hlsl.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 89d6e02f97594f64ca2da4c8124df6cf -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h.meta deleted file mode 100644 index aad361f..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 5d6e692075988194382122bac7819f02 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h.meta deleted file mode 100644 index cf43a8b..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr1.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 7524e42f73f97f34bbeb414ea412a808 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h.meta deleted file mode 100644 index 51859c3..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: a04cb2522aaff1045869a272ed129964 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl deleted file mode 100644 index 747f380..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl +++ /dev/null @@ -1,78 +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. - -#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_PREPARED_INPUT_COLOR 5 -#define FSR2_BIND_SRV_LANCZOS_LUT 6 -#define FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7 -#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 8 -#define FSR2_BIND_SRV_AUTO_EXPOSURE 9 -#define FSR2_BIND_SRV_LUMA_HISTORY 10 - -#define FSR2_BIND_UAV_INTERNAL_UPSCALED 0 -#define FSR2_BIND_UAV_LOCK_STATUS 1 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 2 -#define FSR2_BIND_UAV_NEW_LOCKS 3 -#define FSR2_BIND_UAV_LUMA_HISTORY 4 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR2_THREAD_GROUP_HEIGHT - 1) / FFX_FSR2_THREAD_GROUP_HEIGHT; - uGroupId.y = GroupRows - uGroupId.y - 1; - - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - Accumulate(uDispatchThreadId); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta deleted file mode 100644 index cad5022..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_accumulate_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 356ec46d3f01672428b5a7a0de727548 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl deleted file mode 100644 index a78a8e3..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl +++ /dev/null @@ -1,85 +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. - -#define FSR2_BIND_SRV_INPUT_OPAQUE_ONLY 0 -#define FSR2_BIND_SRV_INPUT_COLOR 1 -#define FSR2_BIND_UAV_AUTOREACTIVE 0 - -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_REACTIVE 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -#if defined(FSR2_BIND_CB_REACTIVE) -cbuffer cbGenerateReactive : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_REACTIVE) -{ - float scale; - float threshold; - float binaryValue; - uint flags; -}; -#endif - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - float3 ColorPreAlpha = LoadOpaqueOnly( FFX_MIN16_I2(uDispatchThreadId) ).rgb; - float3 ColorPostAlpha = LoadInputColor(uDispatchThreadId).rgb; - - if (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP) - { - ColorPreAlpha = Tonemap(ColorPreAlpha); - ColorPostAlpha = Tonemap(ColorPostAlpha); - } - - if (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP) - { - ColorPreAlpha = InverseTonemap(ColorPreAlpha); - ColorPostAlpha = InverseTonemap(ColorPostAlpha); - } - - float out_reactive_value = 0.f; - float3 delta = abs(ColorPostAlpha - ColorPreAlpha); - - out_reactive_value = (flags & FFX_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta); - out_reactive_value *= scale; - - out_reactive_value = (flags & FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < threshold ? 0 : binaryValue) : out_reactive_value; - - rw_output_autoreactive[uDispatchThreadId] = out_reactive_value; -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta deleted file mode 100644 index 2e93435..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_autogen_reactive_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: cc76bd6f46792f3418a56b79eb5c959b -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h deleted file mode 100644 index de79c82..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h +++ /dev/null @@ -1,817 +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) -#ifdef __hlsl_dx_compiler -#pragma dxc diagnostic push -#pragma dxc diagnostic ignored "-Wambig-lit-shift" -#endif //__hlsl_dx_compiler -#include "ffx_core.h" -#ifdef __hlsl_dx_compiler -#pragma dxc diagnostic pop -#endif //__hlsl_dx_compiler -#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(FFX_GPU) -#pragma warning(disable: 3205) // conversion from larger type to smaller -#endif // #if defined(FFX_GPU) - -#define DECLARE_SRV_REGISTER(regIndex) t##regIndex -#define DECLARE_UAV_REGISTER(regIndex) u##regIndex -#define DECLARE_CB_REGISTER(regIndex) b##regIndex -#define FFX_FSR2_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) -#define FFX_FSR2_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) -#define FFX_FSR2_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) - -#if defined(FSR2_BIND_CB_FSR2) || defined(FFX_INTERNAL) - cbuffer cbFSR2 : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_FSR2) - { - 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; - - FfxInt32 iDummy; - }; - -#define FFX_FSR2_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR2) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR2 size. -#endif - -#if defined(FFX_GPU) -#define FFX_FSR2_ROOTSIG_STRINGIFY(p) FFX_FSR2_ROOTSIG_STR(p) -#define FFX_FSR2_ROOTSIG_STR(p) #p -#define FFX_FSR2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_1_SIZE) ", b0), " \ - "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ - "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] - -#define FFX_FSR2_CONSTANT_BUFFER_2_SIZE 6 // Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size. - -#define FFX_FSR2_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_RESOURCE_IDENTIFIER_COUNT) ")), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_1_SIZE) ", b0), " \ - "RootConstants(num32BitConstants=" FFX_FSR2_ROOTSIG_STRINGIFY(FFX_FSR2_CONSTANT_BUFFER_2_SIZE) ", b1), " \ - "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ - "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ - "addressU = TEXTURE_ADDRESS_CLAMP, " \ - "addressV = TEXTURE_ADDRESS_CLAMP, " \ - "addressW = TEXTURE_ADDRESS_CLAMP, " \ - "comparisonFunc = COMPARISON_NEVER, " \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] -#if defined(FFX_FSR2_EMBED_ROOTSIG) -#define FFX_FSR2_EMBED_ROOTSIG_CONTENT FFX_FSR2_ROOTSIG -#define FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT FFX_FSR2_CB2_ROOTSIG -#else -#define FFX_FSR2_EMBED_ROOTSIG_CONTENT -#define FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -#endif // #if FFX_FSR2_EMBED_ROOTSIG -#endif // #if defined(FFX_GPU) - -// Declare and sample camera buffers as regular textures, unless overridden -#if !defined(UNITY_FSR2_TEX2D) -#define UNITY_FSR2_TEX2D(type) Texture2D -#endif -#if !defined(UNITY_FSR2_POS) -#define UNITY_FSR2_POS(pxPos) (pxPos) -#endif -#if !defined(UNITY_FSR2_UV) -#define UNITY_FSR2_UV(uv) (uv) -#endif - -/* Define getter functions in the order they are defined in the CB! */ -FfxInt32x2 RenderSize() -{ - return iRenderSize; -} - -FfxInt32x2 MaxRenderSize() -{ - return iMaxRenderSize; -} - -FfxInt32x2 DisplaySize() -{ - return iDisplaySize; -} - -FfxInt32x2 InputColorResourceDimensions() -{ - return iInputColorResourceDimensions; -} - -FfxInt32x2 LumaMipDimensions() -{ - return iLumaMipDimensions; -} - -FfxInt32 LumaMipLevelToUse() -{ - return iLumaMipLevelToUse; -} - -FfxInt32 FrameIndex() -{ - return iFrameIndex; -} - -FfxFloat32x2 Jitter() -{ - return fJitter; -} - -FfxFloat32x4 DeviceToViewSpaceTransformFactors() -{ - return fDeviceToViewDepth; -} - -FfxFloat32x2 MotionVectorScale() -{ - return fMotionVectorScale; -} - -FfxFloat32x2 DownscaleFactor() -{ - return fDownscaleFactor; -} - -FfxFloat32x2 MotionVectorJitterCancellation() -{ - return fMotionVectorJitterCancellation; -} - -FfxFloat32 PreExposure() -{ - return fPreExposure; -} - -FfxFloat32 PreviousFramePreExposure() -{ - return fPreviousFramePreExposure; -} - -FfxFloat32 TanHalfFoV() -{ - return fTanHalfFOV; -} - -FfxFloat32 JitterSequenceLength() -{ - return fJitterSequenceLength; -} - -FfxFloat32 DeltaTime() -{ - return fDeltaTime; -} - -FfxFloat32 DynamicResChangeFactor() -{ - return fDynamicResChangeFactor; -} - -FfxFloat32 ViewSpaceToMetersFactor() -{ - return fViewSpaceToMetersFactor; -} - - -SamplerState s_PointClamp : register(s0); -SamplerState s_LinearClamp : register(s1); - -// SRVs -#if defined(FFX_INTERNAL) - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY); - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_COLOR); - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS); - UNITY_FSR2_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_DEPTH); - Texture2D r_input_exposure : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_EXPOSURE); - Texture2D r_auto_exposure : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE); - Texture2D r_reactive_mask : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK); - Texture2D r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK); - Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH); - Texture2D r_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS); - Texture2D r_previous_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS); - Texture2D r_dilatedDepth : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH); - Texture2D r_internal_upscaled_color : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR); - Texture2D r_lock_status : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS); - Texture2D r_lock_input_luma : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA); - Texture2D r_new_locks : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS); - Texture2D r_prepared_input_color : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR); - Texture2D r_luma_history : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY); - Texture2D r_rcas_input : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_RCAS_INPUT); - Texture2D r_lanczos_lut : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_LANCZOS_LUT); - Texture2D r_imgMips : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE); - Texture2D r_upsample_maximum_bias_lut : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT); - Texture2D r_dilated_reactive_masks : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS); - Texture2D r_input_prev_color_pre_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - Texture2D r_input_prev_color_post_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - - Texture2D r_debug_out : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT); - - // UAV declarations - RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH); - RWTexture2D rw_dilated_motion_vectors : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS); - RWTexture2D rw_dilatedDepth : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH); - RWTexture2D rw_internal_upscaled_color : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR); - RWTexture2D rw_lock_status : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS); - RWTexture2D rw_lock_input_luma : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA); - RWTexture2D rw_new_locks : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS); - RWTexture2D rw_prepared_input_color : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR); - RWTexture2D rw_luma_history : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY); - RWTexture2D rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT); - - globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE); - globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5); - RWTexture2D rw_dilated_reactive_masks : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS); - RWTexture2D rw_auto_exposure : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE); - globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT); - RWTexture2D rw_debug_out : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT); - - RWTexture2D rw_output_autoreactive : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTOREACTIVE); - RWTexture2D rw_output_autocomposition : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_AUTOCOMPOSITION); - RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR2_DECLARE_UAV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - -#else // #if defined(FFX_INTERNAL) - #if defined FSR2_BIND_SRV_INPUT_COLOR - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); - #endif - #if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); - #endif - #if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS - UNITY_FSR2_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_INPUT_DEPTH - UNITY_FSR2_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); - #endif - #if defined FSR2_BIND_SRV_INPUT_EXPOSURE - Texture2D r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); - #endif - #if defined FSR2_BIND_SRV_AUTO_EXPOSURE - Texture2D r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); - #endif - #if defined FSR2_BIND_SRV_REACTIVE_MASK - Texture2D r_reactive_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); - #endif - #if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK - Texture2D r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); - #endif - #if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH - Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); - #endif - #if defined FSR2_BIND_SRV_DILATED_MOTION_VECTORS - Texture2D r_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS - Texture2D r_previous_dilated_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_SRV_DILATED_DEPTH - Texture2D r_dilatedDepth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_DEPTH); - #endif - #if defined FSR2_BIND_SRV_INTERNAL_UPSCALED - Texture2D r_internal_upscaled_color : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INTERNAL_UPSCALED); - #endif - #if defined FSR2_BIND_SRV_LOCK_STATUS - Texture2D r_lock_status : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LOCK_STATUS); - #endif - #if defined FSR2_BIND_SRV_LOCK_INPUT_LUMA - Texture2D r_lock_input_luma : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LOCK_INPUT_LUMA); - #endif - #if defined FSR2_BIND_SRV_NEW_LOCKS - Texture2D r_new_locks : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_NEW_LOCKS); - #endif - #if defined FSR2_BIND_SRV_PREPARED_INPUT_COLOR - Texture2D r_prepared_input_color : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_PREPARED_INPUT_COLOR); - #endif - #if defined FSR2_BIND_SRV_LUMA_HISTORY - Texture2D r_luma_history : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LUMA_HISTORY); - #endif - #if defined FSR2_BIND_SRV_RCAS_INPUT - Texture2D r_rcas_input : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RCAS_INPUT); - #endif - #if defined FSR2_BIND_SRV_LANCZOS_LUT - Texture2D r_lanczos_lut : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_LANCZOS_LUT); - #endif - #if defined FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS - Texture2D r_imgMips : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS); - #endif - #if defined FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT - Texture2D r_upsample_maximum_bias_lut : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT); - #endif - #if defined FSR2_BIND_SRV_DILATED_REACTIVE_MASKS - Texture2D r_dilated_reactive_masks : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS); - #endif - - #if defined FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR - Texture2D r_input_prev_color_pre_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); - #endif - #if defined FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR - Texture2D r_input_prev_color_post_alpha : FFX_FSR2_DECLARE_SRV(FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); - #endif - - // UAV declarations - #if defined FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH - RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH); - #endif - #if defined FSR2_BIND_UAV_DILATED_MOTION_VECTORS - RWTexture2D rw_dilated_motion_vectors : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_MOTION_VECTORS); - #endif - #if defined FSR2_BIND_UAV_DILATED_DEPTH - RWTexture2D rw_dilatedDepth : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_DEPTH); - #endif - #if defined FSR2_BIND_UAV_INTERNAL_UPSCALED - RWTexture2D rw_internal_upscaled_color : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_INTERNAL_UPSCALED); - #endif - #if defined FSR2_BIND_UAV_LOCK_STATUS - RWTexture2D rw_lock_status : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LOCK_STATUS); - #endif - #if defined FSR2_BIND_UAV_LOCK_INPUT_LUMA - RWTexture2D rw_lock_input_luma : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LOCK_INPUT_LUMA); - #endif - #if defined FSR2_BIND_UAV_NEW_LOCKS - RWTexture2D rw_new_locks : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_NEW_LOCKS); - #endif - #if defined FSR2_BIND_UAV_PREPARED_INPUT_COLOR - RWTexture2D rw_prepared_input_color : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREPARED_INPUT_COLOR); - #endif - #if defined FSR2_BIND_UAV_LUMA_HISTORY - RWTexture2D rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); - #endif - #if defined FSR2_BIND_UAV_UPSCALED_OUTPUT - RWTexture2D rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE - globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE_MIP_5 - globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_5); - #endif - #if defined FSR2_BIND_UAV_DILATED_REACTIVE_MASKS - RWTexture2D rw_dilated_reactive_masks : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_DILATED_REACTIVE_MASKS); - #endif - #if defined FSR2_BIND_UAV_EXPOSURE - RWTexture2D rw_exposure : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE); - #endif - #if defined FSR2_BIND_UAV_AUTO_EXPOSURE - RWTexture2D rw_auto_exposure : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTO_EXPOSURE); - #endif - #if defined FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC - globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC); - #endif - - #if defined FSR2_BIND_UAV_AUTOREACTIVE - RWTexture2D rw_output_autoreactive : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTOREACTIVE); - #endif - #if defined FSR2_BIND_UAV_AUTOCOMPOSITION - RWTexture2D rw_output_autocomposition : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_AUTOCOMPOSITION); - #endif - #if defined FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR - RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR); - #endif - #if defined FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR - RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR); - #endif -#endif // #if defined(FFX_INTERNAL) - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) || defined(FFX_INTERNAL) -FfxFloat32 LoadMipLuma(FfxUInt32x2 iPxPos, FfxUInt32 mipLevel) -{ - return r_imgMips.mips[mipLevel][iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS) || defined(FFX_INTERNAL) -FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) -{ - return r_imgMips.SampleLevel(s_LinearClamp, fUV, mipLevel); -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) -{ - return r_input_depth[UNITY_FSR2_POS(iPxPos)]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) -{ - return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR2_UV(fUV), 0).x; -} -#endif - -#if defined(FSR2_BIND_SRV_REACTIVE_MASK) || defined(FFX_INTERNAL) -FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) -{ - return r_reactive_mask[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) || defined(FFX_INTERNAL) -FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) -{ - return r_transparency_and_composition_mask[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) -{ - return r_input_color_jittered[UNITY_FSR2_POS(iPxPos)].rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) -{ - return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR2_UV(fUV), 0).rgb; -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos) -{ - return r_prepared_input_color[iPxPos].xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) -{ - FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR2_POS(iPxDilatedMotionVectorPos)].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) || defined(FFX_INTERNAL) -FfxFloat32x4 LoadHistory(FfxUInt32x2 iPxHistory) -{ - return r_internal_upscaled_color[iPxHistory]; -} -#endif - -#if defined(FSR2_BIND_UAV_LUMA_HISTORY) || defined(FFX_INTERNAL) -void StoreLumaHistory(FfxUInt32x2 iPxPos, FfxFloat32x4 fLumaHistory) -{ - rw_luma_history[iPxPos] = fLumaHistory; -} - -FfxFloat32x4 LoadRwLumaHistory(FFX_MIN16_I2 iPxPos) -{ - return rw_luma_history[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_LUMA_HISTORY) || defined(FFX_INTERNAL) -FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV) -{ - return r_luma_history.SampleLevel(s_LinearClamp, fUV, 0); -} -#endif - -#if defined(FFX_INTERNAL) -FfxFloat32x4 SampleDebug(FfxFloat32x2 fUV) -{ - return r_debug_out.SampleLevel(s_LinearClamp, fUV, 0).w; -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) || defined(FFX_INTERNAL) -void StoreReprojectedHistory(FfxUInt32x2 iPxHistory, FfxFloat32x4 fHistory) -{ - rw_internal_upscaled_color[iPxHistory] = fHistory; -} -#endif - -#if defined(FSR2_BIND_UAV_INTERNAL_UPSCALED) || defined(FFX_INTERNAL) -void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight) -{ - rw_internal_upscaled_color[iPxPos] = fColorAndWeight; -} -#endif - -#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) || defined(FFX_INTERNAL) -void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) -{ - rw_upscaled_output[iPxPos] = FfxFloat32x4(fColor, 1.f); -} -#endif - -//LOCK_LIFETIME_REMAINING == 0 -//Should make LockInitialLifetime() return a const 1.0f later -#if defined(FSR2_BIND_SRV_LOCK_STATUS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadLockStatus(FfxUInt32x2 iPxPos) -{ - return r_lock_status[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_STATUS) || defined(FFX_INTERNAL) -void StoreLockStatus(FfxUInt32x2 iPxPos, FfxFloat32x2 fLockStatus) -{ - rw_lock_status[iPxPos] = fLockStatus; -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_INPUT_LUMA) || defined(FFX_INTERNAL) -FfxFloat32 LoadLockInputLuma(FfxUInt32x2 iPxPos) -{ - return r_lock_input_luma[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_LOCK_INPUT_LUMA) || defined(FFX_INTERNAL) -void StoreLockInputLuma(FfxUInt32x2 iPxPos, FfxFloat32 fLuma) -{ - rw_lock_input_luma[iPxPos] = fLuma; -} -#endif - -#if defined(FSR2_BIND_SRV_NEW_LOCKS) || defined(FFX_INTERNAL) -FfxFloat32 LoadNewLocks(FfxUInt32x2 iPxPos) -{ - return r_new_locks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) || defined(FFX_INTERNAL) -FfxFloat32 LoadRwNewLocks(FfxUInt32x2 iPxPos) -{ - return rw_new_locks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_NEW_LOCKS) || defined(FFX_INTERNAL) -void StoreNewLocks(FfxUInt32x2 iPxPos, FfxFloat32 newLock) -{ - rw_new_locks[iPxPos] = newLock; -} -#endif - -#if defined(FSR2_BIND_UAV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -void StorePreparedInputColor(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped) -{ - rw_prepared_input_color[iPxPos] = fTonemapped; -} -#endif - -#if defined(FSR2_BIND_SRV_PREPARED_INPUT_COLOR) || defined(FFX_INTERNAL) -FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV) -{ - return r_prepared_input_color.SampleLevel(s_LinearClamp, fUV, 0).w; -} -#endif - -#if defined(FSR2_BIND_SRV_LOCK_STATUS) || defined(FFX_INTERNAL) -FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV) -{ - FfxFloat32x2 fLockStatus = r_lock_status.SampleLevel(s_LinearClamp, fUV, 0); - return fLockStatus; -} -#endif - -#if defined(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadReconstructedPrevDepth(FfxUInt32x2 iPxPos) -{ - return asfloat(r_reconstructed_previous_nearest_depth[iPxPos]); -} -#endif - -#if defined(FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) || defined(FFX_INTERNAL) -void StoreReconstructedDepth(FfxUInt32x2 iPxSample, FfxFloat32 fDepth) -{ - FfxUInt32 uDepth = asuint(fDepth); - - #if FFX_FSR2_OPTION_INVERTED_DEPTH - InterlockedMax(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); - #else - InterlockedMin(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) || defined(FFX_INTERNAL) -void SetReconstructedDepth(FfxUInt32x2 iPxSample, const FfxUInt32 uValue) -{ - rw_reconstructed_previous_nearest_depth[iPxSample] = uValue; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_DEPTH) || defined(FFX_INTERNAL) -void StoreDilatedDepth(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth) -{ - rw_dilatedDepth[iPxPos] = fDepth; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector) -{ - rw_dilated_motion_vectors[iPxPos] = fMotionVector; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadDilatedMotionVector(FfxUInt32x2 iPxInput) -{ - return r_dilated_motion_vectors[iPxInput].xy; -} -#endif - -#if defined(FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxUInt32x2 iPxInput) -{ - return r_previous_dilated_motion_vectors[iPxInput].xy; -} - -FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 uv) -{ - return r_previous_dilated_motion_vectors.SampleLevel(s_LinearClamp, uv, 0).xy; -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_DEPTH) || defined(FFX_INTERNAL) -FfxFloat32 LoadDilatedDepth(FfxUInt32x2 iPxInput) -{ - return r_dilatedDepth[iPxInput]; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_EXPOSURE) || defined(FFX_INTERNAL) -FfxFloat32 Exposure() -{ - FfxFloat32 exposure = r_input_exposure[FfxUInt32x2(0, 0)].x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -#if defined(FSR2_BIND_SRV_AUTO_EXPOSURE) || defined(FFX_INTERNAL) -FfxFloat32 AutoExposure() -{ - FfxFloat32 exposure = r_auto_exposure[FfxUInt32x2(0, 0)].x; - - if (exposure == 0.0f) { - exposure = 1.0f; - } - - return exposure; -} -#endif - -FfxFloat32 SampleLanczos2Weight(FfxFloat32 x) -{ -#if defined(FSR2_BIND_SRV_LANCZOS_LUT) || defined(FFX_INTERNAL) - return r_lanczos_lut.SampleLevel(s_LinearClamp, FfxFloat32x2(x / 2, 0.5f), 0); -#else - return 0.f; -#endif -} - -#if defined(FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT) || defined(FFX_INTERNAL) -FfxFloat32 SampleUpsampleMaximumBias(FfxFloat32x2 uv) -{ - // Stored as a SNORM, so make sure to multiply by 2 to retrieve the actual expected range. - return FfxFloat32(2.0) * r_upsample_maximum_bias_lut.SampleLevel(s_LinearClamp, abs(uv) * 2.0, 0); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV) -{ - return r_dilated_reactive_masks.SampleLevel(s_LinearClamp, fUV, 0); -} -#endif - -#if defined(FSR2_BIND_SRV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos) -{ - return r_dilated_reactive_masks[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_DILATED_REACTIVE_MASKS) || defined(FFX_INTERNAL) -void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks) -{ - rw_dilated_reactive_masks[iPxPos] = fDilatedReactiveMasks; -} -#endif - -#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_opaque_only[UNITY_FSR2_POS(iPxPos)].xyz; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_PRE_ALPHA_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_prev_color_pre_alpha[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_SRV_PREV_POST_ALPHA_COLOR) || defined(FFX_INTERNAL) -FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) -{ - return r_input_prev_color_post_alpha[iPxPos]; -} -#endif - -#if defined(FSR2_BIND_UAV_AUTOREACTIVE) || defined(FFX_INTERNAL) -#if defined(FSR2_BIND_UAV_AUTOCOMPOSITION) || defined(FFX_INTERNAL) -void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive) -{ - rw_output_autoreactive[iPxPos] = fReactive.x; - - rw_output_autocomposition[iPxPos] = fReactive.y; -} -#endif -#endif - -#if defined(FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR) || defined(FFX_INTERNAL) -void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - rw_output_prev_color_pre_alpha[iPxPos] = color; - -} -#endif - -#if defined(FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR) || defined(FFX_INTERNAL) -void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) -{ - rw_output_prev_color_post_alpha[iPxPos] = color; -} -#endif - -#endif // #if defined(FFX_GPU) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta deleted file mode 100644 index 97858ae..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_callbacks_hlsl.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: eb121968296f9ba44b35d7e18d2b79df -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h.meta deleted file mode 100644 index 0e3bb9c..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_common.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 2176dca22b6e9604da8329c79abae68d -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta deleted file mode 100644 index c8cb631..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: dbcdb6dfb36311a49aa7b05bc5054280 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl deleted file mode 100644 index 2b96636..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl +++ /dev/null @@ -1,131 +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. - -#define FSR2_BIND_SRV_INPUT_COLOR 0 -#define FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC 0 -#define FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 1 -#define FSR2_BIND_UAV_EXPOSURE_MIP_5 2 -#define FSR2_BIND_UAV_AUTO_EXPOSURE 3 -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_SPD 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -#if defined(FSR2_BIND_CB_SPD) - cbuffer cbSPD : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_SPD) { - - FfxUInt32 mips; - FfxUInt32 numWorkGroups; - FfxUInt32x2 workGroupOffset; - FfxUInt32x2 renderSize; - }; - - FfxUInt32 MipCount() - { - return mips; - } - - FfxUInt32 NumWorkGroups() - { - return numWorkGroups; - } - - FfxUInt32x2 WorkGroupOffset() - { - return workGroupOffset; - } - - FfxUInt32x2 SPD_RenderSize() - { - return renderSize; - } -#endif - - -FfxFloat32x2 SPD_LoadExposureBuffer() -{ - return rw_auto_exposure[FfxInt32x2(0,0)]; -} - -void SPD_SetExposureBuffer(FfxFloat32x2 value) -{ - rw_auto_exposure[FfxInt32x2(0,0)] = value; -} - -FfxFloat32x4 SPD_LoadMipmap5(FfxInt32x2 iPxPos) -{ - return FfxFloat32x4(rw_img_mip_5[iPxPos], 0, 0, 0); -} - -void SPD_SetMipmap(FfxInt32x2 iPxPos, FfxInt32 slice, FfxFloat32 value) -{ - switch (slice) - { - case FFX_FSR2_SHADING_CHANGE_MIP_LEVEL: - rw_img_mip_shading_change[iPxPos] = value; - break; - case 5: - rw_img_mip_5[iPxPos] = value; - break; - default: - - // avoid flattened side effect -#if defined(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE) || defined(FFX_INTERNAL) - rw_img_mip_shading_change[iPxPos] = rw_img_mip_shading_change[iPxPos]; -#elif defined(FSR2_BIND_UAV_EXPOSURE_MIP_5) || defined(FFX_INTERNAL) - rw_img_mip_5[iPxPos] = rw_img_mip_5[iPxPos]; -#endif - break; - } -} - -void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter) -{ - InterlockedAdd(rw_spd_global_atomic[FfxInt32x2(0,0)], 1, spdCounter); -} - -void SPD_ResetAtomicCounter() -{ - rw_spd_global_atomic[FfxInt32x2(0,0)] = 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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -void CS(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex) -{ - ComputeAutoExposure(WorkGroupId, LocalThreadIndex); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta deleted file mode 100644 index ac39806..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 19dfb00afb70c3144b43ec2dc05ecdd9 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h.meta deleted file mode 100644 index dbdf299..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: f7c16477aeb3a9b4f94f4ef818d10d9b -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl deleted file mode 100644 index 3cf501c..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl +++ /dev/null @@ -1,66 +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. - -#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_PREVIOUS_DILATED_MOTION_VECTORS 5 -#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 6 -#define FSR2_BIND_SRV_INPUT_COLOR 7 -#define FSR2_BIND_SRV_INPUT_DEPTH 8 -#define FSR2_BIND_SRV_INPUT_EXPOSURE 9 - -#define FSR2_BIND_UAV_DILATED_REACTIVE_MASKS 0 -#define FSR2_BIND_UAV_PREPARED_INPUT_COLOR 1 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS( - int2 iGroupId : SV_GroupID, - int2 iDispatchThreadId : SV_DispatchThreadID, - int2 iGroupThreadId : SV_GroupThreadID, - int iGroupIndex : SV_GroupIndex) -{ - DepthClip(iDispatchThreadId); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta deleted file mode 100644 index d7ce66d..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7981b48622ddaa944909ebf209284d83 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h.meta deleted file mode 100644 index 21f4814..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 9b4cdc5f81194ac4fa946c31b86234ed -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl deleted file mode 100644 index 1409dce..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl +++ /dev/null @@ -1,53 +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. - -#define FSR2_BIND_SRV_LOCK_INPUT_LUMA 0 -#define FSR2_BIND_UAV_NEW_LOCKS 0 -#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 1 -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) -{ - uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId; - - ComputeLock(uDispatchThreadId); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta deleted file mode 100644 index 4ded638..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_lock_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 471a3f7a033c72f4fa737d4f8238a9bd -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta deleted file mode 100644 index ddb6dda..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 3945c3cfd2cc1a64cb0513864d88d8ca -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h.meta deleted file mode 100644 index e962499..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 7bd7d4eb34c626342966cb9b3fe00363 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl deleted file mode 100644 index f447b7e..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl +++ /dev/null @@ -1,75 +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. - -#define FSR2_BIND_SRV_INPUT_EXPOSURE 0 -#define FSR2_BIND_SRV_RCAS_INPUT 1 -#define FSR2_BIND_UAV_UPSCALED_OUTPUT 0 -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_RCAS 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -//Move to prototype shader! -#if defined(FSR2_BIND_CB_RCAS) - cbuffer cbRCAS : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_RCAS) - { - uint4 rcasConfig; - }; - - uint4 RCASConfig() - { - return rcasConfig; - } -#else - uint4 RCASConfig() - { - return 0; - } -#endif - - -float4 LoadRCAS_Input(FfxInt32x2 iPxPos) -{ - return r_rcas_input[iPxPos]; -} - -#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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_CB2_ROOTSIG_CONTENT -void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID) -{ - RCAS(LocalThreadId, WorkGroupId, Dtid); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta deleted file mode 100644 index b7e089b..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 871ca1938c701d64f94ef8ec00ef06f4 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta deleted file mode 100644 index 9b82a1a..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 13cd33c3d34a317409049dfd939e64ef -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl deleted file mode 100644 index 33c044e..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl +++ /dev/null @@ -1,63 +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. - -#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_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 -#define FSR2_BIND_UAV_DILATED_MOTION_VECTORS 1 -#define FSR2_BIND_UAV_DILATED_DEPTH 2 -#define FSR2_BIND_UAV_LOCK_INPUT_LUMA 3 - -#define FSR2_BIND_CB_FSR2 0 - -#include "ffx_fsr2_callbacks_hlsl.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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_PREFER_WAVE64 -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT -void CS( - int2 iGroupId : SV_GroupID, - int2 iDispatchThreadId : SV_DispatchThreadID, - int2 iGroupThreadId : SV_GroupThreadID, - int iGroupIndex : SV_GroupIndex -) -{ - ReconstructAndDilate(iDispatchThreadId); -} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta deleted file mode 100644 index 4f5036c..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9355c255c8505ae48ae89af286943747 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h.meta deleted file mode 100644 index ef8ce86..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reproject.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 63fc917ca6895cb4aac237ea35edb838 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h deleted file mode 100644 index 535dbc3..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h +++ /dev/null @@ -1,105 +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. - -#ifndef FFX_FSR2_RESOURCES_H -#define FFX_FSR2_RESOURCES_H - -#if defined(FFX_CPU) || defined(FFX_GPU) -#define FFX_FSR2_RESOURCE_IDENTIFIER_NULL 0 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_COLOR 2 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_DEPTH 4 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7 -#define FFX_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH 10 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS 12 -#define FFX_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS 13 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY 15 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LANCZOS_LUT 17 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18 -#define FFX_FSR2_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19 -#define FFX_FSR2_RESOURCE_IDENTIFIER_RCAS_INPUT 20 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26 -#define FFX_FSR2_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27 -#define FFX_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40 -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTOREACTIVE 44 -#define FFX_FSR2_RESOURCE_IDENTIFIER_AUTOCOMPOSITION 45 - -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR 46 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR 47 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_1 48 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_1 49 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_2 50 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_2 51 -#define FFX_FSR2_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 52 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_1 53 -#define FFX_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_2 54 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 55 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 56 -#define FFX_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 57 - -// Shading change detection mip level setting, value must be in the range [FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12] -#define FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 -#define FFX_FSR2_SHADING_CHANGE_MIP_LEVEL (FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFX_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE) - -#define FFX_FSR2_RESOURCE_IDENTIFIER_COUNT 58 - -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_FSR2 0 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_SPD 1 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_RCAS 2 -#define FFX_FSR2_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3 - -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1 -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2 -#define FFX_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4 -#define FFX_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8 - -#endif // #if defined(FFX_CPU) || defined(FFX_GPU) - -#endif //!defined( FFX_FSR2_RESOURCES_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h.meta deleted file mode 100644 index 69e95a4..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_resources.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: fd5bed2bf4ba07444ae815390168a15d -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h.meta deleted file mode 100644 index acc8bab..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_sample.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: ba3ee190167b6c240aaeb1f8f4dbcb67 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta deleted file mode 100644 index a2af34e..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 18b8590c99b171a4e9af68dfd2c3ff02 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta deleted file mode 100644 index d133259..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9feb1fa4d6cff5a4799298dc69b12a8e -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h.meta deleted file mode 100644 index c9fa0a3..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 1ff3a385cfe07db4387e4d7b457238f8 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h.meta deleted file mode 100644 index d896fc1..0000000 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h.meta +++ /dev/null @@ -1,60 +0,0 @@ -fileFormatVersion: 2 -guid: 3ef69a900a925bb498651c10581e0979 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude GameCoreScarlett: 1 - Exclude GameCoreXboxOne: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude PS4: 1 - Exclude PS5: 1 - Exclude WebGL: 1 - Exclude Win: 1 - Exclude Win64: 1 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: None - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3.meta new file mode 100644 index 0000000..3e30dae --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 37c436021e67c00459f44b59099c024a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute similarity index 61% rename from Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute index a359485..5cbfb80 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_accumulate_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute @@ -21,21 +21,21 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#pragma multi_compile_local __ FFX_FSR2_OPTION_HDR_COLOR_INPUT -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ FFX_FSR2_OPTION_APPLY_SHARPENING +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" // Ensure the correct value is defined for this keyword, as it is used to select one of multiple sampler functions -#ifdef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#undef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 1 +#ifdef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#undef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE 1 #endif -#include "shaders/ffx_fsr2_accumulate_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_accumulate_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta new file mode 100644 index 0000000..dbe5282 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_accumulate_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9b45f0ae7673694ba57a4aadfe212e9 +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute new file mode 100644 index 0000000..e13c001 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Nico de Poel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// 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. + +#pragma kernel CS + +#pragma multi_compile_local __ FFX_HALF +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH + +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP + +#include "ffx_fsr3upscaler_unity_common.cginc" + +#include "shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta new file mode 100644 index 0000000..1df041b --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_autogen_reactive_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5716b91fdaa4e9e439df6b96a796fe6e +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute similarity index 76% rename from Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute index 385dfe4..d5903c0 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_compute_luminance_pyramid_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute @@ -20,14 +20,14 @@ #pragma kernel CS -//#pragma multi_compile_local __ FFX_HALF // causes a hard-coded error message from the shader include ¯\_(ツ)_/¯ -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_HALF +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" // Wave operations require shader model 6.0; this can only be enabled when using DXC on D3D12 // These pragmas are commented out by default as Unity will sometimes ignore the #if's and try to enable these features anyway. @@ -36,7 +36,7 @@ //#pragma require WaveBasic // Required for WaveGetLaneIndex //#pragma require WaveBallot // Required for WaveReadLaneAt //#else -#define SPD_NO_WAVE_OPERATIONS +#define FFX_SPD_NO_WAVE_OPERATIONS //#endif -#include "shaders/ffx_fsr2_compute_luminance_pyramid_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta new file mode 100644 index 0000000..9e002c0 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_compute_luminance_pyramid_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d253be05abcdc80428503d3e4cce3a36 +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute similarity index 74% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute index d27a02d..0ccd388 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_autogen_reactive_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute @@ -21,12 +21,12 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_autogen_reactive_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta new file mode 100644 index 0000000..d695f48 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_depth_clip_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20e44016ed34b0d4b8de499d1b566c69 +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute similarity index 77% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute index 5f8c13d..e38ad99 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_lock_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute @@ -21,10 +21,10 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_lock_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_lock_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta new file mode 100644 index 0000000..c01e009 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_lock_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a135306e6d1857e43a86ef20db2a47fe +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute similarity index 77% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute index 6d97414..04c2fe4 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_rcas_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute @@ -20,10 +20,10 @@ #pragma kernel CS -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_rcas_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_rcas_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta new file mode 100644 index 0000000..cd12641 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_rcas_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7aaf5cfff022de2499e9b0412f947f6c +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute new file mode 100644 index 0000000..ee2f276 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute @@ -0,0 +1,33 @@ +// Copyright (c) 2023 Nico de Poel +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// 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. + +#pragma kernel CS + +#pragma multi_compile_local __ FFX_HALF +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH + +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP + +#include "ffx_fsr3upscaler_unity_common.cginc" + +#include "shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta new file mode 100644 index 0000000..1053c34 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_reconstruct_previous_depth_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f59e5b9179d74844ae06a30ae1e0629 +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute similarity index 74% rename from Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute index 4e41933..6338918 100644 --- a/Assets/Resources/FSR2/ffx_fsr2_depth_clip_pass.compute +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute @@ -21,12 +21,12 @@ #pragma kernel CS #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile_local __ FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS +#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile_local __ UNITY_FSR2_HDRP +#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP -#include "ffx_fsr2_unity_common.cginc" +#include "ffx_fsr3upscaler_unity_common.cginc" -#include "shaders/ffx_fsr2_depth_clip_pass.hlsl" +#include "shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl" diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta new file mode 100644 index 0000000..ad42fbb --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_tcr_autogen_pass.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75cdc6ef23f08ed498d4da511923fcea +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc similarity index 92% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc index 98c5b17..758bb0c 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/ffx_fsr2_unity_common.cginc +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Nico de Poel +// Copyright (c) 2023 Nico de Poel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,7 @@ // Workaround for HDRP using texture arrays for its camera buffers on some platforms // The below defines are copied from: Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl -#if defined(UNITY_FSR2_HDRP) +#if defined(UNITY_FSR3UPSCALER_HDRP) // Must be in sync with C# with property useTexArray in TextureXR.cs #if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) #define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED @@ -73,9 +73,10 @@ #endif // Declare and sample camera buffers as texture arrays - #define UNITY_FSR2_TEX2D(type) Texture2DArray - #define UNITY_FSR2_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) - #define UNITY_FSR2_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) + #define UNITY_FSR3_TEX2D(type) Texture2DArray + #define UNITY_FSR3_RWTEX2D(type) RWTexture2DArray + #define UNITY_FSR3_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) + #define UNITY_FSR3_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) #endif #endif diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta new file mode 100644 index 0000000..5a68b6c --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/ffx_fsr3upscaler_unity_common.cginc.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3ce00ba677bb7e14bb91772fd68bfe6b +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders.meta similarity index 77% rename from Assets/Resources/FSR2/shaders.meta rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders.meta index 676ff9a..8a4ff2b 100644 --- a/Assets/Resources/FSR2/shaders.meta +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4a24e63edc822264a871f58397325d51 +guid: 8364d4f86c613ec4d999d062f5f773b8 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl new file mode 100644 index 0000000..d2f1b32 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl @@ -0,0 +1,79 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0 +#define FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS 1 +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 2 +#else +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2 +#endif +#define FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED 3 +#define FSR3UPSCALER_BIND_SRV_LOCK_STATUS 4 +#define FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR 5 +#define FSR3UPSCALER_BIND_SRV_LANCZOS_LUT 6 +#define FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7 +#define FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS 8 +#define FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE 9 +#define FSR3UPSCALER_BIND_SRV_LUMA_HISTORY 10 + +#define FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED 0 +#define FSR3UPSCALER_BIND_UAV_LOCK_STATUS 1 +#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 2 +#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 3 +#define FSR3UPSCALER_BIND_UAV_LUMA_HISTORY 4 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_upsample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h" +#include "fsr3upscaler/ffx_fsr3upscaler_reproject.h" +#include "fsr3upscaler/ffx_fsr3upscaler_accumulate.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT - 1) / FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT; + uGroupId.y = GroupRows - uGroupId.y - 1; + + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + Accumulate(uDispatchThreadId); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta new file mode 100644 index 0000000..80f209e --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_accumulate_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 507ab779c38eddb429cdcedf9c108d1b +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl new file mode 100644 index 0000000..0d6e2eb --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl @@ -0,0 +1,77 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1 + +#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_REACTIVE 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + float3 ColorPreAlpha = LoadOpaqueOnly( FFX_MIN16_I2(uDispatchThreadId) ).rgb; + float3 ColorPostAlpha = LoadInputColor(uDispatchThreadId).rgb; + + if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP) + { + ColorPreAlpha = Tonemap(ColorPreAlpha); + ColorPostAlpha = Tonemap(ColorPostAlpha); + } + + if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP) + { + ColorPreAlpha = InverseTonemap(ColorPreAlpha); + ColorPostAlpha = InverseTonemap(ColorPostAlpha); + } + + float out_reactive_value = 0.f; + float3 delta = abs(ColorPostAlpha - ColorPreAlpha); + + out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta); + out_reactive_value *= GenReactiveScale(); + + out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < GenReactiveThreshold() ? 0 : GenReactiveBinaryValue()) : out_reactive_value; + + rw_output_autoreactive[uDispatchThreadId] = out_reactive_value; +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta new file mode 100644 index 0000000..c55f004 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 52cdb7a7c30cb614984908593ed19082 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl new file mode 100644 index 0000000..93b7332 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl @@ -0,0 +1,55 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 0 + +#define FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC 0 +#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 1 +#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 2 +#define FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_SPD 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 256 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +void CS(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex) +{ + ComputeAutoExposure(WorkGroupId, LocalThreadIndex); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta new file mode 100644 index 0000000..508b43e --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2d149b52ba0f5bb468a94a71dbbcb66f +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl new file mode 100644 index 0000000..70cc7ba --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl @@ -0,0 +1,67 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 +#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 1 +#define FSR3UPSCALER_BIND_SRV_DILATED_DEPTH 2 +#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 3 +#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 4 +#define FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS 5 +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 6 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 7 +#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 8 +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 9 + +#define FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS 0 +#define FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR 1 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_depth_clip.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS( + int2 iGroupId : SV_GroupID, + int2 iDispatchThreadId : SV_DispatchThreadID, + int2 iGroupThreadId : SV_GroupThreadID, + int iGroupIndex : SV_GroupIndex) +{ + DepthClip(iDispatchThreadId); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta new file mode 100644 index 0000000..cde3a5e --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: da435b71cf57e2247b80ae0f0f86d1f8 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl new file mode 100644 index 0000000..26b28f0 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl @@ -0,0 +1,56 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA 0 + +#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 0 +#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 1 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_lock.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) +{ + uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId; + + ComputeLock(uDispatchThreadId); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta new file mode 100644 index 0000000..45c99dc --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_lock_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 98d2cbbda5e90dd4ebd1d70abbb63a09 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl new file mode 100644 index 0000000..bebdeb3 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl @@ -0,0 +1,53 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0 +#define FSR3UPSCALER_BIND_SRV_RCAS_INPUT 1 + +#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 0 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_RCAS 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_rcas.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 64 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID) +{ + RCAS(LocalThreadId, WorkGroupId, Dtid); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta new file mode 100644 index 0000000..fb9bfe2 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_rcas_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9a15fc73170a9bc478801c8fa4d8d574 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl new file mode 100644 index 0000000..f277fd1 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl @@ -0,0 +1,64 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 1 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 2 +#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 3 + +#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0 +#define FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS 1 +#define FSR3UPSCALER_BIND_UAV_DILATED_DEPTH 2 +#define FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_sample.h" +#include "fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_PREFER_WAVE64 +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +void CS( + int2 iGroupId : SV_GroupID, + int2 iDispatchThreadId : SV_DispatchThreadID, + int2 iGroupThreadId : SV_GroupThreadID, + int iGroupIndex : SV_GroupIndex +) +{ + ReconstructAndDilate(iDispatchThreadId); +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta new file mode 100644 index 0000000..6489d6d --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bafb3726a76b97a49bb343d8a4323754 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl similarity index 56% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl index 8e635d1..6180885 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen_pass.hlsl +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl @@ -19,68 +19,44 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#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 4 -#define FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 5 - -#define FSR2_BIND_UAV_AUTOREACTIVE 0 -#define FSR2_BIND_UAV_AUTOCOMPOSITION 1 -#define FSR2_BIND_UAV_PREV_PRE_ALPHA_COLOR 2 -#define FSR2_BIND_UAV_PREV_POST_ALPHA_COLOR 3 - -#define FSR2_BIND_CB_FSR2 0 -#define FSR2_BIND_CB_AUTOREACTIVE 1 - -#include "ffx_fsr2_callbacks_hlsl.h" -#include "ffx_fsr2_common.h" - -#if defined(FSR2_BIND_CB_AUTOREACTIVE) - cbuffer cbGenerateReactive : FFX_FSR2_DECLARE_CB(FSR2_BIND_CB_AUTOREACTIVE) - { - float fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels - float fTcScale; - float fReactiveScale; - float fReactiveMax; - }; - float getTcThreshold() - { - return fTcThreshold; - } -#else - #define fTcThreshold 0.05f - #define fTcScale 1.00f - #define fReactiveScale 10.0f - #define fReactiveMax 0.90f - float getTcThreshold() - { - return fTcThreshold; - } -#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 [numthreads(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT, FFX_FSR2_THREAD_GROUP_DEPTH)] -#endif // #ifndef FFX_FSR2_NUM_THREADS - -FFX_FSR2_NUM_THREADS -FFX_FSR2_EMBED_ROOTSIG_CONTENT +#define FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0 +#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1 +#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2 +#define FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR 3 +#define FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR 4 +#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 4 +#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 5 + +#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0 +#define FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION 1 +#define FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR 2 +#define FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR 3 + +#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0 +#define FSR3UPSCALER_BIND_CB_AUTOREACTIVE 1 + +#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h" +#include "fsr3upscaler/ffx_fsr3upscaler_common.h" +#include "fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h" + +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8 +#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT +#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1 +#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH +#ifndef FFX_FSR3UPSCALER_NUM_THREADS +#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)] +#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS + +FFX_FSR3UPSCALER_NUM_THREADS +FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID) { - FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(uGroupId * uint2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId); + FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId); // 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 diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta new file mode 100644 index 0000000..02c5f46 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 712d171118b59fc4fb28d0d487060d42 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler.meta new file mode 100644 index 0000000..2626a2e --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ae9c6d015ae76544f9e8117e79ea862b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h similarity index 83% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h index 4594dc1..f0b62ab 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_common_types.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -18,6 +18,8 @@ // 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. + + #ifndef FFX_COMMON_TYPES_H #define FFX_COMMON_TYPES_H @@ -25,127 +27,200 @@ #define FFX_PARAMETER_IN #define FFX_PARAMETER_OUT #define FFX_PARAMETER_INOUT +#define FFX_PARAMETER_UNIFORM #elif defined(FFX_HLSL) #define FFX_PARAMETER_IN in #define FFX_PARAMETER_OUT out #define FFX_PARAMETER_INOUT inout +#define FFX_PARAMETER_UNIFORM uniform #elif defined(FFX_GLSL) #define FFX_PARAMETER_IN in #define FFX_PARAMETER_OUT out #define FFX_PARAMETER_INOUT inout +#define FFX_PARAMETER_UNIFORM const //[cacao_placeholder] until a better fit is found! #endif // #if defined(FFX_CPU) #if defined(FFX_CPU) /// A typedef for a boolean value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef bool FfxBoolean; /// A typedef for a unsigned 8bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint8_t FfxUInt8; /// A typedef for a unsigned 16bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint16_t FfxUInt16; /// A typedef for a unsigned 32bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32; /// A typedef for a unsigned 64bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint64_t FfxUInt64; /// A typedef for a signed 8bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int8_t FfxInt8; /// A typedef for a signed 16bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int16_t FfxInt16; /// A typedef for a signed 32bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int32_t FfxInt32; /// A typedef for a signed 64bit integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef int64_t FfxInt64; /// A typedef for a floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32; /// A typedef for a 2-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x2[2]; /// A typedef for a 3-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x3[3]; /// A typedef for a 4-dimensional floating point value. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef float FfxFloat32x4[4]; /// A typedef for a 2-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x2[2]; /// A typedef for a 3-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x3[3]; /// A typedef for a 4-dimensional 32bit unsigned integer. /// -/// @ingroup CPU +/// @ingroup CPUTypes typedef uint32_t FfxUInt32x4[4]; #endif // #if defined(FFX_CPU) #if defined(FFX_HLSL) + +#define FfxFloat32Mat4 matrix +#define FfxFloat32Mat3 matrix + /// A typedef for a boolean value. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef bool FfxBoolean; -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM>=62 + +/// @defgroup HLSL62Types HLSL 6.2 And Above Types +/// HLSL 6.2 and above type defines for all commonly used variables +/// +/// @ingroup HLSLTypes + +/// A typedef for a floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t FfxFloat32; + +/// A typedef for a 2-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t2 FfxFloat32x2; + +/// A typedef for a 3-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t3 FfxFloat32x3; + +/// A typedef for a 4-dimensional floating point value. +/// +/// @ingroup HLSL62Types typedef float32_t4 FfxFloat32x4; +/// A [cacao_placeholder] typedef for matrix type until confirmed. +typedef float4x4 FfxFloat32x4x4; +typedef float3x3 FfxFloat32x3x3; +typedef float2x2 FfxFloat32x2x2; + /// A typedef for a unsigned 32bit integer. /// -/// @ingroup GPU +/// @ingroup HLSL62Types typedef uint32_t FfxUInt32; + +/// A typedef for a 2-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t2 FfxUInt32x2; + +/// A typedef for a 3-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t3 FfxUInt32x3; + +/// A typedef for a 4-dimensional 32bit unsigned integer. +/// +/// @ingroup HLSL62Types typedef uint32_t4 FfxUInt32x4; + +/// A typedef for a signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t FfxInt32; + +/// A typedef for a 2-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t2 FfxInt32x2; + +/// A typedef for a 3-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t3 FfxInt32x3; + +/// A typedef for a 4-dimensional signed 32bit integer. +/// +/// @ingroup HLSL62Types typedef int32_t4 FfxInt32x4; -#else + +#else // #if FFX_HLSL_SM>=62 + +/// @defgroup HLSLBaseTypes HLSL 6.1 And Below Types +/// HLSL 6.1 and below type defines for all commonly used variables +/// +/// @ingroup HLSLTypes + #define FfxFloat32 float #define FfxFloat32x2 float2 #define FfxFloat32x3 float3 #define FfxFloat32x4 float4 +/// A [cacao_placeholder] typedef for matrix type until confirmed. +#define FfxFloat32x4x4 float4x4 +#define FfxFloat32x3x3 float3x3 +#define FfxFloat32x2x2 float2x2 + /// A typedef for a unsigned 32bit integer. /// /// @ingroup GPU @@ -153,14 +228,18 @@ typedef uint FfxUInt32; typedef uint2 FfxUInt32x2; typedef uint3 FfxUInt32x3; typedef uint4 FfxUInt32x4; + typedef int FfxInt32; typedef int2 FfxInt32x2; typedef int3 FfxInt32x3; typedef int4 FfxInt32x4; -#endif // #if defined(FFX_HLSL_6_2) + +#endif // #if FFX_HLSL_SM>=62 #if FFX_HALF -#if FFX_HLSL_6_2 + +#if FFX_HLSL_SM >= 62 + typedef float16_t FfxFloat16; typedef float16_t2 FfxFloat16x2; typedef float16_t3 FfxFloat16x3; @@ -168,7 +247,7 @@ typedef float16_t4 FfxFloat16x4; /// A typedef for an unsigned 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef uint16_t FfxUInt16; typedef uint16_t2 FfxUInt16x2; typedef uint16_t3 FfxUInt16x3; @@ -176,7 +255,7 @@ typedef uint16_t4 FfxUInt16x4; /// A typedef for a signed 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef int16_t FfxInt16; typedef int16_t2 FfxInt16x2; typedef int16_t3 FfxInt16x3; @@ -204,7 +283,7 @@ typedef short FfxInt16; typedef short2 FfxInt16x2; typedef short3 FfxInt16x3; typedef short4 FfxInt16x4; -#else +#else // #if FFX_HLSL_SM>=62 typedef min16float FfxFloat16; typedef min16float2 FfxFloat16x2; typedef min16float3 FfxFloat16x3; @@ -212,7 +291,7 @@ typedef min16float4 FfxFloat16x4; /// A typedef for an unsigned 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef min16uint FfxUInt16; typedef min16uint2 FfxUInt16x2; typedef min16uint3 FfxUInt16x3; @@ -220,19 +299,25 @@ typedef min16uint4 FfxUInt16x4; /// A typedef for a signed 16bit integer. /// -/// @ingroup GPU +/// @ingroup HLSLTypes typedef min16int FfxInt16; typedef min16int2 FfxInt16x2; typedef min16int3 FfxInt16x3; typedef min16int4 FfxInt16x4; -#endif // FFX_HLSL_6_2 +#endif // #if FFX_HLSL_SM>=62 + #endif // FFX_HALF + #endif // #if defined(FFX_HLSL) #if defined(FFX_GLSL) + +#define FfxFloat32Mat4 mat4 +#define FfxFloat32Mat3 mat3 + /// A typedef for a boolean value. /// -/// @ingroup GPU +/// @ingroup GLSLTypes #define FfxBoolean bool #define FfxFloat32 float #define FfxFloat32x2 vec2 @@ -246,6 +331,12 @@ typedef min16int4 FfxInt16x4; #define FfxInt32x2 ivec2 #define FfxInt32x3 ivec3 #define FfxInt32x4 ivec4 + +/// A [cacao_placeholder] typedef for matrix type until confirmed. +#define FfxFloat32x4x4 mat4 +#define FfxFloat32x3x3 mat3 +#define FfxFloat32x2x2 mat2 + #if FFX_HALF #define FfxFloat16 float16_t #define FfxFloat16x2 f16vec2 @@ -264,11 +355,11 @@ typedef min16int4 FfxInt16x4; // Global toggles: // #define FFX_HALF (1) -// #define FFX_HLSL_6_2 (1) +// #define FFX_HLSL_SM (62) -#if defined(FFX_HALF) && !defined(SHADER_API_PSSL) +#if FFX_HALF && !defined(SHADER_API_PSSL) -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM >= 62 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName; #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; @@ -278,7 +369,7 @@ typedef min16int4 FfxInt16x4; #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix TypeName; -#else //FFX_HLSL_6_2 +#else //FFX_HLSL_SM>=62 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef min16##BaseComponentType TypeName; #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector TypeName; @@ -288,7 +379,7 @@ typedef min16int4 FfxInt16x4; #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ); #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ); -#endif //FFX_HLSL_6_2 +#endif //FFX_HLSL_SM>=62 #else //FFX_HALF diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta new file mode 100644 index 0000000..8d9b15f --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_common_types.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 7974b728d5c1b6d4a8a8e3965d03f96d +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_core.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h similarity index 66% rename from Assets/Resources/FSR2/shaders/ffx_core.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h index 4e687d6..02f6b3f 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,17 +19,40 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -/// @defgroup Core -/// @defgroup HLSL -/// @defgroup GLSL -/// @defgroup GPU -/// @defgroup CPU -/// @defgroup CAS -/// @defgroup FSR1 + +/// @defgroup FfxGPU GPU +/// The FidelityFX SDK GPU References +/// +/// @ingroup ffxSDK + +/// @defgroup FfxHLSL HLSL References +/// FidelityFX SDK HLSL GPU References +/// +/// @ingroup FfxGPU + +/// @defgroup FfxGLSL GLSL References +/// FidelityFX SDK GLSL GPU References +/// +/// @ingroup FfxGPU + +/// @defgroup FfxGPUEffects FidelityFX GPU References +/// FidelityFX Effect GPU Reference Documentation +/// +/// @ingroup FfxGPU + +/// @defgroup GPUCore GPU Core +/// GPU defines and functions +/// +/// @ingroup FfxGPU #if !defined(FFX_CORE_H) #define FFX_CORE_H +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic push +#pragma dxc diagnostic ignored "-Wambig-lit-shift" +#endif //__hlsl_dx_compiler + #include "ffx_common_types.h" #if defined(FFX_CPU) @@ -49,4 +72,9 @@ #include "ffx_core_gpu_common_half.h" #include "ffx_core_portability.h" #endif // #if defined(FFX_GPU) -#endif // #if !defined(FFX_CORE_H) \ No newline at end of file + +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic pop +#endif //__hlsl_dx_compiler + +#endif // #if !defined(FFX_CORE_H) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta new file mode 100644 index 0000000..562741a --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: b91c5f52b89ff554dacb51045a802ed8 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h similarity index 93% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h index 3bf0295..865258d 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_cpu.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,23 +19,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + /// A define for a true value in a boolean expression. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_TRUE (1) /// A define for a false value in a boolean expression. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_FALSE (0) #if !defined(FFX_STATIC) /// A define to abstract declaration of static variables and functions. /// -/// @ingroup CPU +/// @ingroup CPUTypes #define FFX_STATIC static #endif // #if !defined(FFX_STATIC) +/// @defgroup CPUCore CPU Core +/// Core CPU-side defines and functions +/// +/// @ingroup ffxHost + #ifdef __clang__ #pragma clang diagnostic ignored "-Wunused-variable" #endif @@ -47,7 +53,7 @@ /// @returns /// An unsigned 32bit integer value containing the bit pattern of x. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxUInt32 ffxAsUInt32(FfxFloat32 x) { union @@ -89,7 +95,7 @@ FFX_STATIC FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) { return y * t + (-x * t + x); @@ -102,10 +108,10 @@ FFX_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) /// @returns /// The reciprocal value of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 x) { - return 1.0f / a; + return 1.0f / x; } /// Compute the square root of a value. @@ -115,7 +121,7 @@ FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 a) /// @returns /// The the square root of x. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxFloat32 ffxSqrt(FfxFloat32 x) { return sqrt(x); @@ -135,10 +141,10 @@ FFX_STATIC FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b) /// @returns /// The fractional part of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 x) { - return a - floor(a); + return x - floor(x); } /// Compute the reciprocal square root of a value. @@ -148,10 +154,10 @@ FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 a) /// @returns /// The reciprocal square root value of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 rsqrt(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 rsqrt(FfxFloat32 x) { - return ffxReciprocal(ffxSqrt(a)); + return ffxReciprocal(ffxSqrt(x)); } FFX_STATIC FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) @@ -181,10 +187,10 @@ FFX_STATIC FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) /// @returns /// The clamped version of x. /// -/// @ingroup CPU -FFX_STATIC FfxFloat32 ffxSaturate(FfxFloat32 a) +/// @ingroup CPUCore +FFX_STATIC FfxFloat32 ffxSaturate(FfxFloat32 x) { - return ffxMin(1.0f, ffxMax(0.0f, a)); + return ffxMin(1.0f, ffxMax(0.0f, x)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -245,7 +251,7 @@ FFX_STATIC void opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a) /// @returns /// The closest 16bit floating point value to f. /// -/// @ingroup CPU +/// @ingroup CPUCore FFX_STATIC FfxUInt32 f32tof16(FfxFloat32 f) { static FfxUInt16 base[512] = { @@ -320,13 +326,13 @@ FFX_STATIC FfxUInt32 f32tof16(FfxFloat32 f) /// point representation, and then stores the X and Y components in the lower and upper 16 bits of the /// 32bit unsigned integer respectively. /// -/// @param [in] value A 2-dimensional floating point value to convert and pack. +/// @param [in] x A 2-dimensional floating point value to convert and pack. /// /// @returns /// A packed 32bit value containing 2 16bit floating point values. /// -/// @ingroup CPU -FFX_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 a) +/// @ingroup CPUCore +FFX_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 x) { - return f32tof16(a[0]) + (f32tof16(a[1]) << 16); + return f32tof16(x[0]) + (f32tof16(x[1]) << 16); } diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta new file mode 100644 index 0000000..9aed874 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_cpu.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 4c88c0b7a4dec1e479272449c19ca981 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h similarity index 91% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h index ae07642..2f687df 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,31 +19,35 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + /// A define for a true value in a boolean expression. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_TRUE (true) /// A define for a false value in a boolean expression. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_FALSE (false) /// A define value for positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_FLOAT ffxAsFloat(0x7f800000u) /// A define value for negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_FLOAT ffxAsFloat(0xff800000u) /// A define value for PI. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_PI (3.14159) +FFX_STATIC const FfxFloat32 FFX_FP16_MIN = 6.10e-05f; +FFX_STATIC const FfxFloat32 FFX_FP16_MAX = 65504.0f; +FFX_STATIC const FfxFloat32 FFX_TONEMAP_EPSILON = 1.0f / FFX_FP16_MAX; /// Compute the reciprocal of value. /// @@ -52,7 +56,7 @@ /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxReciprocal(FfxFloat32 value) { return rcp(value); @@ -65,7 +69,7 @@ FfxFloat32 ffxReciprocal(FfxFloat32 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxReciprocal(FfxFloat32x2 value) { return rcp(value); @@ -78,7 +82,7 @@ FfxFloat32x2 ffxReciprocal(FfxFloat32x2 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxReciprocal(FfxFloat32x3 value) { return rcp(value); @@ -91,7 +95,7 @@ FfxFloat32x3 ffxReciprocal(FfxFloat32x3 value) /// @returns /// The 1 / value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxReciprocal(FfxFloat32x4 value) { return rcp(value); @@ -105,7 +109,7 @@ FfxFloat32x4 ffxReciprocal(FfxFloat32x4 value) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) { return min(x, y); @@ -119,7 +123,7 @@ FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxMin(FfxFloat32x2 x, FfxFloat32x2 y) { return min(x, y); @@ -133,7 +137,7 @@ FfxFloat32x2 ffxMin(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxMin(FfxFloat32x3 x, FfxFloat32x3 y) { return min(x, y); @@ -147,7 +151,7 @@ FfxFloat32x3 ffxMin(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxMin(FfxFloat32x4 x, FfxFloat32x4 y) { return min(x, y); @@ -161,7 +165,7 @@ FfxFloat32x4 ffxMin(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32 ffxMin(FfxInt32 x, FfxInt32 y) { return min(x, y); @@ -175,7 +179,7 @@ FfxInt32 ffxMin(FfxInt32 x, FfxInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x2 ffxMin(FfxInt32x2 x, FfxInt32x2 y) { return min(x, y); @@ -189,7 +193,7 @@ FfxInt32x2 ffxMin(FfxInt32x2 x, FfxInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x3 ffxMin(FfxInt32x3 x, FfxInt32x3 y) { return min(x, y); @@ -203,7 +207,7 @@ FfxInt32x3 ffxMin(FfxInt32x3 x, FfxInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x4 ffxMin(FfxInt32x4 x, FfxInt32x4 y) { return min(x, y); @@ -217,7 +221,7 @@ FfxInt32x4 ffxMin(FfxInt32x4 x, FfxInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y) { return min(x, y); @@ -231,7 +235,7 @@ FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxMin(FfxUInt32x2 x, FfxUInt32x2 y) { return min(x, y); @@ -245,7 +249,7 @@ FfxUInt32x2 ffxMin(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxMin(FfxUInt32x3 x, FfxUInt32x3 y) { return min(x, y); @@ -259,7 +263,7 @@ FfxUInt32x3 ffxMin(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxMin(FfxUInt32x4 x, FfxUInt32x4 y) { return min(x, y); @@ -273,7 +277,7 @@ FfxUInt32x4 ffxMin(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y) { return max(x, y); @@ -287,7 +291,7 @@ FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxMax(FfxFloat32x2 x, FfxFloat32x2 y) { return max(x, y); @@ -301,7 +305,7 @@ FfxFloat32x2 ffxMax(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxMax(FfxFloat32x3 x, FfxFloat32x3 y) { return max(x, y); @@ -315,7 +319,7 @@ FfxFloat32x3 ffxMax(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxMax(FfxFloat32x4 x, FfxFloat32x4 y) { return max(x, y); @@ -329,7 +333,7 @@ FfxFloat32x4 ffxMax(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32 ffxMax(FfxInt32 x, FfxInt32 y) { return max(x, y); @@ -343,7 +347,7 @@ FfxInt32 ffxMax(FfxInt32 x, FfxInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x2 ffxMax(FfxInt32x2 x, FfxInt32x2 y) { return max(x, y); @@ -357,7 +361,7 @@ FfxInt32x2 ffxMax(FfxInt32x2 x, FfxInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x3 ffxMax(FfxInt32x3 x, FfxInt32x3 y) { return max(x, y); @@ -371,7 +375,7 @@ FfxInt32x3 ffxMax(FfxInt32x3 x, FfxInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt32x4 ffxMax(FfxInt32x4 x, FfxInt32x4 y) { return max(x, y); @@ -385,7 +389,7 @@ FfxInt32x4 ffxMax(FfxInt32x4 x, FfxInt32x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) { return max(x, y); @@ -399,7 +403,7 @@ FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxMax(FfxUInt32x2 x, FfxUInt32x2 y) { return max(x, y); @@ -413,7 +417,7 @@ FfxUInt32x2 ffxMax(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxMax(FfxUInt32x3 x, FfxUInt32x3 y) { return max(x, y); @@ -427,7 +431,7 @@ FfxUInt32x3 ffxMax(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxMax(FfxUInt32x4 x, FfxUInt32x4 y) { return max(x, y); @@ -441,7 +445,7 @@ FfxUInt32x4 ffxMax(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxPow(FfxFloat32 x, FfxFloat32 y) { return pow(x, y); @@ -455,7 +459,7 @@ FfxFloat32 ffxPow(FfxFloat32 x, FfxFloat32 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxPow(FfxFloat32x2 x, FfxFloat32x2 y) { return pow(x, y); @@ -469,7 +473,7 @@ FfxFloat32x2 ffxPow(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxPow(FfxFloat32x3 x, FfxFloat32x3 y) { return pow(x, y); @@ -483,7 +487,7 @@ FfxFloat32x3 ffxPow(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxPow(FfxFloat32x4 x, FfxFloat32x4 y) { return pow(x, y); @@ -496,7 +500,7 @@ FfxFloat32x4 ffxPow(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxSqrt(FfxFloat32 x) { return sqrt(x); @@ -509,7 +513,7 @@ FfxFloat32 ffxSqrt(FfxFloat32 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxSqrt(FfxFloat32x2 x) { return sqrt(x); @@ -522,7 +526,7 @@ FfxFloat32x2 ffxSqrt(FfxFloat32x2 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxSqrt(FfxFloat32x3 x) { return sqrt(x); @@ -535,7 +539,7 @@ FfxFloat32x3 ffxSqrt(FfxFloat32x3 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxSqrt(FfxFloat32x4 x) { return sqrt(x); @@ -549,7 +553,7 @@ FfxFloat32x4 ffxSqrt(FfxFloat32x4 x) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxCopySignBit(FfxFloat32 d, FfxFloat32 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & FfxUInt32(0x80000000u))); @@ -563,7 +567,7 @@ FfxFloat32 ffxCopySignBit(FfxFloat32 d, FfxFloat32 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxCopySignBit(FfxFloat32x2 d, FfxFloat32x2 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast2(0x80000000u))); @@ -577,7 +581,7 @@ FfxFloat32x2 ffxCopySignBit(FfxFloat32x2 d, FfxFloat32x2 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxCopySignBit(FfxFloat32x3 d, FfxFloat32x3 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast3(0x80000000u))); @@ -591,7 +595,7 @@ FfxFloat32x3 ffxCopySignBit(FfxFloat32x3 d, FfxFloat32x3 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxCopySignBit(FfxFloat32x4 d, FfxFloat32x4 s) { return ffxAsFloat(ffxAsUInt32(d) | (ffxAsUInt32(s) & ffxBroadcast4(0x80000000u))); @@ -614,7 +618,7 @@ FfxFloat32x4 ffxCopySignBit(FfxFloat32x4 d, FfxFloat32x4 s) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxIsSigned(FfxFloat32 m) { return ffxSaturate(m * FfxFloat32(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -637,7 +641,7 @@ FfxFloat32 ffxIsSigned(FfxFloat32 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxIsSigned(FfxFloat32x2 m) { return ffxSaturate(m * ffxBroadcast2(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -660,7 +664,7 @@ FfxFloat32x2 ffxIsSigned(FfxFloat32x2 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxIsSigned(FfxFloat32x3 m) { return ffxSaturate(m * ffxBroadcast3(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -683,7 +687,7 @@ FfxFloat32x3 ffxIsSigned(FfxFloat32x3 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or positive. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxIsSigned(FfxFloat32x4 m) { return ffxSaturate(m * ffxBroadcast4(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -701,7 +705,7 @@ FfxFloat32x4 ffxIsSigned(FfxFloat32x4 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxIsGreaterThanZero(FfxFloat32 m) { return ffxSaturate(m * FfxFloat32(FFX_POSITIVE_INFINITY_FLOAT)); @@ -719,7 +723,7 @@ FfxFloat32 ffxIsGreaterThanZero(FfxFloat32 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxIsGreaterThanZero(FfxFloat32x2 m) { return ffxSaturate(m * ffxBroadcast2(FFX_POSITIVE_INFINITY_FLOAT)); @@ -737,7 +741,7 @@ FfxFloat32x2 ffxIsGreaterThanZero(FfxFloat32x2 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxIsGreaterThanZero(FfxFloat32x3 m) { return ffxSaturate(m * ffxBroadcast3(FFX_POSITIVE_INFINITY_FLOAT)); @@ -755,7 +759,7 @@ FfxFloat32x3 ffxIsGreaterThanZero(FfxFloat32x3 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxIsGreaterThanZero(FfxFloat32x4 m) { return ffxSaturate(m * ffxBroadcast4(FFX_POSITIVE_INFINITY_FLOAT)); @@ -775,7 +779,7 @@ FfxFloat32x4 ffxIsGreaterThanZero(FfxFloat32x4 m) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxFloatToSortableInteger(FfxUInt32 value) { return value ^ ((AShrSU1(value, FfxUInt32(31))) | FfxUInt32(0x80000000)); @@ -792,7 +796,7 @@ FfxUInt32 ffxFloatToSortableInteger(FfxUInt32 value) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxSortableIntegerToFloat(FfxUInt32 value) { return value ^ ((~AShrSU1(value, FfxUInt32(31))) | FfxUInt32(0x80000000)); @@ -811,10 +815,10 @@ FfxUInt32 ffxSortableIntegerToFloat(FfxUInt32 value) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateSqrt(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateSqrt(FfxFloat32 value) { - return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(1)) + FfxUInt32(0x1fbc4639)); + return ffxAsFloat((ffxAsUInt32(value) >> FfxUInt32(1)) + FfxUInt32(0x1fbc4639)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -830,10 +834,10 @@ FfxFloat32 ffxApproximateSqrt(FfxFloat32 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateReciprocal(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateReciprocal(FfxFloat32 value) { - return ffxAsFloat(FfxUInt32(0x7ef07ebb) - ffxAsUInt32(a)); + return ffxAsFloat(FfxUInt32(0x7ef07ebb) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -849,7 +853,7 @@ FfxFloat32 ffxApproximateReciprocal(FfxFloat32 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateReciprocalMedium(FfxFloat32 value) { FfxFloat32 b = ffxAsFloat(FfxUInt32(0x7ef19fff) - ffxAsUInt32(value)); @@ -869,10 +873,10 @@ FfxFloat32 ffxApproximateReciprocalMedium(FfxFloat32 value) /// @returns /// An approximation of the reciprocal square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 a) +/// @ingroup GPUCore +FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 value) { - return ffxAsFloat(FfxUInt32(0x5f347d74) - (ffxAsUInt32(a) >> FfxUInt32(1))); + return ffxAsFloat(FfxUInt32(0x5f347d74) - (ffxAsUInt32(value) >> FfxUInt32(1))); } /// Calculate a low-quality approximation for the square root of a value. @@ -888,10 +892,10 @@ FfxFloat32 ffxApproximateReciprocalSquareRoot(FfxFloat32 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(1u)) + ffxBroadcast2(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast2(1u)) + ffxBroadcast2(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -907,10 +911,10 @@ FfxFloat32x2 ffxApproximateSqrt(FfxFloat32x2 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 value) { - return ffxAsFloat(ffxBroadcast2(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast2(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -926,11 +930,11 @@ FfxFloat32x2 ffxApproximateReciprocal(FfxFloat32x2 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 value) { - FfxFloat32x2 b = ffxAsFloat(ffxBroadcast2(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast2(2.0f)); + FfxFloat32x2 b = ffxAsFloat(ffxBroadcast2(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast2(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -946,10 +950,10 @@ FfxFloat32x2 ffxApproximateReciprocalMedium(FfxFloat32x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 a) +/// @ingroup GPUCore +FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 value) { - return ffxAsFloat(ffxBroadcast2(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast2(1u))); + return ffxAsFloat(ffxBroadcast2(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast2(1u))); } /// Calculate a low-quality approximation for the square root of a value. @@ -965,10 +969,10 @@ FfxFloat32x2 ffxApproximateReciprocalSquareRoot(FfxFloat32x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(1u)) + ffxBroadcast3(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast3(1u)) + ffxBroadcast3(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -984,10 +988,10 @@ FfxFloat32x3 ffxApproximateSqrt(FfxFloat32x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 value) { - return ffxAsFloat(ffxBroadcast3(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast3(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -1003,11 +1007,11 @@ FfxFloat32x3 ffxApproximateReciprocal(FfxFloat32x3 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 value) { - FfxFloat32x3 b = ffxAsFloat(ffxBroadcast3(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast3(2.0f)); + FfxFloat32x3 b = ffxAsFloat(ffxBroadcast3(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast3(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -1023,10 +1027,10 @@ FfxFloat32x3 ffxApproximateReciprocalMedium(FfxFloat32x3 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 a) +/// @ingroup GPUCore +FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 value) { - return ffxAsFloat(ffxBroadcast3(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast3(1u))); + return ffxAsFloat(ffxBroadcast3(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast3(1u))); } /// Calculate a low-quality approximation for the square root of a value. @@ -1042,10 +1046,10 @@ FfxFloat32x3 ffxApproximateReciprocalSquareRoot(FfxFloat32x3 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 value) { - return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(1u)) + ffxBroadcast4(0x1fbc4639u)); + return ffxAsFloat((ffxAsUInt32(value) >> ffxBroadcast4(1u)) + ffxBroadcast4(0x1fbc4639u)); } /// Calculate a low-quality approximation for the reciprocal of a value. @@ -1061,10 +1065,10 @@ FfxFloat32x4 ffxApproximateSqrt(FfxFloat32x4 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 value) { - return ffxAsFloat(ffxBroadcast4(0x7ef07ebbu) - ffxAsUInt32(a)); + return ffxAsFloat(ffxBroadcast4(0x7ef07ebbu) - ffxAsUInt32(value)); } /// Calculate a medium-quality approximation for the reciprocal of a value. @@ -1080,11 +1084,11 @@ FfxFloat32x4 ffxApproximateReciprocal(FfxFloat32x4 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 value) { - FfxFloat32x4 b = ffxAsFloat(ffxBroadcast4(0x7ef19fffu) - ffxAsUInt32(a)); - return b * (-b * a + ffxBroadcast4(2.0f)); + FfxFloat32x4 b = ffxAsFloat(ffxBroadcast4(0x7ef19fffu) - ffxAsUInt32(value)); + return b * (-b * value + ffxBroadcast4(2.0f)); } /// Calculate a low-quality approximation for the square root of a value. @@ -1100,10 +1104,10 @@ FfxFloat32x4 ffxApproximateReciprocalMedium(FfxFloat32x4 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU -FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 a) +/// @ingroup GPUCore +FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 value) { - return ffxAsFloat(ffxBroadcast4(0x5f347d74u) - (ffxAsUInt32(a) >> ffxBroadcast4(1u))); + return ffxAsFloat(ffxBroadcast4(0x5f347d74u) - (ffxAsUInt32(value) >> ffxBroadcast4(1u))); } /// Calculate dot product of 'a' and 'b'. @@ -1114,7 +1118,7 @@ FfxFloat32x4 ffxApproximateReciprocalSquareRoot(FfxFloat32x4 a) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b) { return dot(a, b); @@ -1128,7 +1132,7 @@ FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b) { return dot(a, b); @@ -1142,7 +1146,7 @@ FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b) /// @returns /// The value of a dot b. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) { return dot(a, b); @@ -1160,7 +1164,7 @@ FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximatePQToGamma2Medium(FfxFloat32 a) { return a * a * a * a; @@ -1177,7 +1181,7 @@ FfxFloat32 ffxApproximatePQToGamma2Medium(FfxFloat32 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximatePQToLinear(FfxFloat32 a) { return a * a * a * a * a * a * a * a; @@ -1194,7 +1198,7 @@ FfxFloat32 ffxApproximatePQToLinear(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQ(FfxFloat32 a) { return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(2)) + FfxUInt32(0x2F9A4E46)); @@ -1211,7 +1215,7 @@ FfxFloat32 ffxApproximateGamma2ToPQ(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQMedium(FfxFloat32 a) { FfxFloat32 b = ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(2)) + FfxUInt32(0x2F9A4E46)); @@ -1230,7 +1234,7 @@ FfxFloat32 ffxApproximateGamma2ToPQMedium(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateGamma2ToPQHigh(FfxFloat32 a) { return ffxSqrt(ffxSqrt(a)); @@ -1247,7 +1251,7 @@ FfxFloat32 ffxApproximateGamma2ToPQHigh(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQ(FfxFloat32 a) { return ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(3)) + FfxUInt32(0x378D8723)); @@ -1264,7 +1268,7 @@ FfxFloat32 ffxApproximateLinearToPQ(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQMedium(FfxFloat32 a) { FfxFloat32 b = ffxAsFloat((ffxAsUInt32(a) >> FfxUInt32(3)) + FfxUInt32(0x378D8723)); @@ -1283,7 +1287,7 @@ FfxFloat32 ffxApproximateLinearToPQMedium(FfxFloat32 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxApproximateLinearToPQHigh(FfxFloat32 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1300,7 +1304,7 @@ FfxFloat32 ffxApproximateLinearToPQHigh(FfxFloat32 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximatePQToGamma2Medium(FfxFloat32x2 a) { return a * a * a * a; @@ -1317,7 +1321,7 @@ FfxFloat32x2 ffxApproximatePQToGamma2Medium(FfxFloat32x2 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximatePQToLinear(FfxFloat32x2 a) { return a * a * a * a * a * a * a * a; @@ -1334,7 +1338,7 @@ FfxFloat32x2 ffxApproximatePQToLinear(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQ(FfxFloat32x2 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(2u)) + ffxBroadcast2(0x2F9A4E46u)); @@ -1351,7 +1355,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQ(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQMedium(FfxFloat32x2 a) { FfxFloat32x2 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(2u)) + ffxBroadcast2(0x2F9A4E46u)); @@ -1370,7 +1374,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQMedium(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateGamma2ToPQHigh(FfxFloat32x2 a) { return ffxSqrt(ffxSqrt(a)); @@ -1387,7 +1391,7 @@ FfxFloat32x2 ffxApproximateGamma2ToPQHigh(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQ(FfxFloat32x2 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(3u)) + ffxBroadcast2(0x378D8723u)); @@ -1404,7 +1408,7 @@ FfxFloat32x2 ffxApproximateLinearToPQ(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQMedium(FfxFloat32x2 a) { FfxFloat32x2 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast2(3u)) + ffxBroadcast2(0x378D8723u)); @@ -1423,7 +1427,7 @@ FfxFloat32x2 ffxApproximateLinearToPQMedium(FfxFloat32x2 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxApproximateLinearToPQHigh(FfxFloat32x2 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1440,7 +1444,7 @@ FfxFloat32x2 ffxApproximateLinearToPQHigh(FfxFloat32x2 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximatePQToGamma2Medium(FfxFloat32x3 a) { return a * a * a * a; @@ -1457,7 +1461,7 @@ FfxFloat32x3 ffxApproximatePQToGamma2Medium(FfxFloat32x3 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximatePQToLinear(FfxFloat32x3 a) { return a * a * a * a * a * a * a * a; @@ -1474,7 +1478,7 @@ FfxFloat32x3 ffxApproximatePQToLinear(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQ(FfxFloat32x3 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(2u)) + ffxBroadcast3(0x2F9A4E46u)); @@ -1491,7 +1495,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQ(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQMedium(FfxFloat32x3 a) { FfxFloat32x3 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(2u)) + ffxBroadcast3(0x2F9A4E46u)); @@ -1510,7 +1514,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQMedium(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateGamma2ToPQHigh(FfxFloat32x3 a) { return ffxSqrt(ffxSqrt(a)); @@ -1527,7 +1531,7 @@ FfxFloat32x3 ffxApproximateGamma2ToPQHigh(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQ(FfxFloat32x3 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(3u)) + ffxBroadcast3(0x378D8723u)); @@ -1544,7 +1548,7 @@ FfxFloat32x3 ffxApproximateLinearToPQ(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQMedium(FfxFloat32x3 a) { FfxFloat32x3 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast3(3u)) + ffxBroadcast3(0x378D8723u)); @@ -1563,7 +1567,7 @@ FfxFloat32x3 ffxApproximateLinearToPQMedium(FfxFloat32x3 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxApproximateLinearToPQHigh(FfxFloat32x3 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1580,7 +1584,7 @@ FfxFloat32x3 ffxApproximateLinearToPQHigh(FfxFloat32x3 a) /// @returns /// The value a converted into Gamma2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximatePQToGamma2Medium(FfxFloat32x4 a) { return a * a * a * a; @@ -1597,7 +1601,7 @@ FfxFloat32x4 ffxApproximatePQToGamma2Medium(FfxFloat32x4 a) /// @returns /// The value a converted into linear. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximatePQToLinear(FfxFloat32x4 a) { return a * a * a * a * a * a * a * a; @@ -1614,7 +1618,7 @@ FfxFloat32x4 ffxApproximatePQToLinear(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQ(FfxFloat32x4 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(2u)) + ffxBroadcast4(0x2F9A4E46u)); @@ -1631,7 +1635,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQ(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQMedium(FfxFloat32x4 a) { FfxFloat32x4 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(2u)) + ffxBroadcast4(0x2F9A4E46u)); @@ -1650,7 +1654,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQMedium(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateGamma2ToPQHigh(FfxFloat32x4 a) { return ffxSqrt(ffxSqrt(a)); @@ -1667,7 +1671,7 @@ FfxFloat32x4 ffxApproximateGamma2ToPQHigh(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQ(FfxFloat32x4 a) { return ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(3u)) + ffxBroadcast4(0x378D8723u)); @@ -1684,7 +1688,7 @@ FfxFloat32x4 ffxApproximateLinearToPQ(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQMedium(FfxFloat32x4 a) { FfxFloat32x4 b = ffxAsFloat((ffxAsUInt32(a) >> ffxBroadcast4(3u)) + ffxBroadcast4(0x378D8723u)); @@ -1703,7 +1707,7 @@ FfxFloat32x4 ffxApproximateLinearToPQMedium(FfxFloat32x4 a) /// @returns /// The value a converted into PQ. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxApproximateLinearToPQHigh(FfxFloat32x4 a) { return ffxSqrt(ffxSqrt(ffxSqrt(a))); @@ -1793,7 +1797,7 @@ FfxFloat32x2 ffxParabolicSinCos(FfxFloat32 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAnd(FfxUInt32 x, FfxUInt32 y) { return min(x, y); @@ -1807,7 +1811,7 @@ FfxUInt32 ffxZeroOneAnd(FfxUInt32 x, FfxUInt32 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x, FfxUInt32x2 y) { return min(x, y); @@ -1821,7 +1825,7 @@ FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x, FfxUInt32x3 y) { return min(x, y); @@ -1835,7 +1839,7 @@ FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x, FfxUInt32x4 y) { return min(x, y); @@ -1844,12 +1848,11 @@ FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x, FfxUInt32x4 y) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAnd(FfxUInt32 x) { return x ^ FfxUInt32(1); @@ -1858,12 +1861,11 @@ FfxUInt32 ffxZeroOneAnd(FfxUInt32 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x) { return x ^ ffxBroadcast2(1u); @@ -1872,12 +1874,11 @@ FfxUInt32x2 ffxZeroOneAnd(FfxUInt32x2 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x) { return x ^ ffxBroadcast3(1u); @@ -1886,12 +1887,11 @@ FfxUInt32x3 ffxZeroOneAnd(FfxUInt32x3 x) /// Conditional free logic NOT operation using two values. /// /// @param [in] x The first value to be fed into the NOT operator. -/// @param [in] y The second value to be fed into the NOT operator. /// /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x) { return x ^ ffxBroadcast4(1u); @@ -1905,7 +1905,7 @@ FfxUInt32x4 ffxZeroOneAnd(FfxUInt32x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneOr(FfxUInt32 x, FfxUInt32 y) { return max(x, y); @@ -1919,7 +1919,7 @@ FfxUInt32 ffxZeroOneOr(FfxUInt32 x, FfxUInt32 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneOr(FfxUInt32x2 x, FfxUInt32x2 y) { return max(x, y); @@ -1933,7 +1933,7 @@ FfxUInt32x2 ffxZeroOneOr(FfxUInt32x2 x, FfxUInt32x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneOr(FfxUInt32x3 x, FfxUInt32x3 y) { return max(x, y); @@ -1947,7 +1947,7 @@ FfxUInt32x3 ffxZeroOneOr(FfxUInt32x3 x, FfxUInt32x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneOr(FfxUInt32x4 x, FfxUInt32x4 y) { return max(x, y); @@ -1960,7 +1960,7 @@ FfxUInt32x4 ffxZeroOneOr(FfxUInt32x4 x, FfxUInt32x4 y) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxZeroOneAndToU1(FfxFloat32 x) { return FfxUInt32(FfxFloat32(1.0) - x); @@ -1973,7 +1973,7 @@ FfxUInt32 ffxZeroOneAndToU1(FfxFloat32 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxZeroOneAndToU2(FfxFloat32x2 x) { return FfxUInt32x2(ffxBroadcast2(1.0) - x); @@ -1986,7 +1986,7 @@ FfxUInt32x2 ffxZeroOneAndToU2(FfxFloat32x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x3 ffxZeroOneAndToU3(FfxFloat32x3 x) { return FfxUInt32x3(ffxBroadcast3(1.0) - x); @@ -1999,7 +1999,7 @@ FfxUInt32x3 ffxZeroOneAndToU3(FfxFloat32x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x4 ffxZeroOneAndToU4(FfxFloat32x4 x) { return FfxUInt32x4(ffxBroadcast4(1.0) - x); @@ -2015,7 +2015,7 @@ FfxUInt32x4 ffxZeroOneAndToU4(FfxFloat32x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneAndOr(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return ffxSaturate(x * y + z); @@ -2031,7 +2031,7 @@ FfxFloat32 ffxZeroOneAndOr(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneAndOr(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return ffxSaturate(x * y + z); @@ -2047,7 +2047,7 @@ FfxFloat32x2 ffxZeroOneAndOr(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneAndOr(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return ffxSaturate(x * y + z); @@ -2063,7 +2063,7 @@ FfxFloat32x3 ffxZeroOneAndOr(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneAndOr(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return ffxSaturate(x * y + z); @@ -2076,7 +2076,7 @@ FfxFloat32x4 ffxZeroOneAndOr(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneIsGreaterThanZero(FfxFloat32 x) { return ffxSaturate(x * FfxFloat32(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2089,7 +2089,7 @@ FfxFloat32 ffxZeroOneIsGreaterThanZero(FfxFloat32 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneIsGreaterThanZero(FfxFloat32x2 x) { return ffxSaturate(x * ffxBroadcast2(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2102,7 +2102,7 @@ FfxFloat32x2 ffxZeroOneIsGreaterThanZero(FfxFloat32x2 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneIsGreaterThanZero(FfxFloat32x3 x) { return ffxSaturate(x * ffxBroadcast3(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2115,7 +2115,7 @@ FfxFloat32x3 ffxZeroOneIsGreaterThanZero(FfxFloat32x3 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneIsGreaterThanZero(FfxFloat32x4 x) { return ffxSaturate(x * ffxBroadcast4(FFX_POSITIVE_INFINITY_FLOAT)); @@ -2128,7 +2128,7 @@ FfxFloat32x4 ffxZeroOneIsGreaterThanZero(FfxFloat32x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneAnd(FfxFloat32 x) { return FfxFloat32(1.0) - x; @@ -2141,7 +2141,7 @@ FfxFloat32 ffxZeroOneAnd(FfxFloat32 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneAnd(FfxFloat32x2 x) { return ffxBroadcast2(1.0) - x; @@ -2154,7 +2154,7 @@ FfxFloat32x2 ffxZeroOneAnd(FfxFloat32x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneAnd(FfxFloat32x3 x) { return ffxBroadcast3(1.0) - x; @@ -2167,7 +2167,7 @@ FfxFloat32x3 ffxZeroOneAnd(FfxFloat32x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneAnd(FfxFloat32x4 x) { return ffxBroadcast4(1.0) - x; @@ -2181,7 +2181,7 @@ FfxFloat32x4 ffxZeroOneAnd(FfxFloat32x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneOr(FfxFloat32 x, FfxFloat32 y) { return max(x, y); @@ -2195,7 +2195,7 @@ FfxFloat32 ffxZeroOneOr(FfxFloat32 x, FfxFloat32 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneOr(FfxFloat32x2 x, FfxFloat32x2 y) { return max(x, y); @@ -2209,7 +2209,7 @@ FfxFloat32x2 ffxZeroOneOr(FfxFloat32x2 x, FfxFloat32x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneOr(FfxFloat32x3 x, FfxFloat32x3 y) { return max(x, y); @@ -2223,7 +2223,7 @@ FfxFloat32x3 ffxZeroOneOr(FfxFloat32x3 x, FfxFloat32x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneOr(FfxFloat32x4 x, FfxFloat32x4 y) { return max(x, y); @@ -2238,7 +2238,7 @@ FfxFloat32x4 ffxZeroOneOr(FfxFloat32x4 x, FfxFloat32x4 y) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneSelect(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { FfxFloat32 r = (-x) * z + z; @@ -2254,7 +2254,7 @@ FfxFloat32 ffxZeroOneSelect(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneSelect(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { FfxFloat32x2 r = (-x) * z + z; @@ -2270,7 +2270,7 @@ FfxFloat32x2 ffxZeroOneSelect(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneSelect(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { FfxFloat32x3 r = (-x) * z + z; @@ -2286,7 +2286,7 @@ FfxFloat32x3 ffxZeroOneSelect(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneSelect(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { FfxFloat32x4 r = (-x) * z + z; @@ -2300,7 +2300,7 @@ FfxFloat32x4 ffxZeroOneSelect(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxZeroOneIsSigned(FfxFloat32 x) { return ffxSaturate(x * FfxFloat32(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2313,7 +2313,7 @@ FfxFloat32 ffxZeroOneIsSigned(FfxFloat32 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxZeroOneIsSigned(FfxFloat32x2 x) { return ffxSaturate(x * ffxBroadcast2(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2326,7 +2326,7 @@ FfxFloat32x2 ffxZeroOneIsSigned(FfxFloat32x2 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxZeroOneIsSigned(FfxFloat32x3 x) { return ffxSaturate(x * ffxBroadcast3(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2339,7 +2339,7 @@ FfxFloat32x3 ffxZeroOneIsSigned(FfxFloat32x3 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x4 ffxZeroOneIsSigned(FfxFloat32x4 x) { return ffxSaturate(x * ffxBroadcast4(FFX_NEGATIVE_INFINITY_FLOAT)); @@ -2358,7 +2358,7 @@ FfxFloat32x4 ffxZeroOneIsSigned(FfxFloat32x4 x) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxRec709FromLinear(FfxFloat32 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2379,7 +2379,7 @@ FfxFloat32 ffxRec709FromLinear(FfxFloat32 color) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxRec709FromLinear(FfxFloat32x2 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2400,7 +2400,7 @@ FfxFloat32x2 ffxRec709FromLinear(FfxFloat32x2 color) /// @returns /// The color in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxRec709FromLinear(FfxFloat32x3 color) { FfxFloat32x3 j = FfxFloat32x3(0.018 * 4.5, 4.5, 0.45); @@ -2420,10 +2420,10 @@ FfxFloat32x3 ffxRec709FromLinear(FfxFloat32x3 color) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32 ffxGammaFromLinear(FfxFloat32 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32 ffxGammaFromLinear(FfxFloat32 value, FfxFloat32 power) { - return pow(color, FfxFloat32(rcpX)); + return pow(value, FfxFloat32(power)); } /// Compute a gamma value from a linear value. @@ -2438,10 +2438,10 @@ FfxFloat32 ffxGammaFromLinear(FfxFloat32 color, FfxFloat32 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 value, FfxFloat32 power) { - return pow(color, ffxBroadcast2(rcpX)); + return pow(value, ffxBroadcast2(power)); } /// Compute a gamma value from a linear value. @@ -2456,10 +2456,10 @@ FfxFloat32x2 ffxGammaFromLinear(FfxFloat32x2 color, FfxFloat32 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU -FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 color, FfxFloat32 rcpX) +/// @ingroup GPUCore +FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 value, FfxFloat32 power) { - return pow(color, ffxBroadcast3(rcpX)); + return pow(value, ffxBroadcast3(power)); } /// Compute a PQ value from a linear value. @@ -2469,10 +2469,10 @@ FfxFloat32x3 ffxGammaFromLinear(FfxFloat32x3 color, FfxFloat32 rcpX) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxPQToLinear(FfxFloat32 x) +/// @ingroup GPUCore +FfxFloat32 ffxPQToLinear(FfxFloat32 value) { - FfxFloat32 p = pow(x, FfxFloat32(0.159302)); + FfxFloat32 p = pow(value, FfxFloat32(0.159302)); return pow((FfxFloat32(0.835938) + FfxFloat32(18.8516) * p) / (FfxFloat32(1.0) + FfxFloat32(18.6875) * p), FfxFloat32(78.8438)); } @@ -2483,10 +2483,10 @@ FfxFloat32 ffxPQToLinear(FfxFloat32 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 x) +/// @ingroup GPUCore +FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 value) { - FfxFloat32x2 p = pow(x, ffxBroadcast2(0.159302)); + FfxFloat32x2 p = pow(value, ffxBroadcast2(0.159302)); return pow((ffxBroadcast2(0.835938) + ffxBroadcast2(18.8516) * p) / (ffxBroadcast2(1.0) + ffxBroadcast2(18.6875) * p), ffxBroadcast2(78.8438)); } @@ -2497,10 +2497,10 @@ FfxFloat32x2 ffxPQToLinear(FfxFloat32x2 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 x) +/// @ingroup GPUCore +FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 value) { - FfxFloat32x3 p = pow(x, ffxBroadcast3(0.159302)); + FfxFloat32x3 p = pow(value, ffxBroadcast3(0.159302)); return pow((ffxBroadcast3(0.835938) + ffxBroadcast3(18.8516) * p) / (ffxBroadcast3(1.0) + ffxBroadcast3(18.6875) * p), ffxBroadcast3(78.8438)); } @@ -2511,12 +2511,12 @@ FfxFloat32x3 ffxPQToLinear(FfxFloat32x3 x) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32 ffxSrgbToLinear(FfxFloat32 color) +/// @ingroup GPUCore +FfxFloat32 ffxSrgbToLinear(FfxFloat32 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.x, color * j.y, pow(color, j.z) * k.x + k.y); + return clamp(j.x, value * j.y, pow(value, j.z) * k.x + k.y); } /// Compute a linear value from a SRGB value. @@ -2526,12 +2526,12 @@ FfxFloat32 ffxSrgbToLinear(FfxFloat32 color) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 color) +/// @ingroup GPUCore +FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.xx, color * j.yy, pow(color, j.zz) * k.xx + k.yy); + return clamp(j.xx, value * j.yy, pow(value, j.zz) * k.xx + k.yy); } /// Compute a linear value from a SRGB value. @@ -2541,12 +2541,12 @@ FfxFloat32x2 ffxSrgbToLinear(FfxFloat32x2 color) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU -FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 color) +/// @ingroup GPUCore +FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 value) { FfxFloat32x3 j = FfxFloat32x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); FfxFloat32x2 k = FfxFloat32x2(1.055, -0.055); - return clamp(j.xxx, color * j.yyy, pow(color, j.zzz) * k.xxx + k.yyy); + return clamp(j.xxx, value * j.yyy, pow(value, j.zzz) * k.xxx + k.yyy); } /// Compute a linear value from a REC.709 value. @@ -2556,7 +2556,7 @@ FfxFloat32x3 ffxSrgbToLinear(FfxFloat32x3 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxLinearFromRec709(FfxFloat32 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2571,7 +2571,7 @@ FfxFloat32 ffxLinearFromRec709(FfxFloat32 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxLinearFromRec709(FfxFloat32x2 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2586,7 +2586,7 @@ FfxFloat32x2 ffxLinearFromRec709(FfxFloat32x2 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxLinearFromRec709(FfxFloat32x3 color) { FfxFloat32x3 j = FfxFloat32x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2604,7 +2604,7 @@ FfxFloat32x3 ffxLinearFromRec709(FfxFloat32x3 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32 ffxLinearFromGamma(FfxFloat32 color, FfxFloat32 power) { return pow(color, FfxFloat32(power)); @@ -2620,7 +2620,7 @@ FfxFloat32 ffxLinearFromGamma(FfxFloat32 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x2 ffxLinearFromGamma(FfxFloat32x2 color, FfxFloat32 power) { return pow(color, ffxBroadcast2(power)); @@ -2636,7 +2636,7 @@ FfxFloat32x2 ffxLinearFromGamma(FfxFloat32x2 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat32x3 ffxLinearFromGamma(FfxFloat32x3 color, FfxFloat32 power) { return pow(color, ffxBroadcast3(power)); @@ -2651,10 +2651,10 @@ FfxFloat32x3 ffxLinearFromGamma(FfxFloat32x3 color, FfxFloat32 power) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxLinearFromPQ(FfxFloat32 x) +/// @ingroup GPUCore +FfxFloat32 ffxLinearFromPQ(FfxFloat32 value) { - FfxFloat32 p = pow(x, FfxFloat32(0.0126833)); + FfxFloat32 p = pow(value, FfxFloat32(0.0126833)); return pow(ffxSaturate(p - FfxFloat32(0.835938)) / (FfxFloat32(18.8516) - FfxFloat32(18.6875) * p), FfxFloat32(6.27739)); } @@ -2667,10 +2667,10 @@ FfxFloat32 ffxLinearFromPQ(FfxFloat32 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 x) +/// @ingroup GPUCore +FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 value) { - FfxFloat32x2 p = pow(x, ffxBroadcast2(0.0126833)); + FfxFloat32x2 p = pow(value, ffxBroadcast2(0.0126833)); return pow(ffxSaturate(p - ffxBroadcast2(0.835938)) / (ffxBroadcast2(18.8516) - ffxBroadcast2(18.6875) * p), ffxBroadcast2(6.27739)); } @@ -2683,10 +2683,10 @@ FfxFloat32x2 ffxLinearFromPQ(FfxFloat32x2 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 x) +/// @ingroup GPUCore +FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 value) { - FfxFloat32x3 p = pow(x, ffxBroadcast3(0.0126833)); + FfxFloat32x3 p = pow(value, ffxBroadcast3(0.0126833)); return pow(ffxSaturate(p - ffxBroadcast3(0.835938)) / (ffxBroadcast3(18.8516) - ffxBroadcast3(18.6875) * p), ffxBroadcast3(6.27739)); } @@ -2699,12 +2699,12 @@ FfxFloat32x3 ffxLinearFromPQ(FfxFloat32x3 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32 ffxLinearFromSrgb(FfxFloat32 color) +/// @ingroup GPUCore +FfxFloat32 ffxLinearFromSrgb(FfxFloat32 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.x), color * j.y, pow(color * k.x + k.y, j.z)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.x), value * j.y, pow(value * k.x + k.y, j.z)); } /// Compute a linear value from a value in a SRGB space. @@ -2716,12 +2716,12 @@ FfxFloat32 ffxLinearFromSrgb(FfxFloat32 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 color) +/// @ingroup GPUCore +FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.xx), color * j.yy, pow(color * k.xx + k.yy, j.zz)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.xx), value * j.yy, pow(value * k.xx + k.yy, j.zz)); } /// Compute a linear value from a value in a SRGB space. @@ -2733,12 +2733,12 @@ FfxFloat32x2 ffxLinearFromSrgb(FfxFloat32x2 color) /// @returns /// A value in linear space. /// -/// @ingroup GPU -FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 color) +/// @ingroup GPUCore +FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 value) { FfxFloat32x3 j = FfxFloat32x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); FfxFloat32x2 k = FfxFloat32x2(1.0 / 1.055, 0.055 / 1.055); - return ffxZeroOneSelect(ffxZeroOneIsSigned(color - j.xxx), color * j.yyy, pow(color * k.xxx + k.yyy, j.zzz)); + return ffxZeroOneSelect(ffxZeroOneIsSigned(value - j.xxx), value * j.yyy, pow(value * k.xxx + k.yyy, j.zzz)); } /// A remapping of 64x1 to 8x8 imposing rotated 2x2 pixel quads in quad linear. @@ -2753,7 +2753,7 @@ FfxFloat32x3 ffxLinearFromSrgb(FfxFloat32x3 color) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxRemapForQuad(FfxUInt32 a) { return FfxUInt32x2(bitfieldExtract(a, 1u, 3u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), a, 1u)); @@ -2777,7 +2777,7 @@ FfxUInt32x2 ffxRemapForQuad(FfxUInt32 a) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxRemapForWaveReduction(FfxUInt32 a) { return FfxUInt32x2(bitfieldInsertMask(bitfieldExtract(a, 2u, 3u), a, 1u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), bitfieldExtract(a, 1u, 2u), 2u)); diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta new file mode 100644 index 0000000..ec380d2 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 05b921699d1374a429e32afca13137e2 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h similarity index 94% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h index c46ccb3..4c73daf 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_gpu_common_half.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,28 +19,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + #if FFX_HALF -#if FFX_HLSL_6_2 +#if FFX_HLSL_SM >= 62 /// A define value for 16bit positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0x7c00u) /// A define value for 16bit negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16((uint16_t)0xfc00u) #else /// A define value for 16bit positive infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_POSITIVE_INFINITY_HALF FFX_TO_FLOAT16(0x7c00u) /// A define value for 16bit negative infinity. /// -/// @ingroup GPU +/// @ingroup GPUCore #define FFX_NEGATIVE_INFINITY_HALF FFX_TO_FLOAT16(0xfc00u) -#endif // FFX_HLSL_6_2 +#endif // #if FFX_HLSL_SM>=62 /// Compute the min of two values. /// @@ -50,7 +51,7 @@ /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxMin(FfxFloat16 x, FfxFloat16 y) { return min(x, y); @@ -64,7 +65,7 @@ FfxFloat16 ffxMin(FfxFloat16 x, FfxFloat16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxMin(FfxFloat16x2 x, FfxFloat16x2 y) { return min(x, y); @@ -78,7 +79,7 @@ FfxFloat16x2 ffxMin(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxMin(FfxFloat16x3 x, FfxFloat16x3 y) { return min(x, y); @@ -92,7 +93,7 @@ FfxFloat16x3 ffxMin(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxMin(FfxFloat16x4 x, FfxFloat16x4 y) { return min(x, y); @@ -106,7 +107,7 @@ FfxFloat16x4 ffxMin(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16 ffxMin(FfxInt16 x, FfxInt16 y) { return min(x, y); @@ -120,7 +121,7 @@ FfxInt16 ffxMin(FfxInt16 x, FfxInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x2 ffxMin(FfxInt16x2 x, FfxInt16x2 y) { return min(x, y); @@ -134,7 +135,7 @@ FfxInt16x2 ffxMin(FfxInt16x2 x, FfxInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x3 ffxMin(FfxInt16x3 x, FfxInt16x3 y) { return min(x, y); @@ -148,7 +149,7 @@ FfxInt16x3 ffxMin(FfxInt16x3 x, FfxInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x4 ffxMin(FfxInt16x4 x, FfxInt16x4 y) { return min(x, y); @@ -162,7 +163,7 @@ FfxInt16x4 ffxMin(FfxInt16x4 x, FfxInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxMin(FfxUInt16 x, FfxUInt16 y) { return min(x, y); @@ -176,7 +177,7 @@ FfxUInt16 ffxMin(FfxUInt16 x, FfxUInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxMin(FfxUInt16x2 x, FfxUInt16x2 y) { return min(x, y); @@ -190,7 +191,7 @@ FfxUInt16x2 ffxMin(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxMin(FfxUInt16x3 x, FfxUInt16x3 y) { return min(x, y); @@ -204,7 +205,7 @@ FfxUInt16x3 ffxMin(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxMin(FfxUInt16x4 x, FfxUInt16x4 y) { return min(x, y); @@ -218,7 +219,7 @@ FfxUInt16x4 ffxMin(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxMax(FfxFloat16 x, FfxFloat16 y) { return max(x, y); @@ -232,7 +233,7 @@ FfxFloat16 ffxMax(FfxFloat16 x, FfxFloat16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxMax(FfxFloat16x2 x, FfxFloat16x2 y) { return max(x, y); @@ -246,7 +247,7 @@ FfxFloat16x2 ffxMax(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxMax(FfxFloat16x3 x, FfxFloat16x3 y) { return max(x, y); @@ -260,7 +261,7 @@ FfxFloat16x3 ffxMax(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxMax(FfxFloat16x4 x, FfxFloat16x4 y) { return max(x, y); @@ -274,7 +275,7 @@ FfxFloat16x4 ffxMax(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16 ffxMax(FfxInt16 x, FfxInt16 y) { return max(x, y); @@ -288,7 +289,7 @@ FfxInt16 ffxMax(FfxInt16 x, FfxInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x2 ffxMax(FfxInt16x2 x, FfxInt16x2 y) { return max(x, y); @@ -302,7 +303,7 @@ FfxInt16x2 ffxMax(FfxInt16x2 x, FfxInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x3 ffxMax(FfxInt16x3 x, FfxInt16x3 y) { return max(x, y); @@ -316,7 +317,7 @@ FfxInt16x3 ffxMax(FfxInt16x3 x, FfxInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxInt16x4 ffxMax(FfxInt16x4 x, FfxInt16x4 y) { return max(x, y); @@ -330,7 +331,7 @@ FfxInt16x4 ffxMax(FfxInt16x4 x, FfxInt16x4 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxMax(FfxUInt16 x, FfxUInt16 y) { return max(x, y); @@ -344,7 +345,7 @@ FfxUInt16 ffxMax(FfxUInt16 x, FfxUInt16 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxMax(FfxUInt16x2 x, FfxUInt16x2 y) { return max(x, y); @@ -358,7 +359,7 @@ FfxUInt16x2 ffxMax(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxMax(FfxUInt16x3 x, FfxUInt16x3 y) { return max(x, y); @@ -372,7 +373,7 @@ FfxUInt16x3 ffxMax(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// The the lowest of two values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxMax(FfxUInt16x4 x, FfxUInt16x4 y) { return max(x, y); @@ -386,7 +387,7 @@ FfxUInt16x4 ffxMax(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxPow(FfxFloat16 x, FfxFloat16 y) { return pow(x, y); @@ -400,7 +401,7 @@ FfxFloat16 ffxPow(FfxFloat16 x, FfxFloat16 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPow(FfxFloat16x2 x, FfxFloat16x2 y) { return pow(x, y); @@ -414,7 +415,7 @@ FfxFloat16x2 ffxPow(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxPow(FfxFloat16x3 x, FfxFloat16x3 y) { return pow(x, y); @@ -428,7 +429,7 @@ FfxFloat16x3 ffxPow(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// The value of the first parameter raised to the power of the second. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxPow(FfxFloat16x4 x, FfxFloat16x4 y) { return pow(x, y); @@ -441,7 +442,7 @@ FfxFloat16x4 ffxPow(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSqrt(FfxFloat16 x) { return sqrt(x); @@ -454,7 +455,7 @@ FfxFloat16 ffxSqrt(FfxFloat16 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSqrt(FfxFloat16x2 x) { return sqrt(x); @@ -467,7 +468,7 @@ FfxFloat16x2 ffxSqrt(FfxFloat16x2 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSqrt(FfxFloat16x3 x) { return sqrt(x); @@ -480,7 +481,7 @@ FfxFloat16x3 ffxSqrt(FfxFloat16x3 x) /// @returns /// The the square root of x. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxSqrt(FfxFloat16x4 x) { return sqrt(x); @@ -494,7 +495,7 @@ FfxFloat16x4 ffxSqrt(FfxFloat16x4 x) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxCopySignBitHalf(FfxFloat16 d, FfxFloat16 s) { return FFX_TO_FLOAT16(FFX_TO_UINT16(d) | (FFX_TO_UINT16(s) & FFX_BROADCAST_UINT16(0x8000u))); @@ -508,7 +509,7 @@ FfxFloat16 ffxCopySignBitHalf(FfxFloat16 d, FfxFloat16 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxCopySignBitHalf(FfxFloat16x2 d, FfxFloat16x2 s) { return FFX_TO_FLOAT16X2(FFX_TO_UINT16X2(d) | (FFX_TO_UINT16X2(s) & FFX_BROADCAST_UINT16X2(0x8000u))); @@ -522,7 +523,7 @@ FfxFloat16x2 ffxCopySignBitHalf(FfxFloat16x2 d, FfxFloat16x2 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxCopySignBitHalf(FfxFloat16x3 d, FfxFloat16x3 s) { return FFX_TO_FLOAT16X3(FFX_TO_UINT16X3(d) | (FFX_TO_UINT16X3(s) & FFX_BROADCAST_UINT16X3(0x8000u))); @@ -536,7 +537,7 @@ FfxFloat16x3 ffxCopySignBitHalf(FfxFloat16x3 d, FfxFloat16x3 s) /// @returns /// The value of d with the sign bit from s. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxCopySignBitHalf(FfxFloat16x4 d, FfxFloat16x4 s) { return FFX_TO_FLOAT16X4(FFX_TO_UINT16X4(d) | (FFX_TO_UINT16X4(s) & FFX_BROADCAST_UINT16X4(0x8000u))); @@ -559,10 +560,10 @@ FfxFloat16x4 ffxCopySignBitHalf(FfxFloat16x4 d, FfxFloat16x4 s) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxIsSignedHalf(FfxFloat16 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -582,10 +583,10 @@ FfxFloat16 ffxIsSignedHalf(FfxFloat16 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxIsSignedHalf(FfxFloat16x2 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -605,10 +606,10 @@ FfxFloat16x2 ffxIsSignedHalf(FfxFloat16x2 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxIsSignedHalf(FfxFloat16x3 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -628,10 +629,10 @@ FfxFloat16x3 ffxIsSignedHalf(FfxFloat16x3 m) /// @returns /// 1.0 when the value is negative, or 0.0 when the value is 0 or position. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxIsSignedHalf(FfxFloat16x4 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -646,10 +647,10 @@ FfxFloat16x4 ffxIsSignedHalf(FfxFloat16x4 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxIsGreaterThanZeroHalf(FfxFloat16 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(m * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -664,10 +665,10 @@ FfxFloat16 ffxIsGreaterThanZeroHalf(FfxFloat16 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxIsGreaterThanZeroHalf(FfxFloat16x2 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(m * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -682,10 +683,10 @@ FfxFloat16x2 ffxIsGreaterThanZeroHalf(FfxFloat16x2 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxIsGreaterThanZeroHalf(FfxFloat16x3 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(m * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF))); } /// A single operation to return the following: @@ -700,10 +701,10 @@ FfxFloat16x3 ffxIsGreaterThanZeroHalf(FfxFloat16x3 m) /// @returns /// 1.0 when the value is position, or 0.0 when the value is 0 or negative. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxIsGreaterThanZeroHalf(FfxFloat16x4 m) { - return ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(m * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF))); } /// Convert a 16bit floating point value to sortable integer. @@ -720,7 +721,7 @@ FfxFloat16x4 ffxIsGreaterThanZeroHalf(FfxFloat16x4 m) /// @returns /// The sortable integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxFloatToSortableIntegerHalf(FfxUInt16 x) { return x ^ ((ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16(15))) | FFX_BROADCAST_UINT16(0x8000)); @@ -737,7 +738,7 @@ FfxUInt16 ffxFloatToSortableIntegerHalf(FfxUInt16 x) /// @returns /// The floating point value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxSortableIntegerToFloatHalf(FfxUInt16 x) { return x ^ ((~ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16(15))) | FFX_BROADCAST_UINT16(0x8000)); @@ -757,7 +758,7 @@ FfxUInt16 ffxSortableIntegerToFloatHalf(FfxUInt16 x) /// @returns /// The sortable integer values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxFloatToSortableIntegerHalf(FfxUInt16x2 x) { return x ^ ((ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16X2(15))) | FFX_BROADCAST_UINT16X2(0x8000)); @@ -774,7 +775,7 @@ FfxUInt16x2 ffxFloatToSortableIntegerHalf(FfxUInt16x2 x) /// @returns /// The floating point values. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxSortableIntegerToFloatHalf(FfxUInt16x2 x) { return x ^ ((~ffxBitShiftRightHalf(x, FFX_BROADCAST_UINT16X2(15))) | FFX_BROADCAST_UINT16X2(0x8000)); @@ -790,7 +791,7 @@ FfxUInt16x2 ffxSortableIntegerToFloatHalf(FfxUInt16x2 x) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY0ZeroX0(FfxUInt32x2 i) { return ((i.x) & 0xffu) | ((i.y << 16) & 0xff0000u); @@ -806,7 +807,7 @@ FfxUInt32 ffxPackBytesZeroY0ZeroX0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY1ZeroX1(FfxUInt32x2 i) { return ((i.x >> 8) & 0xffu) | ((i.y << 8) & 0xff0000u); @@ -822,7 +823,7 @@ FfxUInt32 ffxPackBytesZeroY1ZeroX1(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY2ZeroX2(FfxUInt32x2 i) { return ((i.x >> 16) & 0xffu) | ((i.y) & 0xff0000u); @@ -838,7 +839,7 @@ FfxUInt32 ffxPackBytesZeroY2ZeroX2(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesZeroY3ZeroX3(FfxUInt32x2 i) { return ((i.x >> 24) & 0xffu) | ((i.y >> 8) & 0xff0000u); @@ -854,7 +855,7 @@ FfxUInt32 ffxPackBytesZeroY3ZeroX3(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2Y1X0(FfxUInt32x2 i) { return ((i.x) & 0x000000ffu) | (i.y & 0xffffff00u); @@ -870,7 +871,7 @@ FfxUInt32 ffxPackBytesY3Y2Y1X0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2Y1X2(FfxUInt32x2 i) { return ((i.x >> 16) & 0x000000ffu) | (i.y & 0xffffff00u); @@ -886,7 +887,7 @@ FfxUInt32 ffxPackBytesY3Y2Y1X2(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2X0Y0(FfxUInt32x2 i) { return ((i.x << 8) & 0x0000ff00u) | (i.y & 0xffff00ffu); @@ -902,7 +903,7 @@ FfxUInt32 ffxPackBytesY3Y2X0Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3Y2X2Y0(FfxUInt32x2 i) { return ((i.x >> 8) & 0x0000ff00u) | (i.y & 0xffff00ffu); @@ -918,7 +919,7 @@ FfxUInt32 ffxPackBytesY3Y2X2Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3X0Y1Y0(FfxUInt32x2 i) { return ((i.x << 16) & 0x00ff0000u) | (i.y & 0xff00ffffu); @@ -934,7 +935,7 @@ FfxUInt32 ffxPackBytesY3X0Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY3X2Y1Y0(FfxUInt32x2 i) { return ((i.x) & 0x00ff0000u) | (i.y & 0xff00ffffu); @@ -950,7 +951,7 @@ FfxUInt32 ffxPackBytesY3X2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesX0Y2Y1Y0(FfxUInt32x2 i) { return ((i.x << 24) & 0xff000000u) | (i.y & 0x00ffffffu); @@ -966,7 +967,7 @@ FfxUInt32 ffxPackBytesX0Y2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesX2Y2Y1Y0(FfxUInt32x2 i) { return ((i.x << 8) & 0xff000000u) | (i.y & 0x00ffffffu); @@ -982,7 +983,7 @@ FfxUInt32 ffxPackBytesX2Y2Y1Y0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY2X2Y0X0(FfxUInt32x2 i) { return ((i.x) & 0x00ff00ffu) | ((i.y << 8) & 0xff00ff00u); @@ -998,7 +999,7 @@ FfxUInt32 ffxPackBytesY2X2Y0X0(FfxUInt32x2 i) /// @returns /// The packed integer value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32 ffxPackBytesY2Y0X2X0(FfxUInt32x2 i) { return (((i.x) & 0xffu) | ((i.x >> 8) & 0xff00u) | ((i.y << 16) & 0xff0000u) | ((i.y << 8) & 0xff000000u)); @@ -1012,7 +1013,7 @@ FfxUInt32 ffxPackBytesY2Y0X2X0(FfxUInt32x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxPackX0Y0X1Y1UnsignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) { x *= FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0); @@ -1037,7 +1038,7 @@ FfxUInt16x2 ffxPackX0Y0X1Y1UnsignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1061,7 +1062,7 @@ FfxUInt32x2 ffxPermuteUByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1085,7 +1086,7 @@ FfxUInt32x2 ffxPermuteUByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1109,7 +1110,7 @@ FfxUInt32x2 ffxPermuteUByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteUByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0))); @@ -1123,7 +1124,7 @@ FfxUInt32x2 ffxPermuteUByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1136,7 +1137,7 @@ FfxFloat16x2 ffxPermuteUByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1149,7 +1150,7 @@ FfxFloat16x2 ffxPermuteUByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1162,7 +1163,7 @@ FfxFloat16x2 ffxPermuteUByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteUByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i))) * FFX_BROADCAST_FLOAT16X2(32768.0); @@ -1176,7 +1177,7 @@ FfxFloat16x2 ffxPermuteUByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxPackX0Y0X1Y1SignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) { x = x * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0); @@ -1195,7 +1196,7 @@ FfxUInt16x2 ffxPackX0Y0X1Y1SignedToUint16x2(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1213,7 +1214,7 @@ FfxUInt32x2 ffxPermuteSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1231,7 +1232,7 @@ FfxUInt32x2 ffxPermuteSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1249,7 +1250,7 @@ FfxUInt32x2 ffxPermuteSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))); @@ -1270,7 +1271,7 @@ FfxUInt32x2 ffxPermuteSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1291,7 +1292,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte0Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1312,7 +1313,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte1Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1333,7 +1334,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte2Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The packed FfxUInt32x2 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt32x2 ffxPermuteZeroBasedSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x2 i) { FfxUInt32 b = FFX_UINT16X2_TO_UINT32(FFX_TO_UINT16X2(i * FFX_BROADCAST_FLOAT16X2(1.0 / 32768.0) + FFX_BROADCAST_FLOAT16X2(0.25 / 32768.0))) ^ 0x00800080u; @@ -1349,7 +1350,7 @@ FfxUInt32x2 ffxPermuteZeroBasedSByte3Float16x2ToUint2(FfxUInt32x2 d, FfxFloat16x /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1364,7 +1365,7 @@ FfxFloat16x2 ffxPermuteSByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1379,7 +1380,7 @@ FfxFloat16x2 ffxPermuteSByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1394,7 +1395,7 @@ FfxFloat16x2 ffxPermuteSByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteSByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i))) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1409,7 +1410,7 @@ FfxFloat16x2 ffxPermuteSByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte0Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY0ZeroX0(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1424,7 +1425,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte0Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte1Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY1ZeroX1(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1439,7 +1440,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte1Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte2Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY2ZeroX2(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1454,7 +1455,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte2Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// The unpacked FfxFloat16x2. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxPermuteZeroBasedSByte3Uint2ToFloat16x2(FfxUInt32x2 i) { return FFX_TO_FLOAT16X2(FFX_UINT32_TO_UINT16X2(ffxPackBytesZeroY3ZeroX3(i) ^ 0x00800080u)) * FFX_BROADCAST_FLOAT16X2(32768.0) - FFX_BROADCAST_FLOAT16X2(0.25); @@ -1473,7 +1474,7 @@ FfxFloat16x2 ffxPermuteZeroBasedSByte3Uint2ToFloat16x2(FfxUInt32x2 i) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateSqrtHalf(FfxFloat16 a) { return FFX_TO_FLOAT16((FFX_TO_UINT16(a) >> FFX_BROADCAST_UINT16(1)) + FFX_BROADCAST_UINT16(0x1de2)); @@ -1492,7 +1493,7 @@ FfxFloat16 ffxApproximateSqrtHalf(FfxFloat16 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateSqrtHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2((FFX_TO_UINT16X2(a) >> FFX_BROADCAST_UINT16X2(1)) + FFX_BROADCAST_UINT16X2(0x1de2)); @@ -1511,7 +1512,7 @@ FfxFloat16x2 ffxApproximateSqrtHalf(FfxFloat16x2 a) /// @returns /// An approximation of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateSqrtHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3((FFX_TO_UINT16X3(a) >> FFX_BROADCAST_UINT16X3(1)) + FFX_BROADCAST_UINT16X3(0x1de2)); @@ -1530,7 +1531,7 @@ FfxFloat16x3 ffxApproximateSqrtHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalHalf(FfxFloat16 a) { return FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x7784) - FFX_TO_UINT16(a)); @@ -1549,7 +1550,7 @@ FfxFloat16 ffxApproximateReciprocalHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x7784) - FFX_TO_UINT16X2(a)); @@ -1568,7 +1569,7 @@ FfxFloat16x2 ffxApproximateReciprocalHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x7784) - FFX_TO_UINT16X3(a)); @@ -1587,7 +1588,7 @@ FfxFloat16x3 ffxApproximateReciprocalHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalHalf(FfxFloat16x4 a) { return FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x7784) - FFX_TO_UINT16X4(a)); @@ -1606,7 +1607,7 @@ FfxFloat16x4 ffxApproximateReciprocalHalf(FfxFloat16x4 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalMediumHalf(FfxFloat16 a) { FfxFloat16 b = FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x778d) - FFX_TO_UINT16(a)); @@ -1626,7 +1627,7 @@ FfxFloat16 ffxApproximateReciprocalMediumHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalMediumHalf(FfxFloat16x2 a) { FfxFloat16x2 b = FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x778d) - FFX_TO_UINT16X2(a)); @@ -1646,7 +1647,7 @@ FfxFloat16x2 ffxApproximateReciprocalMediumHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalMediumHalf(FfxFloat16x3 a) { FfxFloat16x3 b = FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x778d) - FFX_TO_UINT16X3(a)); @@ -1666,7 +1667,7 @@ FfxFloat16x3 ffxApproximateReciprocalMediumHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal, estimated to medium quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalMediumHalf(FfxFloat16x4 a) { FfxFloat16x4 b = FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x778d) - FFX_TO_UINT16X4(a)); @@ -1686,7 +1687,7 @@ FfxFloat16x4 ffxApproximateReciprocalMediumHalf(FfxFloat16x4 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxApproximateReciprocalSquareRootHalf(FfxFloat16 a) { return FFX_TO_FLOAT16(FFX_BROADCAST_UINT16(0x59a3) - (FFX_TO_UINT16(a) >> FFX_BROADCAST_UINT16(1))); @@ -1705,7 +1706,7 @@ FfxFloat16 ffxApproximateReciprocalSquareRootHalf(FfxFloat16 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x2 a) { return FFX_TO_FLOAT16X2(FFX_BROADCAST_UINT16X2(0x59a3) - (FFX_TO_UINT16X2(a) >> FFX_BROADCAST_UINT16X2(1))); @@ -1724,7 +1725,7 @@ FfxFloat16x2 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x2 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x3 a) { return FFX_TO_FLOAT16X3(FFX_BROADCAST_UINT16X3(0x59a3) - (FFX_TO_UINT16X3(a) >> FFX_BROADCAST_UINT16X3(1))); @@ -1743,7 +1744,7 @@ FfxFloat16x3 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x3 a) /// @returns /// An approximation of the reciprocal of the square root, estimated to low quality. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxApproximateReciprocalSquareRootHalf(FfxFloat16x4 a) { return FFX_TO_FLOAT16X4(FFX_BROADCAST_UINT16X4(0x59a3) - (FFX_TO_UINT16X4(a) >> FFX_BROADCAST_UINT16X4(1))); @@ -1833,7 +1834,7 @@ FfxFloat16x2 ffxParabolicSinCosHalf(FfxFloat16 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneAndHalf(FfxUInt16 x, FfxUInt16 y) { return min(x, y); @@ -1847,7 +1848,7 @@ FfxUInt16 ffxZeroOneAndHalf(FfxUInt16 x, FfxUInt16 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneAndHalf(FfxUInt16x2 x, FfxUInt16x2 y) { return min(x, y); @@ -1861,7 +1862,7 @@ FfxUInt16x2 ffxZeroOneAndHalf(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneAndHalf(FfxUInt16x3 x, FfxUInt16x3 y) { return min(x, y); @@ -1875,7 +1876,7 @@ FfxUInt16x3 ffxZeroOneAndHalf(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneAndHalf(FfxUInt16x4 x, FfxUInt16x4 y) { return min(x, y); @@ -1889,7 +1890,7 @@ FfxUInt16x4 ffxZeroOneAndHalf(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneNotHalf(FfxUInt16 x) { return x ^ FFX_BROADCAST_UINT16(1); @@ -1903,7 +1904,7 @@ FfxUInt16 ffxZeroOneNotHalf(FfxUInt16 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneNotHalf(FfxUInt16x2 x) { return x ^ FFX_BROADCAST_UINT16X2(1); @@ -1917,7 +1918,7 @@ FfxUInt16x2 ffxZeroOneNotHalf(FfxUInt16x2 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneNotHalf(FfxUInt16x3 x) { return x ^ FFX_BROADCAST_UINT16X3(1); @@ -1931,7 +1932,7 @@ FfxUInt16x3 ffxZeroOneNotHalf(FfxUInt16x3 x) /// @returns /// Result of the NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneNotHalf(FfxUInt16x4 x) { return x ^ FFX_BROADCAST_UINT16X4(1); @@ -1945,7 +1946,7 @@ FfxUInt16x4 ffxZeroOneNotHalf(FfxUInt16x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneOrHalf(FfxUInt16 x, FfxUInt16 y) { return max(x, y); @@ -1959,7 +1960,7 @@ FfxUInt16 ffxZeroOneOrHalf(FfxUInt16 x, FfxUInt16 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneOrHalf(FfxUInt16x2 x, FfxUInt16x2 y) { return max(x, y); @@ -1973,7 +1974,7 @@ FfxUInt16x2 ffxZeroOneOrHalf(FfxUInt16x2 x, FfxUInt16x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneOrHalf(FfxUInt16x3 x, FfxUInt16x3 y) { return max(x, y); @@ -1987,7 +1988,7 @@ FfxUInt16x3 ffxZeroOneOrHalf(FfxUInt16x3 x, FfxUInt16x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneOrHalf(FfxUInt16x4 x, FfxUInt16x4 y) { return max(x, y); @@ -2000,7 +2001,7 @@ FfxUInt16x4 ffxZeroOneOrHalf(FfxUInt16x4 x, FfxUInt16x4 y) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16 ffxZeroOneFloat16ToUint16(FfxFloat16 x) { return FFX_TO_UINT16(x * FFX_TO_FLOAT16(FFX_TO_UINT16(1))); @@ -2013,7 +2014,7 @@ FfxUInt16 ffxZeroOneFloat16ToUint16(FfxFloat16 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxZeroOneFloat16x2ToUint16x2(FfxFloat16x2 x) { return FFX_TO_UINT16X2(x * FFX_TO_FLOAT16X2(FfxUInt16x2(1, 1))); @@ -2026,7 +2027,7 @@ FfxUInt16x2 ffxZeroOneFloat16x2ToUint16x2(FfxFloat16x2 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x3 ffxZeroOneFloat16x3ToUint16x3(FfxFloat16x3 x) { return FFX_TO_UINT16X3(x * FFX_TO_FLOAT16X3(FfxUInt16x3(1, 1, 1))); @@ -2039,7 +2040,7 @@ FfxUInt16x3 ffxZeroOneFloat16x3ToUint16x3(FfxFloat16x3 x) /// @returns /// The converted Uint value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x4 ffxZeroOneFloat16x4ToUint16x4(FfxFloat16x4 x) { return FFX_TO_UINT16X4(x * FFX_TO_FLOAT16X4(FfxUInt16x4(1, 1, 1, 1))); @@ -2052,7 +2053,7 @@ FfxUInt16x4 ffxZeroOneFloat16x4ToUint16x4(FfxFloat16x4 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneUint16ToFloat16(FfxUInt16 x) { return FFX_TO_FLOAT16(x * FFX_TO_UINT16(FFX_TO_FLOAT16(1.0))); @@ -2065,7 +2066,7 @@ FfxFloat16 ffxZeroOneUint16ToFloat16(FfxUInt16 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneUint16x2ToFloat16x2(FfxUInt16x2 x) { return FFX_TO_FLOAT16X2(x * FFX_TO_UINT16X2(FfxUInt16x2(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2078,7 +2079,7 @@ FfxFloat16x2 ffxZeroOneUint16x2ToFloat16x2(FfxUInt16x2 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneUint16x3ToFloat16x3(FfxUInt16x3 x) { return FFX_TO_FLOAT16X3(x * FFX_TO_UINT16X3(FfxUInt16x3(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2091,7 +2092,7 @@ FfxFloat16x3 ffxZeroOneUint16x3ToFloat16x3(FfxUInt16x3 x) /// @returns /// The converted half-precision FfxFloat32 value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneUint16x4ToFloat16x4(FfxUInt16x4 x) { return FFX_TO_FLOAT16X4(x * FFX_TO_UINT16X4(FfxUInt16x4(FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0), FFX_TO_FLOAT16(1.0)))); @@ -2105,7 +2106,7 @@ FfxFloat16x4 ffxZeroOneUint16x4ToFloat16x4(FfxUInt16x4 x) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneAndHalf(FfxFloat16 x, FfxFloat16 y) { return min(x, y); @@ -2119,7 +2120,7 @@ FfxFloat16 ffxZeroOneAndHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneAndHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return min(x, y); @@ -2133,7 +2134,7 @@ FfxFloat16x2 ffxZeroOneAndHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneAndHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return min(x, y); @@ -2147,7 +2148,7 @@ FfxFloat16x3 ffxZeroOneAndHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the AND operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneAndHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return min(x, y); @@ -2161,7 +2162,7 @@ FfxFloat16x4 ffxZeroOneAndHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSignedZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y) { return (-x) * y + FFX_BROADCAST_FLOAT16(1.0); @@ -2175,7 +2176,7 @@ FfxFloat16 ffxSignedZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSignedZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X2(1.0); @@ -2189,7 +2190,7 @@ FfxFloat16x2 ffxSignedZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSignedZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X3(1.0); @@ -2203,7 +2204,7 @@ FfxFloat16x3 ffxSignedZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the AND NOT operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxSignedZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return (-x) * y + FFX_BROADCAST_FLOAT16X4(1.0); @@ -2219,10 +2220,10 @@ FfxFloat16x4 ffxSignedZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) { - return ffxSaturate(x * y + z); + return FfxFloat16(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2235,10 +2236,10 @@ FfxFloat16 ffxZeroOneAndOrHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x2(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2251,10 +2252,10 @@ FfxFloat16x2 ffxZeroOneAndOrHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x3(ffxSaturate(x * y + z)); } /// Conditional free logic AND operation using two half-precision values followed by @@ -2267,10 +2268,10 @@ FfxFloat16x3 ffxZeroOneAndOrHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) { - return ffxSaturate(x * y + z); + return FfxFloat16x4(ffxSaturate(x * y + z)); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2280,10 +2281,10 @@ FfxFloat16x4 ffxZeroOneAndOrHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2293,10 +2294,10 @@ FfxFloat16 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x2 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2306,10 +2307,10 @@ FfxFloat16x2 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x2 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x3 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_POSITIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if greater than zero and 0.0 if not. @@ -2319,10 +2320,10 @@ FfxFloat16x3 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x3 x) /// @returns /// Result of the greater than zero comparison. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x4 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_POSITIVE_INFINITY_HALF))); } /// Conditional free logic signed NOT operation using two half-precision FfxFloat32 values. @@ -2332,7 +2333,7 @@ FfxFloat16x4 ffxZeroOneIsGreaterThanZeroHalf(FfxFloat16x4 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneNotHalf(FfxFloat16 x) { return FFX_BROADCAST_FLOAT16(1.0) - x; @@ -2345,7 +2346,7 @@ FfxFloat16 ffxZeroOneNotHalf(FfxFloat16 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneNotHalf(FfxFloat16x2 x) { return FFX_BROADCAST_FLOAT16X2(1.0) - x; @@ -2358,7 +2359,7 @@ FfxFloat16x2 ffxZeroOneNotHalf(FfxFloat16x2 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneNotHalf(FfxFloat16x3 x) { return FFX_BROADCAST_FLOAT16X3(1.0) - x; @@ -2371,7 +2372,7 @@ FfxFloat16x3 ffxZeroOneNotHalf(FfxFloat16x3 x) /// @returns /// Result of the AND OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneNotHalf(FfxFloat16x4 x) { return FFX_BROADCAST_FLOAT16X4(1.0) - x; @@ -2385,7 +2386,7 @@ FfxFloat16x4 ffxZeroOneNotHalf(FfxFloat16x4 x) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneOrHalf(FfxFloat16 x, FfxFloat16 y) { return max(x, y); @@ -2399,7 +2400,7 @@ FfxFloat16 ffxZeroOneOrHalf(FfxFloat16 x, FfxFloat16 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) { return max(x, y); @@ -2413,7 +2414,7 @@ FfxFloat16x2 ffxZeroOneOrHalf(FfxFloat16x2 x, FfxFloat16x2 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) { return max(x, y); @@ -2427,7 +2428,7 @@ FfxFloat16x3 ffxZeroOneOrHalf(FfxFloat16x3 x, FfxFloat16x3 y) /// @returns /// Result of the OR operation. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) { return max(x, y); @@ -2442,7 +2443,7 @@ FfxFloat16x4 ffxZeroOneOrHalf(FfxFloat16x4 x, FfxFloat16x4 y) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneSelectHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) { FfxFloat16 r = (-x) * z + z; @@ -2458,7 +2459,7 @@ FfxFloat16 ffxZeroOneSelectHalf(FfxFloat16 x, FfxFloat16 y, FfxFloat16 z) /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneSelectHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z) { FfxFloat16x2 r = (-x) * z + z; @@ -2474,7 +2475,7 @@ FfxFloat16x2 ffxZeroOneSelectHalf(FfxFloat16x2 x, FfxFloat16x2 y, FfxFloat16x2 z /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneSelectHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z) { FfxFloat16x3 r = (-x) * z + z; @@ -2490,7 +2491,7 @@ FfxFloat16x3 ffxZeroOneSelectHalf(FfxFloat16x3 x, FfxFloat16x3 y, FfxFloat16x3 z /// @returns /// The selected value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneSelectHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z) { FfxFloat16x4 r = (-x) * z + z; @@ -2504,10 +2505,10 @@ FfxFloat16x4 ffxZeroOneSelectHalf(FfxFloat16x4 x, FfxFloat16x4 y, FfxFloat16x4 z /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxZeroOneIsSignedHalf(FfxFloat16 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16(ffxSaturate(x * FFX_BROADCAST_FLOAT16(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2517,10 +2518,10 @@ FfxFloat16 ffxZeroOneIsSignedHalf(FfxFloat16 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxZeroOneIsSignedHalf(FfxFloat16x2 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x2(ffxSaturate(x * FFX_BROADCAST_FLOAT16X2(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2530,10 +2531,10 @@ FfxFloat16x2 ffxZeroOneIsSignedHalf(FfxFloat16x2 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxZeroOneIsSignedHalf(FfxFloat16x3 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x3(ffxSaturate(x * FFX_BROADCAST_FLOAT16X3(FFX_NEGATIVE_INFINITY_HALF))); } /// Given a half-precision value, returns 1.0 if less than zero and 0.0 if not. @@ -2543,10 +2544,10 @@ FfxFloat16x3 ffxZeroOneIsSignedHalf(FfxFloat16x3 x) /// @returns /// Result of the sign value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x4 ffxZeroOneIsSignedHalf(FfxFloat16x4 x) { - return ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF)); + return FfxFloat16x4(ffxSaturate(x * FFX_BROADCAST_FLOAT16X4(FFX_NEGATIVE_INFINITY_HALF))); } /// Compute a Rec.709 color space. @@ -2562,7 +2563,7 @@ FfxFloat16x4 ffxZeroOneIsSignedHalf(FfxFloat16x4 x) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxRec709FromLinearHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2583,7 +2584,7 @@ FfxFloat16 ffxRec709FromLinearHalf(FfxFloat16 c) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxRec709FromLinearHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2604,7 +2605,7 @@ FfxFloat16x2 ffxRec709FromLinearHalf(FfxFloat16x2 c) /// @returns /// The color in Rec.709 space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxRec709FromLinearHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.018 * 4.5, 4.5, 0.45); @@ -2624,7 +2625,7 @@ FfxFloat16x3 ffxRec709FromLinearHalf(FfxFloat16x3 c) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxGammaFromLinearHalf(FfxFloat16 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16(rcpX)); @@ -2642,7 +2643,7 @@ FfxFloat16 ffxGammaFromLinearHalf(FfxFloat16 c, FfxFloat16 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxGammaFromLinearHalf(FfxFloat16x2 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16X2(rcpX)); @@ -2660,7 +2661,7 @@ FfxFloat16x2 ffxGammaFromLinearHalf(FfxFloat16x2 c, FfxFloat16 rcpX) /// @returns /// A value in gamma space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxGammaFromLinearHalf(FfxFloat16x3 c, FfxFloat16 rcpX) { return pow(c, FFX_BROADCAST_FLOAT16X3(rcpX)); @@ -2673,7 +2674,7 @@ FfxFloat16x3 ffxGammaFromLinearHalf(FfxFloat16x3 c, FfxFloat16 rcpX) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSrgbFromLinearHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2688,7 +2689,7 @@ FfxFloat16 ffxSrgbFromLinearHalf(FfxFloat16 c) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSrgbFromLinearHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2703,7 +2704,7 @@ FfxFloat16x2 ffxSrgbFromLinearHalf(FfxFloat16x2 c) /// @returns /// A value in SRGB space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSrgbFromLinearHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.0031308 * 12.92, 12.92, 1.0 / 2.4); @@ -2718,7 +2719,7 @@ FfxFloat16x3 ffxSrgbFromLinearHalf(FfxFloat16x3 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxSquareRootHalf(FfxFloat16 c) { return sqrt(c); @@ -2731,7 +2732,7 @@ FfxFloat16 ffxSquareRootHalf(FfxFloat16 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxSquareRootHalf(FfxFloat16x2 c) { return sqrt(c); @@ -2744,7 +2745,7 @@ FfxFloat16x2 ffxSquareRootHalf(FfxFloat16x2 c) /// @returns /// A square root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxSquareRootHalf(FfxFloat16x3 c) { return sqrt(c); @@ -2757,7 +2758,7 @@ FfxFloat16x3 ffxSquareRootHalf(FfxFloat16x3 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxCubeRootHalf(FfxFloat16 c) { return pow(c, FFX_BROADCAST_FLOAT16(1.0 / 3.0)); @@ -2770,7 +2771,7 @@ FfxFloat16 ffxCubeRootHalf(FfxFloat16 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxCubeRootHalf(FfxFloat16x2 c) { return pow(c, FFX_BROADCAST_FLOAT16X2(1.0 / 3.0)); @@ -2783,7 +2784,7 @@ FfxFloat16x2 ffxCubeRootHalf(FfxFloat16x2 c) /// @returns /// A cube root of the input value. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxCubeRootHalf(FfxFloat16x3 c) { return pow(c, FFX_BROADCAST_FLOAT16X3(1.0 / 3.0)); @@ -2796,7 +2797,7 @@ FfxFloat16x3 ffxCubeRootHalf(FfxFloat16x3 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromRec709Half(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2811,7 +2812,7 @@ FfxFloat16 ffxLinearFromRec709Half(FfxFloat16 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromRec709Half(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2826,7 +2827,7 @@ FfxFloat16x2 ffxLinearFromRec709Half(FfxFloat16x2 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromRec709Half(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.081 / 4.5, 1.0 / 4.5, 1.0 / 0.45); @@ -2844,7 +2845,7 @@ FfxFloat16x3 ffxLinearFromRec709Half(FfxFloat16x3 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromGammaHalf(FfxFloat16 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16(x)); @@ -2860,7 +2861,7 @@ FfxFloat16 ffxLinearFromGammaHalf(FfxFloat16 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromGammaHalf(FfxFloat16x2 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16X2(x)); @@ -2876,7 +2877,7 @@ FfxFloat16x2 ffxLinearFromGammaHalf(FfxFloat16x2 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromGammaHalf(FfxFloat16x3 c, FfxFloat16 x) { return pow(c, FFX_BROADCAST_FLOAT16X3(x)); @@ -2891,7 +2892,7 @@ FfxFloat16x3 ffxLinearFromGammaHalf(FfxFloat16x3 c, FfxFloat16 x) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16 ffxLinearFromSrgbHalf(FfxFloat16 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2908,7 +2909,7 @@ FfxFloat16 ffxLinearFromSrgbHalf(FfxFloat16 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x2 ffxLinearFromSrgbHalf(FfxFloat16x2 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2925,7 +2926,7 @@ FfxFloat16x2 ffxLinearFromSrgbHalf(FfxFloat16x2 c) /// @returns /// A value in linear space. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxFloat16x3 ffxLinearFromSrgbHalf(FfxFloat16x3 c) { FfxFloat16x3 j = FfxFloat16x3(0.04045 / 12.92, 1.0 / 12.92, 2.4); @@ -2945,7 +2946,7 @@ FfxFloat16x3 ffxLinearFromSrgbHalf(FfxFloat16x3 c) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxRemapForQuadHalf(FfxUInt32 a) { return FfxUInt16x2(bitfieldExtract(a, 1u, 3u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), a, 1u)); @@ -2969,7 +2970,7 @@ FfxUInt16x2 ffxRemapForQuadHalf(FfxUInt32 a) /// @returns /// The remapped 2D coordinates. /// -/// @ingroup GPU +/// @ingroup GPUCore FfxUInt16x2 ffxRemapForWaveReductionHalf(FfxUInt32 a) { return FfxUInt16x2(bitfieldInsertMask(bitfieldExtract(a, 2u, 3u), a, 1u), bitfieldInsertMask(bitfieldExtract(a, 3u, 3u), bitfieldExtract(a, 1u, 2u), 2u)); diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta new file mode 100644 index 0000000..e78eec4 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_gpu_common_half.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 1bdb323791a91a5438ee8e1e63187840 +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_core_hlsl.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h similarity index 86% rename from Assets/Resources/FSR2/shaders/ffx_core_hlsl.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h index ad4ff65..337eb06 100644 --- a/Assets/Resources/FSR2/shaders/ffx_core_hlsl.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,188 +19,221 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + +/// @defgroup HLSLCore HLSL Core +/// HLSL core defines and functions +/// +/// @ingroup FfxHLSL + +#define DECLARE_SRV_REGISTER(regIndex) t##regIndex +#define DECLARE_UAV_REGISTER(regIndex) u##regIndex +#define DECLARE_CB_REGISTER(regIndex) b##regIndex +#define FFX_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) +#define FFX_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) +#define FFX_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) + /// A define for abstracting shared memory between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GROUPSHARED groupshared /// A define for abstracting compute memory barriers between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GROUP_MEMORY_BARRIER GroupMemoryBarrierWithGroupSync +/// A define for abstracting compute atomic additions between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_ATOMIC_ADD(x, y) InterlockedAdd(x, y) + /// A define added to accept static markup on functions to aid CPU/GPU portability of code. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_STATIC static /// A define for abstracting loop unrolling between shading languages. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_UNROLL [unroll] /// A define for abstracting a 'greater than' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GREATER_THAN(x, y) x > y /// A define for abstracting a 'greater than or equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_GREATER_THAN_EQUAL(x, y) x >= y /// A define for abstracting a 'less than' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_LESS_THAN(x, y) x < y /// A define for abstracting a 'less than or equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_LESS_THAN_EQUAL(x, y) x <= y /// A define for abstracting an 'equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_EQUAL(x, y) x == y /// A define for abstracting a 'not equal' comparison operator between two types. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_NOT_EQUAL(x, y) x != y +/// A define for abstracting matrix multiply operations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_MATRIX_MULTIPLY(a, b) mul(a, b) + +/// A define for abstracting vector transformations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_TRANSFORM_VECTOR(a, b) mul(a, b) + +/// A define for abstracting modulo operations between shading languages. +/// +/// @ingroup HLSLCore +#define FFX_MODULO(a, b) (fmod(a, b)) + /// Broadcast a scalar value to a 1-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32(x) FfxFloat32(x) /// Broadcast a scalar value to a 2-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X2(x) FfxFloat32(x) /// Broadcast a scalar value to a 3-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X3(x) FfxFloat32(x) /// Broadcast a scalar value to a 4-dimensional floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_FLOAT32X4(x) FfxFloat32(x) /// Broadcast a scalar value to a 1-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32(x) FfxUInt32(x) /// Broadcast a scalar value to a 2-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X2(x) FfxUInt32(x) /// Broadcast a scalar value to a 4-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X3(x) FfxUInt32(x) /// Broadcast a scalar value to a 4-dimensional unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_UINT32X4(x) FfxUInt32(x) /// Broadcast a scalar value to a 1-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32(x) FfxInt32(x) /// Broadcast a scalar value to a 2-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X2(x) FfxInt32(x) /// Broadcast a scalar value to a 3-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X3(x) FfxInt32(x) /// Broadcast a scalar value to a 4-dimensional signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_INT32X4(x) FfxInt32(x) /// Broadcast a scalar value to a 1-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 2-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X2(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 3-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X3(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 4-dimensional half-precision floating point vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_FLOAT16X4(a) FFX_MIN16_F(a) /// Broadcast a scalar value to a 1-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 2-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X2(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 3-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X3(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 4-dimensional half-precision unsigned integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_UINT16X4(a) FFX_MIN16_U(a) /// Broadcast a scalar value to a 1-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 2-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X2(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 3-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X3(a) FFX_MIN16_I(a) /// Broadcast a scalar value to a 4-dimensional half-precision signed integer vector. /// -/// @ingroup GPU +/// @ingroup HLSLCore #define FFX_BROADCAST_MIN_INT16X4(a) FFX_MIN16_I(a) /// Pack 2x32-bit floating point values in a single 32bit value. -/// +/// /// This function first converts each component of value into their nearest 16-bit floating /// point representation, and then stores the X and Y components in the lower and upper 16 bits of the /// 32bit unsigned integer respectively. /// /// @param [in] value A 2-dimensional floating point value to convert and pack. -/// +/// /// @returns /// A packed 32bit value containing 2 16bit floating point values. -/// -/// @ingroup HLSL +/// +/// @ingroup HLSLCore FfxUInt32 packHalf2x16(FfxFloat32x2 value) { return f32tof16(value.x) | (f32tof16(value.y) << 16); @@ -213,7 +246,7 @@ FfxUInt32 packHalf2x16(FfxFloat32x2 value) /// @returns /// A 2-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxBroadcast2(FfxFloat32 value) { return FfxFloat32x2(value, value); @@ -226,7 +259,7 @@ FfxFloat32x2 ffxBroadcast2(FfxFloat32 value) /// @returns /// A 3-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxBroadcast3(FfxFloat32 value) { return FfxFloat32x3(value, value, value); @@ -239,7 +272,7 @@ FfxFloat32x3 ffxBroadcast3(FfxFloat32 value) /// @returns /// A 4-dimensional floating point vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxBroadcast4(FfxFloat32 value) { return FfxFloat32x4(value, value, value, value); @@ -252,7 +285,7 @@ FfxFloat32x4 ffxBroadcast4(FfxFloat32 value) /// @returns /// A 2-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxInt32x2 ffxBroadcast2(FfxInt32 value) { return FfxInt32x2(value, value); @@ -265,7 +298,7 @@ FfxInt32x2 ffxBroadcast2(FfxInt32 value) /// @returns /// A 3-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxBroadcast3(FfxInt32 value) { return FfxUInt32x3(value, value, value); @@ -278,7 +311,7 @@ FfxUInt32x3 ffxBroadcast3(FfxInt32 value) /// @returns /// A 4-dimensional signed integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxInt32x4 ffxBroadcast4(FfxInt32 value) { return FfxInt32x4(value, value, value, value); @@ -291,7 +324,7 @@ FfxInt32x4 ffxBroadcast4(FfxInt32 value) /// @returns /// A 2-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxBroadcast2(FfxUInt32 value) { return FfxUInt32x2(value, value); @@ -304,7 +337,7 @@ FfxUInt32x2 ffxBroadcast2(FfxUInt32 value) /// @returns /// A 3-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxBroadcast3(FfxUInt32 value) { return FfxUInt32x3(value, value, value); @@ -317,7 +350,7 @@ FfxUInt32x3 ffxBroadcast3(FfxUInt32 value) /// @returns /// A 4-dimensional unsigned integer vector with value in each component. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxBroadcast4(FfxUInt32 value) { return FfxUInt32x4(value, value, value, value); @@ -342,12 +375,12 @@ FfxUInt32 bitfieldInsertMask(FfxUInt32 src, FfxUInt32 ins, FfxUInt32 bits) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxAsUInt32(FfxFloat32 x) { return asuint(x); @@ -355,12 +388,12 @@ FfxUInt32 ffxAsUInt32(FfxFloat32 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x) { return asuint(x); @@ -368,12 +401,12 @@ FfxUInt32x2 ffxAsUInt32(FfxFloat32x2 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x) { return asuint(x); @@ -381,12 +414,12 @@ FfxUInt32x3 ffxAsUInt32(FfxFloat32x3 x) /// Interprets the bit pattern of x as an unsigned integer. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as an unsigned integer. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x) { return asuint(x); @@ -394,12 +427,12 @@ FfxUInt32x4 ffxAsUInt32(FfxFloat32x4 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxAsFloat(FfxUInt32 x) { return asfloat(x); @@ -407,12 +440,12 @@ FfxFloat32 ffxAsFloat(FfxUInt32 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x) { return asfloat(x); @@ -420,12 +453,12 @@ FfxFloat32x2 ffxAsFloat(FfxUInt32x2 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x) { return asfloat(x); @@ -433,12 +466,12 @@ FfxFloat32x3 ffxAsFloat(FfxUInt32x3 x) /// Interprets the bit pattern of x as a floating-point number. /// -/// @param [in] value The input value. +/// @param [in] x The input value. /// /// @returns /// The input interpreted as a floating-point number. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x) { return asfloat(x); @@ -458,7 +491,7 @@ FfxFloat32x4 ffxAsFloat(FfxUInt32x4 x) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) { return lerp(x, y, t); @@ -478,7 +511,7 @@ FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32 t) { return lerp(x, y, t); @@ -498,7 +531,7 @@ FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 t) { return lerp(x, y, t); @@ -518,7 +551,7 @@ FfxFloat32x2 ffxLerp(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32 t) { return lerp(x, y, t); @@ -538,7 +571,7 @@ FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 t) { return lerp(x, y, t); @@ -558,7 +591,7 @@ FfxFloat32x3 ffxLerp(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32 t) { return lerp(x, y, t); @@ -578,7 +611,7 @@ FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32 t) /// @returns /// A linearly interpolated value between x and y according to t. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 t) { return lerp(x, y, t); @@ -591,7 +624,7 @@ FfxFloat32x4 ffxLerp(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 t) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxSaturate(FfxFloat32 x) { return saturate(x); @@ -604,7 +637,7 @@ FfxFloat32 ffxSaturate(FfxFloat32 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxSaturate(FfxFloat32x2 x) { return saturate(x); @@ -617,7 +650,7 @@ FfxFloat32x2 ffxSaturate(FfxFloat32x2 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxSaturate(FfxFloat32x3 x) { return saturate(x); @@ -630,7 +663,7 @@ FfxFloat32x3 ffxSaturate(FfxFloat32x3 x) /// @returns /// The clamped version of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxSaturate(FfxFloat32x4 x) { return saturate(x); @@ -645,11 +678,11 @@ FfxFloat32x4 ffxSaturate(FfxFloat32x4 x) /// function. /// /// @param [in] x The value to compute the fractional part from. -/// +/// /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxFract(FfxFloat32 x) { return x - floor(x); @@ -668,7 +701,7 @@ FfxFloat32 ffxFract(FfxFloat32 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxFract(FfxFloat32x2 x) { return x - floor(x); @@ -687,7 +720,7 @@ FfxFloat32x2 ffxFract(FfxFloat32x2 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxFract(FfxFloat32x3 x) { return x - floor(x); @@ -698,7 +731,7 @@ FfxFloat32x3 ffxFract(FfxFloat32x3 x) /// 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 +/// 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. @@ -706,7 +739,7 @@ FfxFloat32x3 ffxFract(FfxFloat32x3 x) /// @returns /// The fractional part of x. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxFract(FfxFloat32x4 x) { return x - floor(x); @@ -715,15 +748,15 @@ FfxFloat32x4 ffxFract(FfxFloat32x4 x) /// 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 HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return max(x, max(y, z)); @@ -732,7 +765,7 @@ FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 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. @@ -740,7 +773,7 @@ FfxFloat32 ffxMax3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return max(x, max(y, z)); @@ -749,7 +782,7 @@ FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 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. @@ -757,7 +790,7 @@ FfxFloat32x2 ffxMax3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return max(x, max(y, z)); @@ -774,7 +807,7 @@ FfxFloat32x3 ffxMax3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return max(x, max(y, z)); @@ -791,7 +824,7 @@ FfxFloat32x4 ffxMax3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) { return max(x, max(y, z)); @@ -808,7 +841,7 @@ FfxUInt32 ffxMax3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) { return max(x, max(y, z)); @@ -825,7 +858,7 @@ FfxUInt32x2 ffxMax3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) { return max(x, max(y, z)); @@ -842,7 +875,7 @@ FfxUInt32x3 ffxMax3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// @returns /// The maximum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) { return max(x, max(y, z)); @@ -859,7 +892,7 @@ FfxUInt32x4 ffxMax3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMed3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return max(min(x, y), min(max(x, y), z)); @@ -876,7 +909,7 @@ FfxFloat32 ffxMed3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMed3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return max(min(x, y), min(max(x, y), z)); @@ -893,7 +926,7 @@ FfxFloat32x2 ffxMed3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMed3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return max(min(x, y), min(max(x, y), z)); @@ -910,7 +943,7 @@ FfxFloat32x3 ffxMed3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The median value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMed3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return max(min(x, y), min(max(x, y), z)); @@ -990,7 +1023,7 @@ FfxInt32x4 ffxMed3(FfxInt32x4 x, FfxInt32x4 y, FfxInt32x4 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -999,7 +1032,7 @@ FfxInt32x4 ffxMed3(FfxInt32x4 x, FfxInt32x4 y, FfxInt32x4 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) { return min(x, min(y, z)); @@ -1007,7 +1040,7 @@ FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -1016,7 +1049,7 @@ FfxFloat32 ffxMin3(FfxFloat32 x, FfxFloat32 y, FfxFloat32 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) { return min(x, min(y, z)); @@ -1024,7 +1057,7 @@ FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_I32 operation on GCN/RDNA hardware. +/// 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. @@ -1033,7 +1066,7 @@ FfxFloat32x2 ffxMin3(FfxFloat32x2 x, FfxFloat32x2 y, FfxFloat32x2 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) { return min(x, min(y, z)); @@ -1041,7 +1074,7 @@ FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1050,7 +1083,7 @@ FfxFloat32x3 ffxMin3(FfxFloat32x3 x, FfxFloat32x3 y, FfxFloat32x3 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) { return min(x, min(y, z)); @@ -1058,7 +1091,7 @@ FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1067,7 +1100,7 @@ FfxFloat32x4 ffxMin3(FfxFloat32x4 x, FfxFloat32x4 y, FfxFloat32x4 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) { return min(x, min(y, z)); @@ -1075,7 +1108,7 @@ FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1084,7 +1117,7 @@ FfxUInt32 ffxMin3(FfxUInt32 x, FfxUInt32 y, FfxUInt32 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) { return min(x, min(y, z)); @@ -1092,16 +1125,16 @@ FfxUInt32x2 ffxMin3(FfxUInt32x2 x, FfxUInt32x2 y, FfxUInt32x2 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. +/// @param [in] y The second value to include in the min calculation. +/// @param [in] z The third value to include in the min calculation. /// /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) { return min(x, min(y, z)); @@ -1109,7 +1142,7 @@ FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// Compute the minimum of three values. /// -/// NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware. +/// 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. @@ -1118,7 +1151,7 @@ FfxUInt32x3 ffxMin3(FfxUInt32x3 x, FfxUInt32x3 y, FfxUInt32x3 z) /// @returns /// The minimum value of x, y, and z. /// -/// @ingroup HLSL +/// @ingroup HLSLCore FfxUInt32x4 ffxMin3(FfxUInt32x4 x, FfxUInt32x4 y, FfxUInt32x4 z) { return min(x, min(y, z)); @@ -1130,11 +1163,18 @@ FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b) return FfxUInt32(FfxInt32(a) >> FfxInt32(b)); } +FfxUInt32 ffxPackF32(FfxFloat32x2 v){ + FfxUInt32x2 p = FfxUInt32x2(f32tof16(FfxFloat32x2(v).x), f32tof16(FfxFloat32x2(v).y)); + return p.x | (p.y << 16); +} + +FfxFloat32x2 ffxUnpackF32(FfxUInt32 a){ + return f16tof32(FfxUInt32x2(a & 0xFFFF, a >> 16)); +} + //============================================================================================================================== // HLSL HALF //============================================================================================================================== -#if FFX_HALF - //============================================================================================================================== // Need to use manual unpack to get optimal execution (don't use packed types in buffers directly). // Unpack requires this pattern: https://gpuopen.com/first-steps-implementing-fp16/ @@ -1156,10 +1196,59 @@ FFX_MIN16_U4 ffxUint32x2ToUint16x4(FfxUInt32x2 x) { return FFX_MIN16_U4(ffxUint32ToUint16x2(x.x), ffxUint32ToUint16x2(x.y)); } + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32 ffxInvertSafe(FfxFloat32 v){ + FfxFloat32 s = sign(v); + FfxFloat32 s2 = s*s; + return s2/(v + s2 - 1.0); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x2 ffxInvertSafe(FfxFloat32x2 v){ + FfxFloat32x2 s = sign(v); + FfxFloat32x2 s2 = s*s; + return s2/(v + s2 - FfxFloat32x2(1.0, 1.0)); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x3 ffxInvertSafe(FfxFloat32x3 v){ + FfxFloat32x3 s = sign(v); + FfxFloat32x3 s2 = s*s; + return s2/(v + s2 - FfxFloat32x3(1.0, 1.0, 1.0)); +} + +/// @brief Inverts the value while avoiding division by zero. If the value is zero, zero is returned. +/// @param v Value to invert. +/// @return If v = 0 returns 0. If v != 0 returns 1/v. +FfxFloat32x4 ffxInvertSafe(FfxFloat32x4 v){ + FfxFloat32x4 s = sign(v); + FfxFloat32x4 s2 = s*s; + return s2/(v + s2 - FfxFloat32x4(1.0, 1.0, 1.0, 1.0)); +} + #define FFX_UINT32_TO_FLOAT16X2(x) ffxUint32ToFloat16x2(FfxUInt32(x)) +#if FFX_HALF + #define FFX_UINT32X2_TO_FLOAT16X4(x) ffxUint32x2ToFloat16x4(FfxUInt32x2(x)) #define FFX_UINT32_TO_UINT16X2(x) ffxUint32ToUint16x2(FfxUInt32(x)) #define FFX_UINT32X2_TO_UINT16X4(x) ffxUint32x2ToUint16x4(FfxUInt32x2(x)) + +FfxUInt32 ffxPackF16(FfxFloat16x2 v){ + FfxUInt32x2 p = FfxUInt32x2(f32tof16(FfxFloat32x2(v).x), f32tof16(FfxFloat32x2(v).y)); + return p.x | (p.y << 16); +} + +FfxFloat16x2 ffxUnpackF16(FfxUInt32 a){ + return FfxFloat16x2(f16tof32(FfxUInt32x2(a & 0xFFFF, a >> 16))); +} + //------------------------------------------------------------------------------------------------------------------------------ FfxUInt32 FFX_MIN16_F2ToUint32(FFX_MIN16_F2 x) { @@ -1182,7 +1271,7 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_UINT16X2_TO_UINT32(x) FFX_MIN16_U2ToUint32(FFX_MIN16_U2(x)) #define FFX_UINT16X4_TO_UINT32X2(x) FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4(x)) -#if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#if (FFX_HLSL_SM >= 62) && !defined(FFX_NO_16_BIT_CAST) #define FFX_TO_UINT16(x) asuint16(x) #define FFX_TO_UINT16X2(x) asuint16(x) #define FFX_TO_UINT16X3(x) asuint16(x) @@ -1192,9 +1281,9 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_TO_UINT16X2(a) FFX_MIN16_U2(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y)) #define FFX_TO_UINT16X3(a) FFX_MIN16_U3(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y), FFX_TO_UINT16((a).z)) #define FFX_TO_UINT16X4(a) FFX_MIN16_U4(FFX_TO_UINT16((a).x), FFX_TO_UINT16((a).y), FFX_TO_UINT16((a).z), FFX_TO_UINT16((a).w)) -#endif // #if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#endif // #if (FFX_HLSL_SM>=62) && !defined(FFX_NO_16_BIT_CAST) -#if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#if (FFX_HLSL_SM >= 62) && !defined(FFX_NO_16_BIT_CAST) #define FFX_TO_FLOAT16(x) asfloat16(x) #define FFX_TO_FLOAT16X2(x) asfloat16(x) #define FFX_TO_FLOAT16X3(x) asfloat16(x) @@ -1204,7 +1293,7 @@ FfxUInt32x2 FFX_MIN16_U4ToUint32x2(FFX_MIN16_U4 x) #define FFX_TO_FLOAT16X2(a) FFX_MIN16_F2(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y)) #define FFX_TO_FLOAT16X3(a) FFX_MIN16_F3(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y), FFX_TO_FLOAT16((a).z)) #define FFX_TO_FLOAT16X4(a) FFX_MIN16_F4(FFX_TO_FLOAT16((a).x), FFX_TO_FLOAT16((a).y), FFX_TO_FLOAT16((a).z), FFX_TO_FLOAT16((a).w)) -#endif // #if defined(FFX_HLSL_6_2) && !defined(FFX_NO_16_BIT_CAST) +#endif // #if (FFX_HLSL_SM>=62) && !defined(FFX_NO_16_BIT_CAST) //============================================================================================================================== #define FFX_BROADCAST_FLOAT16(a) FFX_MIN16_F(a) @@ -1480,6 +1569,66 @@ FfxUInt32x4 AWaveXorU1(FfxUInt32x4 v, FfxUInt32 x) { return WaveReadLaneAt(v, WaveGetLaneIndex() ^ x); } +FfxBoolean AWaveIsFirstLane() +{ + return WaveIsFirstLane(); +} +FfxUInt32 AWaveLaneIndex() +{ + return WaveGetLaneIndex(); +} +FfxBoolean AWaveReadAtLaneIndexB1(FfxBoolean v, FfxUInt32 x) +{ + return WaveReadLaneAt(v, x); +} +FfxUInt32 AWavePrefixCountBits(FfxBoolean v) +{ + return WavePrefixCountBits(v); +} +FfxUInt32 AWaveActiveCountBits(FfxBoolean v) +{ + return WaveActiveCountBits(v); +} +FfxUInt32 AWaveReadLaneFirstU1(FfxUInt32 v) +{ + return WaveReadLaneFirst(v); +} +FfxUInt32 WaveOr(FfxUInt32 a) +{ + return WaveActiveBitOr(a); +} +FfxFloat32 WaveMin(FfxFloat32 a) +{ + return WaveActiveMin(a); +} +FfxFloat32 WaveMax(FfxFloat32 a) +{ + return WaveActiveMax(a); +} +FfxUInt32 WaveLaneCount() +{ + return WaveGetLaneCount(); +} +FfxBoolean WaveAllTrue(FfxBoolean v) +{ + return WaveActiveAllTrue(v); +} +FfxFloat32 QuadReadX(FfxFloat32 v) +{ + return QuadReadAcrossX(v); +} +FfxFloat32x2 QuadReadX(FfxFloat32x2 v) +{ + return QuadReadAcrossX(v); +} +FfxFloat32 QuadReadY(FfxFloat32 v) +{ + return QuadReadAcrossY(v); +} +FfxFloat32x2 QuadReadY(FfxFloat32x2 v) +{ + return QuadReadAcrossY(v); +} #if FFX_HALF FfxFloat16x2 ffxWaveXorFloat16x2(FfxFloat16x2 v, FfxUInt32 x) @@ -1496,7 +1645,7 @@ FfxUInt16x2 ffxWaveXorUint16x2(FfxUInt16x2 v, FfxUInt32 x) } FfxUInt16x4 ffxWaveXorUint16x4(FfxUInt16x4 v, FfxUInt32 x) { - return AW4_FFX_UINT32(WaveReadLaneAt(FFX_UINT32_AW4(v), WaveGetLaneIndex() ^ x)); + return FFX_UINT32X2_TO_UINT16X4(WaveReadLaneAt(FFX_UINT16X4_TO_UINT32X2(v), WaveGetLaneIndex() ^ x)); } #endif // FFX_HALF #endif // #if defined(FFX_WAVE) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta new file mode 100644 index 0000000..ff56bee --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_hlsl.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 299f67e8b7e1d1a48a577bf8b328ac92 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h similarity index 94% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h index 45be059..84a62d6 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_core_portability.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,6 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + FfxFloat32x3 opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b) { d = a + ffxBroadcast3(b); diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta new file mode 100644 index 0000000..25ff64b --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_core_portability.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 8d2ace0bd52e0e1438e08ddaccd3ba24 +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.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h similarity index 90% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h index 7bd5892..c425de7 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_accumulate.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_ACCUMULATE_H -#define FFX_FSR2_ACCUMULATE_H + +#ifndef FFX_FSR3UPSCALER_ACCUMULATE_H +#define FFX_FSR3UPSCALER_ACCUMULATE_H FfxFloat32 GetPxHrVelocity(FfxFloat32x2 fMotionVector) { @@ -36,9 +37,9 @@ FFX_MIN16_F GetPxHrVelocity(FFX_MIN16_F2 fMotionVector) void Accumulate(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT FfxFloat32x3 fHistoryColor, FfxFloat32x3 fAccumulation, FFX_PARAMETER_IN FfxFloat32x4 fUpsampledColorAndWeight) { // Aviod invalid values when accumulation and upsampled weight is 0 - fAccumulation = ffxMax(FSR2_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www); + fAccumulation = ffxMax(FSR3UPSCALER_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT //YCoCg -> RGB -> Tonemap -> YCoCg (Use RGB tonemapper to avoid color desaturation) fUpsampledColorAndWeight.xyz = RGBToYCoCg(Tonemap(YCoCgToRGB(fUpsampledColorAndWeight.xyz))); fHistoryColor = RGBToYCoCg(Tonemap(YCoCgToRGB(fHistoryColor))); @@ -49,7 +50,7 @@ void Accumulate(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT F fHistoryColor = YCoCgToRGB(fHistoryColor); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fHistoryColor = InverseTonemap(fHistoryColor); #endif } @@ -63,20 +64,13 @@ void RectifyHistory( FfxFloat32 fTemporalReactiveFactor, FfxFloat32 fLumaInstabilityFactor) { - FfxFloat32 fScaleFactorInfluence = ffxMin(20.0f, ffxPow(FfxFloat32(1.0f / length(DownscaleFactor().x * DownscaleFactor().y)), 3.0f)); - const FfxFloat32 fVecolityFactor = ffxSaturate(params.fHrVelocity / 20.0f); const FfxFloat32 fBoxScaleT = ffxMax(params.fDepthClipFactor, ffxMax(params.fAccumulationMask, fVecolityFactor)); - FfxFloat32 fBoxScale = ffxLerp(fScaleFactorInfluence, 1.0f, fBoxScaleT); - - FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale; - FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec; - FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec; - FfxFloat32x3 boxCenter = clippingBox.boxCenter; - FfxFloat32 boxVecSize = length(clippingBox.boxVec); + const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT); - boxMin = ffxMax(clippingBox.aabbMin, boxMin); - boxMax = ffxMin(clippingBox.aabbMax, boxMax); + const FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale; + const FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec; + const FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec; if (any(FFX_GREATER_THAN(boxMin, fHistoryColor)) || any(FFX_GREATER_THAN(fHistoryColor, boxMax))) { @@ -143,7 +137,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param FfxFloat32 fCurrentFrameLuma = clippingBox.boxCenter.x; -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fCurrentFrameLuma = fCurrentFrameLuma / (1.0f + ffxMax(0.0f, fCurrentFrameLuma)); #endif @@ -157,8 +151,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param FfxFloat32 fMin = abs(fDiffs0); - if (fMin >= fUnormThreshold) - { + if (fMin >= fUnormThreshold) { for (int i = N_MINUS_2; i <= N_MINUS_4; i++) { FfxFloat32 fDiffs1 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[i]); @@ -170,7 +163,7 @@ FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams param } } - const FfxFloat32 fBoxSize = clippingBox.boxVec.x; + const FfxFloat32 fBoxSize = clippingBox.boxVec.x; const FfxFloat32 fBoxSizeFactor = ffxPow(ffxSaturate(fBoxSize / 0.1f), 6.0f); fLumaInstability = FfxFloat32(fMin != abs(fDiffs0)) * fBoxSizeFactor; @@ -202,7 +195,7 @@ FfxFloat32 ComputeTemporalReactiveFactor(const AccumulationPassCommonParams para fNewFactor = params.bIsNewSample ? 1.0f : fNewFactor; if (ffxSaturate(params.fHrVelocity * 10.0f) >= 1.0f) { - fNewFactor = ffxMax(FSR2_EPSILON, fNewFactor) * -1.0f; + fNewFactor = ffxMax(FSR3UPSCALER_EPSILON, fNewFactor) * -1.0f; } return fNewFactor; @@ -286,10 +279,10 @@ void Accumulate(FfxInt32x2 iPxHrPos) StoreInternalColorAndWeight(iPxHrPos, FfxFloat32x4(fHistoryColor, fTemporalReactiveFactor)); // Output final color when RCAS is disabled -#if FFX_FSR2_OPTION_APPLY_SHARPENING == 0 +#if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0 WriteUpscaledOutput(iPxHrPos, fHistoryColor); #endif StoreNewLocks(iPxHrPos, 0); } -#endif // FFX_FSR2_ACCUMULATE_H +#endif // FFX_FSR3UPSCALER_ACCUMULATE_H diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta new file mode 100644 index 0000000..08c98e7 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 3fc2f7a2c8c31324a949e1761bf599cc +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/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h new file mode 100644 index 0000000..c70bc1d --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h @@ -0,0 +1,928 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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_fsr3upscaler_resources.h" + +#if defined(FFX_GPU) +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic push +#pragma dxc diagnostic ignored "-Wambig-lit-shift" +#endif //__hlsl_dx_compiler +#include "ffx_core.h" +#ifdef __hlsl_dx_compiler +#pragma dxc diagnostic pop +#endif //__hlsl_dx_compiler +#endif // #if defined(FFX_GPU) + +#if defined(FFX_GPU) +#ifndef FFX_PREFER_WAVE64 +#define FFX_PREFER_WAVE64 +#endif // FFX_PREFER_WAVE64 + +#if defined(FFX_GPU) +#pragma warning(disable: 3205) // conversion from larger type to smaller +#endif // #if defined(FFX_GPU) + +#define DECLARE_SRV_REGISTER(regIndex) t##regIndex +#define DECLARE_UAV_REGISTER(regIndex) u##regIndex +#define DECLARE_CB_REGISTER(regIndex) b##regIndex +#define FFX_FSR3UPSCALER_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) +#define FFX_FSR3UPSCALER_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) +#define FFX_FSR3UPSCALER_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) + +#if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + cbuffer cbFSR3Upscaler : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + { + 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; + + FfxInt32 iDummy; + }; + +#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR3Upscaler) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR3Upscaler size. + +/* Define getter functions in the order they are defined in the CB! */ +FfxInt32x2 RenderSize() +{ + return iRenderSize; +} + +FfxInt32x2 MaxRenderSize() +{ + return iMaxRenderSize; +} + +FfxInt32x2 DisplaySize() +{ + return iDisplaySize; +} + +FfxInt32x2 InputColorResourceDimensions() +{ + return iInputColorResourceDimensions; +} + +FfxInt32x2 LumaMipDimensions() +{ + return iLumaMipDimensions; +} + +FfxInt32 LumaMipLevelToUse() +{ + return iLumaMipLevelToUse; +} + +FfxInt32 FrameIndex() +{ + return iFrameIndex; +} + +FfxFloat32x2 Jitter() +{ + return fJitter; +} + +FfxFloat32x4 DeviceToViewSpaceTransformFactors() +{ + return fDeviceToViewDepth; +} + +FfxFloat32x2 MotionVectorScale() +{ + return fMotionVectorScale; +} + +FfxFloat32x2 DownscaleFactor() +{ + return fDownscaleFactor; +} + +FfxFloat32x2 MotionVectorJitterCancellation() +{ + return fMotionVectorJitterCancellation; +} + +FfxFloat32 PreExposure() +{ + return fPreExposure; +} + +FfxFloat32 PreviousFramePreExposure() +{ + return fPreviousFramePreExposure; +} + +FfxFloat32 TanHalfFoV() +{ + return fTanHalfFOV; +} + +FfxFloat32 JitterSequenceLength() +{ + return fJitterSequenceLength; +} + +FfxFloat32 DeltaTime() +{ + return fDeltaTime; +} + +FfxFloat32 DynamicResChangeFactor() +{ + return fDynamicResChangeFactor; +} + +FfxFloat32 ViewSpaceToMetersFactor() +{ + return fViewSpaceToMetersFactor; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER) + +#define FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(p) FFX_FSR3UPSCALER_ROOTSIG_STR(p) +#define FFX_FSR3UPSCALER_ROOTSIG_STR(p) #p +#define FFX_FSR3UPSCALER_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", b0), " \ + "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ + "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] + +#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE 6 // Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size. + +#define FFX_FSR3UPSCALER_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", b0), " \ + "RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE) ", b1), " \ + "StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ + "StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ + "addressU = TEXTURE_ADDRESS_CLAMP, " \ + "addressV = TEXTURE_ADDRESS_CLAMP, " \ + "addressW = TEXTURE_ADDRESS_CLAMP, " \ + "comparisonFunc = COMPARISON_NEVER, " \ + "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] +#if defined(FFX_FSR3UPSCALER_EMBED_ROOTSIG) +#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT FFX_FSR3UPSCALER_ROOTSIG +#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT FFX_FSR3UPSCALER_CB2_ROOTSIG +#else +#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT +#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT +#endif // #if FFX_FSR3UPSCALER_EMBED_ROOTSIG + +#if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) +cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) +{ + FfxFloat32 fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels + FfxFloat32 fTcScale; + FfxFloat32 fReactiveScale; + FfxFloat32 fReactiveMax; +}; + +FfxFloat32 TcThreshold() +{ + return fTcThreshold; +} + +FfxFloat32 TcScale() +{ + return fTcScale; +} + +FfxFloat32 ReactiveScale() +{ + return fReactiveScale; +} + +FfxFloat32 ReactiveMax() +{ + return fReactiveMax; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE) + +#if defined(FSR3UPSCALER_BIND_CB_RCAS) +cbuffer cbRCAS : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_RCAS) +{ + FfxUInt32x4 rcasConfig; +}; + +FfxUInt32x4 RCASConfig() +{ + return rcasConfig; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_RCAS) + + +#if defined(FSR3UPSCALER_BIND_CB_REACTIVE) +cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_REACTIVE) +{ + FfxFloat32 gen_reactive_scale; + FfxFloat32 gen_reactive_threshold; + FfxFloat32 gen_reactive_binaryValue; + FfxUInt32 gen_reactive_flags; +}; + +FfxFloat32 GenReactiveScale() +{ + return gen_reactive_scale; +} + +FfxFloat32 GenReactiveThreshold() +{ + return gen_reactive_threshold; +} + +FfxFloat32 GenReactiveBinaryValue() +{ + return gen_reactive_binaryValue; +} + +FfxUInt32 GenReactiveFlags() +{ + return gen_reactive_flags; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_REACTIVE) + +#if defined(FSR3UPSCALER_BIND_CB_SPD) +cbuffer cbSPD : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_SPD) { + + FfxUInt32 mips; + FfxUInt32 numWorkGroups; + FfxUInt32x2 workGroupOffset; + FfxUInt32x2 renderSize; +}; + +FfxUInt32 MipCount() +{ + return mips; +} + +FfxUInt32 NumWorkGroups() +{ + return numWorkGroups; +} + +FfxUInt32x2 WorkGroupOffset() +{ + return workGroupOffset; +} + +FfxUInt32x2 SPD_RenderSize() +{ + return renderSize; +} +#endif // #if defined(FSR3UPSCALER_BIND_CB_SPD) + +// Declare and sample camera buffers as regular textures, unless overridden +#if !defined(UNITY_FSR3_TEX2D) +#define UNITY_FSR3_TEX2D(type) Texture2D +#endif +#if !defined(UNITY_FSR3_RWTEX2D) +#define UNITY_FSR3_RWTEX2D(type) RWTexture2D +#endif +#if !defined(UNITY_FSR3_POS) +#define UNITY_FSR3_POS(pxPos) (pxPos) +#endif +#if !defined(UNITY_FSR3_UV) +#define UNITY_FSR3_UV(uv) (uv) +#endif + +SamplerState s_PointClamp : register(s0); +SamplerState s_LinearClamp : register(s1); + + // SRVs + #if defined FSR3UPSCALER_BIND_SRV_INPUT_COLOR + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS + UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_DEPTH + UNITY_FSR3_TEX2D(FfxFloat32) r_input_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE + Texture2D r_input_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE + Texture2D r_auto_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_SRV_REACTIVE_MASK + Texture2D r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK); + #endif + #if defined FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK + Texture2D r_transparency_and_composition_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); + #endif + #if defined FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH + Texture2D r_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS + Texture2D r_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS + Texture2D r_previous_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_DEPTH + Texture2D r_dilated_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED + Texture2D r_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LOCK_STATUS + Texture2D r_lock_status : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_STATUS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA + Texture2D r_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA); + #endif + #if defined FSR3UPSCALER_BIND_SRV_NEW_LOCKS + Texture2D r_new_locks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_NEW_LOCKS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR + Texture2D r_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LUMA_HISTORY + Texture2D r_luma_history : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY); + #endif + #if defined FSR3UPSCALER_BIND_SRV_RCAS_INPUT + Texture2D r_rcas_input : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RCAS_INPUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_LANCZOS_LUT + Texture2D r_lanczos_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS + Texture2D r_imgMips : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS); + #endif + #if defined FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT + Texture2D r_upsample_maximum_bias_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT); + #endif + #if defined FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS + Texture2D r_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS); + #endif + + #if defined FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR + Texture2D r_input_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR + Texture2D r_input_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR); + #endif + + // UAV declarations + #if defined FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH + RWTexture2D rw_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS + RWTexture2D rw_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_DEPTH + RWTexture2D rw_dilated_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH); + #endif + #if defined FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED + RWTexture2D rw_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LOCK_STATUS + RWTexture2D rw_lock_status : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_STATUS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA + RWTexture2D rw_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA); + #endif + #if defined FSR3UPSCALER_BIND_UAV_NEW_LOCKS + RWTexture2D rw_new_locks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_NEW_LOCKS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR + RWTexture2D rw_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_UAV_LUMA_HISTORY + RWTexture2D rw_luma_history : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY); + #endif + #if defined FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT + UNITY_FSR3_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + globallycoherent RWTexture2D rw_img_mip_shading_change : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + globallycoherent RWTexture2D rw_img_mip_5 : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5); + #endif + #if defined FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS + RWTexture2D rw_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS); + #endif + #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE + RWTexture2D rw_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + RWTexture2D rw_auto_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + globallycoherent RWTexture2D rw_spd_global_atomic : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC); + #endif + + #if defined FSR3UPSCALER_BIND_UAV_AUTOREACTIVE + RWTexture2D rw_output_autoreactive : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE); + #endif + #if defined FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION + RWTexture2D rw_output_autocomposition : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR + RWTexture2D rw_output_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR); + #endif + #if defined FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR + RWTexture2D rw_output_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR); + #endif + +#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS) +FfxFloat32 LoadMipLuma(FfxUInt32x2 iPxPos, FfxUInt32 mipLevel) +{ + return r_imgMips.mips[mipLevel][iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS) +FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) +{ + return r_imgMips.SampleLevel(s_LinearClamp, fUV, mipLevel); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) +FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) +{ + return r_input_depth[UNITY_FSR3_POS(iPxPos)]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) +FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) +{ + return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).x; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK) +FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) +{ + return r_reactive_mask[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) +FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) +{ + return r_transparency_and_composition_mask[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) +FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) +{ + return r_input_color_jittered[UNITY_FSR3_POS(iPxPos)].rgb; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) +FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) +{ + return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).rgb; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR) +FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos) +{ + return r_prepared_input_color[iPxPos].xyz; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS) +FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) +{ + FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR3_POS(iPxDilatedMotionVectorPos)].xy; + + FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); + +#if FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS + fUvMotionVector -= MotionVectorJitterCancellation(); +#endif + + return fUvMotionVector; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED) +FfxFloat32x4 LoadHistory(FfxUInt32x2 iPxHistory) +{ + return r_internal_upscaled_color[iPxHistory]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY) +void StoreLumaHistory(FfxUInt32x2 iPxPos, FfxFloat32x4 fLumaHistory) +{ + rw_luma_history[iPxPos] = fLumaHistory; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY) +FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV) +{ + return r_luma_history.SampleLevel(s_LinearClamp, fUV, 0); +} +#endif + +FfxFloat32x4 LoadRCAS_Input(FfxInt32x2 iPxPos) +{ +#if defined(FSR3UPSCALER_BIND_SRV_RCAS_INPUT) + return r_rcas_input[iPxPos]; +#else + return 0.0; +#endif +} + +#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED) +void StoreReprojectedHistory(FfxUInt32x2 iPxHistory, FfxFloat32x4 fHistory) +{ + rw_internal_upscaled_color[iPxHistory] = fHistory; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED) +void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight) +{ + rw_internal_upscaled_color[iPxPos] = fColorAndWeight; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT) +void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) +{ + rw_upscaled_output[UNITY_FSR3_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); +} +#endif + +//LOCK_LIFETIME_REMAINING == 0 +//Should make LockInitialLifetime() return a const 1.0f later +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS) +FfxFloat32x2 LoadLockStatus(FfxUInt32x2 iPxPos) +{ + return r_lock_status[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LOCK_STATUS) +void StoreLockStatus(FfxUInt32x2 iPxPos, FfxFloat32x2 fLockStatus) +{ + rw_lock_status[iPxPos] = fLockStatus; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA) +FfxFloat32 LoadLockInputLuma(FfxUInt32x2 iPxPos) +{ + return r_lock_input_luma[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA) +void StoreLockInputLuma(FfxUInt32x2 iPxPos, FfxFloat32 fLuma) +{ + rw_lock_input_luma[iPxPos] = fLuma; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_NEW_LOCKS) +FfxFloat32 LoadNewLocks(FfxUInt32x2 iPxPos) +{ + return r_new_locks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS) +FfxFloat32 LoadRwNewLocks(FfxUInt32x2 iPxPos) +{ + return rw_new_locks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS) +void StoreNewLocks(FfxUInt32x2 iPxPos, FfxFloat32 newLock) +{ + rw_new_locks[iPxPos] = newLock; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR) +void StorePreparedInputColor(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped) +{ + rw_prepared_input_color[iPxPos] = fTonemapped; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR) +FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV) +{ + return r_prepared_input_color.SampleLevel(s_LinearClamp, fUV, 0).w; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS) +FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV) +{ + FfxFloat32x2 fLockStatus = r_lock_status.SampleLevel(s_LinearClamp, fUV, 0); + return fLockStatus; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +FfxFloat32 LoadReconstructedPrevDepth(FfxUInt32x2 iPxPos) +{ + return asfloat(r_reconstructed_previous_nearest_depth[iPxPos]); +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +void StoreReconstructedDepth(FfxUInt32x2 iPxSample, FfxFloat32 fDepth) +{ + FfxUInt32 uDepth = asuint(fDepth); + + #if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH + InterlockedMax(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); + #else + InterlockedMin(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); // min for standard, max for inverted depth + #endif +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH) +void SetReconstructedDepth(FfxUInt32x2 iPxSample, const FfxUInt32 uValue) +{ + rw_reconstructed_previous_nearest_depth[iPxSample] = uValue; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH) +void StoreDilatedDepth(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth) +{ + rw_dilated_depth[iPxPos] = fDepth; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS) +void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector) +{ + rw_dilated_motion_vectors[iPxPos] = fMotionVector; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS) +FfxFloat32x2 LoadDilatedMotionVector(FfxUInt32x2 iPxInput) +{ + return r_dilated_motion_vectors[iPxInput].xy; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS) +FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxUInt32x2 iPxInput) +{ + return r_previous_dilated_motion_vectors[iPxInput].xy; +} + +FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 uv) +{ + return r_previous_dilated_motion_vectors.SampleLevel(s_LinearClamp, uv, 0).xy; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH) +FfxFloat32 LoadDilatedDepth(FfxUInt32x2 iPxInput) +{ + return r_dilated_depth[iPxInput]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE) +FfxFloat32 Exposure() +{ + FfxFloat32 exposure = r_input_exposure[FfxUInt32x2(0, 0)].x; + + if (exposure == 0.0f) { + exposure = 1.0f; + } + + return exposure; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE) +FfxFloat32 AutoExposure() +{ + FfxFloat32 exposure = r_auto_exposure[FfxUInt32x2(0, 0)].x; + + if (exposure == 0.0f) { + exposure = 1.0f; + } + + return exposure; +} +#endif + +FfxFloat32 SampleLanczos2Weight(FfxFloat32 x) +{ +#if defined(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT) + return r_lanczos_lut.SampleLevel(s_LinearClamp, FfxFloat32x2(x / 2, 0.5f), 0); +#else + return 0.f; +#endif +} + +#if defined(FSR3UPSCALER_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.0) * r_upsample_maximum_bias_lut.SampleLevel(s_LinearClamp, abs(uv) * 2.0, 0); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS) +FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV) +{ + return r_dilated_reactive_masks.SampleLevel(s_LinearClamp, fUV, 0); +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS) +FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos) +{ + return r_dilated_reactive_masks[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS) +void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks) +{ + rw_dilated_reactive_masks[iPxPos] = fDilatedReactiveMasks; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY) +FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_opaque_only[UNITY_FSR3_POS(iPxPos)].xyz; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR) +FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_prev_color_pre_alpha[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR) +FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) +{ + return r_input_prev_color_post_alpha[iPxPos]; +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE) +#if defined(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION) +void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive) +{ + rw_output_autoreactive[iPxPos] = fReactive.x; + + rw_output_autocomposition[iPxPos] = fReactive.y; +} +#endif +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR) +void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) +{ + rw_output_prev_color_pre_alpha[iPxPos] = color; + +} +#endif + +#if defined(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR) +void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color) +{ + rw_output_prev_color_post_alpha[iPxPos] = color; +} +#endif + +FfxFloat32x2 SPD_LoadExposureBuffer() +{ +#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + return rw_auto_exposure[FfxInt32x2(0, 0)]; +#else + return FfxFloat32x2(0.f, 0.f); +#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE +} + +void SPD_SetExposureBuffer(FfxFloat32x2 value) +{ +#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE + rw_auto_exposure[FfxInt32x2(0, 0)] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE +} + +FfxFloat32x4 SPD_LoadMipmap5(FfxInt32x2 iPxPos) +{ +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + return FfxFloat32x4(rw_img_mip_5[iPxPos], 0, 0, 0); +#else + return FfxFloat32x4(0.f, 0.f, 0.f, 0.f); +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 +} + +void SPD_SetMipmap(FfxInt32x2 iPxPos, FfxUInt32 slice, FfxFloat32 value) +{ + switch (slice) + { + case FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL: +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + rw_img_mip_shading_change[iPxPos] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE + break; + case 5: +#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + rw_img_mip_5[iPxPos] = value; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + break; + default: + + // avoid flattened side effect +#if defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE) + rw_img_mip_shading_change[iPxPos] = rw_img_mip_shading_change[iPxPos]; +#elif defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5) + rw_img_mip_5[iPxPos] = rw_img_mip_5[iPxPos]; +#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 + break; + } +} + +void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter) +{ +#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + InterlockedAdd(rw_spd_global_atomic[FfxInt32x2(0, 0)], 1, spdCounter); +#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC +} + +void SPD_ResetAtomicCounter() +{ +#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC + rw_spd_global_atomic[FfxInt32x2(0, 0)] = 0; +#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC +} + +#endif // #if defined(FFX_GPU) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta new file mode 100644 index 0000000..e060d2c --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: ba849fdeb042e7f458c81408414db834 +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_common.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h similarity index 91% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_common.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h index 0c72aa8..1f78a29 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_common.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if !defined(FFX_FSR2_COMMON_H) -#define FFX_FSR2_COMMON_H + +#if !defined(FFX_FSR3UPSCALER_COMMON_H) +#define FFX_FSR3UPSCALER_COMMON_H #if defined(FFX_CPU) || defined(FFX_GPU) //Locks @@ -29,12 +30,12 @@ #endif // #if defined(FFX_CPU) || defined(FFX_GPU) #if defined(FFX_GPU) -FFX_STATIC const FfxFloat32 FSR2_FP16_MIN = 6.10e-05f; -FFX_STATIC const FfxFloat32 FSR2_FP16_MAX = 65504.0f; -FFX_STATIC const FfxFloat32 FSR2_EPSILON = 1e-03f; -FFX_STATIC const FfxFloat32 FSR2_TONEMAP_EPSILON = 1.0f / FSR2_FP16_MAX; -FFX_STATIC const FfxFloat32 FSR2_FLT_MAX = 3.402823466e+38f; -FFX_STATIC const FfxFloat32 FSR2_FLT_MIN = 1.175494351e-38f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MIN = 6.10e-05f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MAX = 65504.0f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_EPSILON = 1e-03f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_TONEMAP_EPSILON = 1.0f / FSR3UPSCALER_FP16_MAX; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MAX = 3.402823466e+38f; +FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MIN = 1.175494351e-38f; // treat vector truncation warnings as errors #pragma warning(error: 3206) @@ -128,8 +129,8 @@ void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBox rectificationBox rectificationBox.boxCenter = FfxFloat32x3(0, 0, 0); rectificationBox.boxVec = FfxFloat32x3(0, 0, 0); - rectificationBox.aabbMin = FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX); - rectificationBox.aabbMax = -FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX); + rectificationBox.aabbMin = FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX); + rectificationBox.aabbMax = -FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX); } #if FFX_HALF void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox) @@ -138,8 +139,8 @@ void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificati rectificationBox.boxCenter = FFX_MIN16_F3(0, 0, 0); rectificationBox.boxVec = FFX_MIN16_F3(0, 0, 0); - rectificationBox.aabbMin = FFX_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX); - rectificationBox.aabbMax = -FFX_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX); + rectificationBox.aabbMin = FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX); + rectificationBox.aabbMax = -FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX); } #endif @@ -198,7 +199,7 @@ void RectificationBoxAddSample(FfxBoolean bInitialSample, FFX_PARAMETER_INOUT Re void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBox rectificationBox) { - rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f)); + rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f)); rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight; rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight; FfxFloat32x3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter)); @@ -207,7 +208,7 @@ void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBox #if FFX_HALF void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox) { - rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFX_MIN16_F(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FFX_MIN16_F(1.f)); + rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFX_MIN16_F(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FFX_MIN16_F(1.f)); rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight; rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight; FFX_MIN16_F3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter)); @@ -339,7 +340,7 @@ FfxFloat32x3 Tonemap(FfxFloat32x3 fRgb) FfxFloat32x3 InverseTonemap(FfxFloat32x3 fRgb) { - return fRgb / ffxMax(FSR2_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; + return fRgb / ffxMax(FSR3UPSCALER_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; } #if FFX_HALF @@ -350,7 +351,7 @@ FFX_MIN16_F3 Tonemap(FFX_MIN16_F3 fRgb) FFX_MIN16_F3 InverseTonemap(FFX_MIN16_F3 fRgb) { - return fRgb / ffxMax(FFX_MIN16_F(FSR2_TONEMAP_EPSILON), FFX_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; + return fRgb / ffxMax(FFX_MIN16_F(FSR3UPSCALER_TONEMAP_EPSILON), FFX_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; } #endif @@ -454,7 +455,7 @@ FfxFloat32 GetViewSpaceDepth(FfxFloat32 fDeviceDepth) { const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors(); - // fDeviceToViewDepth details found in ffx_fsr2.cpp + // fDeviceToViewDepth details found in ffx_fsr3upscaler.cpp return (fDeviceToViewDepth[1] / (fDeviceDepth - fDeviceToViewDepth[0])); } @@ -483,7 +484,7 @@ FfxFloat32x3 GetViewSpacePositionInMeters(FfxInt32x2 iViewportPos, FfxInt32x2 iV FfxFloat32 GetMaxDistanceInMeters() { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH return GetViewSpaceDepth(0.0f) * ViewSpaceToMetersFactor(); #else return GetViewSpaceDepth(1.0f) * ViewSpaceToMetersFactor(); @@ -495,7 +496,7 @@ FfxFloat32x3 PrepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure, FfxFloat32 fPre fRgb /= fPreExposure; fRgb *= fExposure; - fRgb = clamp(fRgb, 0.0f, FSR2_FP16_MAX); + fRgb = clamp(fRgb, 0.0f, FSR3UPSCALER_FP16_MAX); return fRgb; } @@ -562,4 +563,4 @@ FfxFloat32 PointToPlaneDistance(PlaneData plane, FfxFloat32x3 fPoint) #endif // #if defined(FFX_GPU) -#endif //!defined(FFX_FSR2_COMMON_H) +#endif //!defined(FFX_FSR3UPSCALER_COMMON_H) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta new file mode 100644 index 0000000..2ebe2aa --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_common.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 6a638bec681caac4fa8e2ca198726694 +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.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h similarity index 85% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h index c63f182..d26cf23 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_compute_luminance_pyramid.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,24 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + FFX_GROUPSHARED FfxUInt32 spdCounter; +void SpdIncreaseAtomicCounter(FfxUInt32 slice) +{ + SPD_IncreaseAtomicCounter(spdCounter); +} + +FfxUInt32 SpdGetAtomicCounter() +{ + return spdCounter; +} + +void SpdResetAtomicCounter(FfxUInt32 slice) +{ + SPD_ResetAtomicCounter(); +} + #ifndef SPD_PACKED_ONLY FFX_GROUPSHARED FfxFloat32 spdIntermediateR[16][16]; FFX_GROUPSHARED FfxFloat32 spdIntermediateG[16][16]; @@ -36,7 +52,7 @@ FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 tex, FfxUInt32 slice) fRgb /= PreExposure(); //compute log luma - const FfxFloat32 fLogLuma = log(ffxMax(FSR2_EPSILON, RGBToLuma(fRgb))); + const FfxFloat32 fLogLuma = log(ffxMax(FSR3UPSCALER_EPSILON, RGBToLuma(fRgb))); // Make sure out of screen pixels contribute no value to the end result const FfxFloat32 result = all(FFX_LESS_THAN(tex, RenderSize())) ? fLogLuma : 0.0f; @@ -74,21 +90,6 @@ void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 } } -void SpdIncreaseAtomicCounter(FfxUInt32 slice) -{ - SPD_IncreaseAtomicCounter(spdCounter); -} - -FfxUInt32 SpdGetAtomicCounter() -{ - return spdCounter; -} - -void SpdResetAtomicCounter(FfxUInt32 slice) -{ - SPD_ResetAtomicCounter(); -} - FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) { return FfxFloat32x4( @@ -112,40 +113,24 @@ FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFl // define fetch and store functions Packed #if FFX_HALF -#error Callback must be implemented FFX_GROUPSHARED FfxFloat16x2 spdIntermediateRG[16][16]; FFX_GROUPSHARED FfxFloat16x2 spdIntermediateBA[16][16]; FfxFloat16x4 SpdLoadSourceImageH(FfxFloat32x2 tex, FfxUInt32 slice) { - return FfxFloat16x4(imgDst[0][FfxFloat32x3(tex, slice)]); + return FfxFloat16x4(0, 0, 0, 0); } + FfxFloat16x4 SpdLoadH(FfxInt32x2 p, FfxUInt32 slice) { - return FfxFloat16x4(imgDst6[FfxUInt32x3(p, slice)]); + return FfxFloat16x4(0, 0, 0, 0); } + void SpdStoreH(FfxInt32x2 p, FfxFloat16x4 value, FfxUInt32 mip, FfxUInt32 slice) { - if (index == LumaMipLevelToUse() || index == 5) - { - imgDst6[FfxUInt32x3(p, slice)] = FfxFloat32x4(value); - return; - } - imgDst[mip + 1][FfxUInt32x3(p, slice)] = FfxFloat32x4(value); -} -void SpdIncreaseAtomicCounter(FfxUInt32 slice) -{ - InterlockedAdd(rw_spd_global_atomic[FfxInt16x2(0, 0)].counter[slice], 1, spdCounter); -} -FfxUInt32 SpdGetAtomicCounter() -{ - return spdCounter; -} -void SpdResetAtomicCounter(FfxUInt32 slice) -{ - rw_spd_global_atomic[FfxInt16x2(0, 0)].counter[slice] = 0; } + FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y) { return FfxFloat16x4( @@ -154,18 +139,20 @@ FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y) spdIntermediateBA[x][y].x, spdIntermediateBA[x][y].y); } + void SpdStoreIntermediateH(FfxUInt32 x, FfxUInt32 y, FfxFloat16x4 value) { spdIntermediateRG[x][y] = value.xy; spdIntermediateBA[x][y] = value.zw; } + FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxFloat16x4 v3) { return (v0 + v1 + v2 + v3) * FfxFloat16(0.25); } #endif -#include "ffx_spd.h" +#include "spd/ffx_spd.h" void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex) { @@ -186,4 +173,4 @@ void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex) FfxUInt32(WorkGroupId.z), FfxUInt32x2(WorkGroupOffset())); #endif -} \ No newline at end of file +} diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta new file mode 100644 index 0000000..9f1d2ab --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 61bd10363d44ee2478461c9e9efbcb67 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h similarity index 97% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h index fa4c975..53763c8 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_depth_clip.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_DEPTH_CLIP_H -#define FFX_FSR2_DEPTH_CLIP_H + +#ifndef FFX_FSR3UPSCALER_DEPTH_CLIP_H +#define FFX_FSR3UPSCALER_DEPTH_CLIP_H FFX_STATIC const FfxFloat32 DepthClipBaseScale = 4.0f; @@ -48,7 +49,7 @@ FfxFloat32 ComputeDepthClip(FfxFloat32x2 fUvSample, FfxFloat32 fCurrentDepthSamp if (fDepthDiff > 0.0f) { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH const FfxFloat32 fPlaneDepth = ffxMin(fPrevDepthSample, fCurrentDepthSample); #else const FfxFloat32 fPlaneDepth = ffxMax(fPrevDepthSample, fCurrentDepthSample); @@ -243,7 +244,7 @@ void DepthClip(FfxInt32x2 iPxPos) StorePreparedInputColor(iPxPos, FfxFloat32x4(fPreparedYCoCg, fDepthClip)); // Compute dilated reactive mask -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxInt32x2 iSamplePos = iPxPos; #else FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxPos); @@ -255,4 +256,4 @@ void DepthClip(FfxInt32x2 iPxPos) PreProcessReactiveMasks(iPxPos, ffxMax(fTemporalMotionDifference, fMotionDivergence)); } -#endif //!defined( FFX_FSR2_DEPTH_CLIPH ) \ No newline at end of file +#endif //!defined( FFX_FSR3UPSCALER_DEPTH_CLIPH ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta new file mode 100644 index 0000000..21fe627 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_depth_clip.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 7c662249d70c4434da4f2da00e432c38 +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_lock.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h similarity index 91% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_lock.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h index 8347fa8..e1a0d06 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_lock.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,14 +19,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_LOCK_H -#define FFX_FSR2_LOCK_H + +#ifndef FFX_FSR3UPSCALER_LOCK_H +#define FFX_FSR3UPSCALER_LOCK_H void ClearResourcesForNextFrame(in FfxInt32x2 iPxHrPos) { if (all(FFX_LESS_THAN(iPxHrPos, FfxInt32x2(RenderSize())))) { -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH const FfxUInt32 farZ = 0x0; #else const FfxUInt32 farZ = 0x3f800000; @@ -42,7 +43,7 @@ FfxBoolean ComputeThinFeatureConfidence(FfxInt32x2 pos) FfxFloat32 fNucleus = LoadLockInputLuma(pos); FfxFloat32 similar_threshold = 1.05f; - FfxFloat32 dissimilarLumaMin = FSR2_FLT_MAX; + FfxFloat32 dissimilarLumaMin = FSR3UPSCALER_FLT_MAX; FfxFloat32 dissimilarLumaMax = 0; /* @@ -109,7 +110,7 @@ void ComputeLock(FfxInt32x2 iPxLrPos) StoreNewLocks(ComputeHrPosFromLrPos(iPxLrPos), 1.f); } - ClearResourcesForNextFrame(iPxLrPos); + // ClearResourcesForNextFrame(iPxLrPos); } -#endif // FFX_FSR2_LOCK_H +#endif // FFX_FSR3UPSCALER_LOCK_H diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta new file mode 100644 index 0000000..38a5a57 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_lock.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: c7e9f53dd040b2645af5ccd936a94b0e +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h similarity index 91% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h index cee9e14..3709113 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_postprocess_lock_status.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_POSTPROCESS_LOCK_STATUS_H -#define FFX_FSR2_POSTPROCESS_LOCK_STATUS_H + +#ifndef FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H +#define FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H FfxFloat32x4 WrapShadingChangeLuma(FfxInt32x2 iPxSample) { @@ -34,7 +35,7 @@ FFX_MIN16_F4 WrapShadingChangeLuma(FFX_MIN16_I2 iPxSample) } #endif -#if FFX_FSR2_OPTION_POSTPROCESSLOCKSTATUS_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_POSTPROCESSLOCKSTATUS_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBilinearSamplesMin16(FetchShadingChangeLumaSamples, WrapShadingChangeLuma) #else DeclareCustomFetchBicubicSamples(FetchShadingChangeLumaSamples, WrapShadingChangeLuma) @@ -49,7 +50,7 @@ FfxFloat32 GetShadingChangeLuma(FfxInt32x2 iPxHrPos, FfxFloat32x2 fUvCoord) fShadingChangeLuma = Exposure() * exp(ShadingChangeLumaSample(fUvCoord, LumaMipDimensions()).x); #else - const FfxFloat32 fDiv = FfxFloat32(2 << LumaMipLevelToUse()); + const FfxFloat32 fDiv = FfxFloat32(2u << LumaMipLevelToUse()); FfxInt32x2 iMipRenderSize = FfxInt32x2(RenderSize() / fDiv); fUvCoord = ClampUv(fUvCoord, iMipRenderSize, LumaMipDimensions()); @@ -103,4 +104,4 @@ void UpdateLockStatus(AccumulationPassCommonParams params, fLockContributionThisFrame = ffxSaturate(ffxSaturate(fLifetimeContribution * 4.0f) * fShadingChangeContribution); } -#endif //!defined( FFX_FSR2_POSTPROCESS_LOCK_STATUS_H ) +#endif //!defined( FFX_FSR3UPSCALER_POSTPROCESS_LOCK_STATUS_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta new file mode 100644 index 0000000..f8b5616 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 67a8b72ceb93d634f883b086fdccb348 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h similarity index 93% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h index d9006cd..77619a5 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_rcas.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,16 +19,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#define GROUP_SIZE 8 +#define GROUP_SIZE 8 #define FSR_RCAS_DENOISE 1 +#include "ffx_core.h" + void WriteUpscaledOutput(FFX_MIN16_U2 iPxHrPos, FfxFloat32x3 fUpscaledColor) { StoreUpscaledOutput(FFX_MIN16_I2(iPxHrPos), fUpscaledColor); } -#define FSR_RCAS_F +#define FSR_RCAS_F 1 FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p) { FfxFloat32x4 fColor = LoadRCAS_Input(p); @@ -37,11 +39,9 @@ FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p) return fColor; } - void FsrRcasInputF(inout FfxFloat32 r, inout FfxFloat32 g, inout FfxFloat32 b) {} -#include "ffx_fsr1.h" - +#include "fsr1/ffx_fsr1.h" void CurrFilter(FFX_MIN16_U2 pos) { diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta new file mode 100644 index 0000000..7a53a1f --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_rcas.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 692efb7cec0df67408a583a7ff34146a +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h similarity index 91% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h index e9ccc4b..a822dfc 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_reconstruct_dilated_velocity_and_previous_depth.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H -#define FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H + +#ifndef FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H +#define FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H void ReconstructPrevDepth(FfxInt32x2 iPxPos, FfxFloat32 fDepth, FfxFloat32x2 fMotionVector, FfxInt32x2 iPxDepthSize) { @@ -83,7 +84,7 @@ void FindNearestDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxIn if (IsOnScreen(iPos, iPxSize)) { FfxFloat32 fNdDepth = depth[iSampleIndex]; -#if FFX_FSR2_OPTION_INVERTED_DEPTH +#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH if (fNdDepth > fNearestDepth) { #else if (fNdDepth < fNearestDepth) { @@ -105,7 +106,7 @@ FfxFloat32 ComputeLockInputLuma(FfxInt32x2 iPxLrPos) fRgb /= PreExposure(); fRgb *= Exposure(); -#if FFX_FSR2_OPTION_HDR_COLOR_INPUT +#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT fRgb = Tonemap(fRgb); #endif @@ -122,7 +123,7 @@ void ReconstructAndDilate(FfxInt32x2 iPxLrPos) FindNearestDepth(iPxLrPos, RenderSize(), fDilatedDepth, iNearestDepthCoord); -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxInt32x2 iSamplePos = iPxLrPos; FfxInt32x2 iMotionVectorPos = iNearestDepthCoord; #else @@ -142,4 +143,4 @@ void ReconstructAndDilate(FfxInt32x2 iPxLrPos) } -#endif //!defined( FFX_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H ) +#endif //!defined( FFX_FSR3UPSCALER_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta new file mode 100644 index 0000000..78ced0d --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: c8b3854bad30a8b40babc5a9805f294e +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_reproject.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h similarity index 77% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_reproject.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h index f7f3961..29b7584 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_reproject.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,11 +19,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_REPROJECT_H -#define FFX_FSR2_REPROJECT_H -#ifndef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 0 // Reference +#ifndef FFX_FSR3UPSCALER_REPROJECT_H +#define FFX_FSR3UPSCALER_REPROJECT_H + +#ifndef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE 0 // Reference #endif FfxFloat32x4 WrapHistory(FfxInt32x2 iPxSample) @@ -39,12 +40,12 @@ FFX_MIN16_F4 WrapHistory(FFX_MIN16_I2 iPxSample) #endif -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBicubicSamplesMin16(FetchHistorySamples, WrapHistory) -DeclareCustomTextureSampleMin16(HistorySample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) +DeclareCustomTextureSampleMin16(HistorySample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) #else DeclareCustomFetchBicubicSamples(FetchHistorySamples, WrapHistory) -DeclareCustomTextureSample(HistorySample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) +DeclareCustomTextureSample(HistorySample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples) #endif FfxFloat32x4 WrapLockStatus(FfxInt32x2 iPxSample) @@ -63,7 +64,7 @@ FFX_MIN16_F4 WrapLockStatus(FFX_MIN16_I2 iPxSample) #endif #if 1 -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBilinearSamplesMin16(FetchLockStatusSamples, WrapLockStatus) DeclareCustomTextureSampleMin16(LockStatusSample, Bilinear, FetchLockStatusSamples) #else @@ -71,18 +72,18 @@ DeclareCustomFetchBilinearSamples(FetchLockStatusSamples, WrapLockStatus) DeclareCustomTextureSample(LockStatusSample, Bilinear, FetchLockStatusSamples) #endif #else -#if FFX_FSR2_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF +#if FFX_FSR3UPSCALER_OPTION_REPROJECT_SAMPLERS_USE_DATA_HALF && FFX_HALF DeclareCustomFetchBicubicSamplesMin16(FetchLockStatusSamples, WrapLockStatus) -DeclareCustomTextureSampleMin16(LockStatusSample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) +DeclareCustomTextureSampleMin16(LockStatusSample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) #else DeclareCustomFetchBicubicSamples(FetchLockStatusSamples, WrapLockStatus) -DeclareCustomTextureSample(LockStatusSample, FFX_FSR2_GET_LANCZOS_SAMPLER1D(FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) +DeclareCustomTextureSample(LockStatusSample, FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchLockStatusSamples) #endif #endif FfxFloat32x2 GetMotionVector(FfxInt32x2 iPxHrPos, FfxFloat32x2 fHrUv) { -#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS +#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS FfxFloat32x2 fDilatedMotionVector = LoadDilatedMotionVector(FFX_MIN16_I2(fHrUv * RenderSize())); #else FfxFloat32x2 fDilatedMotionVector = LoadInputMotionVector(iPxHrPos); @@ -133,4 +134,4 @@ LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, return state; } -#endif //!defined( FFX_FSR2_REPROJECT_H ) +#endif //!defined( FFX_FSR3UPSCALER_REPROJECT_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta new file mode 100644 index 0000000..ea2e14d --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_reproject.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 9d893016eebb2564f9a66b80afb0849f +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/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h new file mode 100644 index 0000000..d98cfcc --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h @@ -0,0 +1,104 @@ +// This file is part of the FidelityFX SDK. +// +// Copyright (c) 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. + + +#ifndef FFX_FSR3UPSCALER_RESOURCES_H +#define FFX_FSR3UPSCALER_RESOURCES_H + +#if defined(FFX_CPU) || defined(FFX_GPU) +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NULL 0 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_COLOR 2 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_DEPTH 4 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_DEPTH 10 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS 12 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_NEW_LOCKS 13 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY 15 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LANCZOS_LUT 17 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_RCAS_INPUT 20 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOREACTIVE 44 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_AUTOCOMPOSITION_DEPRECATED 45 + +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR 46 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR 47 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_1 48 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_1 49 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR_2 50 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR_2 51 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 52 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 53 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 54 +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 55 + +// Shading change detection mip level setting, value must be in the range [FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12] +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 +#define FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL (FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_SCENE_LUMINANCE) + +#define FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT 56 + +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_FSR3UPSCALER 0 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_SPD 1 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_RCAS 2 +#define FFX_FSR3UPSCALER_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3 + +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4 +#define FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8 + +#endif // #if defined(FFX_CPU) || defined(FFX_GPU) + +#endif //!defined( FFX_FSR3UPSCALER_RESOURCES_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta new file mode 100644 index 0000000..24cdbd2 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_resources.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: b5a95a38dcfaf3946a5095bbbc42939a +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_sample.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h similarity index 96% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_sample.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h index f94f40a..d33f70c 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_sample.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_SAMPLE_H -#define FFX_FSR2_SAMPLE_H + +#ifndef FFX_FSR3UPSCALER_SAMPLE_H +#define FFX_FSR3UPSCALER_SAMPLE_H // suppress warnings #ifdef FFX_HLSL @@ -127,7 +128,7 @@ FFX_MIN16_F4 Bilinear(FetchedBilinearSamplesMin16 BilinearSamples, FFX_MIN16_F2 FfxFloat32 Lanczos2NoClamp(FfxFloat32 x) { const FfxFloat32 PI = 3.141592653589793f; // TODO: share SDK constants - return abs(x) < FSR2_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); + return abs(x) < FSR3UPSCALER_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x)); } FfxFloat32 Lanczos2(FfxFloat32 x) @@ -142,7 +143,7 @@ FfxFloat32 Lanczos2(FfxFloat32 x) FFX_MIN16_F Lanczos2NoClamp(FFX_MIN16_F x) { const FFX_MIN16_F PI = FFX_MIN16_F(3.141592653589793f); // TODO: share SDK constants - return abs(x) < FFX_MIN16_F(FSR2_EPSILON) ? FFX_MIN16_F(1.f) : (sin(PI * x) / (PI * x)) * (sin(FFX_MIN16_F(0.5f) * PI * x) / (FFX_MIN16_F(0.5f) * PI * x)); + return abs(x) < FFX_MIN16_F(FSR3UPSCALER_EPSILON) ? FFX_MIN16_F(1.f) : (sin(PI * x) / (PI * x)) * (sin(FFX_MIN16_F(0.5f) * PI * x) / (FFX_MIN16_F(0.5f) * PI * x)); } #endif @@ -594,12 +595,12 @@ FFX_MIN16_I2 ClampCoord(FFX_MIN16_I2 iPxSample, FFX_MIN16_I2 iPxOffset, FFX_MIN1 return fColorXY; \ } -#define FFX_FSR2_CONCAT_ID(x, y) x ## y -#define FFX_FSR2_CONCAT(x, y) FFX_FSR2_CONCAT_ID(x, y) -#define FFX_FSR2_SAMPLER_1D_0 Lanczos2 -#define FFX_FSR2_SAMPLER_1D_1 Lanczos2LUT -#define FFX_FSR2_SAMPLER_1D_2 Lanczos2Approx +#define FFX_FSR3UPSCALER_CONCAT_ID(x, y) x ## y +#define FFX_FSR3UPSCALER_CONCAT(x, y) FFX_FSR3UPSCALER_CONCAT_ID(x, y) +#define FFX_FSR3UPSCALER_SAMPLER_1D_0 Lanczos2 +#define FFX_FSR3UPSCALER_SAMPLER_1D_1 Lanczos2LUT +#define FFX_FSR3UPSCALER_SAMPLER_1D_2 Lanczos2Approx -#define FFX_FSR2_GET_LANCZOS_SAMPLER1D(x) FFX_FSR2_CONCAT(FFX_FSR2_SAMPLER_1D_, x) +#define FFX_FSR3UPSCALER_GET_LANCZOS_SAMPLER1D(x) FFX_FSR3UPSCALER_CONCAT(FFX_FSR3UPSCALER_SAMPLER_1D_, x) -#endif //!defined( FFX_FSR2_SAMPLE_H ) +#endif //!defined( FFX_FSR3UPSCALER_SAMPLE_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta new file mode 100644 index 0000000..1a46376 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_sample.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: dcb900c9deecd06419a8a4c10c305890 +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_tcr_autogen.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h similarity index 99% rename from Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h index 101b75d..2d446bb 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr2_tcr_autogen.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h @@ -52,7 +52,7 @@ FFX_MIN16_F ComputeAutoTC_01(FFX_MIN16_I2 uDispatchThreadId, FFX_MIN16_I2 iPrevI FFX_MIN16_F retVal = FFX_MIN16_F(ffxSaturate(dot(abs(abs(Y - X) - abs(W - Z)), FfxFloat32x3(1, 1, 1)))); // cleanup very small values - retVal = (retVal < getTcThreshold()) ? FFX_MIN16_F(0.0f) : FFX_MIN16_F(1.f); + retVal = (retVal < TcThreshold()) ? FFX_MIN16_F(0.0f) : FFX_MIN16_F(1.f); return retVal; } diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta new file mode 100644 index 0000000..99d54e7 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: f01d5a8fbd1f34a4ea8d971755a21b6c +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/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h similarity index 85% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h index abdb888..47e7ccf 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_fsr2_upsample.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,8 +19,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifndef FFX_FSR2_UPSAMPLE_H -#define FFX_FSR2_UPSAMPLE_H + +#ifndef FFX_FSR3UPSCALER_UPSAMPLE_H +#define FFX_FSR3UPSCALER_UPSAMPLE_H FFX_STATIC const FfxUInt32 iLanczos2SampleCount = 16; @@ -35,18 +36,18 @@ void Deringing(RectificationBoxMin16 clippingBox, FFX_PARAMETER_INOUT FFX_MIN16_ } #endif -#ifndef FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE -#define FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE 2 // Approximate +#ifndef FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE +#define FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE 2 // Approximate #endif FfxFloat32 GetUpsampleLanczosWeight(FfxFloat32x2 fSrcSampleOffset, FfxFloat32 fKernelWeight) { FfxFloat32x2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx; -#if FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE +#if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE FfxFloat32 fSampleWeight = Lanczos2(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT FfxFloat32 fSampleWeight = Lanczos2_UseLUT(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE FfxFloat32 fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased)); #else #error "Invalid Lanczos type" @@ -58,11 +59,11 @@ FfxFloat32 GetUpsampleLanczosWeight(FfxFloat32x2 fSrcSampleOffset, FfxFloat32 fK FFX_MIN16_F GetUpsampleLanczosWeight(FFX_MIN16_F2 fSrcSampleOffset, FFX_MIN16_F fKernelWeight) { FFX_MIN16_F2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx; -#if FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE +#if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 0 // LANCZOS_TYPE_REFERENCE FFX_MIN16_F fSampleWeight = Lanczos2(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 1 // LANCZOS_TYPE_LUT FFX_MIN16_F fSampleWeight = Lanczos2_UseLUT(length(fSrcSampleOffsetBiased)); -#elif FFX_FSR2_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE +#elif FFX_FSR3UPSCALER_OPTION_UPSAMPLE_USE_LANCZOS_TYPE == 2 // LANCZOS_TYPE_APPROXIMATE FFX_MIN16_F fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased)); // To Test: Save reciproqual sqrt compute @@ -85,16 +86,16 @@ FfxFloat32 ComputeMaxKernelWeight() { FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT RectificationBox clippingBox, FfxFloat32 fReactiveFactor) { - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_begin.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_begin.h" #endif // We compute a sliced lanczos filter with 2 lobes (other slices are accumulated temporaly) FfxFloat32x2 fDstOutputPos = FfxFloat32x2(params.iPxHrPos) + FFX_BROADCAST_FLOAT32X2(0.5f); // Destination resolution output pixel center position FfxFloat32x2 fSrcOutputPos = fDstOutputPos * DownscaleFactor(); // Source resolution output pixel center position FfxInt32x2 iSrcInputPos = FfxInt32x2(floor(fSrcOutputPos)); // TODO: what about weird upscale factors... - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_end.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_end.h" #endif FfxFloat32x3 fSamples[iLanczos2SampleCount]; @@ -174,9 +175,9 @@ FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams p RectificationBoxComputeVarianceBoxData(clippingBox); - fColorAndWeight.w *= FfxFloat32(fColorAndWeight.w > FSR2_EPSILON); + fColorAndWeight.w *= FfxFloat32(fColorAndWeight.w > FSR3UPSCALER_EPSILON); - if (fColorAndWeight.w > FSR2_EPSILON) { + if (fColorAndWeight.w > FSR3UPSCALER_EPSILON) { // Normalize for deringing (we need to compare colors) fColorAndWeight.xyz = fColorAndWeight.xyz / fColorAndWeight.w; fColorAndWeight.w *= fUpsampleLanczosWeightScale; @@ -184,11 +185,11 @@ FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams p Deringing(clippingBox, fColorAndWeight.xyz); } - #if FFX_FSR2_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF - #include "ffx_fsr2_force16_end.h" + #if FFX_FSR3UPSCALER_OPTION_UPSAMPLE_SAMPLERS_USE_DATA_HALF && FFX_HALF + #include "ffx_fsr3upscaler_force16_end.h" #endif return fColorAndWeight; } -#endif //!defined( FFX_FSR2_UPSAMPLE_H ) +#endif //!defined( FFX_FSR3UPSCALER_UPSAMPLE_H ) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta new file mode 100644 index 0000000..e4153a0 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/ffx_fsr3upscaler_upsample.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 3e7832c4a9154414f9eaa125acfe6cd5 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta new file mode 100644 index 0000000..731c94f --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09438bc445e66204f970dc99ca8dae5a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/FSR2/shaders/ffx_fsr1.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h similarity index 97% rename from Assets/Resources/FSR2/shaders/ffx_fsr1.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h index 1ac23cf..e780995 100644 --- a/Assets/Resources/FSR2/shaders/ffx_fsr1.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,9 +19,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wunused-variable" -#endif + +/// @defgroup FfxGPUFsr1 FidelityFX FSR1 +/// FidelityFX Super Resolution 1 GPU documentation +/// +/// @ingroup FfxGPUEffects /// Setup required constant values for EASU (works on CPU or GPU). /// @@ -36,7 +38,7 @@ /// @param [in] outputSizeInPixelsX The display resolution which the input image gets upscaled to in X dimension. /// @param [in] outputSizeInPixelsY The display resolution which the input image gets upscaled to in Y dimension. /// -/// @ingroup FSR1 +/// @ingroup FfxGPUFsr1 FFX_STATIC void ffxFsrPopulateEasuConstants( FFX_PARAMETER_INOUT FfxUInt32x4 con0, FFX_PARAMETER_INOUT FfxUInt32x4 con1, @@ -102,7 +104,7 @@ FFX_STATIC void ffxFsrPopulateEasuConstants( /// @param [in] inputOffsetInPixelsX The input image offset in the X dimension into the resource containing it (useful for dynamic resolution). /// @param [in] inputOffsetInPixelsY The input image offset in the Y dimension into the resource containing it (useful for dynamic resolution). /// -/// @ingroup FSR1 +/// @ingroup FfxGPUFsr1 FFX_STATIC void ffxFsrPopulateEasuConstantsOffset( FFX_PARAMETER_INOUT FfxUInt32x4 con0, FFX_PARAMETER_INOUT FfxUInt32x4 con1, @@ -329,7 +331,7 @@ void ffxFsrEasuFloat( // Normalize with approximation, and cleanup close to zero. FfxFloat32x2 dir2 = dir * dir; FfxFloat32 dirR = dir2.x + dir2.y; - FfxUInt32 zro = dirR < FfxFloat32(1.0 / 32768.0); + FfxBoolean zro = dirR < FfxFloat32(1.0 / 32768.0); dirR = ffxApproximateReciprocalSquareRoot(dirR); dirR = zro ? FfxFloat32(1.0) : dirR; dir.x = zro ? FfxFloat32(1.0) : dir.x; @@ -457,7 +459,7 @@ void FsrEasuSetH( FfxFloat16x2 dirX = lD - lB; dirPX += dirX * w; - lenX = ffxSaturate(abs(dirX) * lenX); + lenX = FfxFloat16x2(ffxSaturate(abs(dirX) * lenX)); lenX *= lenX; lenP += lenX * w; FfxFloat16x2 ec = lE - lC; @@ -466,7 +468,7 @@ void FsrEasuSetH( lenY = ffxReciprocalHalf(lenY); FfxFloat16x2 dirY = lE - lA; dirPY += dirY * w; - lenY = ffxSaturate(abs(dirY) * lenY); + lenY = FfxFloat16x2(ffxSaturate(abs(dirY) * lenY)); lenY *= lenY; lenP += lenY * w; } @@ -526,8 +528,8 @@ void FsrEasuH( dirPY, lenP, ppp, - FfxUInt32(true), - FfxUInt32(false), + FfxBoolean(true), + FfxBoolean(false), FfxFloat16x2(bL, cL), FfxFloat16x2(eL, fL), FfxFloat16x2(fL, gL), @@ -537,8 +539,8 @@ void FsrEasuH( dirPY, lenP, ppp, - FfxUInt32(false), - FfxUInt32(true), + FfxBoolean(false), + FfxBoolean(true), FfxFloat16x2(fL, gL), FfxFloat16x2(iL, jL), FfxFloat16x2(jL, kL), @@ -549,7 +551,7 @@ void FsrEasuH( FfxFloat16x2 dir2 = dir * dir; FfxFloat16 dirR = dir2.x + dir2.y; - FfxBoolean zro = FfxBoolean(dirR < FFX_BROADCAST_FLOAT16(1.0 / 32768.0)); + FfxUInt32 zro = FfxUInt32(dirR < FFX_BROADCAST_FLOAT16(1.0 / 32768.0)); dirR = ffxApproximateReciprocalSquareRootHalf(dirR); dirR = (zro > 0) ? FFX_BROADCAST_FLOAT16(1.0) : dirR; dir.x = (zro > 0) ? FFX_BROADCAST_FLOAT16(1.0) : dir.x; @@ -834,7 +836,7 @@ void FsrEasuH( FfxFloat16 hL=hB*FFX_BROADCAST_FLOAT16(0.5)+(hR*FFX_BROADCAST_FLOAT16(0.5)+hG); // Noise detection. FfxFloat16 nz=FFX_BROADCAST_FLOAT16(0.25)*bL+FFX_BROADCAST_FLOAT16(0.25)*dL+FFX_BROADCAST_FLOAT16(0.25)*fL+FFX_BROADCAST_FLOAT16(0.25)*hL-eL; - nz=ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL))); + nz=FfxFloat16(ffxSaturate(abs(nz)*ffxApproximateReciprocalMediumHalf(ffxMax3Half(ffxMax3Half(bL,dL,eL),fL,hL)-ffxMin3Half(ffxMin3Half(bL,dL,eL),fL,hL)))); nz=FFX_BROADCAST_FLOAT16(-0.5)*nz+FFX_BROADCAST_FLOAT16(1.0); // Min and max of ring. FfxFloat16 mn4R=min(ffxMin3Half(bR,dR,fR),hR); @@ -1175,7 +1177,7 @@ void FsrEasuH( FfxFloat16x3 b = n + FFX_BROADCAST_FLOAT16X3(1.0 / 255.0); b = b * b; FfxFloat16x3 r = (c - b) * ffxApproximateReciprocalMediumHalf(a - b); - c = ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 255.0)); + c = FfxFloat16x3(ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 255.0))); } //------------------------------------------------------------------------------------------------------------------------------ void FsrTepdC10H(inout FfxFloat16x3 c, FfxFloat16 dit) @@ -1186,7 +1188,7 @@ void FsrEasuH( FfxFloat16x3 b = n + FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0); b = b * b; FfxFloat16x3 r = (c - b) * ffxApproximateReciprocalMediumHalf(a - b); - c = ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0)); + c = FfxFloat16x3(ffxSaturate(n + ffxIsGreaterThanZeroHalf(FFX_BROADCAST_FLOAT16X3(dit) - r) * FFX_BROADCAST_FLOAT16X3(1.0 / 1023.0))); } //============================================================================================================================== // This computes dither for positions 'p' and 'p+{8,0}'. @@ -1222,9 +1224,9 @@ void FsrEasuH( FfxFloat16x2 rR = (cR - bR) * ffxApproximateReciprocalMediumHalf(aR - bR); FfxFloat16x2 rG = (cG - bG) * ffxApproximateReciprocalMediumHalf(aG - bG); FfxFloat16x2 rB = (cB - bB) * ffxApproximateReciprocalMediumHalf(aB - bB); - cR = ffxSaturate(nR + ffxIsGreaterThanZeroHalf(dit - rR) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); - cG = ffxSaturate(nG + ffxIsGreaterThanZeroHalf(dit - rG) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); - cB = ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0)); + cR = FfxFloat16x2(ffxSaturate(nR + ffxIsGreaterThanZeroHalf(dit - rR) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); + cG = FfxFloat16x2(ffxSaturate(nG + ffxIsGreaterThanZeroHalf(dit - rG) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); + cB = FfxFloat16x2(ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 255.0))); } //------------------------------------------------------------------------------------------------------------------------------ void FsrTepdC10Hx2(inout FfxFloat16x2 cR,inout FfxFloat16x2 cG,inout FfxFloat16x2 cB,FfxFloat16x2 dit){ @@ -1243,8 +1245,8 @@ void FsrEasuH( FfxFloat16x2 rR=(cR-bR)*ffxApproximateReciprocalMediumHalf(aR-bR); FfxFloat16x2 rG=(cG-bG)*ffxApproximateReciprocalMediumHalf(aG-bG); FfxFloat16x2 rB=(cB-bB)*ffxApproximateReciprocalMediumHalf(aB-bB); - cR=ffxSaturate(nR+ffxIsGreaterThanZeroHalf(dit-rR)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0)); - cG=ffxSaturate(nG+ffxIsGreaterThanZeroHalf(dit-rG)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0)); - cB = ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 1023.0)); + cR=FfxFloat16x2(ffxSaturate(nR+ffxIsGreaterThanZeroHalf(dit-rR)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0))); + cG=FfxFloat16x2(ffxSaturate(nG+ffxIsGreaterThanZeroHalf(dit-rG)*FFX_BROADCAST_FLOAT16X2(1.0/1023.0))); + cB=FfxFloat16x2(ffxSaturate(nB + ffxIsGreaterThanZeroHalf(dit - rB) * FFX_BROADCAST_FLOAT16X2(1.0 / 1023.0))); } #endif diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta new file mode 100644 index 0000000..64e4ffa --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/fsr1/ffx_fsr1.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 628e23510f46ef44bbf0035ce9a63be0 +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/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd.meta new file mode 100644 index 0000000..0b775af --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f03de1579ac3294595ae4f40106b7a2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h similarity index 82% rename from com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h rename to com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h index b94f46f..6441419 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/FSR2/shaders/ffx_spd.h +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. -// -// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved. -// +// +// Copyright (c) 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 @@ -10,7 +10,7 @@ // 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 @@ -19,22 +19,42 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#ifdef FFX_CPU -FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side: dispatch thread group count xy - FfxUInt32x2 workGroupOffset, // GPU side: pass in as constant - FfxUInt32x2 numWorkGroupsAndMips, // GPU side: pass in as constant - FfxUInt32x4 rectInfo, // left, top, width, height - FfxInt32 mips) // optional: if -1, calculate based on rect width and height -{ - workGroupOffset[0] = rectInfo[0] / 64; // rectInfo[0] = left - workGroupOffset[1] = rectInfo[1] / 64; // rectInfo[1] = top + +/// @defgroup FfxGPUSpd FidelityFX SPD +/// FidelityFX Single Pass Downsampler 2.0 GPU documentation +/// +/// @ingroup FfxGPUEffects + +/// Setup required constant values for SPD (CPU). +/// +/// @param [out] dispatchThreadGroupCountXY CPU side: dispatch thread group count xy. z is number of slices of the input texture +/// @param [out] workGroupOffset GPU side: pass in as constant +/// @param [out] numWorkGroupsAndMips GPU side: pass in as constant +/// @param [in] rectInfo left, top, width, height +/// @param [in] mips optional: if -1, calculate based on rect width and height +/// +/// @ingroup FfxGPUSpd +#if defined(FFX_CPU) +FFX_STATIC void ffxSpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, + FfxUInt32x2 workGroupOffset, + FfxUInt32x2 numWorkGroupsAndMips, + FfxUInt32x4 rectInfo, + FfxInt32 mips) +{ + // determines the offset of the first tile to downsample based on + // left (rectInfo[0]) and top (rectInfo[1]) of the subregion. + workGroupOffset[0] = rectInfo[0] / 64; + workGroupOffset[1] = rectInfo[1] / 64; FfxUInt32 endIndexX = (rectInfo[0] + rectInfo[2] - 1) / 64; // rectInfo[0] = left, rectInfo[2] = width FfxUInt32 endIndexY = (rectInfo[1] + rectInfo[3] - 1) / 64; // rectInfo[1] = top, rectInfo[3] = height + // we only need to dispatch as many thread groups as tiles we need to downsample + // number of tiles per slice depends on the subregion to downsample dispatchThreadGroupCountXY[0] = endIndexX + 1 - workGroupOffset[0]; dispatchThreadGroupCountXY[1] = endIndexY + 1 - workGroupOffset[1]; + // number of thread groups per slice numWorkGroupsAndMips[0] = (dispatchThreadGroupCountXY[0]) * (dispatchThreadGroupCountXY[1]); if (mips >= 0) @@ -42,29 +62,37 @@ FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side numWorkGroupsAndMips[1] = FfxUInt32(mips); } else - { + { // calculate based on rect width and height FfxUInt32 resolution = ffxMax(rectInfo[2], rectInfo[3]); numWorkGroupsAndMips[1] = FfxUInt32((ffxMin(floor(log2(FfxFloat32(resolution))), FfxFloat32(12)))); } } -FFX_STATIC void SpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, // CPU side: dispatch thread group count xy - FfxUInt32x2 workGroupOffset, // GPU side: pass in as constant - FfxUInt32x2 numWorkGroupsAndMips, // GPU side: pass in as constant - FfxUInt32x4 rectInfo) // left, top, width, height +/// Setup required constant values for SPD (CPU). +/// +/// @param [out] dispatchThreadGroupCountXY CPU side: dispatch thread group count xy. z is number of slices of the input texture +/// @param [out] workGroupOffset GPU side: pass in as constant +/// @param [out] numWorkGroupsAndMips GPU side: pass in as constant +/// @param [in] rectInfo left, top, width, height +/// +/// @ingroup FfxGPUSpd +FFX_STATIC void ffxSpdSetup(FfxUInt32x2 dispatchThreadGroupCountXY, + FfxUInt32x2 workGroupOffset, + FfxUInt32x2 numWorkGroupsAndMips, + FfxUInt32x4 rectInfo) { - SpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo, -1); + ffxSpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo, -1); } -#endif // #ifdef FFX_CPU +#endif // #if defined(FFX_CPU) //============================================================================================================================== // NON-PACKED VERSION //============================================================================================================================== -#ifdef FFX_GPU -#ifdef SPD_PACKED_ONLY -// Avoid compiler error +#if defined(FFX_GPU) +#if defined(FFX_SPD_PACKED_ONLY) +// Avoid compiler errors by including default implementations of these callbacks. FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 p, FfxUInt32 slice) { return FfxFloat32x4(0.0, 0.0, 0.0, 0.0); @@ -88,18 +116,13 @@ FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFl { return FfxFloat32x4(0.0, 0.0, 0.0, 0.0); } -#endif // #ifdef SPD_PACKED_ONLY +#endif // #if FFX_SPD_PACKED_ONLY //_____________________________________________________________/\_______________________________________________________________ -void SpdWorkgroupShuffleBarrier() +void ffxSpdWorkgroupShuffleBarrier() { -#ifdef FFX_GLSL - barrier(); -#endif -#ifdef FFX_HLSL - GroupMemoryBarrierWithGroupSync(); -#endif + FFX_GROUP_MEMORY_BARRIER(); } // Only last active workgroup should proceed @@ -111,14 +134,14 @@ bool SpdExitWorkgroup(FfxUInt32 numWorkGroups, FfxUInt32 localInvocationIndex, F SpdIncreaseAtomicCounter(slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); return (SpdGetAtomicCounter() != (numWorkGroups - 1)); } // User defined: FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3); FfxFloat32x4 SpdReduceQuad(FfxFloat32x4 v) { -#if defined(FFX_GLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#if defined(FFX_GLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) FfxFloat32x4 v0 = v; FfxFloat32x4 v1 = subgroupQuadSwapHorizontal(v); @@ -126,7 +149,7 @@ FfxFloat32x4 SpdReduceQuad(FfxFloat32x4 v) FfxFloat32x4 v3 = subgroupQuadSwapDiagonal(v); return SpdReduce4(v0, v1, v2, v3); -#elif defined(FFX_HLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#elif defined(FFX_HLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) // requires SM6.0 FfxUInt32 quad = WaveGetLaneIndex() & (~0x3); @@ -196,7 +219,7 @@ FfxFloat32x4 SpdReduceLoadSourceImage4(FfxUInt32x2 i0, FfxUInt32x2 i1, FfxUInt32 FfxFloat32x4 SpdReduceLoadSourceImage(FfxUInt32x2 base, FfxUInt32 slice) { -#ifdef SPD_LINEAR_SAMPLER +#if defined(SPD_LINEAR_SAMPLER) return SpdLoadSourceImage(FfxInt32x2(base), slice); #else return SpdReduceLoadSourceImage4(FfxUInt32x2(base + FfxUInt32x2(0, 0)), FfxUInt32x2(base + FfxUInt32x2(0, 1)), FfxUInt32x2(base + FfxUInt32x2(1, 0)), FfxUInt32x2(base + FfxUInt32x2(1, 1)), slice); @@ -281,13 +304,13 @@ void SpdDownsampleMips_0_1_LDS(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID for (FfxUInt32 i = 0; i < 4; i++) { SpdStoreIntermediate(x, y, v[i]); - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); if (localInvocationIndex < 64) { v[i] = SpdReduceIntermediate(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); SpdStore(FfxInt32x2(workGroupID.xy * 16) + FfxInt32x2(x + (i % 2) * 8, y + (i / 2) * 8), v[i], 1, slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); } if (localInvocationIndex < 64) @@ -301,7 +324,7 @@ void SpdDownsampleMips_0_1_LDS(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID void SpdDownsampleMips_0_1(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) SpdDownsampleMips_0_1_LDS(x, y, workGroupID, localInvocationIndex, mip, slice); #else SpdDownsampleMips_0_1_Intrinsics(x, y, workGroupID, localInvocationIndex, mip, slice); @@ -311,7 +334,7 @@ void SpdDownsampleMips_0_1(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, Ff void SpdDownsampleMip_2(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 64) { FfxFloat32x4 v = SpdReduceIntermediate(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); @@ -340,7 +363,7 @@ void SpdDownsampleMip_2(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_3(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 16) { // x 0 x 0 @@ -380,7 +403,7 @@ void SpdDownsampleMip_3(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_4(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 4) { // x 0 0 0 x 0 0 0 @@ -413,7 +436,7 @@ void SpdDownsampleMip_4(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUI void SpdDownsampleMip_5(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 1) { // x x x x 0 ... @@ -470,48 +493,75 @@ void SpdDownsampleNextFour(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, Ff { if (mips <= baseMip) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_2(x, y, workGroupID, localInvocationIndex, baseMip, slice); if (mips <= baseMip + 1) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_3(x, y, workGroupID, localInvocationIndex, baseMip + 1, slice); if (mips <= baseMip + 2) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_4(x, y, workGroupID, localInvocationIndex, baseMip + 2, slice); if (mips <= baseMip + 3) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_5(workGroupID, localInvocationIndex, baseMip + 3, slice); } +/// Downsamples a 64x64 tile based on the work group id. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// +/// @ingroup FfxGPUSpd void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice) { + // compute MIP level 0 and 1 FfxUInt32x2 sub_xy = ffxRemapForWaveReduction(localInvocationIndex % 64); FfxUInt32 x = sub_xy.x + 8 * ((localInvocationIndex >> 6) % 2); FfxUInt32 y = sub_xy.y + 8 * ((localInvocationIndex >> 7)); SpdDownsampleMips_0_1(x, y, workGroupID, localInvocationIndex, mips, slice); + // compute MIP level 2, 3, 4, 5 SpdDownsampleNextFour(x, y, workGroupID, localInvocationIndex, 2, mips, slice); if (mips <= 6) return; + // increase the global atomic counter for the given slice and check if it's the last remaining thread group: + // terminate if not, continue if yes. if (SpdExitWorkgroup(numWorkGroups, localInvocationIndex, slice)) return; + // reset the global atomic counter back to 0 for the next spd dispatch SpdResetAtomicCounter(slice); - // After mip 6 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // After mip 5 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // compute MIP level 6 and 7 SpdDownsampleMips_6_7(x, y, mips, slice); + // compute MIP level 8, 9, 10, 11 SpdDownsampleNextFour(x, y, FfxUInt32x2(0, 0), localInvocationIndex, 8, mips, slice); } - +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// @param [in] workGroupOffset the work group offset. it's (0,0) in case the entire input texture is downsampled. +/// +/// @ingroup FfxGPUSpd void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice, FfxUInt32x2 workGroupOffset) { SpdDownsample(workGroupID + workGroupOffset, localInvocationIndex, mips, numWorkGroups, slice); @@ -528,13 +578,13 @@ void SpdDownsample(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxU FfxFloat16x4 SpdReduceQuadH(FfxFloat16x4 v) { -#if defined(FFX_GLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#if defined(FFX_GLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) FfxFloat16x4 v0 = v; FfxFloat16x4 v1 = subgroupQuadSwapHorizontal(v); FfxFloat16x4 v2 = subgroupQuadSwapVertical(v); FfxFloat16x4 v3 = subgroupQuadSwapDiagonal(v); return SpdReduce4H(v0, v1, v2, v3); -#elif defined(FFX_HLSL) && !defined(SPD_NO_WAVE_OPERATIONS) +#elif defined(FFX_HLSL) && !defined(FFX_SPD_NO_WAVE_OPERATIONS) // requires SM6.0 FfxUInt32 quad = WaveGetLaneIndex() & (~0x3); FfxFloat16x4 v0 = v; @@ -603,7 +653,7 @@ FfxFloat16x4 SpdReduceLoadSourceImage4H(FfxUInt32x2 i0, FfxUInt32x2 i1, FfxUInt3 FfxFloat16x4 SpdReduceLoadSourceImageH(FfxUInt32x2 base, FfxUInt32 slice) { -#ifdef SPD_LINEAR_SAMPLER +#if defined(SPD_LINEAR_SAMPLER) return SpdLoadSourceImageH(FfxInt32x2(base), slice); #else return SpdReduceLoadSourceImage4H(FfxUInt32x2(base + FfxUInt32x2(0, 0)), FfxUInt32x2(base + FfxUInt32x2(0, 1)), FfxUInt32x2(base + FfxUInt32x2(1, 0)), FfxUInt32x2(base + FfxUInt32x2(1, 1)), slice); @@ -685,16 +735,16 @@ void SpdDownsampleMips_0_1_LDSH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupI if (mips <= 1) return; - for (FfxInt32 i = 0; i < 4; i++) + for (FfxUInt32 i = 0; i < 4; i++) { SpdStoreIntermediateH(x, y, v[i]); - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); if (localInvocationIndex < 64) { v[i] = SpdReduceIntermediateH(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); SpdStoreH(FfxInt32x2(workGroupID.xy * 16) + FfxInt32x2(x + (i % 2) * 8, y + (i / 2) * 8), v[i], 1, slice); } - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); } if (localInvocationIndex < 64) @@ -708,7 +758,7 @@ void SpdDownsampleMips_0_1_LDSH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupI void SpdDownsampleMips_0_1H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) SpdDownsampleMips_0_1_LDSH(x, y, workGroupID, localInvocationIndex, mips, slice); #else SpdDownsampleMips_0_1_IntrinsicsH(x, y, workGroupID, localInvocationIndex, mips, slice); @@ -718,7 +768,7 @@ void SpdDownsampleMips_0_1H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, F void SpdDownsampleMip_2H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 64) { FfxFloat16x4 v = SpdReduceIntermediateH(FfxUInt32x2(x * 2 + 0, y * 2 + 0), FfxUInt32x2(x * 2 + 1, y * 2 + 0), FfxUInt32x2(x * 2 + 0, y * 2 + 1), FfxUInt32x2(x * 2 + 1, y * 2 + 1)); @@ -747,7 +797,7 @@ void SpdDownsampleMip_2H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_3H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 16) { // x 0 x 0 @@ -787,7 +837,7 @@ void SpdDownsampleMip_3H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_4H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 4) { // x 0 0 0 x 0 0 0 @@ -820,7 +870,7 @@ void SpdDownsampleMip_4H(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, FfxU void SpdDownsampleMip_5H(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mip, FfxUInt32 slice) { -#ifdef SPD_NO_WAVE_OPERATIONS +#if defined(FFX_SPD_NO_WAVE_OPERATIONS) if (localInvocationIndex < 1) { // x x x x 0 ... @@ -877,53 +927,83 @@ void SpdDownsampleNextFourH(FfxUInt32 x, FfxUInt32 y, FfxUInt32x2 workGroupID, F { if (mips <= baseMip) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_2H(x, y, workGroupID, localInvocationIndex, baseMip, slice); if (mips <= baseMip + 1) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_3H(x, y, workGroupID, localInvocationIndex, baseMip + 1, slice); if (mips <= baseMip + 2) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_4H(x, y, workGroupID, localInvocationIndex, baseMip + 2, slice); if (mips <= baseMip + 3) return; - SpdWorkgroupShuffleBarrier(); + ffxSpdWorkgroupShuffleBarrier(); SpdDownsampleMip_5H(workGroupID, localInvocationIndex, baseMip + 3, slice); } +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// Uses half types. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// +/// @ingroup FfxGPUSpd void SpdDownsampleH(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice) { FfxUInt32x2 sub_xy = ffxRemapForWaveReduction(localInvocationIndex % 64); FfxUInt32 x = sub_xy.x + 8 * ((localInvocationIndex >> 6) % 2); FfxUInt32 y = sub_xy.y + 8 * ((localInvocationIndex >> 7)); + // compute MIP level 0 and 1 SpdDownsampleMips_0_1H(x, y, workGroupID, localInvocationIndex, mips, slice); + // compute MIP level 2, 3, 4, 5 SpdDownsampleNextFourH(x, y, workGroupID, localInvocationIndex, 2, mips, slice); if (mips < 7) return; + // increase the global atomic counter for the given slice and check if it's the last remaining thread group: + // terminate if not, continue if yes. if (SpdExitWorkgroup(numWorkGroups, localInvocationIndex, slice)) return; + // reset the global atomic counter back to 0 for the next spd dispatch SpdResetAtomicCounter(slice); - // After mip 6 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // After mip 5 there is only a single workgroup left that downsamples the remaining up to 64x64 texels. + // compute MIP level 6 and 7 SpdDownsampleMips_6_7H(x, y, mips, slice); + // compute MIP level 8, 9, 10, 11 SpdDownsampleNextFourH(x, y, FfxUInt32x2(0, 0), localInvocationIndex, 8, mips, slice); } +/// Downsamples a 64x64 tile based on the work group id and work group offset. +/// If after downsampling it's the last active thread group, computes the remaining MIP levels. +/// Uses half types. +/// +/// @param [in] workGroupID index of the work group / thread group +/// @param [in] localInvocationIndex index of the thread within the thread group in 1D +/// @param [in] mips the number of total MIP levels to compute for the input texture +/// @param [in] numWorkGroups the total number of dispatched work groups / thread groups for this slice +/// @param [in] slice the slice of the input texture +/// @param [in] workGroupOffset the work group offset. it's (0,0) in case the entire input texture is downsampled. +/// +/// @ingroup FfxGPUSpd void SpdDownsampleH(FfxUInt32x2 workGroupID, FfxUInt32 localInvocationIndex, FfxUInt32 mips, FfxUInt32 numWorkGroups, FfxUInt32 slice, FfxUInt32x2 workGroupOffset) { SpdDownsampleH(workGroupID + workGroupOffset, localInvocationIndex, mips, numWorkGroups, slice); } #endif // #if FFX_HALF -#endif // #ifdef FFX_GPU +#endif // #if defined(FFX_GPU) diff --git a/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta new file mode 100644 index 0000000..8d4e716 --- /dev/null +++ b/com.unity.postprocessing/PostProcessing/Shaders/FSR3/shaders/fsr3upscaler/spd/ffx_spd.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: face65176ee3b82498bd0b8fed0ddacd +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/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl b/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl index 01501ec..9259be0 100644 --- a/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl +++ b/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl @@ -27,6 +27,8 @@ #include "API/Metal.hlsl" #elif defined(SHADER_API_PSP2) #include "API/PSP2.hlsl" +#elif defined(SHADER_API_WEBGPU) + #include "API/WebGPU.hlsl" #else #include "API/OpenGL.hlsl" #endif diff --git a/com.unity.postprocessing/package.json b/com.unity.postprocessing/package.json index 6b5ef79..6d0688d 100644 --- a/com.unity.postprocessing/package.json +++ b/com.unity.postprocessing/package.json @@ -1,6 +1,6 @@ { "name": "com.unity.postprocessing", - "version": "3.3.1", + "version": "3.4.0", "displayName": "Post Processing", "unity": "2019.4", "unityRelease": "19f1", diff --git a/images/camera-ppv2.png b/images/camera-ppv2.png index 795d36f..d417a13 100644 Binary files a/images/camera-ppv2.png and b/images/camera-ppv2.png differ diff --git a/images/camera-simple.png b/images/camera-simple.png index 0b336da..4c67dac 100644 Binary files a/images/camera-simple.png and b/images/camera-simple.png differ diff --git a/images/comparison.png b/images/comparison.png index 79671bf..e379f8c 100644 Binary files a/images/comparison.png and b/images/comparison.png differ diff --git a/images/ppv2layer.png b/images/ppv2layer.png index 7904d1c..592e68b 100644 Binary files a/images/ppv2layer.png and b/images/ppv2layer.png differ