Browse Source

Merge branch 'framework' into fsr3framegen

fsr3framegen
Nico de Poel 2 years ago
parent
commit
5e9272b75a
  1. 43
      Runtime/Common/FfxPassBase.cs
  2. 4
      Runtime/FSR2/Fsr2Context.cs
  3. 49
      Runtime/FSR2/Fsr2Pass.cs
  4. 4
      Runtime/FSR3/Fsr3UpscalerContext.cs
  5. 55
      Runtime/FSR3/Fsr3UpscalerPass.cs
  6. 4
      Shaders/ffx_fsr2_accumulate_pass.compute
  7. 4
      Shaders/ffx_fsr2_autogen_reactive_pass.compute
  8. 4
      Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute
  9. 4
      Shaders/ffx_fsr2_depth_clip_pass.compute
  10. 4
      Shaders/ffx_fsr2_lock_pass.compute
  11. 4
      Shaders/ffx_fsr2_rcas_pass.compute
  12. 4
      Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute
  13. 4
      Shaders/ffx_fsr2_tcr_autogen_pass.compute
  14. 4
      Shaders/ffx_fsr3upscaler_accumulate_pass.compute
  15. 4
      Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute
  16. 4
      Shaders/ffx_fsr3upscaler_debug_view_pass.compute
  17. 4
      Shaders/ffx_fsr3upscaler_luma_instability_pass.compute
  18. 4
      Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute
  19. 4
      Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute
  20. 4
      Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute
  21. 4
      Shaders/ffx_fsr3upscaler_rcas_pass.compute
  22. 4
      Shaders/ffx_fsr3upscaler_shading_change_pass.compute
  23. 4
      Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute
  24. 4
      Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute
  25. 12
      Shaders/ffx_unity_common.cginc
  26. 0
      Shaders/ffx_unity_common.cginc.meta
  27. 48
      Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h
  28. 60
      Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h

43
Runtime/Common/FfxPassBase.cs

@ -5,29 +5,18 @@ using UnityEngine.Rendering;
namespace FidelityFX namespace FidelityFX
{ {
internal abstract class FfxPassBase<TDispatch>: IDisposable
where TDispatch: struct
internal abstract class FfxPassBase: IDisposable
{ {
private readonly string _techName; private readonly string _techName;
private string _passName;
protected ComputeShader ComputeShader; protected ComputeShader ComputeShader;
protected int KernelIndex; protected int KernelIndex;
protected CustomSampler Sampler;
protected FfxPassBase(string techName) protected FfxPassBase(string techName)
{ {
_techName = 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") 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."); 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; ComputeShader = shader;
KernelIndex = ComputeShader.FindKernel(kernelName); KernelIndex = ComputeShader.FindKernel(kernelName);
Sampler = CustomSampler.Create(passName);
} }
public virtual void Dispose() 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<TDispatch, TFlags> : FfxPassBase<TDispatch>
where TDispatch: struct
internal abstract class FfxPassWithFlags<TFlags> : FfxPassBase
where TFlags: Enum where TFlags: Enum
{ {
protected readonly TFlags Flags; protected readonly TFlags Flags;

4
Runtime/FSR2/Fsr2Context.cs

@ -137,7 +137,7 @@ namespace FidelityFX.FSR2
} }
if (dispatchParams.UseTextureArrays) if (dispatchParams.UseTextureArrays)
commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY");
commandBuffer.EnableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY");
if (_firstExecution) if (_firstExecution)
{ {
@ -261,7 +261,7 @@ namespace FidelityFX.FSR2
Fsr2Resources.DestroyAliasableResources(commandBuffer); Fsr2Resources.DestroyAliasableResources(commandBuffer);
commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY");
commandBuffer.DisableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY");
commandBuffer.EndSample(_sampler); commandBuffer.EndSample(_sampler);
} }

49
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. /// 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. /// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders.
/// </summary> /// </summary>
internal abstract class Fsr2Pass: FfxPassWithFlags<Fsr2.DispatchDescription, Fsr2.InitializationFlags>
internal abstract class Fsr2Pass: FfxPassWithFlags<Fsr2.InitializationFlags>
{ {
internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define
@ -42,6 +42,16 @@ namespace FidelityFX.FSR2
Constants = constants; 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() protected override void SetupShaderKeywords()
{ {
bool useLut = false; bool useLut = false;
@ -74,7 +84,7 @@ namespace FidelityFX.FSR2
InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.computeLuminancePyramidPass); 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); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color);
@ -98,7 +108,7 @@ namespace FidelityFX.FSR2
InitComputeShader("Reconstruct & Dilate", contextDescription.Shaders.reconstructPreviousDepthPass); 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.SrvInputColor, dispatchParams.Color);
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth);
@ -121,7 +131,7 @@ namespace FidelityFX.FSR2
InitComputeShader("Depth Clip", contextDescription.Shaders.depthClipPass); 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.SrvInputColor, dispatchParams.Color);
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth);
@ -149,7 +159,7 @@ namespace FidelityFX.FSR2
InitComputeShader("Create Locks", contextDescription.Shaders.lockPass); 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.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockInputLuma, Fsr2ShaderIDs.UavLockInputLuma);
commandBuffer.SetComputeConstantBufferParam<Fsr2.UpscalerConstants>(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants); commandBuffer.SetComputeConstantBufferParam<Fsr2.UpscalerConstants>(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants);
@ -175,7 +185,7 @@ namespace FidelityFX.FSR2
#endif #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 UNITY_2021_2_OR_NEWER
if (dispatchParams.EnableSharpening) if (dispatchParams.EnableSharpening)
@ -234,7 +244,7 @@ namespace FidelityFX.FSR2
InitComputeShader("RCAS Sharpening", contextDescription.Shaders.sharpenPass); 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.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]);
@ -260,23 +270,22 @@ namespace FidelityFX.FSR2
InitComputeShader("Auto-Generate Reactive Mask", contextDescription.Shaders.autoGenReactivePass); 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) 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<Fsr2.GenerateReactiveConstants>(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<Fsr2.GenerateReactiveConstants>(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); 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.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly);
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color);

