Browse Source

Consolidated texture array-related keywords into a single RP-agnostic global keyword that can be enabled from the HDRP integration.

This also removes the need for the core FSR code to check the current render pipeline and hack in a special HDRP mode.
master
Nico de Poel 2 years ago
parent
commit
5703e106fe
  1. 7
      Runtime/FSR2/Fsr2Pass.cs
  2. 7
      Runtime/FSR3/Fsr3UpscalerPass.cs
  3. 3
      Shaders/ffx_fsr2_accumulate_pass.compute
  4. 3
      Shaders/ffx_fsr2_autogen_reactive_pass.compute
  5. 3
      Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute
  6. 3
      Shaders/ffx_fsr2_depth_clip_pass.compute
  7. 2
      Shaders/ffx_fsr2_lock_pass.compute
  8. 3
      Shaders/ffx_fsr2_rcas_pass.compute
  9. 3
      Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute
  10. 3
      Shaders/ffx_fsr2_tcr_autogen_pass.compute
  11. 3
      Shaders/ffx_fsr3upscaler_accumulate_pass.compute
  12. 3
      Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute
  13. 3
      Shaders/ffx_fsr3upscaler_debug_view_pass.compute
  14. 3
      Shaders/ffx_fsr3upscaler_luma_instability_pass.compute
  15. 3
      Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute
  16. 3
      Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute
  17. 3
      Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute
  18. 3
      Shaders/ffx_fsr3upscaler_rcas_pass.compute
  19. 3
      Shaders/ffx_fsr3upscaler_shading_change_pass.compute
  20. 3
      Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute
  21. 3
      Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute
  22. 7
      Shaders/ffx_fsr_unity_common.cginc

7
Runtime/FSR2/Fsr2Pass.cs

@ -95,13 +95,6 @@ namespace FidelityFX
if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR2_OPTION_INVERTED_DEPTH"); if ((flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR2_OPTION_INVERTED_DEPTH");
if (useLut) ComputeShader.EnableKeyword("FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); if (useLut) ComputeShader.EnableKeyword("FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE");
if ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); if ((flags & Fsr2.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF");
// Inform the shader which render pipeline we're currently using
var pipeline = GraphicsSettings.currentRenderPipeline;
if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline"))
{
ComputeShader.EnableKeyword("UNITY_FSR_HDRP");
}
} }
} }

7
Runtime/FSR3/Fsr3UpscalerPass.cs

@ -93,13 +93,6 @@ namespace FidelityFX
if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH"); if ((flags & Fsr3Upscaler.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH");
if (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE"); if (useLut) ComputeShader.EnableKeyword("FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE");
if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF"); if ((flags & Fsr3Upscaler.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFX_HALF");
// Inform the shader which render pipeline we're currently using
var pipeline = GraphicsSettings.currentRenderPipeline;
if (pipeline != null && pipeline.GetType().Name.Contains("HDRenderPipeline"))
{
ComputeShader.EnableKeyword("UNITY_FSR_HDRP");
}
} }
} }

3
Shaders/ffx_fsr2_accumulate_pass.compute

@ -28,8 +28,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr2_autogen_reactive_pass.compute

@ -25,8 +25,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute

@ -25,8 +25,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr2_depth_clip_pass.compute

@ -25,8 +25,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

2
Shaders/ffx_fsr2_lock_pass.compute

@ -25,6 +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
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"
#include "shaders/ffx_fsr2_lock_pass.hlsl" #include "shaders/ffx_fsr2_lock_pass.hlsl"

3
Shaders/ffx_fsr2_rcas_pass.compute

@ -24,8 +24,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute

@ -26,8 +26,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr2_tcr_autogen_pass.compute

@ -25,8 +25,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_accumulate_pass.compute

@ -26,8 +26,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_debug_view_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_luma_instability_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute

@ -24,8 +24,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_rcas_pass.compute

@ -20,8 +20,7 @@
#pragma kernel CS #pragma kernel CS
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_shading_change_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute

@ -22,8 +22,7 @@
#pragma multi_compile_local __ FFX_HALF #pragma multi_compile_local __ FFX_HALF
#pragma multi_compile_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

3
Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute

@ -23,8 +23,7 @@
#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_local __ UNITY_FSR_HDRP
#pragma multi_compile __ DISABLE_TEXTURE2D_X_ARRAY
#pragma multi_compile __ UNITY_FSR_TEXTURE2D_X_ARRAY
#include "ffx_fsr_unity_common.cginc" #include "ffx_fsr_unity_common.cginc"

7
Shaders/ffx_fsr_unity_common.cginc

@ -46,15 +46,13 @@
#endif #endif
// Workaround for HDRP using texture arrays for its camera buffers on some platforms // Workaround for HDRP using texture arrays for its camera buffers on some platforms
// The below defines are copied from: Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl
#if defined(UNITY_FSR_HDRP)
// Must be in sync with C# with property useTexArray in TextureXR.cs
// The below defines are adapted from: Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl
#if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) #if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN)
#define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED #define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED
#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(DISABLE_TEXTURE2D_X_ARRAY)
#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && defined(UNITY_FSR_TEXTURE2D_X_ARRAY)
#define USE_TEXTURE2D_X_AS_ARRAY #define USE_TEXTURE2D_X_AS_ARRAY
#endif #endif
@ -82,4 +80,3 @@
#define UNITY_FSR_GETDIMS(tex, w, h) { FfxUInt32 uElements; (tex).GetDimensions((w), (h), uElements); } #define UNITY_FSR_GETDIMS(tex, w, h) { FfxUInt32 uElements; (tex).GetDimensions((w), (h), uElements); }
#endif #endif
#endif
Loading…
Cancel
Save