diff --git a/Runtime/Common/FfxPassBase.cs b/Runtime/Common/FfxPassBase.cs index 5985cd2..c1e44cc 100644 --- a/Runtime/Common/FfxPassBase.cs +++ b/Runtime/Common/FfxPassBase.cs @@ -5,29 +5,18 @@ using UnityEngine.Rendering; namespace FidelityFX { - internal abstract class FfxPassBase: IDisposable - where TDispatch: struct + internal abstract class FfxPassBase: IDisposable { private readonly string _techName; + private string _passName; protected ComputeShader ComputeShader; protected int KernelIndex; - - protected CustomSampler Sampler; protected FfxPassBase(string techName) { _techName = techName; } - - public void ScheduleDispatch(CommandBuffer commandBuffer, in TDispatch dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ = 1) - { - commandBuffer.BeginSample(Sampler); - DoScheduleDispatch(commandBuffer, dispatchParams, bufferIndex, dispatchX, dispatchY, dispatchZ); - commandBuffer.EndSample(Sampler); - } - - protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, in TDispatch dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ); protected virtual void InitComputeShader(string passName, ComputeShader shader, string kernelName = "CS") { @@ -36,18 +25,40 @@ namespace FidelityFX throw new MissingReferenceException($"Shader for {_techName} pass '{passName}' could not be loaded! Please ensure it is included in the project correctly."); } + _passName = passName; ComputeShader = shader; KernelIndex = ComputeShader.FindKernel(kernelName); - Sampler = CustomSampler.Create(passName); } public virtual void Dispose() { } + + protected ProfilerSampler ProfilerSample(CommandBuffer commandBuffer) + { + return new ProfilerSampler(_passName, commandBuffer); + } + + protected readonly struct ProfilerSampler : IDisposable + { + private readonly string _name; + private readonly CommandBuffer _commandBuffer; + + public ProfilerSampler(string name, CommandBuffer commandBuffer) + { + _name = name; + _commandBuffer = commandBuffer; + _commandBuffer.BeginSample(_name); + } + + public void Dispose() + { + _commandBuffer.EndSample(_name); + } + } } - internal abstract class FfxPassWithFlags : FfxPassBase - where TDispatch: struct + internal abstract class FfxPassWithFlags : FfxPassBase where TFlags: Enum { protected readonly TFlags Flags; diff --git a/Runtime/FSR2/Fsr2Context.cs b/Runtime/FSR2/Fsr2Context.cs index babd4d3..71bdedb 100644 --- a/Runtime/FSR2/Fsr2Context.cs +++ b/Runtime/FSR2/Fsr2Context.cs @@ -137,7 +137,7 @@ namespace FidelityFX.FSR2 } if (dispatchParams.UseTextureArrays) - commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); + commandBuffer.EnableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY"); if (_firstExecution) { @@ -261,7 +261,7 @@ namespace FidelityFX.FSR2 Fsr2Resources.DestroyAliasableResources(commandBuffer); - commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); + commandBuffer.DisableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY"); commandBuffer.EndSample(_sampler); } diff --git a/Runtime/FSR2/Fsr2Pass.cs b/Runtime/FSR2/Fsr2Pass.cs index 4d8df06..00a8f7e 100644 --- a/Runtime/FSR2/Fsr2Pass.cs +++ b/Runtime/FSR2/Fsr2Pass.cs @@ -28,7 +28,7 @@ namespace FidelityFX.FSR2 /// This loosely matches the FfxPipelineState struct from the original FSR2 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: FfxPassWithFlags + internal abstract class Fsr2Pass: FfxPassWithFlags { internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define @@ -42,6 +42,16 @@ namespace FidelityFX.FSR2 Constants = constants; } + public void ScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ = 1) + { + using (ProfilerSample(commandBuffer)) + { + Dispatch(commandBuffer, dispatchParams, bufferIndex, dispatchX, dispatchY, dispatchZ); + } + } + + protected abstract void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ); + protected override void SetupShaderKeywords() { bool useLut = false; @@ -74,7 +84,7 @@ namespace FidelityFX.FSR2 InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.computeLuminancePyramidPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color); @@ -98,7 +108,7 @@ namespace FidelityFX.FSR2 InitComputeShader("Reconstruct & Dilate", contextDescription.Shaders.reconstructPreviousDepthPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth); @@ -121,7 +131,7 @@ namespace FidelityFX.FSR2 InitComputeShader("Depth Clip", contextDescription.Shaders.depthClipPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth); @@ -149,7 +159,7 @@ namespace FidelityFX.FSR2 InitComputeShader("Create Locks", contextDescription.Shaders.lockPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockInputLuma, Fsr2ShaderIDs.UavLockInputLuma); commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants); @@ -175,7 +185,7 @@ namespace FidelityFX.FSR2 #endif } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { #if UNITY_2021_2_OR_NEWER if (dispatchParams.EnableSharpening) @@ -234,7 +244,7 @@ namespace FidelityFX.FSR2 InitComputeShader("RCAS Sharpening", contextDescription.Shaders.sharpenPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]); @@ -260,23 +270,22 @@ namespace FidelityFX.FSR2 InitComputeShader("Auto-Generate Reactive Mask", contextDescription.Shaders.autoGenReactivePass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { } public void ScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { - commandBuffer.BeginSample(Sampler); - - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale); - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, dispatchParams.OutReactive); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _generateReactiveConstants); - - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); - - commandBuffer.EndSample(Sampler); + using (ProfilerSample(commandBuffer)) + { + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale); + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, dispatchParams.OutReactive); + + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _generateReactiveConstants); + + commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); + } } } @@ -292,7 +301,7 @@ namespace FidelityFX.FSR2 InitComputeShader("Auto-Generate Transparency & Composition Mask", contextDescription.Shaders.tcrAutoGenPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr2.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color); diff --git a/Runtime/FSR3/Fsr3UpscalerContext.cs b/Runtime/FSR3/Fsr3UpscalerContext.cs index c21a80a..b677f81 100644 --- a/Runtime/FSR3/Fsr3UpscalerContext.cs +++ b/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -154,7 +154,7 @@ namespace FidelityFX.FSR3 } if (dispatchParams.UseTextureArrays) - commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); + commandBuffer.EnableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY"); if (_firstExecution) { @@ -284,7 +284,7 @@ namespace FidelityFX.FSR3 Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); - commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); + commandBuffer.DisableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY"); commandBuffer.EndSample(_sampler); } diff --git a/Runtime/FSR3/Fsr3UpscalerPass.cs b/Runtime/FSR3/Fsr3UpscalerPass.cs index 73b7a3c..cdf9e48 100644 --- a/Runtime/FSR3/Fsr3UpscalerPass.cs +++ b/Runtime/FSR3/Fsr3UpscalerPass.cs @@ -28,7 +28,7 @@ namespace FidelityFX.FSR3 /// 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 Fsr3UpscalerPass: FfxPassWithFlags + internal abstract class Fsr3UpscalerPass: FfxPassWithFlags { protected readonly Fsr3UpscalerResources Resources; protected readonly ComputeBuffer Constants; @@ -39,6 +39,16 @@ namespace FidelityFX.FSR3 Resources = resources; Constants = constants; } + + public void ScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ = 1) + { + using (ProfilerSample(commandBuffer)) + { + Dispatch(commandBuffer, dispatchParams, bufferIndex, dispatchX, dispatchY, dispatchZ); + } + } + + protected abstract void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ); protected override void SetupShaderKeywords() { @@ -68,7 +78,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Prepare Inputs", contextDescription.Shaders.prepareInputsPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.Color); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, dispatchParams.Depth); @@ -98,7 +108,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.lumaPyramidPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[bufferIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, Fsr3ShaderIDs.UavIntermediate); @@ -131,7 +141,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Compute Shading Change Pyramid", contextDescription.Shaders.shadingChangePyramidPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[bufferIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreviousLuma, Resources.Luma[bufferIndex ^ 1]); @@ -161,7 +171,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Compute Shading Change", contextDescription.Shaders.shadingChangePass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSpdMips, Resources.SpdMips); @@ -179,7 +189,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Prepare Reactivity", contextDescription.Shaders.prepareReactivityPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvReconstructedPrevNearestDepth, Resources.ReconstructedPrevNearestDepth); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); @@ -207,7 +217,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Compute Luminance Instability", contextDescription.Shaders.lumaInstabilityPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, dispatchParams.Exposure); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); @@ -243,7 +253,7 @@ namespace FidelityFX.FSR3 #endif } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { #if UNITY_2021_2_OR_NEWER if (dispatchParams.EnableSharpening) @@ -297,7 +307,7 @@ namespace FidelityFX.FSR3 InitComputeShader("RCAS Sharpening", contextDescription.Shaders.sharpenPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, dispatchParams.Exposure); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]); @@ -323,23 +333,22 @@ namespace FidelityFX.FSR3 InitComputeShader("Auto-Generate Reactive Mask", contextDescription.Shaders.autoGenReactivePass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { } public void ScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) { - commandBuffer.BeginSample(Sampler); - - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale); - commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, dispatchParams.OutReactive); - - commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants); - - commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); - - commandBuffer.EndSample(Sampler); + using (ProfilerSample(commandBuffer)) + { + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale); + commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavAutoReactive, dispatchParams.OutReactive); + + commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbGenReactive, _generateReactiveConstants); + + commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); + } } } @@ -355,7 +364,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Auto-Generate Transparency & Composition Mask", contextDescription.Shaders.tcrAutoGenPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.Color); @@ -386,7 +395,7 @@ namespace FidelityFX.FSR3 InitComputeShader("Debug View", contextDescription.Shaders.debugViewPass); } - protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) + protected override void Dispatch(CommandBuffer commandBuffer, in Fsr3Upscaler.DispatchDescription dispatchParams, int bufferIndex, int dispatchX, int dispatchY, int dispatchZ) { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); diff --git a/Shaders/ffx_fsr2_accumulate_pass.compute b/Shaders/ffx_fsr2_accumulate_pass.compute index 63532d7..116006a 100644 --- a/Shaders/ffx_fsr2_accumulate_pass.compute +++ b/Shaders/ffx_fsr2_accumulate_pass.compute @@ -28,9 +28,9 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #pragma multi_compile_local __ FFX_FSR2_OPTION_APPLY_SHARPENING -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_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 diff --git a/Shaders/ffx_fsr2_autogen_reactive_pass.compute b/Shaders/ffx_fsr2_autogen_reactive_pass.compute index 6bc2301..91f19d2 100644 --- a/Shaders/ffx_fsr2_autogen_reactive_pass.compute +++ b/Shaders/ffx_fsr2_autogen_reactive_pass.compute @@ -25,8 +25,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_autogen_reactive_pass.hlsl" diff --git a/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute b/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute index 7058cc5..2c47f2a 100644 --- a/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute +++ b/Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute @@ -25,9 +25,9 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_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. diff --git a/Shaders/ffx_fsr2_depth_clip_pass.compute b/Shaders/ffx_fsr2_depth_clip_pass.compute index 582ca6b..970defd 100644 --- a/Shaders/ffx_fsr2_depth_clip_pass.compute +++ b/Shaders/ffx_fsr2_depth_clip_pass.compute @@ -25,8 +25,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_depth_clip_pass.hlsl" diff --git a/Shaders/ffx_fsr2_lock_pass.compute b/Shaders/ffx_fsr2_lock_pass.compute index fb12d2c..7fa4ee5 100644 --- a/Shaders/ffx_fsr2_lock_pass.compute +++ b/Shaders/ffx_fsr2_lock_pass.compute @@ -25,8 +25,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_lock_pass.hlsl" diff --git a/Shaders/ffx_fsr2_rcas_pass.compute b/Shaders/ffx_fsr2_rcas_pass.compute index e6ac7df..8445044 100644 --- a/Shaders/ffx_fsr2_rcas_pass.compute +++ b/Shaders/ffx_fsr2_rcas_pass.compute @@ -24,8 +24,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_rcas_pass.hlsl" diff --git a/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute b/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute index 12f2ec3..ba7f307 100644 --- a/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute +++ b/Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute @@ -26,8 +26,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl" diff --git a/Shaders/ffx_fsr2_tcr_autogen_pass.compute b/Shaders/ffx_fsr2_tcr_autogen_pass.compute index 5d2668a..72e1011 100644 --- a/Shaders/ffx_fsr2_tcr_autogen_pass.compute +++ b/Shaders/ffx_fsr2_tcr_autogen_pass.compute @@ -25,8 +25,8 @@ #pragma multi_compile_local __ FFX_FSR2_OPTION_JITTERED_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr2_tcr_autogen_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_accumulate_pass.compute b/Shaders/ffx_fsr3upscaler_accumulate_pass.compute index a8d6864..8c2e1ed 100644 --- a/Shaders/ffx_fsr3upscaler_accumulate_pass.compute +++ b/Shaders/ffx_fsr3upscaler_accumulate_pass.compute @@ -26,9 +26,9 @@ #pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_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_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE diff --git a/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute b/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute index 500352a..03e937f 100644 --- a/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute +++ b/Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute @@ -22,8 +22,8 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_debug_view_pass.compute b/Shaders/ffx_fsr3upscaler_debug_view_pass.compute index 027e414..d4aaf19 100644 --- a/Shaders/ffx_fsr3upscaler_debug_view_pass.compute +++ b/Shaders/ffx_fsr3upscaler_debug_view_pass.compute @@ -22,8 +22,8 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_debug_view_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute b/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute index 5cffc66..b77652e 100644 --- a/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute +++ b/Shaders/ffx_fsr3upscaler_luma_instability_pass.compute @@ -22,8 +22,8 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_luma_instability_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute b/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute index 347b0d6..b94f382 100644 --- a/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute +++ b/Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute @@ -22,9 +22,9 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_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. diff --git a/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute b/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute index b71ea5d..5f33ec8 100644 --- a/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute +++ b/Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute @@ -24,8 +24,8 @@ #pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS #pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_prepare_inputs_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute b/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute index ebf4e91..ed7d2aa 100644 --- a/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute +++ b/Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute @@ -22,8 +22,8 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_prepare_reactivity_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_rcas_pass.compute b/Shaders/ffx_fsr3upscaler_rcas_pass.compute index 282a9ae..ea83679 100644 --- a/Shaders/ffx_fsr3upscaler_rcas_pass.compute +++ b/Shaders/ffx_fsr3upscaler_rcas_pass.compute @@ -20,8 +20,8 @@ #pragma kernel CS -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_rcas_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_shading_change_pass.compute b/Shaders/ffx_fsr3upscaler_shading_change_pass.compute index 34c3ade..8add698 100644 --- a/Shaders/ffx_fsr3upscaler_shading_change_pass.compute +++ b/Shaders/ffx_fsr3upscaler_shading_change_pass.compute @@ -22,8 +22,8 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_shading_change_pass.hlsl" diff --git a/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute b/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute index ffe5bfe..4816cf2 100644 --- a/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute +++ b/Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute @@ -22,9 +22,9 @@ #pragma multi_compile_local __ FFX_HALF -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" // Wave operations require shader model 6.0; this can only be enabled when using DXC on D3D12 #define FFX_SPD_NO_WAVE_OPERATIONS diff --git a/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute b/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute index 952c052..6161e39 100644 --- a/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute +++ b/Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute @@ -23,8 +23,8 @@ #pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS -#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY +#pragma multi_compile __ UNITY_FFX_TEXTURE2D_X_ARRAY -#include "ffx_fsr_unity_common.cginc" +#include "ffx_unity_common.cginc" #include "shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl" diff --git a/Shaders/ffx_fsr_unity_common.cginc b/Shaders/ffx_unity_common.cginc similarity index 92% rename from Shaders/ffx_fsr_unity_common.cginc rename to Shaders/ffx_unity_common.cginc index b1bcb5c..ea14122 100644 --- a/Shaders/ffx_fsr_unity_common.cginc +++ b/Shaders/ffx_unity_common.cginc @@ -52,7 +52,7 @@ #endif // Control if TEXTURE2D_X macros will expand to texture arrays -#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && defined(UNITY_FSR_TEXTURE2D_X_ARRAY) +#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && defined(UNITY_FFX_TEXTURE2D_X_ARRAY) #define USE_TEXTURE2D_X_AS_ARRAY #endif @@ -73,10 +73,10 @@ #endif // Declare and sample camera buffers as texture arrays - #define UNITY_FSR_TEX2D(type) Texture2DArray - #define UNITY_FSR_RWTEX2D(type) RWTexture2DArray - #define UNITY_FSR_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) - #define UNITY_FSR_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) - #define UNITY_FSR_GETDIMS(tex, w, h) { FfxUInt32 uElements; (tex).GetDimensions((w), (h), uElements); } + #define UNITY_FFX_TEX2D(type) Texture2DArray + #define UNITY_FFX_RWTEX2D(type) RWTexture2DArray + #define UNITY_FFX_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX) + #define UNITY_FFX_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX) + #define UNITY_FFX_GETDIMS(tex, w, h) { FfxUInt32 uElements; (tex).GetDimensions((w), (h), uElements); } #endif diff --git a/Shaders/ffx_fsr_unity_common.cginc.meta b/Shaders/ffx_unity_common.cginc.meta similarity index 100% rename from Shaders/ffx_fsr_unity_common.cginc.meta rename to Shaders/ffx_unity_common.cginc.meta diff --git a/Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h b/Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h index c52cc1a..2029ee5 100644 --- a/Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h +++ b/Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h @@ -340,17 +340,17 @@ FfxUInt32x2 SPD_RenderSize() #endif // #if defined(FSR2_BIND_CB_SPD) // Declare and sample camera buffers as regular textures, unless overridden -#if !defined(UNITY_FSR_TEX2D) -#define UNITY_FSR_TEX2D(type) Texture2D +#if !defined(UNITY_FFX_TEX2D) +#define UNITY_FFX_TEX2D(type) Texture2D #endif -#if !defined(UNITY_FSR_RWTEX2D) -#define UNITY_FSR_RWTEX2D(type) RWTexture2D +#if !defined(UNITY_FFX_RWTEX2D) +#define UNITY_FFX_RWTEX2D(type) RWTexture2D #endif -#if !defined(UNITY_FSR_POS) -#define UNITY_FSR_POS(pxPos) (pxPos) +#if !defined(UNITY_FFX_POS) +#define UNITY_FFX_POS(pxPos) (pxPos) #endif -#if !defined(UNITY_FSR_UV) -#define UNITY_FSR_UV(uv) (uv) +#if !defined(UNITY_FFX_UV) +#define UNITY_FFX_UV(uv) (uv) #endif SamplerState s_PointClamp : register(s0); @@ -358,16 +358,16 @@ SamplerState s_LinearClamp : register(s1); // SRVs #if defined FSR2_BIND_SRV_INPUT_COLOR - UNITY_FSR_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); + UNITY_FFX_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_FSR_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); + UNITY_FFX_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_FSR_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); + UNITY_FFX_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_FSR_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); + UNITY_FFX_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); @@ -376,10 +376,10 @@ SamplerState s_LinearClamp : register(s1); Texture2D r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); #endif #if defined FSR2_BIND_SRV_REACTIVE_MASK - UNITY_FSR_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); + UNITY_FFX_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); #endif #if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK - UNITY_FSR_TEX2D(FfxFloat32) r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); + UNITY_FFX_TEX2D(FfxFloat32) 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); @@ -463,7 +463,7 @@ SamplerState s_LinearClamp : register(s1); RWTexture2D rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); #endif #if defined FSR2_BIND_UAV_UPSCALED_OUTPUT - UNITY_FSR_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); + UNITY_FFX_RWTEX2D(FfxFloat32x4) 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); @@ -514,42 +514,42 @@ FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) #if defined(FSR2_BIND_SRV_INPUT_DEPTH) FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) { - return r_input_depth[UNITY_FSR_POS(iPxPos)]; + return r_input_depth[UNITY_FFX_POS(iPxPos)]; } #endif #if defined(FSR2_BIND_SRV_INPUT_DEPTH) FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) { - return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; + return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).x; } #endif #if defined(FSR2_BIND_SRV_REACTIVE_MASK) FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) { - return r_reactive_mask[UNITY_FSR_POS(iPxPos)]; + return r_reactive_mask[UNITY_FFX_POS(iPxPos)]; } #endif #if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) { - return r_transparency_and_composition_mask[UNITY_FSR_POS(iPxPos)]; + return r_transparency_and_composition_mask[UNITY_FFX_POS(iPxPos)]; } #endif #if defined(FSR2_BIND_SRV_INPUT_COLOR) FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) { - return r_input_color_jittered[UNITY_FSR_POS(iPxPos)].rgb; + return r_input_color_jittered[UNITY_FFX_POS(iPxPos)].rgb; } #endif #if defined(FSR2_BIND_SRV_INPUT_COLOR) FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) { - return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).rgb; + return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).rgb; } #endif @@ -563,7 +563,7 @@ FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos) #if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) { - FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR_POS(iPxDilatedMotionVectorPos)].xy; + FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FFX_POS(iPxDilatedMotionVectorPos)].xy; FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); @@ -622,7 +622,7 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh #if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) { - rw_upscaled_output[UNITY_FSR_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); + rw_upscaled_output[UNITY_FFX_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); } #endif @@ -833,7 +833,7 @@ void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETE #if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) { - return r_input_opaque_only[UNITY_FSR_POS(iPxPos)].xyz; + return r_input_opaque_only[UNITY_FFX_POS(iPxPos)].xyz; } #endif diff --git a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h index 1c3fc99..45bfd43 100644 --- a/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h +++ b/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h @@ -320,20 +320,20 @@ FfxUInt32x2 SPD_RenderSize() #endif // #if defined(FSR3UPSCALER_BIND_CB_SPD) // Declare and sample camera buffers as regular textures, unless overridden -#if !defined(UNITY_FSR_TEX2D) -#define UNITY_FSR_TEX2D(type) Texture2D +#if !defined(UNITY_FFX_TEX2D) +#define UNITY_FFX_TEX2D(type) Texture2D #endif -#if !defined(UNITY_FSR_RWTEX2D) -#define UNITY_FSR_RWTEX2D(type) RWTexture2D +#if !defined(UNITY_FFX_RWTEX2D) +#define UNITY_FFX_RWTEX2D(type) RWTexture2D #endif -#if !defined(UNITY_FSR_POS) -#define UNITY_FSR_POS(pxPos) (pxPos) +#if !defined(UNITY_FFX_POS) +#define UNITY_FFX_POS(pxPos) (pxPos) #endif -#if !defined(UNITY_FSR_UV) -#define UNITY_FSR_UV(uv) (uv) +#if !defined(UNITY_FFX_UV) +#define UNITY_FFX_UV(uv) (uv) #endif -#if !defined(UNITY_FSR_GETDIMS) -#define UNITY_FSR_GETDIMS(tex, w, h) (tex).GetDimensions((w), (h)) +#if !defined(UNITY_FFX_GETDIMS) +#define UNITY_FFX_GETDIMS(tex, w, h) (tex).GetDimensions((w), (h)) #endif SamplerState s_PointClamp : register(s0); @@ -359,85 +359,85 @@ FfxFloat32x2 SampleSPDMipLevel(FfxFloat32x2 fUV, FfxUInt32 mipLevel) #endif #if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) -UNITY_FSR_TEX2D(FfxFloat32) r_input_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH); +UNITY_FFX_TEX2D(FfxFloat32) r_input_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH); FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) { - return r_input_depth[UNITY_FSR_POS(iPxPos)]; + return r_input_depth[UNITY_FFX_POS(iPxPos)]; } FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) { - return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; + return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).x; } #endif #if defined(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK) -UNITY_FSR_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK); +UNITY_FFX_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK); FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) { - return r_reactive_mask[UNITY_FSR_POS(iPxPos)]; + return r_reactive_mask[UNITY_FFX_POS(iPxPos)]; } FfxInt32x2 GetReactiveMaskResourceDimensions() { FfxUInt32 uWidth; FfxUInt32 uHeight; - UNITY_FSR_GETDIMS(r_reactive_mask, uWidth, uHeight); + UNITY_FFX_GETDIMS(r_reactive_mask, uWidth, uHeight); return FfxInt32x2(uWidth, uHeight); } FfxFloat32 SampleReactiveMask(FfxFloat32x2 fUV) { - return r_reactive_mask.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; + return r_reactive_mask.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).x; } #endif #if defined(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) -UNITY_FSR_TEX2D(FfxFloat32) r_transparency_and_composition_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); +UNITY_FFX_TEX2D(FfxFloat32) r_transparency_and_composition_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) { - return r_transparency_and_composition_mask[UNITY_FSR_POS(iPxPos)]; + return r_transparency_and_composition_mask[UNITY_FFX_POS(iPxPos)]; } FfxInt32x2 GetTransparencyAndCompositionMaskResourceDimensions() { FfxUInt32 uWidth; FfxUInt32 uHeight; - UNITY_FSR_GETDIMS(r_transparency_and_composition_mask, uWidth, uHeight); + UNITY_FFX_GETDIMS(r_transparency_and_composition_mask, uWidth, uHeight); return FfxInt32x2(uWidth, uHeight); } FfxFloat32 SampleTransparencyAndCompositionMask(FfxFloat32x2 fUV) { - return r_transparency_and_composition_mask.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; + return r_transparency_and_composition_mask.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).x; } #endif #if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) -UNITY_FSR_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_COLOR); +UNITY_FFX_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_COLOR); FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) { - return r_input_color_jittered[UNITY_FSR_POS(iPxPos)].rgb; + return r_input_color_jittered[UNITY_FFX_POS(iPxPos)].rgb; } FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) { - return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).rgb; + return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FFX_UV(fUV), 0).rgb; } #endif #if defined(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS) -UNITY_FSR_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS); +UNITY_FFX_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS); FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) { - FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR_POS(iPxDilatedMotionVectorPos)].xy; + FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FFX_POS(iPxDilatedMotionVectorPos)].xy; FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); @@ -515,11 +515,11 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh #endif #if defined(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT) -UNITY_FSR_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT); +UNITY_FFX_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT); void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) { - rw_upscaled_output[UNITY_FSR_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); + rw_upscaled_output[UNITY_FFX_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); } #endif @@ -830,11 +830,11 @@ void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETE #endif #if defined(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY) -UNITY_FSR_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY); +UNITY_FFX_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY); FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) { - return r_input_opaque_only[UNITY_FSR_POS(iPxPos)].xyz; + return r_input_opaque_only[UNITY_FFX_POS(iPxPos)].xyz; } #endif