4
Runtime/FSR3/Fsr3UpscalerContext.cs

@ -154,7 +154,7 @@ namespace FidelityFX.FSR3
} }
if (dispatchParams.UseTextureArrays) if (dispatchParams.UseTextureArrays)
commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY");
commandBuffer.EnableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY");
if (_firstExecution) if (_firstExecution)
{ {
@ -284,7 +284,7 @@ namespace FidelityFX.FSR3
Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer); Fsr3UpscalerResources.DestroyAliasableResources(commandBuffer);
commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY");
commandBuffer.DisableShaderKeyword("UNITY_FFX_TEXTURE2D_X_ARRAY");
commandBuffer.EndSample(_sampler); commandBuffer.EndSample(_sampler);
} }

55
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. /// 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. /// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders.
/// </summary> /// </summary>
internal abstract class Fsr3UpscalerPass: FfxPassWithFlags<Fsr3Upscaler.DispatchDescription, Fsr3Upscaler.InitializationFlags>
internal abstract class Fsr3UpscalerPass: FfxPassWithFlags<Fsr3Upscaler.InitializationFlags>
{ {
protected readonly Fsr3UpscalerResources Resources; protected readonly Fsr3UpscalerResources Resources;
protected readonly ComputeBuffer Constants; protected readonly ComputeBuffer Constants;
@ -39,6 +39,16 @@ namespace FidelityFX.FSR3
Resources = resources; Resources = resources;
Constants = constants; 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() protected override void SetupShaderKeywords()
{ {
@ -68,7 +78,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Prepare Inputs", contextDescription.Shaders.prepareInputsPass); 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.SrvInputColor, dispatchParams.Color);
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, dispatchParams.Depth); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, dispatchParams.Depth);
@ -98,7 +108,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.lumaPyramidPass); 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.SrvCurrentLuma, Resources.Luma[bufferIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, Fsr3ShaderIDs.UavIntermediate); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, Fsr3ShaderIDs.UavIntermediate);
@ -131,7 +141,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Compute Shading Change Pyramid", contextDescription.Shaders.shadingChangePyramidPass); 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.SrvCurrentLuma, Resources.Luma[bufferIndex]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreviousLuma, Resources.Luma[bufferIndex ^ 1]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvPreviousLuma, Resources.Luma[bufferIndex ^ 1]);
@ -161,7 +171,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Compute Shading Change", contextDescription.Shaders.shadingChangePass); 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); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvSpdMips, Resources.SpdMips);
@ -179,7 +189,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Prepare Reactivity", contextDescription.Shaders.prepareReactivityPass); 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.SrvReconstructedPrevNearestDepth, Resources.ReconstructedPrevNearestDepth);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity);
@ -207,7 +217,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Compute Luminance Instability", contextDescription.Shaders.lumaInstabilityPass); 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.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks);
@ -243,7 +253,7 @@ namespace FidelityFX.FSR3
#endif #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 UNITY_2021_2_OR_NEWER
if (dispatchParams.EnableSharpening) if (dispatchParams.EnableSharpening)
@ -297,7 +307,7 @@ namespace FidelityFX.FSR3
InitComputeShader("RCAS Sharpening", contextDescription.Shaders.sharpenPass); 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.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[bufferIndex]);
@ -323,23 +333,22 @@ namespace FidelityFX.FSR3
InitComputeShader("Auto-Generate Reactive Mask", contextDescription.Shaders.autoGenReactivePass); 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) 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<Fsr3Upscaler.GenerateReactiveConstants>(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<Fsr3Upscaler.GenerateReactiveConstants>(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); 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.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly);
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.Color); commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, dispatchParams.Color);
@ -386,7 +395,7 @@ namespace FidelityFX.FSR3
InitComputeShader("Debug View", contextDescription.Shaders.debugViewPass); 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.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity);

4
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_INVERTED_DEPTH
#pragma multi_compile_local __ FFX_FSR2_OPTION_APPLY_SHARPENING #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 // 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 #ifdef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_autogen_reactive_pass.hlsl"

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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 // 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. // These pragmas are commented out by default as Unity will sometimes ignore the #if's and try to enable these features anyway.

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_depth_clip_pass.hlsl"

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_lock_pass.hlsl"

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_rcas_pass.hlsl"

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_reconstruct_previous_depth_pass.hlsl"

4
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_JITTERED_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR2_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr2_tcr_autogen_pass.hlsl"

4
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_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING #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 // 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 #ifdef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE

4
Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute

@ -22,8 +22,8 @@
#pragma multi_compile_local __ FFX_HALF #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" #include "shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_debug_view_pass.compute

@ -22,8 +22,8 @@
#pragma multi_compile_local __ FFX_HALF #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" #include "shaders/ffx_fsr3upscaler_debug_view_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_luma_instability_pass.compute

@ -22,8 +22,8 @@
#pragma multi_compile_local __ FFX_HALF #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" #include "shaders/ffx_fsr3upscaler_luma_instability_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute

@ -22,9 +22,9 @@
#pragma multi_compile_local __ FFX_HALF #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 // 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. // These pragmas are commented out by default as Unity will sometimes ignore the #if's and try to enable these features anyway.

4
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_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH #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" #include "shaders/ffx_fsr3upscaler_prepare_inputs_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute

@ -22,8 +22,8 @@
#pragma multi_compile_local __ FFX_HALF #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" #include "shaders/ffx_fsr3upscaler_prepare_reactivity_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_rcas_pass.compute

@ -20,8 +20,8 @@
#pragma kernel CS #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" #include "shaders/ffx_fsr3upscaler_rcas_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_shading_change_pass.compute

@ -22,8 +22,8 @@
#pragma multi_compile_local __ FFX_HALF #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" #include "shaders/ffx_fsr3upscaler_shading_change_pass.hlsl"

4
Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute

@ -22,9 +22,9 @@
#pragma multi_compile_local __ FFX_HALF #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 // Wave operations require shader model 6.0; this can only be enabled when using DXC on D3D12
#define FFX_SPD_NO_WAVE_OPERATIONS #define FFX_SPD_NO_WAVE_OPERATIONS

4
Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute

@ -23,8 +23,8 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS #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" #include "shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl"

12
Shaders/ffx_fsr_unity_common.cginc → Shaders/ffx_unity_common.cginc

@ -52,7 +52,7 @@
#endif #endif
// Control if TEXTURE2D_X macros will expand to texture arrays // 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 #define USE_TEXTURE2D_X_AS_ARRAY
#endif #endif
@ -73,10 +73,10 @@
#endif #endif
// Declare and sample camera buffers as texture arrays // Declare and sample camera buffers as texture arrays
#define UNITY_FSR_TEX2D(type) Texture2DArray<type>
#define UNITY_FSR_RWTEX2D(type) RWTexture2DArray<type>
#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<type>
#define UNITY_FFX_RWTEX2D(type) RWTexture2DArray<type>
#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 #endif

0
Shaders/ffx_fsr_unity_common.cginc.meta → Shaders/ffx_unity_common.cginc.meta

48
Shaders/shaders/fsr2/ffx_fsr2_callbacks_hlsl.h

@ -340,17 +340,17 @@ FfxUInt32x2 SPD_RenderSize()
#endif // #if defined(FSR2_BIND_CB_SPD) #endif // #if defined(FSR2_BIND_CB_SPD)
// Declare and sample camera buffers as regular textures, unless overridden // Declare and sample camera buffers as regular textures, unless overridden
#if !defined(UNITY_FSR_TEX2D)
#define UNITY_FSR_TEX2D(type) Texture2D<type>
#if !defined(UNITY_FFX_TEX2D)
#define UNITY_FFX_TEX2D(type) Texture2D<type>
#endif #endif
#if !defined(UNITY_FSR_RWTEX2D)
#define UNITY_FSR_RWTEX2D(type) RWTexture2D<type>
#if !defined(UNITY_FFX_RWTEX2D)
#define UNITY_FFX_RWTEX2D(type) RWTexture2D<type>
#endif #endif
#if !defined(UNITY_FSR_POS)
#define UNITY_FSR_POS(pxPos) (pxPos)
#if !defined(UNITY_FFX_POS)
#define UNITY_FFX_POS(pxPos) (pxPos)
#endif #endif
#if !defined(UNITY_FSR_UV)
#define UNITY_FSR_UV(uv) (uv)
#if !defined(UNITY_FFX_UV)
#define UNITY_FFX_UV(uv) (uv)
#endif #endif
SamplerState s_PointClamp : register(s0); SamplerState s_PointClamp : register(s0);
@ -358,16 +358,16 @@ SamplerState s_LinearClamp : register(s1);
// SRVs // SRVs
#if defined FSR2_BIND_SRV_INPUT_COLOR #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 #endif
#if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY #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 #endif
#if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS #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 #endif
#if defined FSR2_BIND_SRV_INPUT_DEPTH #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 #endif
#if defined FSR2_BIND_SRV_INPUT_EXPOSURE #if defined FSR2_BIND_SRV_INPUT_EXPOSURE
Texture2D<FfxFloat32x2> r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); Texture2D<FfxFloat32x2> r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE);
@ -376,10 +376,10 @@ SamplerState s_LinearClamp : register(s1);
Texture2D<FfxFloat32x2> r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); Texture2D<FfxFloat32x2> r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE);
#endif #endif
#if defined FSR2_BIND_SRV_REACTIVE_MASK #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 #endif
#if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK #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 #endif
#if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH #if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH
Texture2D<FfxUInt32> r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); Texture2D<FfxUInt32> 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<FfxFloat32x4> rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); RWTexture2D<FfxFloat32x4> rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY);
#endif #endif
#if defined FSR2_BIND_UAV_UPSCALED_OUTPUT #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 #endif
#if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE #if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); globallycoherent RWTexture2D<FfxFloat32> 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) #if defined(FSR2_BIND_SRV_INPUT_DEPTH)
FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos)
{ {
return r_input_depth[UNITY_FSR_POS(iPxPos)];
return r_input_depth[UNITY_FFX_POS(iPxPos)];
} }
#endif #endif
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) #if defined(FSR2_BIND_SRV_INPUT_DEPTH)
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) 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 #endif
#if defined(FSR2_BIND_SRV_REACTIVE_MASK) #if defined(FSR2_BIND_SRV_REACTIVE_MASK)
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos)
{ {
return r_reactive_mask[UNITY_FSR_POS(iPxPos)];
return r_reactive_mask[UNITY_FFX_POS(iPxPos)];
} }
#endif #endif
#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) #if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK)
FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) 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 #endif
#if defined(FSR2_BIND_SRV_INPUT_COLOR) #if defined(FSR2_BIND_SRV_INPUT_COLOR)
FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) 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 #endif
#if defined(FSR2_BIND_SRV_INPUT_COLOR) #if defined(FSR2_BIND_SRV_INPUT_COLOR)
FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) 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 #endif
@ -563,7 +563,7 @@ FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos)
#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) #if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS)
FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) 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(); FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale();
@ -622,7 +622,7 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh
#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) #if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT)
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) 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 #endif
@ -833,7 +833,7 @@ void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETE
#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) #if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY)
FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) 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 #endif

60
Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h

@ -320,20 +320,20 @@ FfxUInt32x2 SPD_RenderSize()
#endif // #if defined(FSR3UPSCALER_BIND_CB_SPD) #endif // #if defined(FSR3UPSCALER_BIND_CB_SPD)
// Declare and sample camera buffers as regular textures, unless overridden // Declare and sample camera buffers as regular textures, unless overridden
#if !defined(UNITY_FSR_TEX2D)
#define UNITY_FSR_TEX2D(type) Texture2D<type>
#if !defined(UNITY_FFX_TEX2D)
#define UNITY_FFX_TEX2D(type) Texture2D<type>
#endif #endif
#if !defined(UNITY_FSR_RWTEX2D)
#define UNITY_FSR_RWTEX2D(type) RWTexture2D<type>
#if !defined(UNITY_FFX_RWTEX2D)
#define UNITY_FFX_RWTEX2D(type) RWTexture2D<type>
#endif #endif
#if !defined(UNITY_FSR_POS)
#define UNITY_FSR_POS(pxPos) (pxPos)
#if !defined(UNITY_FFX_POS)
#define UNITY_FFX_POS(pxPos) (pxPos)
#endif #endif
#if !defined(UNITY_FSR_UV)
#define UNITY_FSR_UV(uv) (uv)
#if !defined(UNITY_FFX_UV)
#define UNITY_FFX_UV(uv) (uv)
#endif #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 #endif
SamplerState s_PointClamp : register(s0); SamplerState s_PointClamp : register(s0);
@ -359,85 +359,85 @@ FfxFloat32x2 SampleSPDMipLevel(FfxFloat32x2 fUV, FfxUInt32 mipLevel)
#endif #endif
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH) #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) FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos)
{ {
return r_input_depth[UNITY_FSR_POS(iPxPos)];
return r_input_depth[UNITY_FFX_POS(iPxPos)];
} }
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) 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 #endif
#if defined(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK) #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) FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos)
{ {
return r_reactive_mask[UNITY_FSR_POS(iPxPos)];
return r_reactive_mask[UNITY_FFX_POS(iPxPos)];
} }
FfxInt32x2 GetReactiveMaskResourceDimensions() FfxInt32x2 GetReactiveMaskResourceDimensions()
{ {
FfxUInt32 uWidth; FfxUInt32 uWidth;
FfxUInt32 uHeight; FfxUInt32 uHeight;
UNITY_FSR_GETDIMS(r_reactive_mask, uWidth, uHeight);
UNITY_FFX_GETDIMS(r_reactive_mask, uWidth, uHeight);
return FfxInt32x2(uWidth, uHeight); return FfxInt32x2(uWidth, uHeight);
} }
FfxFloat32 SampleReactiveMask(FfxFloat32x2 fUV) 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 #endif
#if defined(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) #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) 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() FfxInt32x2 GetTransparencyAndCompositionMaskResourceDimensions()
{ {
FfxUInt32 uWidth; FfxUInt32 uWidth;
FfxUInt32 uHeight; 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); return FfxInt32x2(uWidth, uHeight);
} }
FfxFloat32 SampleTransparencyAndCompositionMask(FfxFloat32x2 fUV) 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 #endif
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR) #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) 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) 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 #endif
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS) #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 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(); FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale();
@ -515,11 +515,11 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh
#endif #endif
#if defined(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT) #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) 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 #endif
@ -830,11 +830,11 @@ void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETE
#endif #endif
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY) #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) 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 #endif

Loading…
Cancel
Save