Compare commits

...

62 Commits

Author SHA1 Message Date
Nico de Poel dad922c338 Swapped Luma and MotionVector outputs on the Reconstruct & Dilate pass, which fixes another apparent alignment issue on PS5 NGGC, causing the motion vectors to break occasionally when switching scaling ratios. 10 months ago
Nico de Poel f8483414f2 Fixed exposure instability for a few seconds after initialization on iOS Metal, and cleared out a shader compiler warning at run-time. 10 months ago
Nico de Poel 1dc6216750 Simplified platform wave operation support check 10 months ago
Nico de Poel fdf2125cfe Revert "Removed Xbox Series from the modern shaders, as it doesn't like Native16Bit at all and just falls back to legacy, and restored Native16Bit to all the modern shaders. Xbox Series will still use DXC and wave operations." 10 months ago
Nico de Poel 99f28af11d Removed Xbox Series from the modern shaders, as it doesn't like Native16Bit at all and just falls back to legacy, and restored Native16Bit to all the modern shaders. Xbox Series will still use DXC and wave operations. 10 months ago
Nico de Poel d7483c31c4 Added some commented-out debug pragmas to the compute shaders 10 months ago
Nico de Poel 1222d236f5 Fixed dynamic resolution scaling: 10 months ago
Nico de Poel 133343b285 Added texture array support for inputs and outputs 10 months ago
Nico de Poel 3ae6628a34 Added a few missing "in" keywords 10 months ago
Nico de Poel 760003744f Added missing bits of temporal reactive implementation in the FP32 code path, and only bind the relevant inputs to the Accumulate shader based on the ASR mode. Fixes Balanced and Performance modes on Xbox One, which for some reason still seems to be running the FP32 code path, no matter what the FFXM_HALF keyword is set to. 10 months ago
Nico de Poel cfae0072e9 Force enable FP16 shader code path, and redefine FFXM_HALF with a truthy value 10 months ago
Nico de Poel 4a8f9455e6 Removed the old license text from the C# source files 10 months ago
Nico de Poel 4c6a7b7309 Removed Native16Bit from the two compute shaders because Xbox Series does not like it. Seems fine for the fragment shader though, which is where it matters most. 10 months ago
Nico de Poel facfd037d2 Added Legacy variants of the ASR shaders, without DXC, Native16Bit or wave operations. Separated them into an AsrShaderBundle that can be selected from at run-time based on the current graphics device. 10 months ago
Nico de Poel 5faf6c2a56 Reworked ASR shaders for modern compilation on DX12, Vulkan, Metal, PS5 and Xbox Series: 10 months ago
Nico de Poel 89269073f7 Removed random write requirement from all render textures that aren't used as UAV (i.e. are used as fragment render targets). Sort of makes GLES3 work, and might provide an appreciable overall efficiency boost as well. 10 months ago
Nico de Poel 1c599af0b6 Merge branch 'asr-console' into armasr 10 months ago
Nico de Poel 3293533bf9 Minor: print the ASR variant to the log when creating the context, makes for easier readback of the log 10 months ago
Nico de Poel 3912c66b0d Bind new locks to the accumulate shader as a regular SRV (read-only), and clear the locks buffer ahead of time instead of at the end of the accumulate shader. This simplifies the shader binding setup, as well as being "more correct" because we're using a temporary RT for the locks buffer, meaning it makes no sense to clear it for the next frame. 10 months ago
Nico de Poel 16cf41493a Swapped the order of the render targets around for the depth clip pass. Fixes prepared input color being black in NGGC because... I don't know, probably an alignment issue of some sort? PS5 is being really stupid here. 10 months ago
Nico de Poel 51e5a86112 Reverted dilated reactive masks format back to R8G8_UNorm, as that works correctly now 10 months ago
Nico de Poel c52a40f706 Use implicit register binding when using UAVs in fragment shaders. Fixes remaining issues with reconstruct and accumulate passes on PS5 CGGC. 10 months ago
Nico de Poel cc74a9cd2f Use implicit register binding for fragment shader random write targets. Fixes UAVs not binding properly on PS5. 10 months ago
Nico de Poel 90490e8819 Temp disabled Native16Bit again, as it does cause compilation issues when building for standalone. Need to make a split between Modern and Legacy here. 10 months ago
Nico de Poel 2f8a0ca595 Added output target pragmas for random write targets. Not sure if these are necessary but it's something to keep an eye on. 10 months ago
Nico de Poel 9aee5758b6 Made some progress towards making ASR FP16 work on PS5: 10 months ago
Nico de Poel bd18c12408 Updated PSSL target output format pragmas with what *should* be the correct values, though the PS5 still disagrees with this 10 months ago
Nico de Poel 5f4d4b37ad Fixed a big derp in the PSSL type definitions, copy-pasted code still contained FFX_HALF instead of FFXM_HALF, which caused 16-bit types to be compiled as 32-bit, causing a bunch of duplicate function definitions. 10 months ago
Nico de Poel 884ca84071 Moved unorm and globallycoherent definitions to the common cginc, rather than stuffing them somewhere in between all the types 10 months ago
Nico de Poel e4ad05a414 Made PSSL pragmas only get included for PSSL to prevent compiler warnings, and require native 16-bit compilation for PSSL. 10 months ago
Nico de Poel 1f7beb397f Merge branch 'armasr' into asr-console 10 months ago
Nico de Poel 8d85253def Enabled Native16Bit requirement for Vulkan, which sets a precedent for other graphics APIs to use this as well 10 months ago
Nico de Poel 090b9135e8 Reworked auto-exposure to use a double buffered render texture, which allows the smooth exposure transition logic to load a value that's guaranteed to be from the previous frame. Fixes artifacting and flickering issues caused by loading & storing to the same texture. 10 months ago
Nico de Poel d088d440f5 Allow live switching between FP16 and FP32 10 months ago
Nico de Poel c0cf3de364 Temporarily disable FP16 altogether, which makes PSSL shader compilation a lot happier. Need to figure out how to make the FP16 utility function definitions work without the shader compiler complaining about duplicate declarations. 10 months ago
Nico de Poel c4b59c7dc3 Bunch of fixes to make ASR Quality somewhat work on PS5, without reactive mask still: 11 months ago
Nico de Poel 6824f1f652 Enable FP16 (FFXM_HALF keyword) usage by default 11 months ago
Nico de Poel 4c93edccde Added type definitions for PSSL (PS4/5) and removed hard-coded FFMX_HALF defines. Let the multi-compile shaders and C# code control that. 11 months ago
Nico de Poel 9ef2bfdef0 Reverted rework of accumulation parameter initialization function to what it originally was, but with a struct clear to zero. 11 months ago
Nico de Poel 389faf3b65 Minor fixes (clearing auto-exposure to 1e8f achieves faster convergence but might cause issues with OpenGL on Nvidia, keep an eye on this!) 11 months ago
Nico de Poel 4a0fc42c2a Fixed RCAS pass still using compute shader bindings 11 months ago
Nico de Poel c92e35ff73 Added balanced and performance preset keywords to the depth clip and accumulate passes, which seem to be the only ones that use it. Makes the Balanced variant work. Performance variant still problematic. 11 months ago
Nico de Poel 943d119706 Fixed a number of issues to make Quality variant work: 11 months ago
Nico de Poel c4df3d45aa Got UAV bindings in fragment shaders to work in what I think is the correct way 11 months ago
Nico de Poel 82734c7606 Went over all the shader inputs and output and implemented them. Realized that some fragment shaders use UAVs with random write, is that even possible in Unity? 11 months ago
Nico de Poel d71b061d16 Added new shader IDs and resource definitions 11 months ago
Nico de Poel 20a930097e Added keywords for balanced/performance presets and GLES support 11 months ago
Nico de Poel 3ef31fac65 Some cleanup and minor fixes 11 months ago
Nico de Poel 2a88584eb2 Added a quick and dirty upscaler integration and fixed global keyword creation 11 months ago
Nico de Poel ac0adc168b Added definition for quality preset variants 11 months ago
Nico de Poel d320a76b89 Turned dispatch descriptions into structs, using in-parameters where applicable 11 months ago
Nico de Poel a0eeda1e84 Updated fragment shader passes to provide their output render targets to the Blit function, including multi-render targets 11 months ago
Nico de Poel d5bbadaa77 Made all the ASR shader keywords global and encapsulated all of the keyword management into a separate class, which will enable and disable keywords globally based on the initialization flags and dispatch parameters. 11 months ago
Nico de Poel dd33e77b6f Reworked ASR passes to allow for blitting using fragment shaders, and got an idea of the problems yet to solve. Modified assets script and added it to the PPV2 resources. Some additional refactoring and bug fixing as well. 11 months ago
Nico de Poel d7191b98e7 Applied a few more recent fixes from the FSR2 codebase 11 months ago
Nico de Poel d3f60e2650 Added ASR runtime source files, as a copy of the FSR2 sources, with a bunch of renaming and stripped of some parts that we know we're not going to need. 11 months ago
Nico de Poel c8eebd63ed Added multi-compile keywords for all fragment shaders, and added Metal workaround for texture atomics 11 months ago
Nico de Poel a85e242d4c Added shaders for the two compute passes, plus a few minor fixes 11 months ago
Nico de Poel d77922cc4b Backported fixes that we already know are going to be necessary for full Unity support: 11 months ago
Nico de Poel 1551a3ccf8 Added the remaining vertex/fragment shader passes and made the same modifications to get them to compile 11 months ago
Nico de Poel c27195fb9a Defined a vertex/fragment shader for the accumulate pass, with initial modifications to make things compile as a proof of concept: 11 months ago
Nico de Poel 66059cb742 Imported ARM ASR shader code for HLSL without any modifications 11 months ago
  1. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs
  2. 9
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset
  3. 13
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling.cs
  4. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR.meta
  5. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime.meta
  6. 321
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs
  7. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs.meta
  8. 136
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrAssets.cs
  9. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrAssets.cs.meta
  10. 61
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrCallbacks.cs
  11. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrCallbacks.cs.meta
  12. 539
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs
  13. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs.meta
  14. 162
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrKeywords.cs
  15. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrKeywords.cs.meta
  16. 338
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs
  17. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs.meta
  18. 227
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrResources.cs
  19. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrResources.cs.meta
  20. 70
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrShaderIDs.cs
  21. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrShaderIDs.cs.meta
  22. 35
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/ResourceView.cs
  23. 11
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/ResourceView.cs.meta
  24. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders.meta
  25. 84
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc
  26. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc.meta
  27. 122
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_legacy.shader
  28. 9
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_legacy.shader.meta
  29. 139
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_modern.shader
  30. 9
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_modern.shader.meta
  31. 13
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_legacy.compute
  32. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_legacy.compute.meta
  33. 15
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_modern.compute
  34. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_modern.compute.meta
  35. 16
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_legacy.compute
  36. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_legacy.compute.meta
  37. 24
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_modern.compute
  38. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_modern.compute.meta
  39. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders.meta
  40. 614
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_common_types.h
  41. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_common_types.h.meta
  42. 69
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core.h
  43. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core.h.meta
  44. 337
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_cpu.h
  45. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_cpu.h.meta
  46. 2812
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common.h
  47. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common.h.meta
  48. 2978
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common_half.h
  49. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common_half.h.meta
  50. 1643
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_hlsl.h
  51. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_hlsl.h.meta
  52. 50
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_portability.h
  53. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_portability.h.meta
  54. 100
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl
  55. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl.meta
  56. 79
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl
  57. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl.meta
  58. 64
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl
  59. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl.meta
  60. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl
  61. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl.meta
  62. 63
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_lock_pass.hlsl
  63. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_lock_pass.hlsl.meta
  64. 52
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_rcas_pass_fs.hlsl
  65. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_rcas_pass_fs.hlsl.meta
  66. 68
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl
  67. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl.meta
  68. 44
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_vs.hlsl
  69. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_vs.hlsl.meta
  70. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1.meta
  71. 1251
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1/ffxm_fsr1.h
  72. 76
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1/ffxm_fsr1.h.meta
  73. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2.meta
  74. 379
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h
  75. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h.meta
  76. 1040
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h
  77. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h.meta
  78. 595
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_common.h
  79. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_common.h.meta
  80. 212
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_compute_luminance_pyramid.h
  81. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_compute_luminance_pyramid.h.meta
  82. 349
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_depth_clip.h
  83. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_depth_clip.h.meta
  84. 131
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_lock.h
  85. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_lock.h.meta
  86. 101
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h
  87. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h.meta
  88. 91
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_rcas.h
  89. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_rcas.h.meta
  90. 155
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reconstruct_dilated_velocity_and_previous_depth.h
  91. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta
  92. 390
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h
  93. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h.meta
  94. 100
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_resources.h
  95. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_resources.h.meta
  96. 699
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_sample.h
  97. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_sample.h.meta
  98. 195
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_upsample.h
  99. 67
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_upsample.h.meta
  100. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/spd.meta

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs

@ -34,6 +34,7 @@ namespace UnityEditor.Rendering.PostProcessing
SerializedProperty m_FsrQualityMode;
SerializedProperty m_FsrPerformSharpen;
SerializedProperty m_FsrSharpness;
SerializedProperty m_FsrEnableFP16;
SerializedProperty m_FsrExposureSource;
SerializedProperty m_FsrExposureTexture;
SerializedProperty m_FsrPreExposure;
@ -94,6 +95,7 @@ namespace UnityEditor.Rendering.PostProcessing
m_FsrQualityMode = FindProperty(x => x.upscaling.qualityMode);
m_FsrPerformSharpen = FindProperty(x => x.upscaling.performSharpenPass);
m_FsrSharpness = FindProperty(x => x.upscaling.sharpness);
m_FsrEnableFP16 = FindProperty(x => x.upscaling.enableFP16);
m_FsrExposureSource = FindProperty(x => x.upscaling.exposureSource);
m_FsrExposureTexture = FindProperty(x => x.upscaling.exposure);
m_FsrPreExposure = FindProperty(x => x.upscaling.preExposure);
@ -230,6 +232,7 @@ namespace UnityEditor.Rendering.PostProcessing
EditorGUILayout.PropertyField(m_FsrQualityMode);
EditorGUILayout.PropertyField(m_FsrPerformSharpen);
EditorGUILayout.PropertyField(m_FsrSharpness);
EditorGUILayout.PropertyField(m_FsrEnableFP16);
EditorGUILayout.PropertyField(m_FsrExposureSource);
if (m_FsrExposureSource.intValue == (int)Upscaling.ExposureSource.Manual) EditorGUILayout.PropertyField(m_FsrExposureTexture);
EditorGUILayout.PropertyField(m_FsrPreExposure);

9
Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset

@ -159,3 +159,12 @@ MonoBehaviour:
convert: {fileID: 7200000, guid: a41757aacd8b70e42a4001d514bfbe53, type: 3}
activate: {fileID: 7200000, guid: d7de362950af6fe4e90da7d6e32f9826, type: 3}
upscale: {fileID: 7200000, guid: 5d28d29787492b74aa736a21f70572c7, type: 3}
asrUpscalerShaders:
legacyShaders:
fragmentShader: {fileID: 4800000, guid: 42e5314e46109a441a4527349d8df6e4, type: 3}
computeLuminancePyramidPass: {fileID: 7200000, guid: 41d0c3a77d97a904e96ebc2bf18129f6, type: 3}
lockPass: {fileID: 7200000, guid: a09277df48840a84196b3bac299544ea, type: 3}
modernShaders:
fragmentShader: {fileID: 4800000, guid: 147cc2cffac69ef4eb3ea8addafc9d10, type: 3}
computeLuminancePyramidPass: {fileID: 7200000, guid: 57220d870cb441c8a6df8a9e15a74283, type: 3}
lockPass: {fileID: 7200000, guid: a6e1d5d5372d467790fcf2d089b50ef7, type: 3}

13
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling.cs

@ -15,7 +15,9 @@ namespace UnityEngine.Rendering.PostProcessing
{
[InspectorName("FidelityFX Super Resolution 2.2 (FSR2)")] FSR2,
[InspectorName("FidelityFX Super Resolution 3.1 (FSR3)")] FSR3,
//[InspectorName("Arm Accuracy Super Resolution (ASR)")] ASR,
[InspectorName("Arm Accuracy Super Resolution (ASR) Quality")] ASR_Quality,
[InspectorName("Arm Accuracy Super Resolution (ASR) Balanced")] ASR_Balanced,
[InspectorName("Arm Accuracy Super Resolution (ASR) Performance")] ASR_Performance,
[InspectorName("Snapdragon Game Super Resolution 2 (SGSR2) 2-Pass Fragment")] SGSR2_2PassFS,
[InspectorName("Snapdragon Game Super Resolution 2 (SGSR2) 2-Pass Compute")] SGSR2_2PassCS,
[InspectorName("Snapdragon Game Super Resolution 2 (SGSR2) 3-Pass Compute")] SGSR2_3PassCS,
@ -32,6 +34,8 @@ namespace UnityEngine.Rendering.PostProcessing
public bool performSharpenPass = true;
[Tooltip("Strength of the sharpening effect.")]
[Range(0, 1)] public float sharpness = 0.8f;
public bool enableFP16 = true;
[Tooltip("Choose where to get the exposure value from. Use auto-exposure from either the upscaler or Unity, provide a manual exposure texture, or use a default value.")]
public ExposureSource exposureSource = ExposureSource.Auto;
@ -110,6 +114,7 @@ namespace UnityEngine.Rendering.PostProcessing
private Fsr2.QualityMode _prevQualityMode;
private ExposureSource _prevExposureSource;
private Vector2Int _prevUpscaleSize;
private bool _prevFP16;
private Rect _originalRect;
@ -163,7 +168,7 @@ namespace UnityEngine.Rendering.PostProcessing
// Monitor for any resolution changes and recreate the upscaler context if necessary
// We can't create an upscaler context without info from the post-processing context, so delay the initial setup until here
if (!_initialized || _upscaler == null || _upscaleSize.x != _prevUpscaleSize.x || _upscaleSize.y != _prevUpscaleSize.y ||
upscalerType != _prevUpscalerType || qualityMode != _prevQualityMode || exposureSource != _prevExposureSource)
upscalerType != _prevUpscalerType || qualityMode != _prevQualityMode || exposureSource != _prevExposureSource || enableFP16 != _prevFP16)
{
DestroyUpscaler();
CreateUpscaler(context);
@ -182,6 +187,9 @@ namespace UnityEngine.Rendering.PostProcessing
{
UpscalerType.FSR2 when FSR2Upscaler.IsSupported => new FSR2Upscaler(),
UpscalerType.FSR3 when FSR3Upscaler.IsSupported => new FSR3Upscaler(),
UpscalerType.ASR_Quality when ASRUpscaler.IsSupported => new ASRUpscaler_Quality(),
UpscalerType.ASR_Balanced when ASRUpscaler.IsSupported => new ASRUpscaler_Balanced(),
UpscalerType.ASR_Performance when ASRUpscaler.IsSupported => new ASRUpscaler_Performance(),
UpscalerType.SGSR2_2PassFS => new SGSR2Upscaler_2PassFS(),
UpscalerType.SGSR2_2PassCS when SGSR2Upscaler.IsSupported => new SGSR2Upscaler_2PassCS(),
UpscalerType.SGSR2_3PassCS when SGSR2Upscaler.IsSupported => new SGSR2Upscaler_3PassCS(),
@ -194,6 +202,7 @@ namespace UnityEngine.Rendering.PostProcessing
_prevQualityMode = qualityMode;
_prevExposureSource = exposureSource;
_prevUpscaleSize = _upscaleSize;
_prevFP16 = enableFP16;
_callbacks = callbacksFactory(context);

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fbb474d5e9430814eb7b83620c3d4189
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6bbfbdd9fd482bd4ea5e998953ae9972
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

321
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs

@ -0,0 +1,321 @@
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// A collection of helper functions and data structures required by the ASR process.
/// </summary>
public static class Asr
{
/// <summary>
/// Creates a new ASR context with standard parameters that are appropriate for the current platform.
/// </summary>
public static AsrContext CreateContext(Variant variant, Vector2Int displaySize, Vector2Int maxRenderSize, AsrShaderBundle shaders, InitializationFlags flags = 0)
{
if (SystemInfo.usesReversedZBuffer)
flags |= InitializationFlags.EnableDepthInverted;
else
flags &= ~InitializationFlags.EnableDepthInverted;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
flags |= InitializationFlags.EnableDebugChecking;
#endif
Debug.Log($"Setting up ASR {variant} with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, flags: {flags}");
var contextDescription = new ContextDescription
{
Flags = flags,
Variant = variant,
DisplaySize = displaySize,
MaxRenderSize = maxRenderSize,
Shaders = shaders.GetShadersForCurrentPlatform(),
};
var context = new AsrContext();
context.Create(contextDescription);
return context;
}
public static float GetUpscaleRatioFromQualityMode(QualityMode qualityMode)
{
switch (qualityMode)
{
case QualityMode.NativeAA:
return 1.0f;
case QualityMode.UltraQuality:
return 1.2f;
case QualityMode.Quality:
return 1.5f;
case QualityMode.Balanced:
return 1.7f;
case QualityMode.Performance:
return 2.0f;
case QualityMode.UltraPerformance:
return 3.0f;
default:
return 1.0f;
}
}
public static void GetRenderResolutionFromQualityMode(
out int renderWidth, out int renderHeight,
int displayWidth, int displayHeight, QualityMode qualityMode)
{
float ratio = GetUpscaleRatioFromQualityMode(qualityMode);
renderWidth = Mathf.RoundToInt(displayWidth / ratio);
renderHeight = Mathf.RoundToInt(displayHeight / ratio);
}
public static float GetMipmapBiasOffset(int renderWidth, int displayWidth)
{
return Mathf.Log((float)renderWidth / displayWidth, 2.0f) - 1.0f;
}
public static int GetJitterPhaseCount(int renderWidth, int displayWidth)
{
const float basePhaseCount = 8.0f;
int jitterPhaseCount = (int)(basePhaseCount * Mathf.Pow((float)displayWidth / renderWidth, 2.0f));
return jitterPhaseCount;
}
public static void GetJitterOffset(out float outX, out float outY, int index, int phaseCount)
{
outX = Halton((index % phaseCount) + 1, 2) - 0.5f;
outY = Halton((index % phaseCount) + 1, 3) - 0.5f;
}
// Calculate halton number for index and base.
private static float Halton(int index, int @base)
{
float f = 1.0f, result = 0.0f;
for (int currentIndex = index; currentIndex > 0;) {
f /= @base;
result += f * (currentIndex % @base);
currentIndex = (int)Mathf.Floor((float)currentIndex / @base);
}
return result;
}
public static float Lanczos2(float value)
{
return Mathf.Abs(value) < Mathf.Epsilon ? 1.0f : Mathf.Sin(Mathf.PI * value) / (Mathf.PI * value) * (Mathf.Sin(0.5f * Mathf.PI * value) / (0.5f * Mathf.PI * value));
}
#if !UNITY_2021_1_OR_NEWER
internal static void SetBufferData(this CommandBuffer commandBuffer, ComputeBuffer computeBuffer, Array data)
{
commandBuffer.SetComputeBufferData(computeBuffer, data);
}
#endif
/// <summary>
/// Alternative for CommandBuffer.SetComputeTextureParam that guards against attempts to bind mip levels that don't exist.
/// </summary>
internal static void SetComputeTextureMipParam(this CommandBuffer commandBuffer, ComputeShader computeShader, int kernelIndex, int nameID, Texture texture, int mipLevel)
{
mipLevel = Math.Min(mipLevel, texture.mipmapCount - 1);
commandBuffer.SetComputeTextureParam(computeShader, kernelIndex, nameID, texture, mipLevel);
}
internal static void SetComputeResourceParam(this CommandBuffer commandBuffer, ComputeShader computeShader, int kernelIndex, int nameID, in ResourceView resource)
{
commandBuffer.SetComputeTextureParam(computeShader, kernelIndex, nameID, resource.RenderTarget, resource.MipLevel, resource.SubElement);
}
internal static void SetComputeConstantBufferParam(this CommandBuffer commandBuffer, ComputeShader computeShader, int nameID, ComputeBuffer buffer)
{
commandBuffer.SetComputeConstantBufferParam(computeShader, nameID, buffer, 0, buffer.stride);
}
internal static void SetGlobalResource(this CommandBuffer commandBuffer, int nameID, in ResourceView resource)
{
commandBuffer.SetGlobalTexture(nameID, resource.RenderTarget, resource.SubElement);
}
internal static void DestroyObject(UnityEngine.Object obj)
{
if (obj == null)
return;
#if UNITY_EDITOR
if (Application.isPlaying && !UnityEditor.EditorApplication.isPaused)
UnityEngine.Object.Destroy(obj);
else
UnityEngine.Object.DestroyImmediate(obj);
#else
UnityEngine.Object.Destroy(obj);
#endif
}
public enum Variant
{
Quality, // Maintains the same image quality as the original FSR2.
Balanced, // Gives a significant improvement in both bandwidth savings and performance uplift while maintaining close image quality to the 'quality' preset.
Performance, // A more aggressive preset that will give you the highest performance with some quality sacrifices.
}
public enum QualityMode
{
NativeAA = 0,
UltraQuality = 1,
Quality = 2,
Balanced = 3,
Performance = 4,
UltraPerformance = 5,
}
[Flags]
public enum InitializationFlags
{
EnableHighDynamicRange = 1 << 0,
EnableDisplayResolutionMotionVectors = 1 << 1,
EnableMotionVectorsJitterCancellation = 1 << 2,
EnableDepthInverted = 1 << 3,
EnableDepthInfinite = 1 << 4,
EnableAutoExposure = 1 << 5,
EnableDynamicResolution = 1 << 6,
EnableFP16Usage = 1 << 7,
EnableDebugChecking = 1 << 8,
}
/// <summary>
/// A structure encapsulating the parameters required to initialize FidelityFX Super Resolution 2 upscaling.
/// </summary>
public struct ContextDescription
{
public InitializationFlags Flags;
public Variant Variant;
public Vector2Int MaxRenderSize;
public Vector2Int DisplaySize;
public AsrShaders Shaders;
}
/// <summary>
/// A structure encapsulating the parameters for dispatching the various passes of FidelityFX Super Resolution 2.
/// </summary>
public struct DispatchDescription
{
public ResourceView Color;
public ResourceView Depth;
public ResourceView MotionVectors;
public ResourceView Exposure; // optional
public ResourceView Reactive; // optional
public ResourceView TransparencyAndComposition; // optional
public ResourceView Output;
public Vector2 JitterOffset;
public Vector2 MotionVectorScale;
public Vector2Int RenderSize;
public Vector2Int InputResourceSize;
public bool EnableSharpening;
public float Sharpness;
public float FrameTimeDelta; // in seconds
public float PreExposure;
public bool Reset;
public float CameraNear;
public float CameraFar;
public float CameraFovAngleVertical;
public float ViewSpaceToMetersFactor;
public bool UseTextureArrays; // Enable texture array bindings, primarily used for HDRP and XR
}
/// <summary>
/// A structure encapsulating the parameters for automatic generation of a reactive mask.
/// </summary>
public struct GenerateReactiveDescription
{
public ResourceView ColorOpaqueOnly;
public ResourceView ColorPreUpscale;
public ResourceView OutReactive;
public Vector2Int RenderSize;
public float Scale;
public float CutoffThreshold;
public float BinaryValue;
public GenerateReactiveFlags Flags;
public static readonly GenerateReactiveDescription Default = new GenerateReactiveDescription
{
Scale = 0.5f,
CutoffThreshold = 0.2f,
BinaryValue = 0.9f,
Flags = GenerateReactiveFlags.ApplyTonemap | GenerateReactiveFlags.ApplyThreshold | GenerateReactiveFlags.UseComponentsMax,
};
}
[Flags]
public enum GenerateReactiveFlags
{
ApplyTonemap = 1 << 0,
ApplyInverseTonemap = 1 << 1,
ApplyThreshold = 1 << 2,
UseComponentsMax = 1 << 3,
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct UpscalerConstants
{
public Vector2Int renderSize;
public Vector2Int maxRenderSize;
public Vector2Int displaySize;
public Vector2Int inputColorResourceDimensions;
public Vector2Int lumaMipDimensions;
public int lumaMipLevelToUse;
public int frameIndex;
public Vector4 deviceToViewDepth;
public Vector2 jitterOffset;
public Vector2 motionVectorScale;
public Vector2 downscaleFactor;
public Vector2 motionVectorJitterCancellation;
public float preExposure;
public float previousFramePreExposure;
public float tanHalfFOV;
public float jitterPhaseCount;
public float deltaTime;
public float dynamicResChangeFactor;
public float viewSpaceToMetersFactor;
public float padding;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct SpdConstants
{
public uint mips;
public uint numWorkGroups;
public uint workGroupOffsetX, workGroupOffsetY;
public uint renderSizeX, renderSizeY;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct GenerateReactiveConstants
{
public float scale;
public float threshold;
public float binaryValue;
public uint flags;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
internal struct RcasConstants
{
public RcasConstants(uint sharpness, uint halfSharp)
{
this.sharpness = sharpness;
this.halfSharp = halfSharp;
dummy0 = dummy1 = 0;
}
public readonly uint sharpness;
public readonly uint halfSharp;
public readonly uint dummy0;
public readonly uint dummy1;
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/Asr.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c7350363c6d8a2b4096a9ed97dc4ed95
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

136
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrAssets.cs

@ -0,0 +1,136 @@
using UnityEngine;
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// Scriptable object containing all shader resources required by Arm Accuracy Super Resolution (ASR).
/// These can be stored in an asset file and referenced from a scene or prefab, avoiding the need to load the shaders from a Resources folder.
/// </summary>
[CreateAssetMenu(fileName = "ASR Assets", menuName = "ARM/ASR Assets", order = 1102)]
public class AsrAssets : ScriptableObject
{
public AsrShaderBundle shaderBundle;
#if UNITY_EDITOR
private void Reset()
{
shaderBundle = new AsrShaderBundle
{
legacyShaders = new AsrShaders
{
fragmentShader = FindFragmentShader("ffxm_fsr2_fragment_legacy"),
computeLuminancePyramidPass = FindComputeShader("ffxm_fsr2_luma_pyramid_legacy"),
lockPass = FindComputeShader("ffxm_fsr2_lock_legacy"),
},
modernShaders = new AsrShaders
{
fragmentShader = FindFragmentShader("ffxm_fsr2_fragment_modern"),
computeLuminancePyramidPass = FindComputeShader("ffxm_fsr2_luma_pyramid_modern"),
lockPass = FindComputeShader("ffxm_fsr2_lock_modern"),
},
};
}
private static Shader FindFragmentShader(string name)
{
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:Shader {name}");
if (assetGuids == null || assetGuids.Length == 0)
return null;
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]);
return UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>(assetPath);
}
private static ComputeShader FindComputeShader(string name)
{
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}");
if (assetGuids == null || assetGuids.Length == 0)
return null;
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]);
return UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(assetPath);
}
#endif
}
[System.Serializable]
public class AsrShaderBundle
{
public AsrShaders legacyShaders;
public AsrShaders modernShaders;
public AsrShaders GetShadersForCurrentPlatform()
{
switch (SystemInfo.graphicsDeviceType)
{
case GraphicsDeviceType.Direct3D12:
case GraphicsDeviceType.Vulkan:
case GraphicsDeviceType.Metal:
case GraphicsDeviceType.PlayStation5:
case GraphicsDeviceType.PlayStation5NGGC:
case GraphicsDeviceType.GameCoreXboxSeries:
return modernShaders;
default:
return legacyShaders;
}
}
}
/// <summary>
/// All the compute shaders used by ASR.
/// </summary>
[System.Serializable]
public class AsrShaders
{
/// <summary>
/// Combined shader file containing all non-compute passes.
/// </summary>
public Shader fragmentShader;
/// <summary>
/// The compute shader used by the luminance pyramid computation pass.
/// </summary>
public ComputeShader computeLuminancePyramidPass;
/// <summary>
/// The compute shader used by the lock pass.
/// </summary>
public ComputeShader lockPass;
/// <summary>
/// Returns a copy of this class and its contents.
/// </summary>
public AsrShaders Clone()
{
return (AsrShaders)MemberwiseClone();
}
/// <summary>
/// Returns a copy of this class with clones of all its shaders.
/// This can be useful if you're running multiple ASR instances with different shader configurations.
/// Be sure to clean up these clones through Dispose once you're done with them.
/// </summary>
public AsrShaders DeepCopy()
{
return new AsrShaders
{
fragmentShader = Object.Instantiate(fragmentShader),
computeLuminancePyramidPass = Object.Instantiate(computeLuminancePyramidPass),
lockPass = Object.Instantiate(lockPass),
};
}
/// <summary>
/// Destroy all the shaders within this instance.
/// Use this only on clones created through DeepCopy.
/// </summary>
public void Dispose()
{
Object.Destroy(fragmentShader);
Object.Destroy(computeLuminancePyramidPass);
Object.Destroy(lockPass);
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrAssets.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a41695239eb36740847744b34c5af43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

61
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrCallbacks.cs

@ -0,0 +1,61 @@
using UnityEngine;
namespace ArmASR
{
/// <summary>
/// A collection of callbacks required by the ASR process.
/// This allows some customization by the game dev on how to integrate ASR upscaling into their own game setup.
/// </summary>
public interface IAsrCallbacks
{
/// <summary>
/// Apply a mipmap bias to in-game textures to prevent them from becoming blurry as the internal rendering resolution lowers.
/// This will need to be customized on a per-game basis, as there is no clear universal way to determine what are "in-game" textures.
/// The default implementation will simply apply a mipmap bias to all 2D textures, which will include things like UI textures and which might miss things like terrain texture arrays.
///
/// Depending on how your game organizes its assets, you will want to create a filter that more specifically selects the textures that need to have this mipmap bias applied.
/// You may also want to store the bias offset value and apply it to any assets that are loaded in on demand.
/// </summary>
void ApplyMipmapBias(float biasOffset);
void UndoMipmapBias();
}
/// <summary>
/// Default implementation of IAsrCallbacks.
/// These are fine for testing but a proper game will want to extend and override these methods.
/// </summary>
public class AsrCallbacksBase: IAsrCallbacks
{
protected float CurrentBiasOffset = 0;
public virtual void ApplyMipmapBias(float biasOffset)
{
if (float.IsNaN(biasOffset) || float.IsInfinity(biasOffset))
return;
CurrentBiasOffset += biasOffset;
if (Mathf.Approximately(CurrentBiasOffset, 0f))
{
CurrentBiasOffset = 0f;
}
foreach (var texture in Resources.FindObjectsOfTypeAll<Texture2D>())
{
if (texture.mipmapCount <= 1)
continue;
texture.mipMapBias += biasOffset;
}
}
public virtual void UndoMipmapBias()
{
if (CurrentBiasOffset == 0f)
return;
ApplyMipmapBias(-CurrentBiasOffset);
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrCallbacks.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 78f16fcb80e6325429dfa567a4ed5d4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

539
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs

@ -0,0 +1,539 @@
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// This class loosely matches the FfxFsr2Context struct from the original FSR2 codebase.
/// It manages the various resources and compute passes required by the ASR process.
/// Note that this class does not know anything about Unity render pipelines; all it knows is CommandBuffers and RenderTargetIdentifiers.
/// This should make it suitable for integration with any of the available Unity render pipelines.
/// </summary>
public class AsrContext
{
private const int MaxQueuedFrames = 16;
private Asr.ContextDescription _contextDescription;
private AsrPass _computeLuminancePyramidPass;
private AsrPass _reconstructPreviousDepthPass;
private AsrPass _depthClipPass;
private AsrPass _lockPass;
private AsrPass _accumulatePass;
private AsrPass _sharpenPass;
private AsrPass _generateReactivePass;
private AsrPass _tcrAutogeneratePass;
private readonly AsrResources _resources = new AsrResources();
private readonly AsrKeywords _keywords = new AsrKeywords();
private ComputeBuffer _upscalerConstantsBuffer;
private readonly Asr.UpscalerConstants[] _upscalerConstantsArray = { new Asr.UpscalerConstants() };
private ref Asr.UpscalerConstants UpscalerConsts => ref _upscalerConstantsArray[0];
private ComputeBuffer _spdConstantsBuffer;
private readonly Asr.SpdConstants[] _spdConstantsArray = { new Asr.SpdConstants() };
private ref Asr.SpdConstants SpdConsts => ref _spdConstantsArray[0];
private ComputeBuffer _rcasConstantsBuffer;
private readonly Asr.RcasConstants[] _rcasConstantsArray = new Asr.RcasConstants[1];
private ref Asr.RcasConstants RcasConsts => ref _rcasConstantsArray[0];
private ComputeBuffer _generateReactiveConstantsBuffer;
private readonly Asr.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Asr.GenerateReactiveConstants() };
private ref Asr.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0];
private bool _firstExecution;
private Vector2 _previousJitterOffset;
private int _resourceFrameIndex;
public void Create(in Asr.ContextDescription contextDescription)
{
_contextDescription = contextDescription;
_contextDescription.Flags |= Asr.InitializationFlags.EnableFP16Usage; // Always force FP16 code path
_upscalerConstantsBuffer = CreateConstantBuffer<Asr.UpscalerConstants>();
_spdConstantsBuffer = CreateConstantBuffer<Asr.SpdConstants>();
_rcasConstantsBuffer = CreateConstantBuffer<Asr.RcasConstants>();
_generateReactiveConstantsBuffer = CreateConstantBuffer<Asr.GenerateReactiveConstants>();
// Set defaults
_firstExecution = true;
_resourceFrameIndex = 0;
UpscalerConsts.displaySize = _contextDescription.DisplaySize;
_resources.Create(_contextDescription);
CreatePasses();
}
private void CreatePasses()
{
_computeLuminancePyramidPass = new AsrComputeLuminancePyramidPass(_contextDescription, _resources, _upscalerConstantsBuffer, _spdConstantsBuffer);
_reconstructPreviousDepthPass = new AsrReconstructPreviousDepthPass(_contextDescription, _resources, _upscalerConstantsBuffer);
_depthClipPass = new AsrDepthClipPass(_contextDescription, _resources, _upscalerConstantsBuffer);
_lockPass = new AsrLockPass(_contextDescription, _resources, _upscalerConstantsBuffer);
_accumulatePass = new AsrAccumulatePass(_contextDescription, _resources, _upscalerConstantsBuffer);
_sharpenPass = new AsrSharpenPass(_contextDescription, _resources, _upscalerConstantsBuffer, _rcasConstantsBuffer);
_generateReactivePass = new AsrGenerateReactivePass(_contextDescription, _resources, _upscalerConstantsBuffer, _generateReactiveConstantsBuffer);
}
public void Destroy()
{
DestroyPass(ref _tcrAutogeneratePass);
DestroyPass(ref _generateReactivePass);
DestroyPass(ref _sharpenPass);
DestroyPass(ref _accumulatePass);
DestroyPass(ref _lockPass);
DestroyPass(ref _depthClipPass);
DestroyPass(ref _reconstructPreviousDepthPass);
DestroyPass(ref _computeLuminancePyramidPass);
_resources.Destroy();
DestroyConstantBuffer(ref _generateReactiveConstantsBuffer);
DestroyConstantBuffer(ref _rcasConstantsBuffer);
DestroyConstantBuffer(ref _spdConstantsBuffer);
DestroyConstantBuffer(ref _upscalerConstantsBuffer);
}
public void Dispatch(Asr.DispatchDescription dispatchParams, CommandBuffer commandBuffer)
{
if ((_contextDescription.Flags & Asr.InitializationFlags.EnableDebugChecking) != 0)
{
DebugCheckDispatch(dispatchParams);
}
if (dispatchParams.UseTextureArrays)
commandBuffer.EnableShaderKeyword("UNITY_FFXM_TEXTURE2D_X_ARRAY");
_keywords.ApplyKeywords(commandBuffer, _contextDescription.Variant, _contextDescription.Flags, dispatchParams);
AsrResources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams);
if (_firstExecution)
{
commandBuffer.SetRenderTarget(_resources.LockStatus[0]);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
commandBuffer.SetRenderTarget(_resources.LockStatus[1]);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
commandBuffer.SetRenderTarget(AsrShaderIDs.UavPreparedInputColor);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
}
int frameIndex = _resourceFrameIndex % 2;
bool resetAccumulation = dispatchParams.Reset || _firstExecution;
_firstExecution = false;
// If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends
if ((_contextDescription.Flags & Asr.InitializationFlags.EnableAutoExposure) != 0)
dispatchParams.Exposure = new ResourceView(_resources.AutoExposure[frameIndex]);
else if (!dispatchParams.Exposure.IsValid)
dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure);
if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive);
if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive);
SetupConstants(dispatchParams, resetAccumulation);
// Reactive mask bias
const int threadGroupWorkRegionDim = 8;
int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
bool applyPerfModeOptimizations = _contextDescription.Variant == Asr.Variant.Performance;
bool applyBalancedModeOptimizations = _contextDescription.Variant == Asr.Variant.Balanced;
bool isBalancedOrPerformance = applyBalancedModeOptimizations || applyPerfModeOptimizations;
// Clear reconstructed depth for max depth store
if (resetAccumulation)
{
commandBuffer.SetRenderTarget(_resources.LockStatus[frameIndex ^ 1]);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
commandBuffer.SetRenderTarget(_resources.InternalUpscaled[frameIndex ^ 1]);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
if (isBalancedOrPerformance)
{
commandBuffer.SetRenderTarget(_resources.InternalReactive[frameIndex ^ 1]);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
}
commandBuffer.SetRenderTarget(_resources.SceneLuminance);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
// Auto exposure always used to track luma changes in locking logic
commandBuffer.SetRenderTarget(_resources.AutoExposure[frameIndex ^ 1]);
commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f));
// Reset atomic counter to 0
commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
}
// Need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
bool depthInverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) == Asr.InitializationFlags.EnableDepthInverted;
commandBuffer.SetRenderTarget(AsrShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white);
commandBuffer.SetRenderTarget(AsrShaderIDs.UavNewLocks);
commandBuffer.ClearRenderTarget(false, true, Color.clear);
// Auto exposure
SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount);
// Initialize constant buffers data
commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray);
commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray);
// Compute luminance pyramid
_computeLuminancePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y);
// Reconstruct previous depth
_reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex);
// Depth clip
_depthClipPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex);
// Create locks
_lockPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY);
// Accumulate
_accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex);
if (dispatchParams.EnableSharpening)
{
// Compute the constants
SetupRcasConstants(dispatchParams);
commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray);
// Dispatch RCAS
_sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex);
}
_resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames;
AsrResources.DestroyAliasableResources(commandBuffer);
commandBuffer.DisableShaderKeyword("UNITY_FFXM_TEXTURE2D_X_ARRAY");
}
public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer)
{
GenReactiveConsts.scale = dispatchParams.Scale;
GenReactiveConsts.threshold = dispatchParams.CutoffThreshold;
GenReactiveConsts.binaryValue = dispatchParams.BinaryValue;
GenReactiveConsts.flags = (uint)dispatchParams.Flags;
commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray);
((AsrGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams);
}
private void SetupConstants(in Asr.DispatchDescription dispatchParams, bool resetAccumulation)
{
ref Asr.UpscalerConstants constants = ref UpscalerConsts;
constants.jitterOffset = dispatchParams.JitterOffset;
constants.renderSize = dispatchParams.RenderSize;
constants.maxRenderSize = _contextDescription.MaxRenderSize;
constants.inputColorResourceDimensions = dispatchParams.InputResourceSize;
// Compute the horizontal FOV for the shader from the vertical one
float aspectRatio = (float)dispatchParams.RenderSize.x / dispatchParams.RenderSize.y;
float cameraAngleHorizontal = Mathf.Atan(Mathf.Tan(dispatchParams.CameraFovAngleVertical / 2.0f) * aspectRatio) * 2.0f;
constants.tanHalfFOV = Mathf.Tan(cameraAngleHorizontal * 0.5f);
constants.viewSpaceToMetersFactor = (dispatchParams.ViewSpaceToMetersFactor > 0.0f) ? dispatchParams.ViewSpaceToMetersFactor : 1.0f;
// Compute params to enable device depth to view space depth computation in shader
constants.deviceToViewDepth = SetupDeviceDepthToViewSpaceDepthParams(dispatchParams);
// To be updated if resource is larger than the actual image size
constants.downscaleFactor = new Vector2((float)constants.renderSize.x / _contextDescription.DisplaySize.x, (float)constants.renderSize.y / _contextDescription.DisplaySize.y);
constants.previousFramePreExposure = constants.preExposure;
constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f;
// Motion vector data
Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Asr.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize;
constants.motionVectorScale = dispatchParams.MotionVectorScale / motionVectorsTargetSize;
// Compute jitter cancellation
if ((_contextDescription.Flags & Asr.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0)
{
constants.motionVectorJitterCancellation = (_previousJitterOffset - constants.jitterOffset) / motionVectorsTargetSize;
_previousJitterOffset = constants.jitterOffset;
}
int jitterPhaseCount = Asr.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x);
if (resetAccumulation || constants.jitterPhaseCount == 0)
{
constants.jitterPhaseCount = jitterPhaseCount;
}
else
{
int jitterPhaseCountDelta = (int)(jitterPhaseCount - constants.jitterPhaseCount);
if (jitterPhaseCountDelta > 0)
constants.jitterPhaseCount++;
else if (jitterPhaseCountDelta < 0)
constants.jitterPhaseCount--;
}
// Convert delta time to seconds and clamp to [0, 1]
constants.deltaTime = Mathf.Clamp01(dispatchParams.FrameTimeDelta);
if (resetAccumulation)
constants.frameIndex = 0;
else
constants.frameIndex++;
// Shading change usage of the SPD mip levels
constants.lumaMipLevelToUse = AsrPass.ShadingChangeMipLevel;
float mipDiv = 2 << constants.lumaMipLevelToUse;
constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv);
constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv);
}
private Vector4 SetupDeviceDepthToViewSpaceDepthParams(in Asr.DispatchDescription dispatchParams)
{
bool inverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) != 0;
bool infinite = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInfinite) != 0;
// make sure it has no impact if near and far plane values are swapped in dispatch params
// the flags "inverted" and "infinite" will decide what transform to use
float min = Mathf.Min(dispatchParams.CameraNear, dispatchParams.CameraFar);
float max = Mathf.Max(dispatchParams.CameraNear, dispatchParams.CameraFar);
if (inverted)
{
(min, max) = (max, min);
}
float q = max / (min - max);
float d = -1.0f;
Vector4 matrixElemC = new Vector4(q, -1.0f - Mathf.Epsilon, q, 0.0f + Mathf.Epsilon);
Vector4 matrixElemE = new Vector4(q * min, -min - Mathf.Epsilon, q * min, max);
// Revert x and y coords
float aspect = (float)dispatchParams.RenderSize.x / dispatchParams.RenderSize.y;
float cotHalfFovY = Mathf.Cos(0.5f * dispatchParams.CameraFovAngleVertical) / Mathf.Sin(0.5f * dispatchParams.CameraFovAngleVertical);
int matrixIndex = (inverted ? 2 : 0) + (infinite ? 1 : 0);
return new Vector4(
d * matrixElemC[matrixIndex],
matrixElemE[matrixIndex],
aspect / cotHalfFovY,
1.0f / cotHalfFovY);
}
private void SetupRcasConstants(in Asr.DispatchDescription dispatchParams)
{
int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (RcasConfigs.Length - 1));
RcasConsts = RcasConfigs[sharpnessIndex];
}
private void SetupSpdConstants(in Asr.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount)
{
RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y);
SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips);
// Downsample
ref Asr.SpdConstants spdConstants = ref SpdConsts;
spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x;
spdConstants.mips = (uint)numWorkGroupsAndMips.y;
spdConstants.workGroupOffsetX = (uint)workGroupOffset.x;
spdConstants.workGroupOffsetY = (uint)workGroupOffset.y;
spdConstants.renderSizeX = (uint)dispatchParams.RenderSize.x;
spdConstants.renderSizeY = (uint)dispatchParams.RenderSize.y;
}
private static void SpdSetup(RectInt rectInfo, out Vector2Int dispatchThreadGroupCount, out Vector2Int workGroupOffset, out Vector2Int numWorkGroupsAndMips, int mips = -1)
{
workGroupOffset = new Vector2Int(rectInfo.x / 64, rectInfo.y / 64);
int endIndexX = (rectInfo.x + rectInfo.width - 1) / 64;
int endIndexY = (rectInfo.y + rectInfo.height - 1) / 64;
dispatchThreadGroupCount = new Vector2Int(endIndexX + 1 - workGroupOffset.x, endIndexY + 1 - workGroupOffset.y);
numWorkGroupsAndMips = new Vector2Int(dispatchThreadGroupCount.x * dispatchThreadGroupCount.y, mips);
if (mips < 0)
{
float resolution = Math.Max(rectInfo.width, rectInfo.height);
numWorkGroupsAndMips.y = Math.Min(Mathf.FloorToInt(Mathf.Log(resolution, 2.0f)), 12);
}
}
private void DebugCheckDispatch(in Asr.DispatchDescription dispatchParams)
{
if (!dispatchParams.Color.IsValid)
{
Debug.LogError("Color resource is null");
}
if (!dispatchParams.Depth.IsValid)
{
Debug.LogError("Depth resource is null");
}
if (!dispatchParams.MotionVectors.IsValid)
{
Debug.LogError("MotionVectors resource is null");
}
if (!dispatchParams.Output.IsValid)
{
Debug.LogError("Output resource is null");
}
if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Asr.InitializationFlags.EnableAutoExposure) != 0)
{
Debug.LogWarning("Exposure resource provided, however auto exposure flag is present");
}
if (Mathf.Abs(dispatchParams.JitterOffset.x) > 1.0f || Mathf.Abs(dispatchParams.JitterOffset.y) > 1.0f)
{
Debug.LogWarning("JitterOffset contains value outside of expected range [-1.0, 1.0]");
}
if (dispatchParams.MotionVectorScale.x > _contextDescription.MaxRenderSize.x || dispatchParams.MotionVectorScale.y > _contextDescription.MaxRenderSize.y)
{
Debug.LogWarning("MotionVectorScale contains scale value greater than MaxRenderSize");
}
if (dispatchParams.MotionVectorScale.x == 0.0f || dispatchParams.MotionVectorScale.y == 0.0f)
{
Debug.LogWarning("MotionVectorScale contains zero scale value");
}
if (dispatchParams.RenderSize.x > _contextDescription.MaxRenderSize.x || dispatchParams.RenderSize.y > _contextDescription.MaxRenderSize.y)
{
Debug.LogWarning("RenderSize is greater than context MaxRenderSize");
}
if (dispatchParams.RenderSize.x == 0 || dispatchParams.RenderSize.y == 0)
{
Debug.LogWarning("RenderSize contains zero dimension");
}
if (dispatchParams.FrameTimeDelta > 1.0f)
{
Debug.LogWarning("FrameTimeDelta is greater than 1.0f - this value should be seconds (~0.0166 for 60fps)");
}
if (dispatchParams.PreExposure == 0.0f)
{
Debug.LogError("PreExposure provided as 0.0f which is invalid");
}
bool infiniteDepth = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInfinite) != 0;
bool inverseDepth = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) != 0;
if (inverseDepth)
{
if (dispatchParams.CameraNear < dispatchParams.CameraFar)
{
Debug.LogWarning("EnableDepthInverted flag is present yet CameraNear is less than CameraFar");
}
if (infiniteDepth)
{
if (dispatchParams.CameraNear < float.MaxValue)
{
Debug.LogWarning("EnableDepthInfinite and EnableDepthInverted present, yet CameraNear != float.MaxValue");
}
}
if (dispatchParams.CameraFar < 0.075f)
{
Debug.LogWarning("EnableDepthInverted present, CameraFar value is very low which may result in depth separation artefacting");
}
}
else
{
if (dispatchParams.CameraNear > dispatchParams.CameraFar)
{
Debug.LogWarning("CameraNear is greater than CameraFar in non-inverted-depth context");
}
if (infiniteDepth)
{
if (dispatchParams.CameraFar < float.MaxValue)
{
Debug.LogWarning("EnableDepthInfinite present, yet CameraFar != float.MaxValue");
}
}
if (dispatchParams.CameraNear < 0.075f)
{
Debug.LogWarning("CameraNear value is very low which may result in depth separation artefacting");
}
}
if (dispatchParams.CameraFovAngleVertical <= 0.0f)
{
Debug.LogError("CameraFovAngleVertical is 0.0f - this value should be > 0.0f");
}
if (dispatchParams.CameraFovAngleVertical > Mathf.PI)
{
Debug.LogError("CameraFovAngleVertical is greater than 180 degrees/PI");
}
}
/// <summary>
/// The ASR C++ codebase uses floats bitwise converted to ints to pass sharpness parameters to the RCAS shader.
/// This is not possible in C# without enabling unsafe code compilation, so to avoid that we instead use a table of precomputed values.
/// </summary>
private static readonly Asr.RcasConstants[] RcasConfigs = new []
{
new Asr.RcasConstants(1048576000u, 872428544u),
new Asr.RcasConstants(1049178080u, 877212745u),
new Asr.RcasConstants(1049823372u, 882390168u),
new Asr.RcasConstants(1050514979u, 887895276u),
new Asr.RcasConstants(1051256227u, 893859143u),
new Asr.RcasConstants(1052050675u, 900216232u),
new Asr.RcasConstants(1052902144u, 907032080u),
new Asr.RcasConstants(1053814727u, 914306687u),
new Asr.RcasConstants(1054792807u, 922105590u),
new Asr.RcasConstants(1055841087u, 930494326u),
new Asr.RcasConstants(1056964608u, 939538432u),
new Asr.RcasConstants(1057566688u, 944322633u),
new Asr.RcasConstants(1058211980u, 949500056u),
new Asr.RcasConstants(1058903587u, 955005164u),
new Asr.RcasConstants(1059644835u, 960969031u),
new Asr.RcasConstants(1060439283u, 967326120u),
new Asr.RcasConstants(1061290752u, 974141968u),
new Asr.RcasConstants(1062203335u, 981416575u),
new Asr.RcasConstants(1063181415u, 989215478u),
new Asr.RcasConstants(1064229695u, 997604214u),
new Asr.RcasConstants(1065353216u, 1006648320),
};
private static ComputeBuffer CreateConstantBuffer<TConstants>() where TConstants: struct
{
return new ComputeBuffer(1, Marshal.SizeOf<TConstants>(), ComputeBufferType.Constant);
}
private static void DestroyConstantBuffer(ref ComputeBuffer bufferRef)
{
if (bufferRef == null)
return;
bufferRef.Release();
bufferRef = null;
}
private static void DestroyPass(ref AsrPass pass)
{
if (pass == null)
return;
pass.Dispose();
pass = null;
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrContext.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c348b7c44539db74994c5846caec5871
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

162
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrKeywords.cs

@ -0,0 +1,162 @@
using UnityEngine;
using UnityEngine.Rendering;
namespace ArmASR
{
public class AsrKeywords
{
private static readonly string OptionHalfPrecision = "FFXM_HALF";
private static readonly string OptionHdrColorInput = "FFXM_FSR2_OPTION_HDR_COLOR_INPUT";
private static readonly string OptionLowResolutionMotionVectors = "FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS";
private static readonly string OptionJitteredMotionVectors = "FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS";
private static readonly string OptionInvertedDepth = "FFXM_FSR2_OPTION_INVERTED_DEPTH";
private static readonly string OptionReprojectUseLut = "FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE";
private static readonly string OptionApplySharpening = "FFXM_FSR2_OPTION_APPLY_SHARPENING";
private static readonly string OptionBalancedPreset = "FFXM_FSR2_OPTION_SHADER_OPT_BALANCED";
private static readonly string OptionPerformancePreset = "FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE";
#if UNITY_2021_2_OR_NEWER
private readonly GlobalKeyword _halfPrecisionKeyword;
private readonly GlobalKeyword _hdrColorInputKeyword;
private readonly GlobalKeyword _lowResMotionVectorsKeyword;
private readonly GlobalKeyword _jitteredMotionVectorsKeyword;
private readonly GlobalKeyword _invertedDepthKeyword;
private readonly GlobalKeyword _reprojectUseLutKeyword;
private readonly GlobalKeyword _applySharpeningKeyword;
private readonly GlobalKeyword _balancedPresetKeyword;
private readonly GlobalKeyword _performancePresetKeyword;
#endif
public AsrKeywords()
{
#if UNITY_2021_2_OR_NEWER
_halfPrecisionKeyword = GlobalKeyword.Create(OptionHalfPrecision);
_hdrColorInputKeyword = GlobalKeyword.Create(OptionHdrColorInput);
_lowResMotionVectorsKeyword = GlobalKeyword.Create(OptionLowResolutionMotionVectors);
_jitteredMotionVectorsKeyword = GlobalKeyword.Create(OptionJitteredMotionVectors);
_invertedDepthKeyword = GlobalKeyword.Create(OptionInvertedDepth);
_reprojectUseLutKeyword = GlobalKeyword.Create(OptionReprojectUseLut);
_applySharpeningKeyword = GlobalKeyword.Create(OptionApplySharpening);
_balancedPresetKeyword = GlobalKeyword.Create(OptionBalancedPreset);
_performancePresetKeyword = GlobalKeyword.Create(OptionPerformancePreset);
#endif
}
public void ApplyKeywords(CommandBuffer commandBuffer, Asr.Variant variant, Asr.InitializationFlags initFlags, in Asr.DispatchDescription dispatchParams)
{
bool useLut = false;
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
if (SystemInfo.computeSubGroupSize == 64)
{
useLut = true;
}
#endif
// This matches the permutation rules from the CreatePipeline* functions
#if UNITY_2021_2_OR_NEWER
if ((initFlags & Asr.InitializationFlags.EnableFP16Usage) != 0)
commandBuffer.EnableKeyword(_halfPrecisionKeyword);
else
commandBuffer.DisableKeyword(_halfPrecisionKeyword);
if ((initFlags & Asr.InitializationFlags.EnableHighDynamicRange) != 0)
commandBuffer.EnableKeyword(_hdrColorInputKeyword);
else
commandBuffer.DisableKeyword(_hdrColorInputKeyword);
if ((initFlags & Asr.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0)
commandBuffer.EnableKeyword(_lowResMotionVectorsKeyword);
else
commandBuffer.DisableKeyword(_lowResMotionVectorsKeyword);
if ((initFlags & Asr.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0)
commandBuffer.EnableKeyword(_jitteredMotionVectorsKeyword);
else
commandBuffer.DisableKeyword(_jitteredMotionVectorsKeyword);
if ((initFlags & Asr.InitializationFlags.EnableDepthInverted) != 0)
commandBuffer.EnableKeyword(_invertedDepthKeyword);
else
commandBuffer.DisableKeyword(_invertedDepthKeyword);
if (useLut)
commandBuffer.EnableKeyword(_reprojectUseLutKeyword);
else
commandBuffer.DisableKeyword(_reprojectUseLutKeyword);
if (dispatchParams.EnableSharpening)
commandBuffer.EnableKeyword(_applySharpeningKeyword);
else
commandBuffer.DisableKeyword(_applySharpeningKeyword);
switch (variant)
{
case Asr.Variant.Quality:
commandBuffer.DisableKeyword(_balancedPresetKeyword);
commandBuffer.DisableKeyword(_performancePresetKeyword);
break;
case Asr.Variant.Balanced:
commandBuffer.EnableKeyword(_balancedPresetKeyword);
commandBuffer.DisableKeyword(_performancePresetKeyword);
break;
case Asr.Variant.Performance:
commandBuffer.EnableKeyword(_balancedPresetKeyword);
commandBuffer.EnableKeyword(_performancePresetKeyword);
break;
}
#else
if ((initFlags & Asr.InitializationFlags.EnableFP16Usage) != 0)
commandBuffer.EnableShaderKeyword(OptionHalfPrecision);
else
commandBuffer.DisableShaderKeyword(OptionHalfPrecision);
if ((initFlags & Asr.InitializationFlags.EnableHighDynamicRange) != 0)
commandBuffer.EnableShaderKeyword(OptionHdrColorInput);
else
commandBuffer.DisableShaderKeyword(OptionHdrColorInput);
if ((initFlags & Asr.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0)
commandBuffer.EnableShaderKeyword(OptionLowResolutionMotionVectors);
else
commandBuffer.DisableShaderKeyword(OptionLowResolutionMotionVectors);
if ((initFlags & Asr.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0)
commandBuffer.EnableShaderKeyword(OptionJitteredMotionVectors);
else
commandBuffer.DisableShaderKeyword(OptionJitteredMotionVectors);
if ((initFlags & Asr.InitializationFlags.EnableDepthInverted) != 0)
commandBuffer.EnableShaderKeyword(OptionInvertedDepth);
else
commandBuffer.DisableShaderKeyword(OptionInvertedDepth);
if (useLut)
commandBuffer.EnableShaderKeyword(OptionReprojectUseLut);
else
commandBuffer.DisableShaderKeyword(OptionReprojectUseLut);
if (dispatchParams.EnableSharpening)
commandBuffer.EnableShaderKeyword(OptionApplySharpening);
else
commandBuffer.DisableShaderKeyword(OptionApplySharpening);
switch (variant)
{
case Asr.Variant.Quality:
commandBuffer.DisableShaderKeyword(OptionBalancedPreset);
commandBuffer.DisableShaderKeyword(OptionPerformancePreset);
break;
case Asr.Variant.Balanced:
commandBuffer.EnableShaderKeyword(OptionBalancedPreset);
commandBuffer.DisableShaderKeyword(OptionPerformancePreset);
break;
case Asr.Variant.Performance:
commandBuffer.EnableShaderKeyword(OptionBalancedPreset);
commandBuffer.EnableShaderKeyword(OptionPerformancePreset);
break;
}
#endif
}
}
}

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrKeywords.cs.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a2636bdd1878444fb3d3475610d379df
timeCreated: 1742641520

338
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs

@ -0,0 +1,338 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// Base class for all the compute passes that make up the ASR process.
/// This loosely matches the FfxPipelineState struct from the original ASR 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.
/// </summary>
internal abstract class AsrPass: IDisposable
{
internal const int ShadingChangeMipLevel = 4; // This matches the FFXM_FSR2_SHADING_CHANGE_MIP_LEVEL define
protected readonly Asr.ContextDescription ContextDescription;
protected readonly AsrResources Resources;
protected readonly ComputeBuffer Constants;
protected ComputeShader ComputeShader;
protected int KernelIndex;
protected Material FragmentMaterial;
protected int FragmentPass;
protected MaterialPropertyBlock FragmentProperties;
private CustomSampler _sampler;
protected AsrPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
{
ContextDescription = contextDescription;
Resources = resources;
Constants = constants;
}
public virtual void Dispose()
{
if (FragmentMaterial != null)
{
Asr.DestroyObject(FragmentMaterial);
FragmentMaterial = null;
}
}
public void ScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX = 0, int dispatchY = 0)
{
BeginSample(commandBuffer);
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY);
EndSample(commandBuffer);
}
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY);
protected void InitComputeShader(string passName, ComputeShader shader)
{
if (shader == null)
{
throw new MissingReferenceException($"Shader for ASR pass '{passName}' could not be loaded! Please ensure it is included in the project correctly.");
}
ComputeShader = shader;
KernelIndex = ComputeShader.FindKernel("main");
_sampler = CustomSampler.Create(passName);
}
protected void InitFragmentShader(string passName, Shader shader, int passNumber)
{
if (shader == null)
{
throw new MissingReferenceException($"Shader for ASR pass '{passName}' could not be loaded! Please ensure it is included in the project correctly.");
}
FragmentMaterial = new Material(shader);
FragmentPass = passNumber;
FragmentProperties = new MaterialPropertyBlock();
_sampler = CustomSampler.Create(passName);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void BlitFragment(CommandBuffer commandBuffer, RenderTargetIdentifier renderTarget)
{
commandBuffer.SetRenderTarget(renderTarget);
BlitFragment(commandBuffer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void BlitFragment(CommandBuffer commandBuffer, RenderTargetIdentifier[] renderTargets)
{
commandBuffer.SetRenderTarget(renderTargets, renderTargets[0]);
BlitFragment(commandBuffer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void BlitFragment(CommandBuffer commandBuffer)
{
commandBuffer.DrawProcedural(Matrix4x4.identity, FragmentMaterial, FragmentPass, MeshTopology.Triangles, 3, 1, FragmentProperties);
}
[Conditional("ENABLE_PROFILER"), MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void BeginSample(CommandBuffer cmd)
{
cmd.BeginSample(_sampler);
}
[Conditional("ENABLE_PROFILER"), MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void EndSample(CommandBuffer cmd)
{
cmd.EndSample(_sampler);
}
}
internal class AsrComputeLuminancePyramidPass : AsrPass
{
private readonly ComputeBuffer _spdConstants;
public AsrComputeLuminancePyramidPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants, ComputeBuffer spdConstants)
: base(contextDescription, resources, constants)
{
_spdConstants = spdConstants;
InitComputeShader("Compute Luminance Pyramid", contextDescription.Shaders.computeLuminancePyramidPass);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, AsrShaderIDs.SrvInputColor, dispatchParams.Color);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.SrvAutoExposure, Resources.AutoExposure[frameIndex ^ 1]);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavAutoExposure, Resources.AutoExposure[frameIndex]);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, AsrShaderIDs.CbSpd, _spdConstants, 0, _spdConstants.stride);
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1);
}
}
internal class AsrReconstructPreviousDepthPass : AsrPass
{
private readonly RenderTargetIdentifier[] _mrt = new RenderTargetIdentifier[3];
public AsrReconstructPreviousDepthPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitFragmentShader("Reconstruct & Dilate", contextDescription.Shaders.fragmentShader, 1);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputColor, dispatchParams.Color);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputDepth, dispatchParams.Depth);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputExposure, dispatchParams.Exposure);
// UAV binding in fragment shader, index needs to match the register binding in HLSL
commandBuffer.SetRandomWriteTarget(3, AsrShaderIDs.UavReconstructedPrevNearestDepth);
_mrt[0] = AsrShaderIDs.RtDilatedDepth; // fDepth
_mrt[1] = AsrShaderIDs.RtLockInputLuma; // fLuma
_mrt[2] = Resources.DilatedMotionVectors[frameIndex]; // fMotionVector
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
BlitFragment(commandBuffer, _mrt);
commandBuffer.ClearRandomWriteTargets();
}
}
internal class AsrDepthClipPass : AsrPass
{
private readonly RenderTargetIdentifier[] _mrt = new RenderTargetIdentifier[2];
public AsrDepthClipPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitFragmentShader("Depth Clip", contextDescription.Shaders.fragmentShader, 2);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputColor, dispatchParams.Color);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputDepth, dispatchParams.Depth);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvReactiveMask, dispatchParams.Reactive);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvTransparencyAndCompositionMask, dispatchParams.TransparencyAndComposition);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvReconstructedPrevNearestDepth, AsrShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvDilatedDepth, AsrShaderIDs.UavDilatedDepth);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]);
_mrt[0] = AsrShaderIDs.RtPreparedInputColor; // fTonemapped
_mrt[1] = AsrShaderIDs.RtDilatedReactiveMasks; // fDilatedReactiveMasks
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
BlitFragment(commandBuffer, _mrt);
}
}
internal class AsrLockPass : AsrPass
{
public AsrLockPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitComputeShader("Create Locks", contextDescription.Shaders.lockPass);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.SrvLockInputLuma, AsrShaderIDs.UavLockInputLuma);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavNewLocks, AsrShaderIDs.UavNewLocks);
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, AsrShaderIDs.UavReconstructedPrevNearestDepth, AsrShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1);
}
}
internal class AsrAccumulatePass : AsrPass
{
private readonly RenderTargetIdentifier[] _mrt = new RenderTargetIdentifier[4];
public AsrAccumulatePass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants)
: base(contextDescription, resources, constants)
{
InitFragmentShader("Reproject & Accumulate", contextDescription.Shaders.fragmentShader, 3);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
if ((ContextDescription.Flags & Asr.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0)
{
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]);
}
else
{
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors);
}
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvDilatedReactiveMasks, AsrShaderIDs.UavDilatedReactiveMasks);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvPreparedInputColor, AsrShaderIDs.UavPreparedInputColor);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLanczosLut, Resources.LanczosLut);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvAutoExposure, Resources.AutoExposure[frameIndex]);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvNewLocks, AsrShaderIDs.UavNewLocks);
if (ContextDescription.Variant == Asr.Variant.Quality)
{
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]);
_mrt[0] = Resources.InternalUpscaled[frameIndex]; // fColorAndWeight
_mrt[1] = Resources.LockStatus[frameIndex]; // fLockStatus
_mrt[2] = Resources.LumaHistory[frameIndex]; // fLumaHistory
}
else
{
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvInternalTemporalReactive, Resources.InternalReactive[frameIndex ^ 1]);
_mrt[0] = Resources.InternalUpscaled[frameIndex]; // fUpscaledColor
_mrt[1] = Resources.InternalReactive[frameIndex]; // fTemporalReactive
_mrt[2] = Resources.LockStatus[frameIndex]; // fLockStatus
}
_mrt[3] = dispatchParams.EnableSharpening ? BuiltinRenderTextureType.None : dispatchParams.Output.RenderTarget; // fColor
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
BlitFragment(commandBuffer, _mrt);
commandBuffer.ClearRandomWriteTargets();
}
}
internal class AsrSharpenPass : AsrPass
{
private readonly ComputeBuffer _rcasConstants;
public AsrSharpenPass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants, ComputeBuffer rcasConstants)
: base(contextDescription, resources, constants)
{
_rcasConstants = rcasConstants;
InitFragmentShader("RCAS Sharpening", contextDescription.Shaders.fragmentShader, 4);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputExposure, dispatchParams.Exposure);
commandBuffer.SetGlobalTexture(AsrShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]);
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbRcas, _rcasConstants, 0, _rcasConstants.stride);
BlitFragment(commandBuffer, dispatchParams.Output.RenderTarget);
}
}
internal class AsrGenerateReactivePass : AsrPass
{
private readonly ComputeBuffer _generateReactiveConstants;
public AsrGenerateReactivePass(in Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants, ComputeBuffer generateReactiveConstants)
: base(contextDescription, resources, constants)
{
_generateReactiveConstants = generateReactiveConstants;
InitFragmentShader("Auto-Generate Reactive Mask", contextDescription.Shaders.fragmentShader, 0);
}
protected override void DoScheduleDispatch(CommandBuffer commandBuffer, in Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY)
{
}
public void ScheduleDispatch(CommandBuffer commandBuffer, in Asr.GenerateReactiveDescription dispatchParams)
{
BeginSample(commandBuffer);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly);
commandBuffer.SetGlobalResource(AsrShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale);
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbFsr2, Constants, 0, Constants.stride);
FragmentProperties.SetConstantBuffer(AsrShaderIDs.CbGenReactive, _generateReactiveConstants, 0, _generateReactiveConstants.stride);
BlitFragment(commandBuffer, dispatchParams.OutReactive.RenderTarget);
EndSample(commandBuffer);
}
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrPass.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7fb53d9f929886c4ab35be8d9010b9c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

227
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrResources.cs

@ -0,0 +1,227 @@
using System;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// Helper class for bundling and managing persistent resources required by the ASR process.
/// This includes lookup tables, default fallback resources and double-buffered resources that get swapped between frames.
/// </summary>
internal class AsrResources
{
public Texture2D DefaultExposure;
public Texture2D DefaultReactive;
public Texture2D LanczosLut;
public Texture2D MaximumBiasLut;
public RenderTexture SpdAtomicCounter;
public RenderTexture SceneLuminance;
public readonly RenderTexture[] AutoExposure = new RenderTexture[2];
public readonly RenderTexture[] DilatedMotionVectors = new RenderTexture[2];
public readonly RenderTexture[] LockStatus = new RenderTexture[2];
public readonly RenderTexture[] InternalUpscaled = new RenderTexture[2];
public readonly RenderTexture[] InternalReactive = new RenderTexture[2];
public readonly RenderTexture[] LumaHistory = new RenderTexture[2];
public void Create(in Asr.ContextDescription contextDescription)
{
// Generate the data for the LUT
const int lanczos2LutWidth = 128;
float[] lanczos2Weights = new float[lanczos2LutWidth];
for (int currentLanczosWidthIndex = 0; currentLanczosWidthIndex < lanczos2LutWidth; ++currentLanczosWidthIndex)
{
float x = 2.0f * currentLanczosWidthIndex / (lanczos2LutWidth - 1);
float y = Asr.Lanczos2(x);
lanczos2Weights[currentLanczosWidthIndex] = y;
}
float[] maximumBias = new float[MaximumBiasTextureWidth * MaximumBiasTextureHeight];
for (int i = 0; i < maximumBias.Length; ++i)
{
maximumBias[i] = MaximumBias[i] / 2.0f;
}
GetFormatRequirements(contextDescription, out bool isBalancedOrPerformance, out _, out _, out GraphicsFormat r16Format, out GraphicsFormat rg16Format);
// Resource FSR2_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE
// R16_SNorm textures are not supported by Unity on most platforms, strangely enough. So instead we use R32_SFloat and upload pre-normalized float data.
LanczosLut = new Texture2D(lanczos2LutWidth, 1, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "ASR_LanczosLutData" };
LanczosLut.SetPixelData(lanczos2Weights, 0);
LanczosLut.Apply();
// Resource FSR2_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE
MaximumBiasLut = new Texture2D(MaximumBiasTextureWidth, MaximumBiasTextureHeight, GraphicsFormat.R32_SFloat, TextureCreationFlags.None) { name = "ASR_MaximumUpsampleBias" };
MaximumBiasLut.SetPixelData(maximumBias, 0);
MaximumBiasLut.Apply();
// Resource FSR2_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
DefaultExposure = new Texture2D(1, 1, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None) { name = "ASR_DefaultExposure" };
DefaultExposure.SetPixel(0, 0, Color.clear);
DefaultExposure.Apply();
// Resource FSR2_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE
DefaultReactive = new Texture2D(1, 1, GraphicsFormat.R8_UNorm, TextureCreationFlags.None) { name = "ASR_DefaultReactivityMask" };
DefaultReactive.SetPixel(0, 0, Color.clear);
DefaultReactive.Apply();
// Resource FSR2_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
// Despite what the original FSR2 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal.
SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "ASR_SpdAtomicCounter", enableRandomWrite = true };
SpdAtomicCounter.Create();
// Resource FSR2_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this.
int w = contextDescription.MaxRenderSize.x / 2, h = contextDescription.MaxRenderSize.y / 2;
int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Math.Max(w, h), 2.0f));
SceneLuminance = new RenderTexture(w, h, 0, r16Format, mipCount) { name = "ASR_ExposureMips", enableRandomWrite = true, useMipMap = true, autoGenerateMips = false };
SceneLuminance.Create();
// Resource FSR2_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(AutoExposure, "ASR_AutoExposure", Vector2Int.one, rg16Format, enableRandomWrite: true);
// Resources FSR2_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(DilatedMotionVectors, "ASR_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat);
// Resources FSR2_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(LockStatus, "ASR_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat);
// Resources FSR2_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(InternalUpscaled, "ASR_InternalUpscaled", contextDescription.DisplaySize, !isBalancedOrPerformance ? GraphicsFormat.R16G16B16A16_SFloat : GraphicsFormat.B10G11R11_UFloatPack32);
// Additional textures used by either balanced or performance presets
if (isBalancedOrPerformance)
{
// Resources FSR2_InternalReactive1/2: FFXM_RESOURCE_USAGE_RENDERTARGET, FFXM_SURFACE_FORMAT_R8_SNORM, FFXM_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(InternalReactive, "ASR_InternalReactive", contextDescription.DisplaySize, GraphicsFormat.R8_SNorm);
}
else // Quality preset specific
{
// Resources FSR2_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(LumaHistory, "ASR_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm);
}
}
// Set up shared aliasable resources, i.e. temporary render textures
// These do not need to persist between frames, but they do need to be available between passes
public static void CreateAliasableResources(CommandBuffer commandBuffer, in Asr.ContextDescription contextDescription, in Asr.DispatchDescription dispatchParams)
{
Vector2Int displaySize = contextDescription.DisplaySize;
Vector2Int maxRenderSize = contextDescription.MaxRenderSize;
GetFormatRequirements(contextDescription, out _, out bool preparedInputColorNeedsFp16, out GraphicsFormat r8Format, out _, out _);
// FSR2_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true);
// FSR2_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1);
// FSR2_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1);
// FSR2_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1);
// FSR2_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, preparedInputColorNeedsFp16 ? GraphicsFormat.R16G16B16A16_SFloat : GraphicsFormat.R8G8B8A8_UNorm, 1);
// FSR2_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer.GetTemporaryRT(AsrShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, r8Format, 1, true);
}
private static void GetFormatRequirements(in Asr.ContextDescription contextDescription,
out bool isBalancedOrPerformance, out bool preparedInputColorNeedsFP16,
out GraphicsFormat r8Format, out GraphicsFormat r16Format, out GraphicsFormat rg16Format)
{
bool applyPerfModeOptimizations = contextDescription.Variant == Asr.Variant.Performance;
bool applyBalancedModeOptimizations = contextDescription.Variant == Asr.Variant.Balanced;
isBalancedOrPerformance = applyBalancedModeOptimizations || applyPerfModeOptimizations;
preparedInputColorNeedsFP16 = !applyPerfModeOptimizations;
// OpenGLES 3.2 specific: We need to work around some GLES limitations for some resources.
bool isOpenGLES = SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3;
r8Format = isOpenGLES ? GraphicsFormat.R32_SFloat : GraphicsFormat.R8_UNorm;
r16Format = isOpenGLES ? GraphicsFormat.R32_SFloat : GraphicsFormat.R16_SFloat;
rg16Format = isOpenGLES ? GraphicsFormat.R16G16B16A16_SFloat : GraphicsFormat.R16G16_SFloat;
}
public static void DestroyAliasableResources(CommandBuffer commandBuffer)
{
// Release all the aliasable resources used this frame
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavReconstructedPrevNearestDepth);
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavDilatedDepth);
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavLockInputLuma);
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavDilatedReactiveMasks);
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavPreparedInputColor);
commandBuffer.ReleaseTemporaryRT(AsrShaderIDs.UavNewLocks);
}
private static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, Vector2Int size, GraphicsFormat format, bool enableRandomWrite = false)
{
for (int i = 0; i < 2; ++i)
{
resource[i] = new RenderTexture(size.x, size.y, 0, format) { name = name + (i + 1), enableRandomWrite = enableRandomWrite };
resource[i].Create();
}
}
public void Destroy()
{
DestroyResource(LumaHistory);
DestroyResource(InternalReactive);
DestroyResource(InternalUpscaled);
DestroyResource(LockStatus);
DestroyResource(DilatedMotionVectors);
DestroyResource(AutoExposure);
DestroyResource(ref SceneLuminance);
DestroyResource(ref DefaultReactive);
DestroyResource(ref DefaultExposure);
DestroyResource(ref MaximumBiasLut);
DestroyResource(ref LanczosLut);
}
private static void DestroyResource(ref Texture2D resource)
{
Asr.DestroyObject(resource);
resource = null;
}
private static void DestroyResource(ref RenderTexture resource)
{
if (resource == null)
return;
resource.Release();
resource = null;
}
private static void DestroyResource(RenderTexture[] resource)
{
for (int i = 0; i < resource.Length; ++i)
DestroyResource(ref resource[i]);
}
private const int MaximumBiasTextureWidth = 16;
private const int MaximumBiasTextureHeight = 16;
private static readonly float[] MaximumBias =
{
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.876f, 1.809f, 1.772f, 1.753f, 1.748f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.869f, 1.801f, 1.764f, 1.745f, 1.739f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.976f, 1.841f, 1.774f, 1.737f, 1.716f, 1.71f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.914f, 1.784f, 1.716f, 1.673f, 1.649f, 1.641f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.793f, 1.676f, 1.604f, 1.562f, 1.54f, 1.533f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.802f, 1.619f, 1.536f, 1.492f, 1.467f, 1.454f, 1.449f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.812f, 1.575f, 1.496f, 1.456f, 1.432f, 1.416f, 1.408f, 1.405f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.555f, 1.479f, 1.438f, 1.413f, 1.398f, 1.387f, 1.381f, 1.379f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.812f, 1.555f, 1.474f, 1.43f, 1.404f, 1.387f, 1.376f, 1.368f, 1.363f, 1.362f,
2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 1.802f, 1.575f, 1.479f, 1.43f, 1.401f, 1.382f, 1.369f, 1.36f, 1.354f, 1.351f, 1.35f,
2.0f, 2.0f, 1.976f, 1.914f, 1.793f, 1.619f, 1.496f, 1.438f, 1.404f, 1.382f, 1.367f, 1.357f, 1.349f, 1.344f, 1.341f, 1.34f,
1.876f, 1.869f, 1.841f, 1.784f, 1.676f, 1.536f, 1.456f, 1.413f, 1.387f, 1.369f, 1.357f, 1.347f, 1.341f, 1.336f, 1.333f, 1.332f,
1.809f, 1.801f, 1.774f, 1.716f, 1.604f, 1.492f, 1.432f, 1.398f, 1.376f, 1.36f, 1.349f, 1.341f, 1.335f, 1.33f, 1.328f, 1.327f,
1.772f, 1.764f, 1.737f, 1.673f, 1.562f, 1.467f, 1.416f, 1.387f, 1.368f, 1.354f, 1.344f, 1.336f, 1.33f, 1.326f, 1.323f, 1.323f,
1.753f, 1.745f, 1.716f, 1.649f, 1.54f, 1.454f, 1.408f, 1.381f, 1.363f, 1.351f, 1.341f, 1.333f, 1.328f, 1.323f, 1.321f, 1.32f,
1.748f, 1.739f, 1.71f, 1.641f, 1.533f, 1.449f, 1.405f, 1.379f, 1.362f, 1.35f, 1.34f, 1.332f, 1.327f, 1.323f, 1.32f, 1.319f,
};
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrResources.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 538f6eefa95c8ee4d9f6a9bc4bb3188e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

70
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrShaderIDs.cs

@ -0,0 +1,70 @@
using UnityEngine;
namespace ArmASR
{
public static class AsrShaderIDs
{
// Shader resource views, i.e. read-only bindings
public static readonly int SrvInputColor = Shader.PropertyToID("r_input_color_jittered");
public static readonly int SrvOpaqueOnly = Shader.PropertyToID("r_input_opaque_only");
public static readonly int SrvInputMotionVectors = Shader.PropertyToID("r_input_motion_vectors");
public static readonly int SrvInputDepth = Shader.PropertyToID("r_input_depth");
public static readonly int SrvInputExposure = Shader.PropertyToID("r_input_exposure");
public static readonly int SrvAutoExposure = Shader.PropertyToID("r_auto_exposure");
public static readonly int SrvReactiveMask = Shader.PropertyToID("r_reactive_mask");
public static readonly int SrvTransparencyAndCompositionMask = Shader.PropertyToID("r_transparency_and_composition_mask");
public static readonly int SrvReconstructedPrevNearestDepth = Shader.PropertyToID("r_reconstructed_previous_nearest_depth");
public static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors");
public static readonly int SrvPrevDilatedMotionVectors = Shader.PropertyToID("r_previous_dilated_motion_vectors");
public static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilatedDepth");
public static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color");
public static readonly int SrvInternalTemporalReactive = Shader.PropertyToID("r_internal_temporal_reactive");
public static readonly int SrvLockStatus = Shader.PropertyToID("r_lock_status");
public static readonly int SrvNewLocks = Shader.PropertyToID("r_new_locks");
public static readonly int SrvLockInputLuma = Shader.PropertyToID("r_lock_input_luma");
public static readonly int SrvPreparedInputColor = Shader.PropertyToID("r_prepared_input_color");
public static readonly int SrvLumaHistory = Shader.PropertyToID("r_luma_history");
public static readonly int SrvRcasInput = Shader.PropertyToID("r_rcas_input");
public static readonly int SrvLanczosLut = Shader.PropertyToID("r_lanczos_lut");
public static readonly int SrvSceneLuminanceMips = Shader.PropertyToID("r_imgMips");
public static readonly int SrvUpscaleMaximumBiasLut = Shader.PropertyToID("r_upsample_maximum_bias_lut");
public static readonly int SrvDilatedReactiveMasks = Shader.PropertyToID("r_dilated_reactive_masks");
// Unordered access views, i.e. random read/write bindings
public static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth");
public static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors");
public static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilatedDepth");
public static readonly int UavInternalUpscaled = Shader.PropertyToID("rw_internal_upscaled_color");
public static readonly int UavLockStatus = Shader.PropertyToID("rw_lock_status");
public static readonly int UavLockInputLuma = Shader.PropertyToID("rw_lock_input_luma");
public static readonly int UavNewLocks = Shader.PropertyToID("rw_new_locks");
public static readonly int UavPreparedInputColor = Shader.PropertyToID("rw_prepared_input_color");
public static readonly int UavLumaHistory = Shader.PropertyToID("rw_luma_history");
public static readonly int UavUpscaledOutput = Shader.PropertyToID("rw_upscaled_output");
public static readonly int UavExposureMipLumaChange = Shader.PropertyToID("rw_img_mip_shading_change");
public static readonly int UavExposureMip5 = Shader.PropertyToID("rw_img_mip_5");
public static readonly int UavDilatedReactiveMasks = Shader.PropertyToID("rw_dilated_reactive_masks");
public static readonly int UavAutoExposure = Shader.PropertyToID("rw_auto_exposure");
public static readonly int UavSpdAtomicCount = Shader.PropertyToID("rw_spd_global_atomic");
public static readonly int UavAutoReactive = Shader.PropertyToID("rw_output_autoreactive");
// Render textures, i.e. output targets for fragment shaders
public static readonly int RtInternalUpscalerColor = Shader.PropertyToID("rw_internal_upscaled_color");
public static readonly int RtInternalTemporalReactive = Shader.PropertyToID("rw_internal_temporal_reactive");
public static readonly int RtLockStatus = Shader.PropertyToID("rw_lock_status");
public static readonly int RtLumaHistory = Shader.PropertyToID("rw_luma_history");
public static readonly int RtUpscaledOutput = Shader.PropertyToID("rw_upscaled_output");
public static readonly int RtDilatedReactiveMasks = Shader.PropertyToID("rw_dilated_reactive_masks");
public static readonly int RtPreparedInputColor = Shader.PropertyToID("rw_prepared_input_color");
public static readonly int RtDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors");
public static readonly int RtDilatedDepth = Shader.PropertyToID("rw_dilatedDepth");
public static readonly int RtLockInputLuma = Shader.PropertyToID("rw_lock_input_luma");
public static readonly int RtAutoReactive = Shader.PropertyToID("rw_output_autoreactive");
// Constant buffer bindings
public static readonly int CbFsr2 = Shader.PropertyToID("cbFSR2");
public static readonly int CbSpd = Shader.PropertyToID("cbSPD");
public static readonly int CbRcas = Shader.PropertyToID("cbRCAS");
public static readonly int CbGenReactive = Shader.PropertyToID("cbGenerateReactive");
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/AsrShaderIDs.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0173241f8bd75e419590b43a3739e0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

35
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/ResourceView.cs

@ -0,0 +1,35 @@
using UnityEngine.Rendering;
namespace ArmASR
{
/// <summary>
/// An immutable structure wrapping all the necessary information to bind a specific buffer or attachment of a render target to a compute shader.
/// </summary>
public readonly struct ResourceView
{
/// <summary>
/// This value is the equivalent of not setting any value at all; all struct fields will have their default values.
/// It does not refer to a valid texture, therefore any variable set to this value should be checked for IsValid and reassigned before being bound to a shader.
/// </summary>
public static readonly ResourceView Unassigned = new ResourceView(default);
/// <summary>
/// This value contains a valid texture reference that can be bound to a shader, however it is just an empty placeholder texture.
/// Binding this to a shader can be seen as setting the texture variable inside the shader to null.
/// </summary>
public static readonly ResourceView None = new ResourceView(BuiltinRenderTextureType.None);
public ResourceView(in RenderTargetIdentifier renderTarget, RenderTextureSubElement subElement = RenderTextureSubElement.Default, int mipLevel = 0)
{
RenderTarget = renderTarget;
SubElement = subElement;
MipLevel = mipLevel;
}
public bool IsValid => !RenderTarget.Equals(default);
public readonly RenderTargetIdentifier RenderTarget;
public readonly RenderTextureSubElement SubElement;
public readonly int MipLevel;
}
}

11
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Runtime/ResourceView.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e2e3cd4f5c3d4146b6fe3f93685751b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d231e3fb22497e3448f149c48709d08d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

84
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc

@ -0,0 +1,84 @@
#pragma warning(disable: 3078) // Loop control variable conflicts
#pragma warning(disable: 3203) // Signed/unsigned mismatch
#pragma warning(disable: 3205) // Conversion from larger type to smaller, possible loss of data
#pragma warning(disable: 3556) // Integer divides might be much slower, try using uints if possible
// If these keywords are set by Unity, redefine them to have a truthy value
#if defined(FFXM_HALF)
#undef FFXM_HALF
#define FFXM_HALF (1)
#endif
#ifdef FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#undef FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#define FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE 1
#endif
#ifdef FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#undef FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#define FFXM_FSR2_OPTION_SHADER_OPT_BALANCED 1
#endif
// Ensure the correct value is defined for this keyword, as it is used to select one of multiple sampler functions
#ifdef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#undef FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#define FFX_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 1
#endif
// ASR has some special code paths for OpenGL ES 3.2
#if defined(SHADER_API_GLES3)
#define FFXM_SHADER_PLATFORM_GLES_3_2 (1)
#define unorm
#endif
// Work around the lack of texture atomics on Metal
#if defined(SHADER_API_METAL)
#define InterlockedAdd(dest, val, orig) { (orig) = (dest); (dest) += (val); }
#define InterlockedMin(dest, val) { (dest) = min((dest), (val)); }
#define InterlockedMax(dest, val) { (dest) = max((dest), (val)); }
#endif
// PSSL uses different semantics and doesn't support certain type qualifiers
#if defined(SHADER_API_PSSL)
#define SV_VERTEXID S_VERTEX_ID
#define SV_POSITION S_POSITION
#define SV_TARGET0 S_TARGET_OUTPUT0
#define SV_TARGET1 S_TARGET_OUTPUT1
#define SV_TARGET2 S_TARGET_OUTPUT2
#define SV_TARGET3 S_TARGET_OUTPUT3
#define unorm
#define globallycoherent
#endif
// Workaround for HDRP using texture arrays for its camera buffers on some platforms
// 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)
#define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED
#endif
// Control if TEXTURE2D_X macros will expand to texture arrays
#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && defined(UNITY_FFXM_TEXTURE2D_X_ARRAY)
#define USE_TEXTURE2D_X_AS_ARRAY
#endif
// Early defines for single-pass instancing
#if defined(STEREO_INSTANCING_ON) && defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED)
#define UNITY_STEREO_INSTANCING_ENABLED
#endif
// Helper macros to handle XR single-pass with Texture2DArray
#if defined(USE_TEXTURE2D_X_AS_ARRAY)
// Only single-pass stereo instancing used array indexing
#if defined(UNITY_STEREO_INSTANCING_ENABLED)
static uint unity_StereoEyeIndex;
#define SLICE_ARRAY_INDEX unity_StereoEyeIndex
#else
#define SLICE_ARRAY_INDEX 0
#endif
// 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)
#endif

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_common.cginc.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6836bc2e151d44e0bd1991fd7bfaee30
timeCreated: 1742410813

122
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_legacy.shader

@ -0,0 +1,122 @@
Shader "TND/ASR/ffxm_fsr2_fragment_legacy"
{
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass // 0
{
Name "Auto-Generate Reactive Mask"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl"
ENDHLSL
}
Pass // 1
{
Name "Reconstruct Previous Depth"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_HDR_COLOR_INPUT
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl"
ENDHLSL
}
Pass // 2
{
Name "Depth Clip"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl"
ENDHLSL
}
Pass // 3
{
Name "Accumulate"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#pragma multi_compile __ FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#pragma multi_compile __ FFXM_FSR2_OPTION_HDR_COLOR_INPUT
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_APPLY_SHARPENING
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_accumulate_pass_fs.hlsl"
ENDHLSL
}
Pass // 4
{
Name "Sharpen"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_rcas_pass_fs.hlsl"
ENDHLSL
}
}
}

9
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_legacy.shader.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 42e5314e46109a441a4527349d8df6e4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

139
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_modern.shader

@ -0,0 +1,139 @@
Shader "TND/ASR/ffxm_fsr2_fragment_modern"
{
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass // 0
{
Name "Auto-Generate Reactive Mask"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
#pragma require Native16Bit
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl"
ENDHLSL
}
Pass // 1
{
Name "Reconstruct Previous Depth"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
#pragma require Native16Bit
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_HDR_COLOR_INPUT
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl"
ENDHLSL
}
Pass // 2
{
Name "Depth Clip"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
#pragma require Native16Bit
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl"
ENDHLSL
}
Pass // 3
{
Name "Accumulate"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
#pragma require Native16Bit
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_BALANCED
#pragma multi_compile __ FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE
#pragma multi_compile __ FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#pragma multi_compile __ FFXM_FSR2_OPTION_HDR_COLOR_INPUT
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_APPLY_SHARPENING
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_accumulate_pass_fs.hlsl"
ENDHLSL
}
Pass // 4
{
Name "Sharpen"
HLSLPROGRAM
#pragma vertex VertMain
#pragma fragment main
#pragma target 4.5
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
#pragma require Native16Bit
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_vs.hlsl"
#include "shaders/ffxm_fsr2_rcas_pass_fs.hlsl"
ENDHLSL
}
}
Fallback "TND/ASR/ffxm_fsr2_fragment_legacy"
}

9
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_fragment_modern.shader.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 147cc2cffac69ef4eb3ea8addafc9d10
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

13
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_legacy.compute

@ -0,0 +1,13 @@
#pragma kernel main
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_lock_pass.hlsl"

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_legacy.compute.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a09277df48840a84196b3bac299544ea
timeCreated: 1742417134

15
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_modern.compute

@ -0,0 +1,15 @@
#pragma kernel main
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
#include "shaders/ffxm_fsr2_lock_pass.hlsl"

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_lock_modern.compute.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a6e1d5d5372d467790fcf2d089b50ef7
timeCreated: 1742417134

16
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_legacy.compute

@ -0,0 +1,16 @@
#pragma kernel main
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
// Disable wave operations altogether
#define FFXM_SPD_NO_WAVE_OPERATIONS
#include "shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl"

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_legacy.compute.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 41d0c3a77d97a904e96ebc2bf18129f6
timeCreated: 1742416757

24
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_modern.compute

@ -0,0 +1,24 @@
#pragma kernel main
#pragma only_renderers d3d11 vulkan metal ps5 xboxseries
#pragma use_dxc
//#pragma enable_d3d11_debug_symbols
#pragma multi_compile __ FFXM_HALF
#pragma multi_compile __ FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS
#pragma multi_compile __ FFXM_FSR2_OPTION_INVERTED_DEPTH
#pragma multi_compile __ UNITY_FFXM_TEXTURE2D_X_ARRAY
#include "ffxm_fsr2_common.cginc"
// Enable wave operations for the platforms that support it
#if defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(SHADER_API_MOBILE)
#pragma require WaveBasic // Required for WaveGetLaneIndex
#pragma require WaveBallot // Required for WaveReadLaneAt
#pragma require QuadShuffle // Required for QuadReadAcross
#else
#define FFXM_SPD_NO_WAVE_OPERATIONS
#endif
#include "shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl"

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/ffxm_fsr2_luma_pyramid_modern.compute.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 57220d870cb441c8a6df8a9e15a74283
timeCreated: 1742416757

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f7cc575273c4b124596cac0be2abd8ff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

614
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_common_types.h

@ -0,0 +1,614 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_COMMON_TYPES_H
#define FFXM_COMMON_TYPES_H
#if defined(FFXM_CPU)
#define FFXM_PARAMETER_IN
#define FFXM_PARAMETER_OUT
#define FFXM_PARAMETER_INOUT
#define FFXM_PARAMETER_UNIFORM
#elif defined(FFXM_HLSL)
#define FFXM_PARAMETER_IN in
#define FFXM_PARAMETER_OUT out
#define FFXM_PARAMETER_INOUT inout
#define FFXM_PARAMETER_UNIFORM uniform
#elif defined(FFXM_GLSL)
#define FFXM_PARAMETER_IN in
#define FFXM_PARAMETER_OUT out
#define FFXM_PARAMETER_INOUT inout
#define FFXM_PARAMETER_UNIFORM const //[cacao_placeholder] until a better fit is found!
#endif // #if defined(FFXM_CPU)
#if defined(FFXM_CPU)
/// A typedef for a boolean value.
///
/// @ingroup CPUTypes
typedef bool FfxBoolean;
/// A typedef for a unsigned 8bit integer.
///
/// @ingroup CPUTypes
typedef uint8_t FfxUInt8;
/// A typedef for a unsigned 16bit integer.
///
/// @ingroup CPUTypes
typedef uint16_t FfxUInt16;
/// A typedef for a unsigned 32bit integer.
///
/// @ingroup CPUTypes
typedef uint32_t FfxUInt32;
/// A typedef for a unsigned 64bit integer.
///
/// @ingroup CPUTypes
typedef uint64_t FfxUInt64;
/// A typedef for a signed 8bit integer.
///
/// @ingroup CPUTypes
typedef int8_t FfxInt8;
/// A typedef for a signed 16bit integer.
///
/// @ingroup CPUTypes
typedef int16_t FfxInt16;
/// A typedef for a signed 32bit integer.
///
/// @ingroup CPUTypes
typedef int32_t FfxInt32;
/// A typedef for a signed 64bit integer.
///
/// @ingroup CPUTypes
typedef int64_t FfxInt64;
/// A typedef for a floating point value.
///
/// @ingroup CPUTypes
typedef float FfxFloat32;
/// A typedef for a 2-dimensional floating point value.
///
/// @ingroup CPUTypes
typedef float FfxFloat32x2[2];
/// A typedef for a 3-dimensional floating point value.
///
/// @ingroup CPUTypes
typedef float FfxFloat32x3[3];
/// A typedef for a 4-dimensional floating point value.
///
/// @ingroup CPUTypes
typedef float FfxFloat32x4[4];
/// A typedef for a 2-dimensional 32bit unsigned integer.
///
/// @ingroup CPUTypes
typedef uint32_t FfxUInt32x2[2];
/// A typedef for a 3-dimensional 32bit unsigned integer.
///
/// @ingroup CPUTypes
typedef uint32_t FfxUInt32x3[3];
/// A typedef for a 4-dimensional 32bit unsigned integer.
///
/// @ingroup CPUTypes
typedef uint32_t FfxUInt32x4[4];
#endif // #if defined(FFXM_CPU)
#if defined(FFXM_HLSL)
// Unless defined, go for the conservative option.
#if !defined(FFXM_HLSL_6_2)
#define FFXM_HLSL_6_2 (0)
#endif
#define FfxFloat32Mat4 matrix <float, 4, 4>
#define FfxFloat32Mat3 matrix <float, 3, 3>
/// A typedef for a boolean value.
///
/// @ingroup HLSLTypes
typedef bool FfxBoolean;
#if FFXM_HLSL_6_2
/// @defgroup HLSL62Types HLSL 6.2 And Above Types
/// HLSL 6.2 and above type defines for all commonly used variables
///
/// @ingroup HLSLTypes
/// A typedef for a floating point value.
///
/// @ingroup HLSL62Types
typedef float32_t FfxFloat32;
/// A typedef for a 2-dimensional floating point value.
///
/// @ingroup HLSL62Types
typedef float32_t2 FfxFloat32x2;
/// A typedef for a 3-dimensional floating point value.
///
/// @ingroup HLSL62Types
typedef float32_t3 FfxFloat32x3;
/// A typedef for a 4-dimensional floating point value.
///
/// @ingroup HLSL62Types
typedef float32_t4 FfxFloat32x4;
/// A [cacao_placeholder] typedef for matrix type until confirmed.
typedef float4x4 FfxFloat32x4x4;
typedef float3x3 FfxFloat32x3x3;
typedef float2x2 FfxFloat32x2x2;
/// A typedef for a unsigned 32bit integer.
///
/// @ingroup HLSL62Types
typedef uint32_t FfxUInt32;
/// A typedef for a 2-dimensional 32bit unsigned integer.
///
/// @ingroup HLSL62Types
typedef uint32_t2 FfxUInt32x2;
/// A typedef for a 3-dimensional 32bit unsigned integer.
///
/// @ingroup HLSL62Types
typedef uint32_t3 FfxUInt32x3;
/// A typedef for a 4-dimensional 32bit unsigned integer.
///
/// @ingroup HLSL62Types
typedef uint32_t4 FfxUInt32x4;
/// A typedef for a signed 32bit integer.
///
/// @ingroup HLSL62Types
typedef int32_t FfxInt32;
/// A typedef for a 2-dimensional signed 32bit integer.
///
/// @ingroup HLSL62Types
typedef int32_t2 FfxInt32x2;
/// A typedef for a 3-dimensional signed 32bit integer.
///
/// @ingroup HLSL62Types
typedef int32_t3 FfxInt32x3;
/// A typedef for a 4-dimensional signed 32bit integer.
///
/// @ingroup HLSL62Types
typedef int32_t4 FfxInt32x4;
#else // #if defined(FFXM_HLSL_6_2)
/// @defgroup HLSLBaseTypes HLSL 6.1 And Below Types
/// HLSL 6.1 and below type defines for all commonly used variables
///
/// @ingroup HLSLTypes
#define FfxFloat32 float
#define FfxFloat32x2 float2
#define FfxFloat32x3 float3
#define FfxFloat32x4 float4
/// A [cacao_placeholder] typedef for matrix type until confirmed.
#define FfxFloat32x4x4 float4x4
#define FfxFloat32x3x3 float3x3
#define FfxFloat32x2x2 float2x2
/// A typedef for a unsigned 32bit integer.
///
/// @ingroup GPU
typedef uint FfxUInt32;
typedef uint2 FfxUInt32x2;
typedef uint3 FfxUInt32x3;
typedef uint4 FfxUInt32x4;
typedef int FfxInt32;
typedef int2 FfxInt32x2;
typedef int3 FfxInt32x3;
typedef int4 FfxInt32x4;
#endif // #if defined(FFXM_HLSL_6_2)
#if FFXM_HALF
#if FFXM_HLSL_6_2
typedef float16_t FfxFloat16;
typedef float16_t2 FfxFloat16x2;
typedef float16_t3 FfxFloat16x3;
typedef float16_t4 FfxFloat16x4;
/// A typedef for an unsigned 16bit integer.
///
/// @ingroup HLSLTypes
typedef uint16_t FfxUInt16;
typedef uint16_t2 FfxUInt16x2;
typedef uint16_t3 FfxUInt16x3;
typedef uint16_t4 FfxUInt16x4;
/// A typedef for a signed 16bit integer.
///
/// @ingroup HLSLTypes
typedef int16_t FfxInt16;
typedef int16_t2 FfxInt16x2;
typedef int16_t3 FfxInt16x3;
typedef int16_t4 FfxInt16x4;
#elif SHADER_API_PSSL
#pragma argument(realtypes) // Enable true 16-bit types
typedef half FfxFloat16;
typedef half2 FfxFloat16x2;
typedef half3 FfxFloat16x3;
typedef half4 FfxFloat16x4;
/// A typedef for an unsigned 16bit integer.
///
/// @ingroup GPU
typedef ushort FfxUInt16;
typedef ushort2 FfxUInt16x2;
typedef ushort3 FfxUInt16x3;
typedef ushort4 FfxUInt16x4;
/// A typedef for a signed 16bit integer.
///
/// @ingroup GPU
typedef short FfxInt16;
typedef short2 FfxInt16x2;
typedef short3 FfxInt16x3;
typedef short4 FfxInt16x4;
#else // #if FFXM_HLSL_6_2
typedef min16float FfxFloat16;
typedef min16float2 FfxFloat16x2;
typedef min16float3 FfxFloat16x3;
typedef min16float4 FfxFloat16x4;
/// A typedef for an unsigned 16bit integer.
///
/// @ingroup HLSLTypes
typedef min16uint FfxUInt16;
typedef min16uint2 FfxUInt16x2;
typedef min16uint3 FfxUInt16x3;
typedef min16uint4 FfxUInt16x4;
/// A typedef for a signed 16bit integer.
///
/// @ingroup HLSLTypes
typedef min16int FfxInt16;
typedef min16int2 FfxInt16x2;
typedef min16int3 FfxInt16x3;
typedef min16int4 FfxInt16x4;
#endif // #if FFXM_HLSL_6_2
#endif // FFXM_HALF
#endif // #if defined(FFXM_HLSL)
#if defined(FFXM_GLSL)
#define FfxFloat32Mat4 mat4
#define FfxFloat32Mat3 mat3
/// A typedef for a boolean value.
///
/// @ingroup GLSLTypes
#define FfxBoolean bool
#define FfxFloat32 float
#define FfxFloat32x2 vec2
#define FfxFloat32x3 vec3
#define FfxFloat32x4 vec4
#define FfxUInt32 uint
#define FfxUInt32x2 uvec2
#define FfxUInt32x3 uvec3
#define FfxUInt32x4 uvec4
#define FfxInt32 int
#define FfxInt32x2 ivec2
#define FfxInt32x3 ivec3
#define FfxInt32x4 ivec4
/// A [cacao_placeholder] typedef for matrix type until confirmed.
#define FfxFloat32x4x4 mat4
#define FfxFloat32x3x3 mat3
#define FfxFloat32x2x2 mat2
#if FFXM_HALF
#define FfxFloat16 float16_t
#define FfxFloat16x2 f16vec2
#define FfxFloat16x3 f16vec3
#define FfxFloat16x4 f16vec4
#define FfxUInt16 uint16_t
#define FfxUInt16x2 u16vec2
#define FfxUInt16x3 u16vec3
#define FfxUInt16x4 u16vec4
#define FfxInt16 int16_t
#define FfxInt16x2 i16vec2
#define FfxInt16x3 i16vec3
#define FfxInt16x4 i16vec4
#endif // FFXM_HALF
#endif // #if defined(FFXM_GLSL)
#if FFXM_HALF && !defined(SHADER_API_PSSL)
#if FFXM_HLSL_6_2
#define FFXM_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
#define FFXM_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
#define FFXM_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
#define FFXM_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
#define FFXM_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
#define FFXM_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
#else //FFXM_HLSL_6_2
#define FFXM_MIN16_SCALAR( TypeName, BaseComponentType ) typedef min16##BaseComponentType TypeName;
#define FFXM_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<min16##BaseComponentType, COL> TypeName;
#define FFXM_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<min16##BaseComponentType, ROW, COL> TypeName;
#define FFXM_16BIT_SCALAR( TypeName, BaseComponentType ) FFXM_MIN16_SCALAR( TypeName, BaseComponentType );
#define FFXM_16BIT_VECTOR( TypeName, BaseComponentType, COL ) FFXM_MIN16_VECTOR( TypeName, BaseComponentType, COL );
#define FFXM_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFXM_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL );
#endif //FFXM_HLSL_6_2
#else //FFXM_HALF
#define FFXM_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
#define FFXM_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
#define FFXM_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
#define FFXM_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
#define FFXM_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
#define FFXM_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
#endif //FFXM_HALF
#if defined(FFXM_GPU)
// Common typedefs:
#if defined(FFXM_HLSL) && !defined(SHADER_API_PSSL)
FFXM_MIN16_SCALAR( FFXM_MIN16_F , float );
FFXM_MIN16_VECTOR( FFXM_MIN16_F2, float, 2 );
FFXM_MIN16_VECTOR( FFXM_MIN16_F3, float, 3 );
FFXM_MIN16_VECTOR( FFXM_MIN16_F4, float, 4 );
FFXM_MIN16_SCALAR( FFXM_MIN16_I, int );
FFXM_MIN16_VECTOR( FFXM_MIN16_I2, int, 2 );
FFXM_MIN16_VECTOR( FFXM_MIN16_I3, int, 3 );
FFXM_MIN16_VECTOR( FFXM_MIN16_I4, int, 4 );
FFXM_MIN16_SCALAR( FFXM_MIN16_U, uint );
FFXM_MIN16_VECTOR( FFXM_MIN16_U2, uint, 2 );
FFXM_MIN16_VECTOR( FFXM_MIN16_U3, uint, 3 );
FFXM_MIN16_VECTOR( FFXM_MIN16_U4, uint, 4 );
FFXM_16BIT_SCALAR( FFXM_F16_t , float );
FFXM_16BIT_VECTOR( FFXM_F16_t2, float, 2 );
FFXM_16BIT_VECTOR( FFXM_F16_t3, float, 3 );
FFXM_16BIT_VECTOR( FFXM_F16_t4, float, 4 );
FFXM_16BIT_SCALAR( FFXM_I16_t, int );
FFXM_16BIT_VECTOR( FFXM_I16_t2, int, 2 );
FFXM_16BIT_VECTOR( FFXM_I16_t3, int, 3 );
FFXM_16BIT_VECTOR( FFXM_I16_t4, int, 4 );
FFXM_16BIT_SCALAR( FFXM_U16_t, uint );
FFXM_16BIT_VECTOR( FFXM_U16_t2, uint, 2 );
FFXM_16BIT_VECTOR( FFXM_U16_t3, uint, 3 );
FFXM_16BIT_VECTOR( FFXM_U16_t4, uint, 4 );
#define TYPEDEF_MIN16_TYPES(Prefix) \
typedef FFXM_MIN16_F Prefix##_F; \
typedef FFXM_MIN16_F2 Prefix##_F2; \
typedef FFXM_MIN16_F3 Prefix##_F3; \
typedef FFXM_MIN16_F4 Prefix##_F4; \
typedef FFXM_MIN16_I Prefix##_I; \
typedef FFXM_MIN16_I2 Prefix##_I2; \
typedef FFXM_MIN16_I3 Prefix##_I3; \
typedef FFXM_MIN16_I4 Prefix##_I4; \
typedef FFXM_MIN16_U Prefix##_U; \
typedef FFXM_MIN16_U2 Prefix##_U2; \
typedef FFXM_MIN16_U3 Prefix##_U3; \
typedef FFXM_MIN16_U4 Prefix##_U4;
#define TYPEDEF_16BIT_TYPES(Prefix) \
typedef FFXM_16BIT_F Prefix##_F; \
typedef FFXM_16BIT_F2 Prefix##_F2; \
typedef FFXM_16BIT_F3 Prefix##_F3; \
typedef FFXM_16BIT_F4 Prefix##_F4; \
typedef FFXM_16BIT_I Prefix##_I; \
typedef FFXM_16BIT_I2 Prefix##_I2; \
typedef FFXM_16BIT_I3 Prefix##_I3; \
typedef FFXM_16BIT_I4 Prefix##_I4; \
typedef FFXM_16BIT_U Prefix##_U; \
typedef FFXM_16BIT_U2 Prefix##_U2; \
typedef FFXM_16BIT_U3 Prefix##_U3; \
typedef FFXM_16BIT_U4 Prefix##_U4;
#define TYPEDEF_FULL_PRECISION_TYPES(Prefix) \
typedef FfxFloat32 Prefix##_F; \
typedef FfxFloat32x2 Prefix##_F2; \
typedef FfxFloat32x3 Prefix##_F3; \
typedef FfxFloat32x4 Prefix##_F4; \
typedef FfxInt32 Prefix##_I; \
typedef FfxInt32x2 Prefix##_I2; \
typedef FfxInt32x3 Prefix##_I3; \
typedef FfxInt32x4 Prefix##_I4; \
typedef FfxUInt32 Prefix##_U; \
typedef FfxUInt32x2 Prefix##_U2; \
typedef FfxUInt32x3 Prefix##_U3; \
typedef FfxUInt32x4 Prefix##_U4;
#endif // #if defined(FFXM_HLSL)
#if defined(SHADER_API_PSSL)
#if FFXM_HALF
#define FFXM_MIN16_F half
#define FFXM_MIN16_F2 half2
#define FFXM_MIN16_F3 half3
#define FFXM_MIN16_F4 half4
#define FFXM_MIN16_I short
#define FFXM_MIN16_I2 short2
#define FFXM_MIN16_I3 short3
#define FFXM_MIN16_I4 short4
#define FFXM_MIN16_U ushort
#define FFXM_MIN16_U2 ushort2
#define FFXM_MIN16_U3 ushort3
#define FFXM_MIN16_U4 ushort4
#define FFXM_16BIT_F half
#define FFXM_16BIT_F2 half2
#define FFXM_16BIT_F3 half3
#define FFXM_16BIT_F4 half4
#define FFXM_16BIT_I short
#define FFXM_16BIT_I2 short2
#define FFXM_16BIT_I3 short3
#define FFXM_16BIT_I4 short4
#define FFXM_16BIT_U ushort
#define FFXM_16BIT_U2 ushort2
#define FFXM_16BIT_U3 ushort3
#define FFXM_16BIT_U4 ushort4
#else // FFXM_HALF
#define FFXM_MIN16_F float
#define FFXM_MIN16_F2 float2
#define FFXM_MIN16_F3 float3
#define FFXM_MIN16_F4 float4
#define FFXM_MIN16_I int
#define FFXM_MIN16_I2 int2
#define FFXM_MIN16_I3 int3
#define FFXM_MIN16_I4 int4
#define FFXM_MIN16_U uint
#define FFXM_MIN16_U2 uint2
#define FFXM_MIN16_U3 uint3
#define FFXM_MIN16_U4 uint4
#define FFXM_16BIT_F float
#define FFXM_16BIT_F2 float2
#define FFXM_16BIT_F3 float3
#define FFXM_16BIT_F4 float4
#define FFXM_16BIT_I int
#define FFXM_16BIT_I2 int2
#define FFXM_16BIT_I3 int3
#define FFXM_16BIT_I4 int4
#define FFXM_16BIT_U uint
#define FFXM_16BIT_U2 uint2
#define FFXM_16BIT_U3 uint3
#define FFXM_16BIT_U4 uint4
#endif // FFXM_HALF
#endif // #if defined(SHADER_API_PSSL)
#if defined(FFXM_GLSL)
#if FFXM_HALF
#define FFXM_MIN16_F float16_t
#define FFXM_MIN16_F2 f16vec2
#define FFXM_MIN16_F3 f16vec3
#define FFXM_MIN16_F4 f16vec4
#define FFXM_MIN16_I int16_t
#define FFXM_MIN16_I2 i16vec2
#define FFXM_MIN16_I3 i16vec3
#define FFXM_MIN16_I4 i16vec4
#define FFXM_MIN16_U uint16_t
#define FFXM_MIN16_U2 u16vec2
#define FFXM_MIN16_U3 u16vec3
#define FFXM_MIN16_U4 u16vec4
#define FFXM_16BIT_F float16_t
#define FFXM_16BIT_F2 f16vec2
#define FFXM_16BIT_F3 f16vec3
#define FFXM_16BIT_F4 f16vec4
#define FFXM_16BIT_I int16_t
#define FFXM_16BIT_I2 i16vec2
#define FFXM_16BIT_I3 i16vec3
#define FFXM_16BIT_I4 i16vec4
#define FFXM_16BIT_U uint16_t
#define FFXM_16BIT_U2 u16vec2
#define FFXM_16BIT_U3 u16vec3
#define FFXM_16BIT_U4 u16vec4
#else // FFXM_HALF
#define FFXM_MIN16_F float
#define FFXM_MIN16_F2 vec2
#define FFXM_MIN16_F3 vec3
#define FFXM_MIN16_F4 vec4
#define FFXM_MIN16_I int
#define FFXM_MIN16_I2 ivec2
#define FFXM_MIN16_I3 ivec3
#define FFXM_MIN16_I4 ivec4
#define FFXM_MIN16_U uint
#define FFXM_MIN16_U2 uvec2
#define FFXM_MIN16_U3 uvec3
#define FFXM_MIN16_U4 uvec4
#define FFXM_16BIT_F float
#define FFXM_16BIT_F2 vec2
#define FFXM_16BIT_F3 vec3
#define FFXM_16BIT_F4 vec4
#define FFXM_16BIT_I int
#define FFXM_16BIT_I2 ivec2
#define FFXM_16BIT_I3 ivec3
#define FFXM_16BIT_I4 ivec4
#define FFXM_16BIT_U uint
#define FFXM_16BIT_U2 uvec2
#define FFXM_16BIT_U3 uvec3
#define FFXM_16BIT_U4 uvec4
#endif // FFXM_HALF
#endif // #if defined(FFXM_GLSL)
#endif // #if defined(FFXM_GPU)
#endif // #ifndef FFXM_COMMON_TYPES_H

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_common_types.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 86143f20804e7ad40af9d5e4bb7038f6
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

69
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core.h

@ -0,0 +1,69 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
/// @defgroup FfxGPU GPU
/// The FidelityFX SDK GPU References
///
/// @ingroup ffxSDK
/// @defgroup FfxHLSL HLSL References
/// FidelityFX SDK HLSL GPU References
///
/// @ingroup FfxGPU
/// @defgroup FfxGLSL GLSL References
/// FidelityFX SDK GLSL GPU References
///
/// @ingroup FfxGPU
/// @defgroup FfxGPUEffects FidelityFX GPU References
/// FidelityFX Effect GPU Reference Documentation
///
/// @ingroup FfxGPU
/// @defgroup GPUCore GPU Core
/// GPU defines and functions
///
/// @ingroup FfxGPU
#if !defined(FFXM_CORE_H)
#define FFXM_CORE_H
#include "ffxm_common_types.h"
#if defined(FFXM_CPU)
#include "ffxm_core_cpu.h"
#endif // #if defined(FFXM_CPU)
#if defined(FFXM_GLSL) && defined(FFXM_GPU)
#include "ffxm_core_glsl.h"
#endif // #if defined(FFXM_GLSL) && defined(FFXM_GPU)
#if defined(FFXM_HLSL) && defined(FFXM_GPU)
#include "ffxm_core_hlsl.h"
#endif // #if defined(FFXM_HLSL) && defined(FFXM_GPU)
#if defined(FFXM_GPU)
#include "ffxm_core_gpu_common.h"
#include "ffxm_core_gpu_common_half.h"
#include "ffxm_core_portability.h"
#endif // #if defined(FFXM_GPU)
#endif // #if !defined(FFXM_CORE_H)

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 1de7e5f01f4c625458dbda94917d9aa1
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

337
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_cpu.h

@ -0,0 +1,337 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
/// A define for a true value in a boolean expression.
///
/// @ingroup CPUTypes
#define FFXM_TRUE (1)
/// A define for a false value in a boolean expression.
///
/// @ingroup CPUTypes
#define FFXM_FALSE (0)
#if !defined(FFXM_STATIC)
/// A define to abstract declaration of static variables and functions.
///
/// @ingroup CPUTypes
#define FFXM_STATIC static
#endif // #if !defined(FFXM_STATIC)
/// @defgroup CPUCore CPU Core
/// Core CPU-side defines and functions
///
/// @ingroup ffxHost
#ifdef __clang__
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
/// Interpret the bit layout of an IEEE-754 floating point value as an unsigned integer.
///
/// @param [in] x A 32bit floating value.
///
/// @returns
/// An unsigned 32bit integer value containing the bit pattern of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxUInt32 ffxAsUInt32(FfxFloat32 x)
{
union
{
FfxFloat32 f;
FfxUInt32 u;
} bits;
bits.f = x;
return bits.u;
}
FFXM_STATIC FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b)
{
return a[0] * b[0] + a[1] * b[1];
}
FFXM_STATIC FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b)
{
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
FFXM_STATIC FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b)
{
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
}
/// Compute the linear interopation between two values.
///
/// Implemented by calling the GLSL <c><i>mix</i></c> instrinsic function. Implements the
/// following math:
///
/// (1 - t) * x + t * y
///
/// @param [in] x The first value to lerp between.
/// @param [in] y The second value to lerp between.
/// @param [in] t The value to determine how much of <c><i>x</i></c> and how much of <c><i>y</i></c>.
///
/// @returns
/// A linearly interpolated value between <c><i>x</i></c> and <c><i>y</i></c> according to <c><i>t</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t)
{
return y * t + (-x * t + x);
}
/// Compute the reciprocal of a value.
///
/// @param [in] x The value to compute the reciprocal for.
///
/// @returns
/// The reciprocal value of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 x)
{
return 1.0f / x;
}
/// Compute the square root of a value.
///
/// @param [in] x The first value to compute the min of.
///
/// @returns
/// The the square root of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 ffxSqrt(FfxFloat32 x)
{
return sqrt(x);
}
FFXM_STATIC FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b)
{
return FfxUInt32(FfxInt32(a) >> FfxInt32(b));
}
/// Compute the factional part of a decimal value.
///
/// This function calculates <c><i>x - floor(x)</i></c>.
///
/// @param [in] x The value to compute the fractional part from.
///
/// @returns
/// The fractional part of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 ffxFract(FfxFloat32 x)
{
return x - floor(x);
}
/// Compute the reciprocal square root of a value.
///
/// @param [in] x The value to compute the reciprocal for.
///
/// @returns
/// The reciprocal square root value of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 rsqrt(FfxFloat32 x)
{
return ffxReciprocal(ffxSqrt(x));
}
FFXM_STATIC FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y)
{
return x < y ? x : y;
}
FFXM_STATIC FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y)
{
return x < y ? x : y;
}
FFXM_STATIC FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y)
{
return x > y ? x : y;
}
FFXM_STATIC FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y)
{
return x > y ? x : y;
}
/// Clamp a value to a [0..1] range.
///
/// @param [in] x The value to clamp to [0..1] range.
///
/// @returns
/// The clamped version of <c><i>x</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxFloat32 ffxSaturate(FfxFloat32 x)
{
return ffxMin(1.0f, ffxMax(0.0f, x));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FFXM_STATIC void opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
{
d[0] = a[0] + b;
d[1] = a[1] + b;
d[2] = a[2] + b;
return;
}
FFXM_STATIC void opACpyF3(FfxFloat32x3 d, FfxFloat32x3 a)
{
d[0] = a[0];
d[1] = a[1];
d[2] = a[2];
return;
}
FFXM_STATIC void opAMulF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32x3 b)
{
d[0] = a[0] * b[0];
d[1] = a[1] * b[1];
d[2] = a[2] * b[2];
return;
}
FFXM_STATIC void opAMulOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
{
d[0] = a[0] * b;
d[1] = a[1] * b;
d[2] = a[2] * b;
return;
}
FFXM_STATIC void opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a)
{
d[0] = ffxReciprocal(a[0]);
d[1] = ffxReciprocal(a[1]);
d[2] = ffxReciprocal(a[2]);
return;
}
/// Convert FfxFloat32 to half (in lower 16-bits of output).
///
/// This function implements the same fast technique that is documented here: ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf
///
/// The function supports denormals.
///
/// Some conversion rules are to make computations possibly "safer" on the GPU,
/// -INF & -NaN -> -65504
/// +INF & +NaN -> +65504
///
/// @param [in] f The 32bit floating point value to convert.
///
/// @returns
/// The closest 16bit floating point value to <c><i>f</i></c>.
///
/// @ingroup CPUCore
FFXM_STATIC FfxUInt32 f32tof16(FfxFloat32 f)
{
static FfxUInt16 base[512] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400,
0x0800, 0x0c00, 0x1000, 0x1400, 0x1800, 0x1c00, 0x2000, 0x2400, 0x2800, 0x2c00, 0x3000, 0x3400, 0x3800, 0x3c00, 0x4000, 0x4400, 0x4800, 0x4c00, 0x5000,
0x5400, 0x5800, 0x5c00, 0x6000, 0x6400, 0x6800, 0x6c00, 0x7000, 0x7400, 0x7800, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001, 0x8002,
0x8004, 0x8008, 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400, 0x8800, 0x8c00, 0x9000, 0x9400, 0x9800, 0x9c00, 0xa000, 0xa400, 0xa800, 0xac00,
0xb000, 0xb400, 0xb800, 0xbc00, 0xc000, 0xc400, 0xc800, 0xcc00, 0xd000, 0xd400, 0xd800, 0xdc00, 0xe000, 0xe400, 0xe800, 0xec00, 0xf000, 0xf400, 0xf800,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff
};
static FfxUInt8 shift[512] = {
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18
};
union
{
FfxFloat32 f;
FfxUInt32 u;
} bits;
bits.f = f;
FfxUInt32 u = bits.u;
FfxUInt32 i = u >> 23;
return (FfxUInt32)(base[i]) + ((u & 0x7fffff) >> shift[i]);
}
/// Pack 2x32-bit floating point values in a single 32bit value.
///
/// This function first converts each component of <c><i>value</i></c> into their nearest 16-bit floating
/// point representation, and then stores the X and Y components in the lower and upper 16 bits of the
/// 32bit unsigned integer respectively.
///
/// @param [in] x A 2-dimensional floating point value to convert and pack.
///
/// @returns
/// A packed 32bit value containing 2 16bit floating point values.
///
/// @ingroup CPUCore
FFXM_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 x)
{
return f32tof16(x[0]) + (f32tof16(x[1]) << 16);
}

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_cpu.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 94fb3b7a7fde2f7448c52c5c262f5c01
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

2812
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common.h
File diff suppressed because it is too large
View File

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 049e52a8031c0c44f9c2b503e90b844e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

2978
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common_half.h
File diff suppressed because it is too large
View File

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_gpu_common_half.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: b5e484d04abc3c84788c93d9a2e50b7f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

1643
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_hlsl.h
File diff suppressed because it is too large
View File

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_hlsl.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 3414d977001cdfc47846380911de9f05
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

50
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_portability.h

@ -0,0 +1,50 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
FfxFloat32x3 opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
{
d = a + ffxBroadcast3(b);
return d;
}
FfxFloat32x3 opACpyF3(FfxFloat32x3 d, FfxFloat32x3 a)
{
d = a;
return d;
}
FfxFloat32x3 opAMulF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32x3 b)
{
d = a * b;
return d;
}
FfxFloat32x3 opAMulOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
{
d = a * ffxBroadcast3(b);
return d;
}
FfxFloat32x3 opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a)
{
d = rcp(a);
return d;
}

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_core_portability.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: c599687271fc4f444a2858745fc7f0c5
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

100
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl

@ -0,0 +1,100 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_INPUT_EXPOSURE 0
#define FSR2_BIND_SRV_DILATED_REACTIVE_MASKS 1
#if FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 2
#else
#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 2
#endif
#define FSR2_BIND_SRV_INTERNAL_UPSCALED 3
#define FSR2_BIND_SRV_LOCK_STATUS 4
#define FSR2_BIND_SRV_PREPARED_INPUT_COLOR 5
#define FSR2_BIND_SRV_LANCZOS_LUT 6
#define FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7
#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 8
#define FSR2_BIND_SRV_AUTO_EXPOSURE 9
#define FSR2_BIND_SRV_LUMA_HISTORY 10
#define FSR2_BIND_SRV_TEMPORAL_REACTIVE 11
#define FSR2_BIND_SRV_NEW_LOCKS 12
#define FSR2_BIND_CB_FSR2 0
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_sample.h"
#include "fsr2/ffxm_fsr2_upsample.h"
#include "fsr2/ffxm_fsr2_postprocess_lock_status.h"
#include "fsr2/ffxm_fsr2_reproject.h"
#include "fsr2/ffxm_fsr2_accumulate.h"
#if defined(SHADER_API_PSSL)
#pragma PSSL_target_output_format(target 0 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 1 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 2 FMT_FP16_ABGR)
#endif
struct AccumulateOutputsFS
{
#if !FFXM_SHADER_QUALITY_BALANCED_OR_PERFORMANCE
FfxFloat32x4 fColorAndWeight : SV_TARGET0;
FfxFloat32x2 fLockStatus : SV_TARGET1;
FfxFloat32x4 fLumaHistory : SV_TARGET2;
#if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0
FfxFloat32x4 fColor : SV_TARGET3;
#endif
#else // FFXM_SHADER_QUALITY_BALANCED_OR_PERFORMANCE
FfxFloat32x4 fUpscaledColor : SV_TARGET0;
FfxFloat32 fTemporalReactive : SV_TARGET1;
FfxFloat32x2 fLockStatus : SV_TARGET2;
#if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0
FfxFloat32x4 fColor : SV_TARGET3;
#endif
#endif
};
AccumulateOutputsFS main(float4 SvPosition : SV_POSITION)
{
uint2 uPixelCoord = uint2(SvPosition.xy);
AccumulateOutputs result = Accumulate(uPixelCoord);
AccumulateOutputsFS output = (AccumulateOutputsFS)0;
#if !FFXM_SHADER_QUALITY_BALANCED_OR_PERFORMANCE
output.fColorAndWeight = result.fColorAndWeight;
output.fLumaHistory = result.fLumaHistory;
#else
output.fUpscaledColor = FfxFloat32x4(result.fUpscaledColor, 1.0f);
output.fTemporalReactive = result.fTemporalReactive;
#endif
output.fLockStatus = result.fLockStatus;
#if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0
output.fColor = FfxFloat32x4(result.fColor, 1.0f);
#endif
return output;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_accumulate_pass_fs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 63de8005a89afab4298bbc1e2edf2a01
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

79
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl

@ -0,0 +1,79 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_INPUT_OPAQUE_ONLY 0
#define FSR2_BIND_SRV_INPUT_COLOR 1
#define FSR2_BIND_CB_FSR2 0
#define FSR2_BIND_CB_REACTIVE 1
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#if defined(SHADER_API_PSSL)
#pragma PSSL_target_output_format(default FMT_FP16_ABGR)
#endif
struct GenReactiveMaskOutputs
{
FfxFloat32 fReactiveMask : SV_TARGET0;
};
GenReactiveMaskOutputs main(float4 SvPosition : SV_POSITION)
{
uint2 uPixelCoord = uint2(SvPosition.xy);
float3 ColorPreAlpha = LoadOpaqueOnly( FFXM_MIN16_I2(uPixelCoord) ).rgb;
float3 ColorPostAlpha = LoadInputColor(uPixelCoord).rgb;
if (GenReactiveFlags() & FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP)
{
ColorPreAlpha = Tonemap(ColorPreAlpha);
ColorPostAlpha = Tonemap(ColorPostAlpha);
}
if (GenReactiveFlags() & FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP)
{
ColorPreAlpha = InverseTonemap(ColorPreAlpha);
ColorPostAlpha = InverseTonemap(ColorPostAlpha);
}
float out_reactive_value = 0.f;
float3 delta = abs(ColorPostAlpha - ColorPreAlpha);
out_reactive_value = (GenReactiveFlags() & FFXM_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta);
out_reactive_value *= GenReactiveScale();
out_reactive_value = (GenReactiveFlags() & FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < GenReactiveThreshold() ? 0 : GenReactiveBinaryValue()) : out_reactive_value;
GenReactiveMaskOutputs results = (GenReactiveMaskOutputs)0;
results.fReactiveMask = out_reactive_value;
return results;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_autogen_reactive_pass_fs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 59f96f119bfba924198951bea4194ecd
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

64
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl

@ -0,0 +1,64 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_INPUT_COLOR 0
#define FSR2_BIND_SRV_AUTO_EXPOSURE 1
#define FSR2_BIND_UAV_SPD_GLOBAL_ATOMIC 1
#define FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 2
#define FSR2_BIND_UAV_EXPOSURE_MIP_5 3
#define FSR2_BIND_UAV_AUTO_EXPOSURE 4
#define FSR2_BIND_CB_FSR2 0
#define FSR2_BIND_CB_SPD 1
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_compute_luminance_pyramid.h"
#ifndef FFXM_FSR2_THREAD_GROUP_WIDTH
#define FFXM_FSR2_THREAD_GROUP_WIDTH 256
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_WIDTH
#ifndef FFXM_FSR2_THREAD_GROUP_HEIGHT
#define FFXM_FSR2_THREAD_GROUP_HEIGHT 1
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_HEIGHT
#ifndef FFXM_FSR2_THREAD_GROUP_DEPTH
#define FFXM_FSR2_THREAD_GROUP_DEPTH 1
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_DEPTH
#ifndef FFXM_FSR2_NUM_THREADS
#define FFXM_FSR2_NUM_THREADS [numthreads(FFXM_FSR2_THREAD_GROUP_WIDTH, FFXM_FSR2_THREAD_GROUP_HEIGHT, FFXM_FSR2_THREAD_GROUP_DEPTH)]
#endif // #ifndef FFXM_FSR2_NUM_THREADS
FFXM_PREFER_WAVE64
FFXM_FSR2_NUM_THREADS
FFXM_FSR2_EMBED_CB2_ROOTSIG_CONTENT
void main(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex)
{
ComputeAutoExposure(WorkGroupId, LocalThreadIndex);
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_compute_luminance_pyramid_pass.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4670a9ebaa60c3143be978efc227163b
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl

@ -0,0 +1,67 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0
#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 1
#define FSR2_BIND_SRV_DILATED_DEPTH 2
#define FSR2_BIND_SRV_REACTIVE_MASK 3
#define FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 4
#define FSR2_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS 5
#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 6
#define FSR2_BIND_SRV_INPUT_COLOR 7
#define FSR2_BIND_SRV_INPUT_DEPTH 8
#define FSR2_BIND_SRV_INPUT_EXPOSURE 9
#define FSR2_BIND_CB_FSR2 0
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_sample.h"
#include "fsr2/ffxm_fsr2_depth_clip.h"
#if defined(SHADER_API_PSSL)
#pragma PSSL_target_output_format(target 0 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 1 FMT_FP16_ABGR)
#endif
struct DepthClipOutputsFS
{
FfxFloat32x4 fTonemapped : SV_TARGET0;
FfxFloat32x2 fDilatedReactiveMasks : SV_TARGET1;
};
DepthClipOutputsFS main(float4 SvPosition : SV_POSITION)
{
uint2 uPixelCoord = uint2(SvPosition.xy);
DepthClipOutputs result = DepthClip(uPixelCoord);
DepthClipOutputsFS output = (DepthClipOutputsFS)0;
output.fTonemapped = result.fTonemapped;
output.fDilatedReactiveMasks = result.fDilatedReactiveMasks;
return output;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_depth_clip_pass_fs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2825c941cb2d43145b426c42ec6e7869
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

63
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_lock_pass.hlsl

@ -0,0 +1,63 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_LOCK_INPUT_LUMA 0
#define FSR2_BIND_UAV_NEW_LOCKS 1
#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 2
#define FSR2_BIND_CB_FSR2 0
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_sample.h"
#include "fsr2/ffxm_fsr2_lock.h"
#ifndef FFXM_FSR2_THREAD_GROUP_WIDTH
#define FFXM_FSR2_THREAD_GROUP_WIDTH 8
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_WIDTH
#ifndef FFXM_FSR2_THREAD_GROUP_HEIGHT
#define FFXM_FSR2_THREAD_GROUP_HEIGHT 8
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_HEIGHT
#ifndef FFXM_FSR2_THREAD_GROUP_DEPTH
#define FFXM_FSR2_THREAD_GROUP_DEPTH 1
#endif // #ifndef FFXM_FSR2_THREAD_GROUP_DEPTH
#ifndef FFXM_FSR2_NUM_THREADS
#define FFXM_FSR2_NUM_THREADS [numthreads(FFXM_FSR2_THREAD_GROUP_WIDTH, FFXM_FSR2_THREAD_GROUP_HEIGHT, FFXM_FSR2_THREAD_GROUP_DEPTH)]
#endif // #ifndef FFXM_FSR2_NUM_THREADS
FFXM_PREFER_WAVE64
FFXM_FSR2_NUM_THREADS
FFXM_FSR2_EMBED_ROOTSIG_CONTENT
void main(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
{
uint2 uDispatchThreadId = uGroupId * uint2(FFXM_FSR2_THREAD_GROUP_WIDTH, FFXM_FSR2_THREAD_GROUP_HEIGHT) + uGroupThreadId;
ComputeLock(uDispatchThreadId);
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_lock_pass.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 78914a065e6727e4d8255fb76b44d5da
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

52
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_rcas_pass_fs.hlsl

@ -0,0 +1,52 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_INPUT_EXPOSURE 0
#define FSR2_BIND_SRV_RCAS_INPUT 1
#define FSR2_BIND_CB_FSR2 0
#define FSR2_BIND_CB_RCAS 1
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_rcas.h"
struct RCASOutputsFS
{
FfxFloat32x4 fUpscaledColor : SV_TARGET0;
};
RCASOutputsFS main(float4 SvPosition : SV_POSITION)
{
uint2 uPixelCoord = uint2(SvPosition.xy);
RCASOutputs result = RCAS(uPixelCoord);
RCASOutputsFS output = (RCASOutputsFS)0;
output.fUpscaledColor = FfxFloat32x4(result.fUpscaledColor, 1.0f);
return output;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_rcas_pass_fs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 16a306235fdc01044a347f0cb0a9b147
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

68
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl

@ -0,0 +1,68 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 0
#define FSR2_BIND_SRV_INPUT_DEPTH 1
#define FSR2_BIND_SRV_INPUT_COLOR 2
#define FSR2_BIND_SRV_INPUT_EXPOSURE 3
#define FSR2_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 3
#define FSR2_BIND_CB_FSR2 0
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#include "fsr2/ffxm_fsr2_callbacks_hlsl.h"
#include "fsr2/ffxm_fsr2_common.h"
#include "fsr2/ffxm_fsr2_sample.h"
#include "fsr2/ffxm_fsr2_reconstruct_dilated_velocity_and_previous_depth.h"
#if defined(SHADER_API_PSSL)
#pragma PSSL_target_output_format(target 0 FMT_32_R)
#pragma PSSL_target_output_format(target 1 FMT_32_R)
#pragma PSSL_target_output_format(target 2 FMT_FP16_ABGR)
#pragma PSSL_target_output_format(target 3 FMT_32_R)
#endif
struct ReconstructPrevDepthOutputsFS
{
FfxFloat32 fDepth : SV_TARGET0;
FfxFloat32 fLuma : SV_TARGET1;
FfxFloat32x2 fMotionVector : SV_TARGET2;
};
ReconstructPrevDepthOutputsFS main(float4 SvPosition : SV_POSITION)
{
uint2 uPixelCoord = uint2(SvPosition.xy);
ReconstructPrevDepthOutputs result = ReconstructAndDilate(uPixelCoord);
ReconstructPrevDepthOutputsFS output = (ReconstructPrevDepthOutputsFS)0;
output.fDepth = result.fDepth;
output.fLuma = result.fLuma;
output.fMotionVector = result.fMotionVector;
return output;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_reconstruct_previous_depth_pass_fs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bdcb34025b67be743a32494703775cc1
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

44
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_vs.hlsl

@ -0,0 +1,44 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// Global mandatory defines
#if !defined(FFXM_GPU)
#define FFXM_GPU 1
#endif
#if !defined(FFXM_HLSL)
#define FFXM_HLSL 1
#endif
#define FSR2_BIND_CB_FSR2 0
struct VertexOut
{
float4 position : SV_POSITION;
};
VertexOut VertMain(uint uVertexId : SV_VERTEXID)
{
VertexOut output;
float2 uv = float2(uVertexId & 1, uVertexId >> 1) * 2.0;
output.position = float4(uv * 2.0 - 1.0, 0.0, 1.0);
return output;
}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/ffxm_fsr2_vs.hlsl.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a9dfeac9728e7404f97655aac002e5eb
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 825bf9eee2b16c7499e5cfb3c9721df0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1251
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1/ffxm_fsr1.h
File diff suppressed because it is too large
View File

76
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr1/ffxm_fsr1.h.meta

@ -0,0 +1,76 @@
fileFormatVersion: 2
guid: beffdc3cffeabd84491ac83b32a4d9f8
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
AndroidSharedLibraryType: Executable
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8001d8b2af47f59409d886267a5ce04b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

379
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h

@ -0,0 +1,379 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_ACCUMULATE_H
#define FFXM_FSR2_ACCUMULATE_H
struct AccumulateOutputs
{
#if !FFXM_SHADER_QUALITY_OPT_SEPARATE_TEMPORAL_REACTIVE
FfxFloat32x4 fColorAndWeight;
#else
FfxFloat32x3 fUpscaledColor;
FfxFloat32 fTemporalReactive;
#endif
FfxFloat32x2 fLockStatus;
FfxFloat32x4 fLumaHistory;
#if (FFXM_FSR2_OPTION_APPLY_SHARPENING == 0)
FfxFloat32x3 fColor;
#endif
};
FfxFloat32 GetPxHrVelocity(FfxFloat32x2 fMotionVector)
{
return length(fMotionVector * DisplaySize());
}
#if FFXM_HALF
FFXM_MIN16_F GetPxHrVelocity(FFXM_MIN16_F2 fMotionVector)
{
return length(fMotionVector * FFXM_MIN16_F2(DisplaySize()));
}
#endif
void Accumulate(const AccumulationPassCommonParams params, FFXM_PARAMETER_INOUT FfxFloat32x3 fHistoryColor, FfxFloat32x3 fAccumulation, FFXM_PARAMETER_IN FfxFloat32x4 fUpsampledColorAndWeight)
{
// Aviod invalid values when accumulation and upsampled weight is 0
fAccumulation = ffxMax(FSR2_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www);
#if FFXM_FSR2_OPTION_HDR_COLOR_INPUT
#if FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
fHistoryColor = Tonemap(fHistoryColor);
#else
//YCoCg -> RGB -> Tonemap -> YCoCg (Use RGB tonemapper to avoid color desaturation)
fUpsampledColorAndWeight.xyz = RGBToYCoCg(Tonemap(YCoCgToRGB(fUpsampledColorAndWeight.xyz)));
fHistoryColor = RGBToYCoCg(Tonemap(YCoCgToRGB(fHistoryColor)));
#endif
#endif
const FfxFloat32x3 fAlpha = fUpsampledColorAndWeight.www / fAccumulation;
fHistoryColor = ffxLerp(fHistoryColor, fUpsampledColorAndWeight.xyz, fAlpha);
#if !FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
fHistoryColor = YCoCgToRGB(fHistoryColor);
#endif
#if FFXM_FSR2_OPTION_HDR_COLOR_INPUT
fHistoryColor = InverseTonemap(fHistoryColor);
#endif
}
#if FFXM_HALF
void RectifyHistory(
const AccumulationPassCommonParams params,
RectificationBoxMin16 clippingBox,
FFXM_PARAMETER_INOUT FfxFloat32x3 fHistoryColor,
FFXM_PARAMETER_INOUT FfxFloat32x3 fAccumulation,
FfxFloat32 fLockContributionThisFrame,
FfxFloat32 fTemporalReactiveFactor,
FfxFloat32 fLumaInstabilityFactor)
#else
void RectifyHistory(
const AccumulationPassCommonParams params,
RectificationBox clippingBox,
FFXM_PARAMETER_INOUT FfxFloat32x3 fHistoryColor,
FFXM_PARAMETER_INOUT FfxFloat32x3 fAccumulation,
FfxFloat32 fLockContributionThisFrame,
FfxFloat32 fTemporalReactiveFactor,
FfxFloat32 fLumaInstabilityFactor)
#endif
{
FfxFloat32 fScaleFactorInfluence = ffxMin(20.0f, ffxPow(FfxFloat32(1.0f / length(DownscaleFactor().x * DownscaleFactor().y)), 3.0f));
const FfxFloat32 fVecolityFactor = ffxSaturate(params.fHrVelocity / 20.0f);
const FfxFloat32 fBoxScaleT = ffxMax(params.fDepthClipFactor, ffxMax(params.fAccumulationMask, fVecolityFactor));
FfxFloat32 fBoxScale = ffxLerp(fScaleFactorInfluence, 1.0f, fBoxScaleT);
FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale;
FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec;
FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec;
FfxFloat32x3 boxCenter = clippingBox.boxCenter;
FfxFloat32 boxVecSize = length(clippingBox.boxVec);
boxMin = ffxMax(clippingBox.aabbMin, boxMin);
boxMax = ffxMin(clippingBox.aabbMax, boxMax);
#if FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
boxMin = InverseTonemap(boxMin);
boxMax = InverseTonemap(boxMax);
#endif
if (any(FFXM_GREATER_THAN(boxMin, fHistoryColor)) || any(FFXM_GREATER_THAN(fHistoryColor, boxMax))) {
const FfxFloat32x3 fClampedHistoryColor = clamp(fHistoryColor, boxMin, boxMax);
FfxFloat32x3 fHistoryContribution = ffxMax(fLumaInstabilityFactor, fLockContributionThisFrame).xxx;
const FfxFloat32 fReactiveFactor = params.fDilatedReactiveFactor;
const FfxFloat32 fReactiveContribution = 1.0f - ffxPow(fReactiveFactor, 1.0f / 2.0f);
fHistoryContribution *= fReactiveContribution;
// Scale history color using rectification info, also using accumulation mask to avoid potential invalid color protection
fHistoryColor = ffxLerp(fClampedHistoryColor, fHistoryColor, ffxSaturate(fHistoryContribution));
// Scale accumulation using rectification info
const FfxFloat32x3 fAccumulationMin = ffxMin(fAccumulation, FFXM_BROADCAST_FLOAT32X3(0.1f));
fAccumulation = ffxLerp(fAccumulationMin, fAccumulation, ffxSaturate(fHistoryContribution));
}
}
void FinalizeLockStatus(const AccumulationPassCommonParams params, FfxFloat32x2 fLockStatus, FfxFloat32 fUpsampledWeight, FFXM_PARAMETER_INOUT AccumulateOutputs result)
{
// we expect similar motion for next frame
// kill lock if that location is outside screen, avoid locks to be clamped to screen borders
FfxFloat32x2 fEstimatedUvNextFrame = params.fHrUv - params.fMotionVector;
if (IsUvInside(fEstimatedUvNextFrame) == false) {
KillLock(fLockStatus);
}
else {
// Decrease lock lifetime
const FfxFloat32 fLifetimeDecreaseLanczosMax = FfxFloat32(JitterSequenceLength()) * FfxFloat32(fAverageLanczosWeightPerFrame);
const FfxFloat32 fLifetimeDecrease = FfxFloat32(fUpsampledWeight / fLifetimeDecreaseLanczosMax);
fLockStatus[LOCK_LIFETIME_REMAINING] = ffxMax(FfxFloat32(0), fLockStatus[LOCK_LIFETIME_REMAINING] - fLifetimeDecrease);
}
result.fLockStatus = fLockStatus;
}
FfxFloat32x3 ComputeBaseAccumulationWeight(const AccumulationPassCommonParams params, FfxFloat32 fThisFrameReactiveFactor, FfxBoolean bInMotionLastFrame, FfxFloat32 fUpsampledWeight, LockState lockState)
{
// Always assume max accumulation was reached
FfxFloat32 fBaseAccumulation = fMaxAccumulationLanczosWeight * FfxFloat32(params.bIsExistingSample) * (1.0f - fThisFrameReactiveFactor) * (1.0f - params.fDepthClipFactor);
fBaseAccumulation = ffxMin(fBaseAccumulation, ffxLerp(fBaseAccumulation, fUpsampledWeight * 10.0f, ffxMax(FfxFloat32(bInMotionLastFrame), ffxSaturate(params.fHrVelocity * FfxFloat32(10)))));
fBaseAccumulation = ffxMin(fBaseAccumulation, ffxLerp(fBaseAccumulation, fUpsampledWeight, ffxSaturate(params.fHrVelocity / FfxFloat32(20))));
return fBaseAccumulation.xxx;
}
#if FFXM_HALF
FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams params, RectificationBoxMin16 clippingBox, FfxFloat32 fThisFrameReactiveFactor, FfxFloat32 fLuminanceDiff, FFXM_PARAMETER_INOUT AccumulateOutputs result)
#else
FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams params, RectificationBox clippingBox, FfxFloat32 fThisFrameReactiveFactor, FfxFloat32 fLuminanceDiff, FFXM_PARAMETER_INOUT AccumulateOutputs result)
#endif
{
const FfxFloat32 fUnormThreshold = 1.0f / 255.0f;
const FfxInt32 N_MINUS_1 = 0;
const FfxInt32 N_MINUS_2 = 1;
const FfxInt32 N_MINUS_3 = 2;
const FfxInt32 N_MINUS_4 = 3;
FfxFloat32 fCurrentFrameLuma = clippingBox.boxCenter.x;
#if FFXM_FSR2_OPTION_HDR_COLOR_INPUT
fCurrentFrameLuma = fCurrentFrameLuma / (1.0f + ffxMax(0.0f, fCurrentFrameLuma));
#endif
fCurrentFrameLuma = round(fCurrentFrameLuma * 255.0f) / 255.0f;
const FfxBoolean bSampleLumaHistory = (ffxMax(ffxMax(params.fDepthClipFactor, params.fAccumulationMask), fLuminanceDiff) < 0.1f) && (params.bIsNewSample == false);
FfxFloat32x4 fCurrentFrameLumaHistory = bSampleLumaHistory ? SampleLumaHistory(params.fReprojectedHrUv) : FFXM_BROADCAST_FLOAT32X4(0.0f);
FfxFloat32 fLumaInstability = 0.0f;
FfxFloat32 fDiffs0 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[N_MINUS_1]);
FfxFloat32 fMin = abs(fDiffs0);
if (fMin >= fUnormThreshold) {
for (int i = N_MINUS_2; i <= N_MINUS_4; i++) {
FfxFloat32 fDiffs1 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[i]);
if (sign(fDiffs0) == sign(fDiffs1)) {
// Scale difference to protect historically similar values
const FfxFloat32 fMinBias = 1.0f;
fMin = ffxMin(fMin, abs(fDiffs1) * fMinBias);
}
}
const FfxFloat32 fBoxSize = clippingBox.boxVec.x;
const FfxFloat32 fBoxSizeFactor = ffxPow(ffxSaturate(fBoxSize / 0.1f), 6.0f);
fLumaInstability = FfxFloat32(fMin != abs(fDiffs0)) * fBoxSizeFactor;
fLumaInstability = FfxFloat32(fLumaInstability > fUnormThreshold);
fLumaInstability *= 1.0f - ffxMax(params.fAccumulationMask, ffxPow(fThisFrameReactiveFactor, 1.0f / 6.0f));
}
//shift history
fCurrentFrameLumaHistory[N_MINUS_4] = fCurrentFrameLumaHistory[N_MINUS_3];
fCurrentFrameLumaHistory[N_MINUS_3] = fCurrentFrameLumaHistory[N_MINUS_2];
fCurrentFrameLumaHistory[N_MINUS_2] = fCurrentFrameLumaHistory[N_MINUS_1];
fCurrentFrameLumaHistory[N_MINUS_1] = fCurrentFrameLuma;
result.fLumaHistory = fCurrentFrameLumaHistory;
return fLumaInstability * FfxFloat32(fCurrentFrameLumaHistory[N_MINUS_4] != 0);
}
FfxFloat32 ComputeTemporalReactiveFactor(const AccumulationPassCommonParams params, FfxFloat32 fTemporalReactiveFactor)
{
FfxFloat32 fNewFactor = ffxMin(0.99f, fTemporalReactiveFactor);
fNewFactor = ffxMax(fNewFactor, ffxLerp(fNewFactor, 0.4f, ffxSaturate(params.fHrVelocity)));
fNewFactor = ffxMax(fNewFactor * fNewFactor, ffxMax(params.fDepthClipFactor * 0.1f, params.fDilatedReactiveFactor));
// Force reactive factor for new samples
fNewFactor = params.bIsNewSample ? 1.0f : fNewFactor;
if (ffxSaturate(params.fHrVelocity * 10.0f) >= 1.0f) {
fNewFactor = ffxMax(FSR2_EPSILON, fNewFactor) * -1.0f;
}
return fNewFactor;
}
void initReactiveMaskFactors(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params)
{
const FFXM_MIN16_F2 fDilatedReactiveMasks = FFXM_MIN16_F2(SampleDilatedReactiveMasks(params.fLrUv_HwSampler));
params.fDilatedReactiveFactor = fDilatedReactiveMasks.x;
params.fAccumulationMask = fDilatedReactiveMasks.y;
}
void initDepthClipFactors(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params)
{
params.fDepthClipFactor = FFXM_MIN16_F(ffxSaturate(SampleDepthClip(params.fLrUv_HwSampler)));
}
void initIsNewSample(FFXM_PARAMETER_INOUT AccumulationPassCommonParams params)
{
const FfxBoolean bIsResetFrame = (0 == FrameIndex());
params.bIsNewSample = (params.bIsExistingSample == false || bIsResetFrame);
}
AccumulationPassCommonParams InitParams(FfxInt32x2 iPxHrPos)
{
AccumulationPassCommonParams params = (AccumulationPassCommonParams)0;
params.iPxHrPos = iPxHrPos;
const FfxFloat32x2 fHrUv = (iPxHrPos + 0.5f) / DisplaySize();
params.fHrUv = fHrUv;
const FfxFloat32x2 fLrUvJittered = fHrUv + Jitter() / RenderSize();
params.fLrUv_HwSampler = ClampUv(fLrUvJittered, RenderSize(), MaxRenderSize());
params.fMotionVector = GetMotionVector(iPxHrPos, fHrUv);
params.fHrVelocity = GetPxHrVelocity(params.fMotionVector);
ComputeReprojectedUVs(params, params.fReprojectedHrUv, params.bIsExistingSample);
return params;
}
AccumulateOutputs Accumulate(FfxInt32x2 iPxHrPos)
{
AccumulationPassCommonParams params = InitParams(iPxHrPos);
FfxFloat32x3 fHistoryColor = FfxFloat32x3(0, 0, 0);
FFXM_MIN16_F2 fLockStatus;
InitializeNewLockSample(fLockStatus);
FFXM_MIN16_F fTemporalReactiveFactor = FFXM_MIN16_F(0.0f);
FfxBoolean bInMotionLastFrame = FFXM_FALSE;
LockState lockState = { FFXM_FALSE , FFXM_FALSE };
const FfxBoolean bIsResetFrame = (0 == FrameIndex());
if (params.bIsExistingSample && !bIsResetFrame) {
ReprojectHistoryColor(params, fHistoryColor, fTemporalReactiveFactor, bInMotionLastFrame);
lockState = ReprojectHistoryLockStatus(params, fLockStatus);
}
initReactiveMaskFactors(params);
initDepthClipFactors(params);
FfxFloat32 fThisFrameReactiveFactor = ffxMax(params.fDilatedReactiveFactor, fTemporalReactiveFactor);
FfxFloat32 fLuminanceDiff = 0.0f;
FfxFloat32 fLockContributionThisFrame = 0.0f;
FfxFloat32x2 fLockStatus32 = {fLockStatus.x, fLockStatus.y};
UpdateLockStatus(params, fThisFrameReactiveFactor, lockState, fLockStatus32, fLockContributionThisFrame, fLuminanceDiff);
fLockStatus = FFXM_MIN16_F2(fLockStatus32);
#ifdef FFXM_HLSL
AccumulateOutputs results = (AccumulateOutputs)0;
#else
AccumulateOutputs results;
#endif
// Load upsampled input color
#if FFXM_HALF
#ifdef FFXM_HLSL
RectificationBoxMin16 clippingBox = (RectificationBoxMin16)0;
#else
RectificationBoxMin16 clippingBox;
#endif
#else
#ifdef FFXM_HLSL
RectificationBox clippingBox = (RectificationBox)0;
#else
RectificationBox clippingBox;
#endif
#endif
initIsNewSample(params);
FfxFloat32x4 fUpsampledColorAndWeight = ComputeUpsampledColorAndWeight(params, clippingBox, fThisFrameReactiveFactor);
FinalizeLockStatus(params, fLockStatus, fUpsampledColorAndWeight.w, results);
#if FFXM_SHADER_QUALITY_OPT_DISABLE_LUMA_INSTABILITY
const FfxFloat32 fLumaInstabilityFactor = 0.0f;
#else
const FfxFloat32 fLumaInstabilityFactor = ComputeLumaInstabilityFactor(params, clippingBox, fThisFrameReactiveFactor, fLuminanceDiff, results);
#endif
FfxFloat32x3 fAccumulation = ComputeBaseAccumulationWeight(params, fThisFrameReactiveFactor, bInMotionLastFrame, fUpsampledColorAndWeight.w, lockState);
if (params.bIsNewSample) {
#if FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
fHistoryColor = InverseTonemap(fUpsampledColorAndWeight.xyz);
#else
fHistoryColor = YCoCgToRGB(fUpsampledColorAndWeight.xyz);
#endif
}
else {
RectifyHistory(params, clippingBox, fHistoryColor, fAccumulation, fLockContributionThisFrame, fThisFrameReactiveFactor, fLumaInstabilityFactor);
Accumulate(params, fHistoryColor, fAccumulation, fUpsampledColorAndWeight);
}
fHistoryColor = UnprepareRgb(fHistoryColor, Exposure());
// Get new temporal reactive factor
fTemporalReactiveFactor = FFXM_MIN16_F(ComputeTemporalReactiveFactor(params, fThisFrameReactiveFactor));
#if !FFXM_SHADER_QUALITY_OPT_SEPARATE_TEMPORAL_REACTIVE
results.fColorAndWeight = FfxFloat32x4(fHistoryColor, fTemporalReactiveFactor);
#else
// Output the upscaled color and the temporal reactive factor if these are contained in separate textures
results.fUpscaledColor = fHistoryColor;
results.fTemporalReactive = fTemporalReactiveFactor;
#endif
// Output final color when RCAS is disabled
#if FFXM_FSR2_OPTION_APPLY_SHARPENING == 0
results.fColor = fHistoryColor;
#endif
return results;
}
#endif // FFXM_FSR2_ACCUMULATE_H

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_accumulate.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 508ebc327e5948447894b9bb6f08f843
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

1040
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h
File diff suppressed because it is too large
View File

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_callbacks_hlsl.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 2dc46407945236c43a0c460b616f4204
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

595
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_common.h

@ -0,0 +1,595 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#if !defined(FFXM_FSR2_COMMON_H)
#define FFXM_FSR2_COMMON_H
#if defined(FFXM_CPU) || defined(FFXM_GPU)
//Locks
#define LOCK_LIFETIME_REMAINING 0
#define LOCK_TEMPORAL_LUMA 1
#endif // #if defined(FFXM_CPU) || defined(FFXM_GPU)
#if defined(FFXM_GPU)
FFXM_STATIC const FfxFloat32 FSR2_FP16_MIN = 6.10e-05f;
FFXM_STATIC const FfxFloat32 FSR2_FP16_MAX = 65504.0f;
FFXM_STATIC const FfxFloat32 FSR2_EPSILON = 1e-03f;
FFXM_STATIC const FfxFloat32 FSR2_TONEMAP_EPSILON = 1.0f / FSR2_FP16_MAX;
FFXM_STATIC const FfxFloat32 FSR2_FLT_MAX = 3.402823466e+38f;
FFXM_STATIC const FfxFloat32 FSR2_FLT_MIN = 1.175494351e-38f;
// treat vector truncation warnings as errors
#pragma warning(error: 3206)
// suppress warnings
#pragma warning(disable: 3205) // conversion from larger type to smaller
#pragma warning(disable: 3571) // in ffxPow(f, e), f could be negative
// Reconstructed depth usage
FFXM_STATIC const FfxFloat32 fReconstructedDepthBilinearWeightThreshold = 0.01f;
// Accumulation
#if !FFXM_SHADER_QUALITY_OPT_UPSCALING_LANCZOS_5TAP
FFXM_STATIC const FfxFloat32 fUpsampleLanczosWeightScale = 1.0f / 9.0f;
#else
FFXM_STATIC const FfxFloat32 fUpsampleLanczosWeightScale = 1.0f / 5.0f;
#endif
FFXM_STATIC const FfxFloat32 fMaxAccumulationLanczosWeight = 1.0f;
FFXM_STATIC const FfxFloat32 fAverageLanczosWeightPerFrame = 0.74f * fUpsampleLanczosWeightScale; // Average lanczos weight for jitter accumulated samples
FFXM_STATIC const FfxFloat32 fAccumulationMaxOnMotion = 3.0f * fUpsampleLanczosWeightScale;
// Auto exposure
FFXM_STATIC const FfxFloat32 resetAutoExposureAverageSmoothing = 1e4f;
// Optimizations defines
#ifndef FFXM_OPT_USE_GATHER_OPS
#define FFXM_OPT_USE_GATHER_OPS 0
#endif
struct AccumulationPassCommonParams
{
FfxInt32x2 iPxHrPos;
FfxFloat32x2 fHrUv;
FfxFloat32x2 fLrUv_HwSampler;
FfxFloat32x2 fMotionVector;
FfxFloat32x2 fReprojectedHrUv;
FfxFloat32 fHrVelocity;
FFXM_MIN16_F fDepthClipFactor;
FFXM_MIN16_F fDilatedReactiveFactor;
FFXM_MIN16_F fAccumulationMask;
//FfxBoolean bIsResetFrame;
FfxBoolean bIsExistingSample;
FfxBoolean bIsNewSample;
};
struct LockState
{
FfxBoolean NewLock; //Set for both unique new and re-locked new
FfxBoolean WasLockedPrevFrame; //Set to identify if the pixel was already locked (relock)
};
void InitializeNewLockSample(FFXM_PARAMETER_OUT FfxFloat32x2 fLockStatus)
{
fLockStatus = FfxFloat32x2(0, 0);
}
#if FFXM_HALF
void InitializeNewLockSample(FFXM_PARAMETER_OUT FFXM_MIN16_F2 fLockStatus)
{
fLockStatus = FFXM_MIN16_F2(0, 0);
}
#endif
void KillLock(FFXM_PARAMETER_INOUT FfxFloat32x2 fLockStatus)
{
fLockStatus[LOCK_LIFETIME_REMAINING] = 0;
}
#if FFXM_HALF
void KillLock(FFXM_PARAMETER_INOUT FFXM_MIN16_F2 fLockStatus)
{
fLockStatus[LOCK_LIFETIME_REMAINING] = FFXM_MIN16_F(0);
}
#endif
struct RectificationBox
{
FfxFloat32x3 boxCenter;
FfxFloat32x3 boxVec;
FfxFloat32x3 aabbMin;
FfxFloat32x3 aabbMax;
FfxFloat32 fBoxCenterWeight;
};
#if FFXM_HALF
struct RectificationBoxMin16
{
FFXM_MIN16_F3 boxCenter;
FFXM_MIN16_F3 boxVec;
FFXM_MIN16_F3 aabbMin;
FFXM_MIN16_F3 aabbMax;
FFXM_MIN16_F fBoxCenterWeight;
};
#endif
void RectificationBoxReset(FFXM_PARAMETER_INOUT RectificationBox rectificationBox)
{
rectificationBox.fBoxCenterWeight = FfxFloat32(0);
rectificationBox.boxCenter = FfxFloat32x3(0, 0, 0);
rectificationBox.boxVec = FfxFloat32x3(0, 0, 0);
rectificationBox.aabbMin = FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX);
rectificationBox.aabbMax = -FfxFloat32x3(FSR2_FLT_MAX, FSR2_FLT_MAX, FSR2_FLT_MAX);
}
#if FFXM_HALF
void RectificationBoxReset(FFXM_PARAMETER_INOUT RectificationBoxMin16 rectificationBox)
{
rectificationBox.fBoxCenterWeight = FFXM_MIN16_F(0);
rectificationBox.boxCenter = FFXM_MIN16_F3(0, 0, 0);
rectificationBox.boxVec = FFXM_MIN16_F3(0, 0, 0);
rectificationBox.aabbMin = FFXM_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX);
rectificationBox.aabbMax = -FFXM_MIN16_F3(FSR2_FP16_MAX, FSR2_FP16_MAX, FSR2_FP16_MAX);
}
#endif
void RectificationBoxAddInitialSample(FFXM_PARAMETER_INOUT RectificationBox rectificationBox, const FfxFloat32x3 colorSample, const FfxFloat32 fSampleWeight)
{
rectificationBox.aabbMin = colorSample;
rectificationBox.aabbMax = colorSample;
FfxFloat32x3 weightedSample = colorSample * fSampleWeight;
rectificationBox.boxCenter = weightedSample;
rectificationBox.boxVec = colorSample * weightedSample;
rectificationBox.fBoxCenterWeight = fSampleWeight;
}
void RectificationBoxAddSample(FfxBoolean bInitialSample, FFXM_PARAMETER_INOUT RectificationBox rectificationBox, const FfxFloat32x3 colorSample, const FfxFloat32 fSampleWeight)
{
if (bInitialSample) {
RectificationBoxAddInitialSample(rectificationBox, colorSample, fSampleWeight);
} else {
rectificationBox.aabbMin = ffxMin(rectificationBox.aabbMin, colorSample);
rectificationBox.aabbMax = ffxMax(rectificationBox.aabbMax, colorSample);
FfxFloat32x3 weightedSample = colorSample * fSampleWeight;
rectificationBox.boxCenter += weightedSample;
rectificationBox.boxVec += colorSample * weightedSample;
rectificationBox.fBoxCenterWeight += fSampleWeight;
}
}
#if FFXM_HALF
void RectificationBoxAddInitialSample(FFXM_PARAMETER_INOUT RectificationBoxMin16 rectificationBox, const FFXM_MIN16_F3 colorSample, const FFXM_MIN16_F fSampleWeight)
{
rectificationBox.aabbMin = colorSample;
rectificationBox.aabbMax = colorSample;
FFXM_MIN16_F3 weightedSample = colorSample * fSampleWeight;
rectificationBox.boxCenter = weightedSample;
rectificationBox.boxVec = colorSample * weightedSample;
rectificationBox.fBoxCenterWeight = fSampleWeight;
}
void RectificationBoxAddSample(FfxBoolean bInitialSample, FFXM_PARAMETER_INOUT RectificationBoxMin16 rectificationBox, const FFXM_MIN16_F3 colorSample, const FFXM_MIN16_F fSampleWeight)
{
if (bInitialSample) {
RectificationBoxAddInitialSample(rectificationBox, colorSample, fSampleWeight);
} else {
rectificationBox.aabbMin = ffxMin(rectificationBox.aabbMin, colorSample);
rectificationBox.aabbMax = ffxMax(rectificationBox.aabbMax, colorSample);
FFXM_MIN16_F3 weightedSample = colorSample * fSampleWeight;
rectificationBox.boxCenter += weightedSample;
rectificationBox.boxVec += colorSample * weightedSample;
rectificationBox.fBoxCenterWeight += fSampleWeight;
}
}
#endif
void RectificationBoxComputeVarianceBoxData(FFXM_PARAMETER_INOUT RectificationBox rectificationBox)
{
rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f));
rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight;
rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight;
FfxFloat32x3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter));
rectificationBox.boxVec = stdDev;
}
#if FFXM_HALF
void RectificationBoxComputeVarianceBoxData(FFXM_PARAMETER_INOUT RectificationBoxMin16 rectificationBox)
{
rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFXM_MIN16_F(FSR2_EPSILON) ? rectificationBox.fBoxCenterWeight : FFXM_MIN16_F(1.f));
rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight;
rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight;
FFXM_MIN16_F3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter));
rectificationBox.boxVec = stdDev;
}
#endif
FfxFloat32x3 SafeRcp3(FfxFloat32x3 v)
{
return (all(FFXM_NOT_EQUAL(v, FfxFloat32x3(0, 0, 0)))) ? (FfxFloat32x3(1, 1, 1) / v) : FfxFloat32x3(0, 0, 0);
}
#if FFXM_HALF
FFXM_MIN16_F3 SafeRcp3(FFXM_MIN16_F3 v)
{
return (all(FFXM_NOT_EQUAL(v, FFXM_MIN16_F3(0, 0, 0)))) ? (FFXM_MIN16_F3(1, 1, 1) / v) : FFXM_MIN16_F3(0, 0, 0);
}
#endif
FfxFloat32 MinDividedByMax(const FfxFloat32 v0, const FfxFloat32 v1)
{
const FfxFloat32 m = ffxMax(v0, v1);
return m != 0 ? ffxMin(v0, v1) / m : 0;
}
#if FFXM_HALF
FFXM_MIN16_F MinDividedByMax(const FFXM_MIN16_F v0, const FFXM_MIN16_F v1)
{
const FFXM_MIN16_F m = ffxMax(v0, v1);
return m != FFXM_MIN16_F(0) ? ffxMin(v0, v1) / m : FFXM_MIN16_F(0);
}
#endif
FfxFloat32x3 YCoCgToRGB(FfxFloat32x3 fYCoCg)
{
FfxFloat32x3 fRgb;
fRgb = FfxFloat32x3(
fYCoCg.x + fYCoCg.y - fYCoCg.z,
fYCoCg.x + fYCoCg.z,
fYCoCg.x - fYCoCg.y - fYCoCg.z);
return fRgb;
}
#if FFXM_HALF
FFXM_MIN16_F3 YCoCgToRGB(FFXM_MIN16_F3 fYCoCg)
{
FFXM_MIN16_F3 fRgb;
fRgb = FFXM_MIN16_F3(
fYCoCg.x + fYCoCg.y - fYCoCg.z,
fYCoCg.x + fYCoCg.z,
fYCoCg.x - fYCoCg.y - fYCoCg.z);
return fRgb;
}
#endif
FfxFloat32x3 RGBToYCoCg(FfxFloat32x3 fRgb)
{
FfxFloat32x3 fYCoCg;
fYCoCg = FfxFloat32x3(
0.25f * fRgb.r + 0.5f * fRgb.g + 0.25f * fRgb.b,
0.5f * fRgb.r - 0.5f * fRgb.b,
-0.25f * fRgb.r + 0.5f * fRgb.g - 0.25f * fRgb.b);
return fYCoCg;
}
#if FFXM_HALF
FFXM_MIN16_F3 RGBToYCoCg(FFXM_MIN16_F3 fRgb)
{
FFXM_MIN16_F3 fYCoCg;
fYCoCg = FFXM_MIN16_F3(
0.25 * fRgb.r + 0.5 * fRgb.g + 0.25 * fRgb.b,
0.5 * fRgb.r - 0.5 * fRgb.b,
-0.25 * fRgb.r + 0.5 * fRgb.g - 0.25 * fRgb.b);
return fYCoCg;
}
#endif
FfxFloat32 RGBToLuma(FfxFloat32x3 fLinearRgb)
{
return dot(fLinearRgb, FfxFloat32x3(0.2126f, 0.7152f, 0.0722f));
}
#if FFXM_HALF
FFXM_MIN16_F RGBToLuma(FFXM_MIN16_F3 fLinearRgb)
{
return dot(fLinearRgb, FFXM_MIN16_F3(0.2126f, 0.7152f, 0.0722f));
}
#endif
FfxFloat32 RGBToPerceivedLuma(FfxFloat32x3 fLinearRgb)
{
FfxFloat32 fLuminance = RGBToLuma(fLinearRgb);
FfxFloat32 fPercievedLuminance = 0;
if (fLuminance <= 216.0f / 24389.0f) {
fPercievedLuminance = fLuminance * (24389.0f / 27.0f);
}
else {
fPercievedLuminance = ffxPow(fLuminance, 1.0f / 3.0f) * 116.0f - 16.0f;
}
return fPercievedLuminance * 0.01f;
}
#if FFXM_HALF
FFXM_MIN16_F RGBToPerceivedLuma(FFXM_MIN16_F3 fLinearRgb)
{
FFXM_MIN16_F fLuminance = RGBToLuma(fLinearRgb);
FFXM_MIN16_F fPercievedLuminance = FFXM_MIN16_F(0);
if (fLuminance <= FFXM_MIN16_F(216.0f / 24389.0f)) {
fPercievedLuminance = fLuminance * FFXM_MIN16_F(24389.0f / 27.0f);
}
else {
fPercievedLuminance = ffxPow(fLuminance, FFXM_MIN16_F(1.0f / 3.0f)) * FFXM_MIN16_F(116.0f) - FFXM_MIN16_F(16.0f);
}
return fPercievedLuminance * FFXM_MIN16_F(0.01f);
}
#endif
FfxFloat32x3 Tonemap(FfxFloat32x3 fRgb)
{
return fRgb / (ffxMax(ffxMax(0.f, fRgb.r), ffxMax(fRgb.g, fRgb.b)) + 1.f).xxx;
}
FfxFloat32x3 InverseTonemap(FfxFloat32x3 fRgb)
{
return fRgb / ffxMax(FSR2_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx;
}
#if FFXM_HALF
FFXM_MIN16_F3 Tonemap(FFXM_MIN16_F3 fRgb)
{
return fRgb / (ffxMax(ffxMax(FFXM_MIN16_F(0.f), fRgb.r), ffxMax(fRgb.g, fRgb.b)) + FFXM_MIN16_F(1.f)).xxx;
}
FFXM_MIN16_F3 InverseTonemap(FFXM_MIN16_F3 fRgb)
{
return fRgb / ffxMax(FFXM_MIN16_F(FSR2_TONEMAP_EPSILON), FFXM_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx;
}
#endif
FfxInt32x2 ClampLoad(FfxInt32x2 iPxSample, FfxInt32x2 iPxOffset, FfxInt32x2 iTextureSize)
{
FfxInt32x2 result = iPxSample + iPxOffset;
result.x = (iPxOffset.x < 0) ? ffxMax(result.x, 0) : result.x;
result.x = (iPxOffset.x > 0) ? ffxMin(result.x, iTextureSize.x - 1) : result.x;
result.y = (iPxOffset.y < 0) ? ffxMax(result.y, 0) : result.y;
result.y = (iPxOffset.y > 0) ? ffxMin(result.y, iTextureSize.y - 1) : result.y;
return result;
// return ffxMed3(iPxSample + iPxOffset, FfxInt32x2(0, 0), iTextureSize - FfxInt32x2(1, 1));
}
#if FFXM_HALF
FFXM_MIN16_I2 ClampLoad(FFXM_MIN16_I2 iPxSample, FFXM_MIN16_I2 iPxOffset, FFXM_MIN16_I2 iTextureSize)
{
FFXM_MIN16_I2 result = iPxSample + iPxOffset;
result.x = (iPxOffset.x < 0) ? ffxMax(result.x, FFXM_MIN16_I(0)) : result.x;
result.x = (iPxOffset.x > 0) ? ffxMin(result.x, iTextureSize.x - FFXM_MIN16_I(1)) : result.x;
result.y = (iPxOffset.y < 0) ? ffxMax(result.y, FFXM_MIN16_I(0)) : result.y;
result.y = (iPxOffset.y > 0) ? ffxMin(result.y, iTextureSize.y - FFXM_MIN16_I(1)) : result.y;
return result;
// return ffxMed3Half(iPxSample + iPxOffset, FFXM_MIN16_I2(0, 0), iTextureSize - FFXM_MIN16_I2(1, 1));
}
#endif
FfxFloat32x2 ClampUv(FfxFloat32x2 fUv, FfxInt32x2 iTextureSize, FfxInt32x2 iResourceSize)
{
const FfxFloat32x2 fSampleLocation = fUv * iTextureSize;
const FfxFloat32x2 fClampedLocation = ffxMax(FfxFloat32x2(0.5f, 0.5f), ffxMin(fSampleLocation, FfxFloat32x2(iTextureSize) - FfxFloat32x2(0.5f, 0.5f)));
const FfxFloat32x2 fClampedUv = fClampedLocation / FfxFloat32x2(iResourceSize);
return fClampedUv;
}
FfxBoolean IsOnScreen(FfxInt32x2 pos, FfxInt32x2 size)
{
return all(FFXM_LESS_THAN(FfxUInt32x2(pos), FfxUInt32x2(size)));
}
#if FFXM_HALF
FfxBoolean IsOnScreen(FFXM_MIN16_I2 pos, FFXM_MIN16_I2 size)
{
return all(FFXM_LESS_THAN(FFXM_MIN16_U2(pos), FFXM_MIN16_U2(size)));
}
#endif
FfxFloat32 ComputeAutoExposureFromLavg(FfxFloat32 Lavg)
{
Lavg = exp(Lavg);
const FfxFloat32 S = 100.0f; //ISO arithmetic speed
const FfxFloat32 K = 12.5f;
FfxFloat32 ExposureISO100 = log2((Lavg * S) / K);
const FfxFloat32 q = 0.65f;
FfxFloat32 Lmax = (78.0f / (q * S)) * ffxPow(2.0f, ExposureISO100);
return 1 / Lmax;
}
#if FFXM_HALF
FFXM_MIN16_F ComputeAutoExposureFromLavg(FFXM_MIN16_F Lavg)
{
Lavg = exp(Lavg);
const FFXM_MIN16_F S = FFXM_MIN16_F(100.0f); //ISO arithmetic speed
const FFXM_MIN16_F K = FFXM_MIN16_F(12.5f);
const FFXM_MIN16_F ExposureISO100 = log2((Lavg * S) / K);
const FFXM_MIN16_F q = FFXM_MIN16_F(0.65f);
const FFXM_MIN16_F Lmax = (FFXM_MIN16_F(78.0f) / (q * S)) * ffxPow(FFXM_MIN16_F(2.0f), ExposureISO100);
return FFXM_MIN16_F(1) / Lmax;
}
#endif
FfxInt32x2 ComputeHrPosFromLrPos(FfxInt32x2 iPxLrPos)
{
FfxFloat32x2 fSrcJitteredPos = FfxFloat32x2(iPxLrPos) + 0.5f - Jitter();
FfxFloat32x2 fLrPosInHr = (fSrcJitteredPos / RenderSize()) * DisplaySize();
FfxInt32x2 iPxHrPos = FfxInt32x2(floor(fLrPosInHr));
return iPxHrPos;
}
#if FFXM_HALF
FFXM_MIN16_I2 ComputeHrPosFromLrPos(FFXM_MIN16_I2 iPxLrPos)
{
FFXM_MIN16_F2 fSrcJitteredPos = FFXM_MIN16_F2(iPxLrPos) + FFXM_MIN16_F(0.5f) - FFXM_MIN16_F2(Jitter());
FFXM_MIN16_F2 fLrPosInHr = (fSrcJitteredPos / FFXM_MIN16_F2(RenderSize())) * FFXM_MIN16_F2(DisplaySize());
FFXM_MIN16_I2 iPxHrPos = FFXM_MIN16_I2(floor(fLrPosInHr));
return iPxHrPos;
}
#endif
FfxFloat32x2 ComputeNdc(FfxFloat32x2 fPxPos, FfxInt32x2 iSize)
{
return fPxPos / FfxFloat32x2(iSize) * FfxFloat32x2(2.0f, -2.0f) + FfxFloat32x2(-1.0f, 1.0f);
}
FfxFloat32 GetViewSpaceDepth(FfxFloat32 fDeviceDepth)
{
const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors();
// fDeviceToViewDepth details found in ffx_fsr2.cpp
return (fDeviceToViewDepth[1] / (fDeviceDepth - fDeviceToViewDepth[0]));
}
FfxFloat32 GetViewSpaceDepthInMeters(FfxFloat32 fDeviceDepth)
{
return GetViewSpaceDepth(fDeviceDepth) * ViewSpaceToMetersFactor();
}
FfxFloat32x3 GetViewSpacePosition(FfxInt32x2 iViewportPos, FfxInt32x2 iViewportSize, FfxFloat32 fDeviceDepth)
{
const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors();
const FfxFloat32 Z = GetViewSpaceDepth(fDeviceDepth);
const FfxFloat32x2 fNdcPos = ComputeNdc(iViewportPos, iViewportSize);
const FfxFloat32 X = fDeviceToViewDepth[2] * fNdcPos.x * Z;
const FfxFloat32 Y = fDeviceToViewDepth[3] * fNdcPos.y * Z;
return FfxFloat32x3(X, Y, Z);
}
FfxFloat32x3 GetViewSpacePositionInMeters(FfxInt32x2 iViewportPos, FfxInt32x2 iViewportSize, FfxFloat32 fDeviceDepth)
{
return GetViewSpacePosition(iViewportPos, iViewportSize, fDeviceDepth) * ViewSpaceToMetersFactor();
}
FfxFloat32 GetMaxDistanceInMeters()
{
#if FFXM_FSR2_OPTION_INVERTED_DEPTH
return GetViewSpaceDepth(0.0f) * ViewSpaceToMetersFactor();
#else
return GetViewSpaceDepth(1.0f) * ViewSpaceToMetersFactor();
#endif
}
FfxFloat32x3 PrepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure, FfxFloat32 fPreExposure)
{
fRgb /= fPreExposure;
fRgb *= fExposure;
fRgb = clamp(fRgb, 0.0f, FSR2_FP16_MAX);
return fRgb;
}
FfxFloat32x3 UnprepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure)
{
fRgb /= fExposure;
fRgb *= PreExposure();
return fRgb;
}
#if FFXM_HALF
FfxFloat16x3 PrepareRgb(FfxFloat16x3 fRgb, FfxFloat16 fExposure, FfxFloat16 fPreExposure)
{
fRgb /= fPreExposure;
fRgb *= fExposure;
fRgb = clamp(fRgb, FfxFloat16(0.0f), FfxFloat16(FSR2_FP16_MAX));
return fRgb;
}
FfxFloat16x3 UnprepareRgb(FfxFloat16x3 fRgb, FfxFloat16 fExposure)
{
fRgb /= fExposure;
fRgb *= FfxFloat16(PreExposure());
return fRgb;
}
#endif
struct BilinearSamplingData
{
FfxInt32x2 iOffsets[4];
FfxFloat32 fWeights[4];
FfxInt32x2 iBasePos;
FfxFloat32x2 fQuadCenterUv;
};
BilinearSamplingData GetBilinearSamplingData(FfxFloat32x2 fUv, FfxInt32x2 iSize)
{
BilinearSamplingData data;
FfxFloat32x2 fPxSample = (fUv * iSize) - FfxFloat32x2(0.5f, 0.5f);
data.iBasePos = FfxInt32x2(floor(fPxSample));
data.fQuadCenterUv = fPxSample / FfxFloat32x2(iSize);
FfxFloat32x2 fPxFrac = ffxFract(fPxSample);
data.iOffsets[0] = FfxInt32x2(0, 0);
data.iOffsets[1] = FfxInt32x2(1, 0);
data.iOffsets[2] = FfxInt32x2(0, 1);
data.iOffsets[3] = FfxInt32x2(1, 1);
data.fWeights[0] = (1 - fPxFrac.x) * (1 - fPxFrac.y);
data.fWeights[1] = (fPxFrac.x) * (1 - fPxFrac.y);
data.fWeights[2] = (1 - fPxFrac.x) * (fPxFrac.y);
data.fWeights[3] = (fPxFrac.x) * (fPxFrac.y);
return data;
}
struct PlaneData
{
FfxFloat32x3 fNormal;
FfxFloat32 fDistanceFromOrigin;
};
PlaneData GetPlaneFromPoints(FfxFloat32x3 fP0, FfxFloat32x3 fP1, FfxFloat32x3 fP2)
{
PlaneData plane;
FfxFloat32x3 v0 = fP0 - fP1;
FfxFloat32x3 v1 = fP0 - fP2;
plane.fNormal = normalize(cross(v0, v1));
plane.fDistanceFromOrigin = -dot(fP0, plane.fNormal);
return plane;
}
FfxFloat32 PointToPlaneDistance(PlaneData plane, FfxFloat32x3 fPoint)
{
return abs(dot(plane.fNormal, fPoint) + plane.fDistanceFromOrigin);
}
#endif // #if defined(FFXM_GPU)
#endif //!defined(FFXM_FSR2_COMMON_H)

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_common.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: ecee34f12256cf741857fcb5696b0996
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

212
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_compute_luminance_pyramid.h

@ -0,0 +1,212 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
FFXM_GROUPSHARED FfxUInt32 spdCounter = 0u;
void SpdIncreaseAtomicCounter(FfxUInt32 slice)
{
SPD_IncreaseAtomicCounter(spdCounter);
}
FfxUInt32 SpdGetAtomicCounter()
{
return spdCounter;
}
void SpdResetAtomicCounter(FfxUInt32 slice)
{
SPD_ResetAtomicCounter();
}
#ifndef SPD_PACKED_ONLY
FFXM_GROUPSHARED FfxFloat32 spdIntermediateR[16][16];
FFXM_GROUPSHARED FfxFloat32 spdIntermediateG[16][16];
FFXM_GROUPSHARED FfxFloat32 spdIntermediateB[16][16];
FFXM_GROUPSHARED FfxFloat32 spdIntermediateA[16][16];
FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 tex, FfxUInt32 slice)
{
FfxFloat32x2 fUv = (tex + 0.5f + Jitter()) / RenderSize();
fUv = ClampUv(fUv, RenderSize(), InputColorResourceDimensions());
FfxFloat32x3 fRgb = SampleInputColor(fUv);
fRgb /= PreExposure();
//compute log luma
const FfxFloat32 fLogLuma = log(ffxMax(FSR2_EPSILON, RGBToLuma(fRgb)));
// Make sure out of screen pixels contribute no value to the end result
const FfxFloat32 result = all(FFXM_LESS_THAN(tex, RenderSize())) ? fLogLuma : 0.0f;
return FfxFloat32x4(result, 0, 0, 0);
}
FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice)
{
return SPD_LoadMipmap5(tex);
}
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice)
{
if (index == LumaMipLevelToUse() || index == 5)
{
SPD_SetMipmap(pix, index, outValue.r);
}
if (index == MipCount() - 1) { //accumulate on 1x1 level
if (all(FFXM_EQUAL(pix, FfxInt32x2(0, 0))))
{
FfxFloat32 prev = SPD_LoadExposureBuffer().y;
FfxFloat32 result = outValue.r;
if (prev < resetAutoExposureAverageSmoothing) // Compare Lavg, so small or negative values
{
FfxFloat32 rate = 1.0f;
result = prev + (result - prev) * (1 - exp(-DeltaTime() * rate));
result = ffxMax(0.0f, result);
}
FfxFloat32x2 spdOutput = FfxFloat32x2(ComputeAutoExposureFromLavg(result), result);
SPD_SetExposureBuffer(spdOutput);
}
}
}
FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y)
{
return FfxFloat32x4(
spdIntermediateR[x][y],
spdIntermediateG[x][y],
spdIntermediateB[x][y],
spdIntermediateA[x][y]);
}
void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value)
{
spdIntermediateR[x][y] = value.x;
spdIntermediateG[x][y] = value.y;
spdIntermediateB[x][y] = value.z;
spdIntermediateA[x][y] = value.w;
}
FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3)
{
return (v0 + v1 + v2 + v3) * 0.25f;
}
#endif
// define fetch and store functions Packed
#if FFXM_HALF
FFXM_GROUPSHARED FfxFloat16x2 spdIntermediateRG[16][16];
FFXM_GROUPSHARED FfxFloat16x2 spdIntermediateBA[16][16];
FfxFloat16x4 SpdLoadSourceImageH(FfxFloat32x2 tex, FfxUInt32 slice)
{
FfxFloat16x2 fUv = FfxFloat16x2((tex + 0.5f + Jitter()) / RenderSize());
fUv = FfxFloat16x2(ClampUv(fUv, RenderSize(), InputColorResourceDimensions()));
FfxFloat16x3 fRgb = FfxFloat16x3(SampleInputColor(fUv));
fRgb /= FfxFloat16(PreExposure());
//compute log luma
const FfxFloat16 fLogLuma = FfxFloat16(log(ffxMax(FSR2_EPSILON, RGBToLuma(fRgb))));
// Make sure out of screen pixels contribute no value to the end result
const FfxFloat16 result = all(FFXM_LESS_THAN(tex, RenderSize())) ? fLogLuma : FfxFloat16(0.0f);
return FfxFloat16x4(result, 0, 0, 0);
}
FfxFloat16x4 SpdLoadH(FfxInt32x2 p, FfxUInt32 slice)
{
return FfxFloat16x4(SPD_LoadMipmap5(p));
}
void SpdStoreH(FfxInt32x2 pix, FfxFloat16x4 outValue, FfxUInt32 index, FfxUInt32 slice)
{
if (index == LumaMipLevelToUse() || index == 5)
{
SPD_SetMipmap(pix, index, outValue.r);
}
if (index == MipCount() - 1) { //accumulate on 1x1 level
if (all(FFXM_EQUAL(pix, FfxInt16x2(0, 0))))
{
FfxFloat16 result = outValue.r;
// If running with GLES 3.2, remove the smooth exposure transition.
#if !FFXM_SHADER_PLATFORM_GLES_3_2
FfxFloat16 prev = FfxFloat16(SPD_LoadExposureBuffer().y);
if (prev < resetAutoExposureAverageSmoothing) // Compare Lavg, so small or negative values
{
FfxFloat16 rate = FfxFloat16(1.0f);
result = FfxFloat16(prev + (result - prev) * (1 - exp(-DeltaTime() * rate)));
}
#endif
FfxFloat16x2 spdOutput = FfxFloat16x2(ComputeAutoExposureFromLavg(result), result);
SPD_SetExposureBuffer(spdOutput);
}
}
}
FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y)
{
return FfxFloat16x4(
spdIntermediateRG[x][y].x,
spdIntermediateRG[x][y].y,
spdIntermediateBA[x][y].x,
spdIntermediateBA[x][y].y);
}
void SpdStoreIntermediateH(FfxUInt32 x, FfxUInt32 y, FfxFloat16x4 value)
{
spdIntermediateRG[x][y] = value.xy;
spdIntermediateBA[x][y] = value.zw;
}
FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxFloat16x4 v3)
{
return (v0 + v1 + v2 + v3) * FfxFloat16(0.25);
}
#endif
#include "../spd/ffxm_spd.h"
void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex)
{
#if FFXM_HALF
SpdDownsampleH(
FfxUInt32x2(WorkGroupId.xy),
FfxUInt32(LocalThreadIndex),
FfxUInt32(MipCount()),
FfxUInt32(NumWorkGroups()),
FfxUInt32(WorkGroupId.z),
FfxUInt32x2(WorkGroupOffset()));
#else
SpdDownsample(
FfxUInt32x2(WorkGroupId.xy),
FfxUInt32(LocalThreadIndex),
FfxUInt32(MipCount()),
FfxUInt32(NumWorkGroups()),
FfxUInt32(WorkGroupId.z),
FfxUInt32x2(WorkGroupOffset()));
#endif
}

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_compute_luminance_pyramid.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 53658e1078243f24aa98041b58bf721d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

349
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_depth_clip.h

@ -0,0 +1,349 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_DEPTH_CLIP_H
#define FFXM_FSR2_DEPTH_CLIP_H
// Can casue some temporal instability
#define OPT_PREFETCH_PREVDEPTH_WITH_GATHER 0
struct DepthClipOutputs
{
FfxFloat32x4 fTonemapped;
FfxFloat32x2 fDilatedReactiveMasks;
};
FFXM_STATIC const FfxFloat32 DepthClipBaseScale = 4.0f;
FfxFloat32 ComputeDepthClip(FfxFloat32x2 fUvSample, FfxFloat32 fCurrentDepthSample)
{
FfxFloat32 fCurrentDepthViewSpace = GetViewSpaceDepth(fCurrentDepthSample);
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUvSample, RenderSize());
FfxFloat32 fDilatedSum = 0.0f;
FfxFloat32 fDepth = 0.0f;
FfxFloat32 fWeightSum = 0.0f;
#if OPT_PREFETCH_PREVDEPTH_WITH_GATHER
FfxFloat32 fDepthSamples[4];
GatherReconstructedPreviousDepthRQuad(bilinearInfo.fQuadCenterUv,
fDepthSamples[0], fDepthSamples[1], fDepthSamples[2], fDepthSamples[3]);
#endif
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++)
{
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex];
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset;
if (IsOnScreen(iSamplePos, RenderSize()))
{
const FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex];
if (fWeight > fReconstructedDepthBilinearWeightThreshold)
{
#if OPT_PREFETCH_PREVDEPTH_WITH_GATHER
const FfxFloat32 fPrevDepthSample = fDepthSamples[iSampleIndex];
#else
const FfxFloat32 fPrevDepthSample = LoadReconstructedPrevDepth(iSamplePos);
#endif
const FfxFloat32 fPrevNearestDepthViewSpace = GetViewSpaceDepth(fPrevDepthSample);
const FfxFloat32 fDepthDiff = fCurrentDepthViewSpace - fPrevNearestDepthViewSpace;
if (fDepthDiff > 0.0f) {
#if FFXM_FSR2_OPTION_INVERTED_DEPTH
const FfxFloat32 fPlaneDepth = ffxMin(fPrevDepthSample, fCurrentDepthSample);
#else
const FfxFloat32 fPlaneDepth = ffxMax(fPrevDepthSample, fCurrentDepthSample);
#endif
const FfxFloat32x3 fCenter = GetViewSpacePosition(FfxInt32x2(RenderSize() * 0.5f), RenderSize(), fPlaneDepth);
const FfxFloat32x3 fCorner = GetViewSpacePosition(FfxInt32x2(0, 0), RenderSize(), fPlaneDepth);
const FfxFloat32 fHalfViewportWidth = length(FfxFloat32x2(RenderSize()));
const FfxFloat32 fDepthThreshold = ffxMax(fCurrentDepthViewSpace, fPrevNearestDepthViewSpace);
const FfxFloat32 Ksep = 1.37e-05f;
const FfxFloat32 Kfov = length(fCorner) / length(fCenter);
const FfxFloat32 fRequiredDepthSeparation = Ksep * Kfov * fHalfViewportWidth * fDepthThreshold;
const FfxFloat32 fResolutionFactor = ffxSaturate(length(FfxFloat32x2(RenderSize())) / length(FfxFloat32x2(1920.0f, 1080.0f)));
const FfxFloat32 fPower = ffxLerp(1.0f, 3.0f, fResolutionFactor);
fDepth += ffxPow(ffxSaturate(FfxFloat32(fRequiredDepthSeparation / fDepthDiff)), fPower) * fWeight;
fWeightSum += fWeight;
}
}
}
}
return (fWeightSum > 0) ? ffxSaturate(1.0f - fDepth / fWeightSum) : 0.0f;
}
FfxFloat32 ComputeMotionDivergence(FfxInt32x2 iPxPos, FfxInt32x2 iPxInputMotionVectorSize)
{
FfxFloat32 minconvergence = 1.0f;
FfxFloat32x2 fMotionVectorNucleus = LoadInputMotionVector(iPxPos);
FfxFloat32 fNucleusVelocityLr = length(fMotionVectorNucleus * RenderSize());
FfxFloat32 fMaxVelocityUv = length(fMotionVectorNucleus);
const FfxFloat32 MotionVectorVelocityEpsilon = 1e-02f;
const FfxFloat32x2 fMVSize = FfxFloat32x2(iPxInputMotionVectorSize);
FfxFloat32x2 fPxBaseUv = FfxFloat32x2(iPxPos) / fMVSize;
FfxFloat32x2 fUnitUv = FfxFloat32x2(1.0f, 1.0f) / fMVSize;
FFXM_MIN16_F2 fMotionVectorSamples[9];
FFXM_MIN16_F2 fTmpDummy = FFXM_MIN16_F2(0.0f, 0.0f);
GatherInputMotionVectorRGQuad(fPxBaseUv,
fMotionVectorSamples[0], fMotionVectorSamples[1],
fMotionVectorSamples[3], fMotionVectorSamples[4]);
GatherInputMotionVectorRGQuad(fUnitUv + fPxBaseUv,
fTmpDummy, fMotionVectorSamples[5],
fMotionVectorSamples[7], fMotionVectorSamples[8]);
fMotionVectorSamples[2] = LoadInputMotionVector(iPxPos + FfxInt32x2(1, -1));
fMotionVectorSamples[6] = LoadInputMotionVector(iPxPos + FfxInt32x2(-1, 1));
if (fNucleusVelocityLr > MotionVectorVelocityEpsilon) {
for (FfxInt32 y = -1; y <= 1; ++y)
{
for (FfxInt32 x = -1; x <= 1; ++x)
{
FfxInt32 sampleIdx = (y + 1) * 3 + x + 1;
FfxFloat32x2 fMotionVector = fMotionVectorSamples[sampleIdx]; //LoadInputMotionVector(sp);
FfxFloat32 fVelocityUv = length(fMotionVector);
fMaxVelocityUv = ffxMax(fVelocityUv, fMaxVelocityUv);
fVelocityUv = ffxMax(fVelocityUv, fMaxVelocityUv);
minconvergence = ffxMin(minconvergence, dot(fMotionVector / fVelocityUv, fMotionVectorNucleus / fVelocityUv));
}
}
}
return ffxSaturate(1.0f - minconvergence) * ffxSaturate(fMaxVelocityUv / 0.01f);
}
FfxFloat32 ComputeDepthDivergence(FfxInt32x2 iPxPos)
{
const FfxFloat32 fMaxDistInMeters = GetMaxDistanceInMeters();
FfxFloat32 fDepthMax = 0.0f;
FfxFloat32 fDepthMin = fMaxDistInMeters;
FfxInt32 iMaxDistFound = 0;
FfxInt32x2 iRenderSize = RenderSize();
const FfxFloat32x2 fRenderSize = FfxFloat32x2(iRenderSize);
FfxFloat32x2 fPxPosBase = FfxFloat32x2(iPxPos) / fRenderSize;
FfxFloat32x2 fUnitUv = FfxFloat32x2(1.0f, 1.0f) / fRenderSize;
FfxFloat32 fDilatedDepthSamples[9];
FfxFloat32 fTmpDummy = 0.0f;
GatherDilatedDepthRQuad(fPxPosBase,
fDilatedDepthSamples[0], fDilatedDepthSamples[1],
fDilatedDepthSamples[3], fDilatedDepthSamples[4]);
GatherDilatedDepthRQuad(fUnitUv + fPxPosBase,
fTmpDummy, fDilatedDepthSamples[5],
fDilatedDepthSamples[7], fDilatedDepthSamples[8]);
fDilatedDepthSamples[2] = LoadDilatedDepth(iPxPos + FfxInt32x2(1, -1));
fDilatedDepthSamples[6] = LoadDilatedDepth(iPxPos + FfxInt32x2(-1, 1));
for (FfxInt32 y = -1; y < 2; y++)
{
for (FfxInt32 x = -1; x < 2; x++)
{
FfxInt32 sampleIdx = (y + 1) * 3 + x + 1;
const FfxInt32x2 iOffset = FfxInt32x2(x, y);
const FfxInt32x2 iSamplePos = iPxPos + iOffset;
const FfxFloat32 fOnScreenFactor = IsOnScreen(iSamplePos, iRenderSize) ? 1.0f : 0.0f;
// FfxFloat32 fDepth = GetViewSpaceDepthInMeters(LoadDilatedDepth(iSamplePos)) * fOnScreenFactor;
FfxFloat32 fDepth = GetViewSpaceDepthInMeters(fDilatedDepthSamples[sampleIdx]) * fOnScreenFactor;
iMaxDistFound |= FfxInt32(fMaxDistInMeters == fDepth);
fDepthMin = ffxMin(fDepthMin, fDepth);
fDepthMax = ffxMax(fDepthMax, fDepth);
}
}
return (1.0f - fDepthMin / fDepthMax) * (FfxBoolean(iMaxDistFound) ? 0.0f : 1.0f);
}
FfxFloat32 ComputeTemporalMotionDivergence(FfxInt32x2 iPxPos)
{
const FfxFloat32x2 fUv = FfxFloat32x2(iPxPos + 0.5f) / RenderSize();
FfxFloat32x2 fMotionVector = LoadDilatedMotionVector(iPxPos);
FfxFloat32x2 fReprojectedUv = fUv + fMotionVector;
fReprojectedUv = ClampUv(fReprojectedUv, RenderSize(), MaxRenderSize());
FfxFloat32x2 fPrevMotionVector = SamplePreviousDilatedMotionVector(fReprojectedUv);
float fPxDistance = length(fMotionVector * DisplaySize());
return fPxDistance > 1.0f ? ffxLerp(0.0f, 1.0f - ffxSaturate(length(fPrevMotionVector) / length(fMotionVector)), ffxSaturate(ffxPow(fPxDistance / 20.0f, 3.0f))) : 0;
}
void PreProcessReactiveMasks(FfxInt32x2 iPxLrPos, FfxFloat32 fMotionDivergence, FFXM_PARAMETER_INOUT DepthClipOutputs results)
{
// Compensate for bilinear sampling in accumulation pass
const FfxInt32x2 iRenderSize = RenderSize();
const FfxFloat32x2 fRenderSize = FfxFloat32x2(iRenderSize);
FfxFloat32x2 fPxPosBase = FfxFloat32x2(iPxLrPos) / fRenderSize;
FfxFloat32x2 fUnitUv = FfxFloat32x2(1.0f, 1.0f) / fRenderSize;
FFXM_MIN16_F2 fReactiveFactor = FFXM_MIN16_F2(0.0f, fMotionDivergence);
FFXM_MIN16_F fMasksSum = FFXM_MIN16_F(0.0f);
FFXM_MIN16_F fTmpDummy = FFXM_MIN16_F(0.0f);
// Reactive samples
FFXM_MIN16_F fReactiveSamples[9];
GatherReactiveRQuad(fPxPosBase,
fReactiveSamples[0], fReactiveSamples[1],
fReactiveSamples[3], fReactiveSamples[4]);
GatherReactiveRQuad(fUnitUv + fPxPosBase,
fTmpDummy, fReactiveSamples[5],
fReactiveSamples[7], fReactiveSamples[8]);
fReactiveSamples[2] = FFXM_MIN16_F(LoadReactiveMask(iPxLrPos + FfxInt32x2(1, -1)));
fReactiveSamples[6] = FFXM_MIN16_F(LoadReactiveMask(iPxLrPos + FfxInt32x2(-1, 1)));
// Transparency and composition mask samples
FFXM_MIN16_F fTransparencyAndCompositionSamples[9];
GatherTransparencyAndCompositionMaskRQuad(fPxPosBase,
fTransparencyAndCompositionSamples[0], fTransparencyAndCompositionSamples[1],
fTransparencyAndCompositionSamples[3], fTransparencyAndCompositionSamples[4]);
GatherTransparencyAndCompositionMaskRQuad(fUnitUv + fPxPosBase,
fTmpDummy, fTransparencyAndCompositionSamples[5],
fTransparencyAndCompositionSamples[7], fTransparencyAndCompositionSamples[8]);
fTransparencyAndCompositionSamples[2] = FFXM_MIN16_F(LoadTransparencyAndCompositionMask(iPxLrPos + FfxInt32x2(1, -1)));
fTransparencyAndCompositionSamples[6] = FFXM_MIN16_F(LoadTransparencyAndCompositionMask(iPxLrPos + FfxInt32x2(-1, 1)));
FFXM_UNROLL
for (FfxInt32 y = -1; y < 2; y++)
{
FFXM_UNROLL
for (FfxInt32 x = -1; x < 2; x++)
{
FfxInt32 sampleIdx = (y + 1) * 3 + x + 1;
fMasksSum += (fReactiveSamples[sampleIdx] + fTransparencyAndCompositionSamples[sampleIdx]);
}
}
if (fMasksSum > FFXM_MIN16_F(0))
{
const FfxFloat32x2 InputColorSize = FfxFloat32x2(InputColorResourceDimensions());
FfxFloat32x2 Base = FfxFloat32x2(iPxLrPos) / InputColorSize;
FFXM_MIN16_F3 fInputColorSamples[9];
// Input color samples
GatherInputColorRGBQuad(Base,
fInputColorSamples[0], fInputColorSamples[1], fInputColorSamples[3], fInputColorSamples[4]);
fInputColorSamples[2] = LoadInputColor(iPxLrPos + FfxInt32x2(1, -1));
fInputColorSamples[5] = LoadInputColor(iPxLrPos + FfxInt32x2(1, 0) );
fInputColorSamples[6] = LoadInputColor(iPxLrPos + FfxInt32x2(-1, 1));
fInputColorSamples[7] = LoadInputColor(iPxLrPos + FfxInt32x2(0, 1) );
fInputColorSamples[8] = LoadInputColor(iPxLrPos + FfxInt32x2(1, 1) );
FFXM_MIN16_F3 fReferenceColor = fInputColorSamples[4];
for (FfxInt32 sampleIdx = 0; sampleIdx < 9; sampleIdx++)
{
FFXM_MIN16_F3 fColorSample = fInputColorSamples[sampleIdx];
FFXM_MIN16_F fReactiveSample = fReactiveSamples[sampleIdx];
FFXM_MIN16_F fTransparencyAndCompositionSample = fTransparencyAndCompositionSamples[sampleIdx];
const FfxFloat32 fMaxLenSq = ffxMax(dot(fReferenceColor, fReferenceColor), dot(fColorSample, fColorSample));
const FFXM_MIN16_F fSimilarity = dot(fReferenceColor, fColorSample) / fMaxLenSq;
// Increase power for non-similar samples
const FFXM_MIN16_F fPowerBiasMax = FFXM_MIN16_F(6.0f);
const FFXM_MIN16_F fSimilarityPower = FFXM_MIN16_F(1.0f + (fPowerBiasMax - fSimilarity * fPowerBiasMax));
const FFXM_MIN16_F fWeightedReactiveSample = ffxPow(fReactiveSample, fSimilarityPower);
const FFXM_MIN16_F fWeightedTransparencyAndCompositionSample = ffxPow(fTransparencyAndCompositionSample, fSimilarityPower);
fReactiveFactor = ffxMax(fReactiveFactor, FFXM_MIN16_F2(fWeightedReactiveSample, fWeightedTransparencyAndCompositionSample));
}
}
results.fDilatedReactiveMasks = fReactiveFactor;
}
FfxFloat32x3 ComputePreparedInputColor(FfxInt32x2 iPxLrPos)
{
//We assume linear data. if non-linear input (sRGB, ...),
//then we should convert to linear first and back to sRGB on output.
FfxFloat32x3 fRgb = ffxMax(FfxFloat32x3(0, 0, 0), LoadInputColor(iPxLrPos));
fRgb = PrepareRgb(fRgb, Exposure(), PreExposure());
#if FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
const FfxFloat32x3 fPreparedYCoCg = Tonemap(fRgb);
#else
const FfxFloat32x3 fPreparedYCoCg = RGBToYCoCg(fRgb);
#endif
return fPreparedYCoCg;
}
FfxFloat32 EvaluateSurface(FfxInt32x2 iPxPos, FfxFloat32x2 fMotionVector)
{
FfxFloat32 d0 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, -1)));
FfxFloat32 d1 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, 0)));
FfxFloat32 d2 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, 1)));
return 1.0f - FfxFloat32(((d0 - d1) > (d1 * 0.01f)) && ((d1 - d2) > (d2 * 0.01f)));
}
DepthClipOutputs DepthClip(FfxInt32x2 iPxPos)
{
FfxFloat32x2 fDepthUv = (iPxPos + 0.5f) / RenderSize();
FfxFloat32x2 fMotionVector = LoadDilatedMotionVector(iPxPos);
// Discard tiny mvs
fMotionVector *= FfxFloat32(length(fMotionVector * DisplaySize()) > 0.01f);
const FfxFloat32x2 fDilatedUv = fDepthUv + fMotionVector;
const FfxFloat32 fDilatedDepth = LoadDilatedDepth(iPxPos);
const FfxFloat32 fCurrentDepthViewSpace = GetViewSpaceDepth(LoadInputDepth(iPxPos));
DepthClipOutputs results;
// Compute prepared input color and depth clip
FfxFloat32 fDepthClip = ComputeDepthClip(fDilatedUv, fDilatedDepth) * EvaluateSurface(iPxPos, fMotionVector);
FfxFloat32x3 fPreparedYCoCg = ComputePreparedInputColor(iPxPos);
results.fTonemapped = FfxFloat32x4(fPreparedYCoCg, fDepthClip);
// Compute dilated reactive mask
#if FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
FfxInt32x2 iSamplePos = iPxPos;
#else
FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxPos);
#endif
FfxFloat32 fMotionDivergence = ComputeMotionDivergence(iSamplePos, RenderSize());
FfxFloat32 fTemporalMotionDifference = ffxSaturate(ComputeTemporalMotionDivergence(iPxPos) - ComputeDepthDivergence(iPxPos));
PreProcessReactiveMasks(iPxPos, ffxMax(fTemporalMotionDifference, fMotionDivergence), results);
return results;
}
#endif //!defined( FFXM_FSR2_DEPTH_CLIPH )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_depth_clip.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 6578e7c7d02073e48926d1974b4d6c92
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

131
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_lock.h

@ -0,0 +1,131 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_LOCK_H
#define FFXM_FSR2_LOCK_H
void ClearResourcesForNextFrame(in FfxInt32x2 iPxHrPos)
{
if (all(FFXM_LESS_THAN(iPxHrPos, FfxInt32x2(RenderSize()))))
{
#if FFXM_FSR2_OPTION_INVERTED_DEPTH
const FfxUInt32 farZ = 0x0;
#else
const FfxUInt32 farZ = 0x3f800000;
#endif
SetReconstructedDepth(iPxHrPos, farZ);
}
}
FfxBoolean ComputeThinFeatureConfidence(FfxInt32x2 pos)
{
const FfxInt32 RADIUS = 1;
FFXM_MIN16_F fNucleus = LoadLockInputLuma(pos);
FFXM_MIN16_F similar_threshold = FFXM_MIN16_F(1.05f);
FFXM_MIN16_F dissimilarLumaMin = FFXM_MIN16_F(FSR2_FP16_MAX);
FFXM_MIN16_F dissimilarLumaMax = FFXM_MIN16_F(0);
/*
0 1 2
3 4 5
6 7 8
*/
#define SETBIT(x) (1U << x)
FfxUInt32 mask = SETBIT(4); //flag fNucleus as similar
const FfxUInt32 uNumRejectionMasks = 4;
const FfxUInt32 uRejectionMasks[uNumRejectionMasks] = {
SETBIT(0) | SETBIT(1) | SETBIT(3) | SETBIT(4), //Upper left
SETBIT(1) | SETBIT(2) | SETBIT(4) | SETBIT(5), //Upper right
SETBIT(3) | SETBIT(4) | SETBIT(6) | SETBIT(7), //Lower left
SETBIT(4) | SETBIT(5) | SETBIT(7) | SETBIT(8), //Lower right
};
FFXM_MIN16_F lumaSamples [9];
FFXM_MIN16_F fTmpDummy = FFXM_MIN16_F(0.0f);
const FfxFloat32x2 fInputLumaSize = FfxFloat32x2(MaxRenderSize());
const FfxFloat32x2 fPxBaseUv = FfxFloat32x2(pos) / fInputLumaSize;
const FfxFloat32x2 fUnitUv = FfxFloat32x2(1.0f, 1.0f) / fInputLumaSize;
// Gather samples
GatherLockInputLumaRQuad(fPxBaseUv,
lumaSamples[0], lumaSamples[1],
lumaSamples[3], lumaSamples[4]);
GatherLockInputLumaRQuad(fUnitUv + fPxBaseUv,
fTmpDummy, lumaSamples[5],
lumaSamples[7], lumaSamples[8]);
lumaSamples[2] = LoadLockInputLuma(pos + FfxInt32x2(1, -1));
lumaSamples[6] = LoadLockInputLuma(pos + FfxInt32x2(-1, 1));
FfxInt32 idx = 0;
FFXM_UNROLL
for (FfxInt32 y = -RADIUS; y <= RADIUS; y++) {
FFXM_UNROLL
for (FfxInt32 x = -RADIUS; x <= RADIUS; x++, idx++) {
if (x == 0 && y == 0) continue;
FfxInt32 sampleIdx = (y + 1) * 3 + x + 1;
FFXM_MIN16_F sampleLuma = lumaSamples[sampleIdx];
FFXM_MIN16_F difference = ffxMax(sampleLuma, fNucleus) / ffxMin(sampleLuma, fNucleus);
if (difference > FFXM_MIN16_F(0) && (difference < similar_threshold)) {
mask |= SETBIT(idx);
} else {
dissimilarLumaMin = ffxMin(dissimilarLumaMin, sampleLuma);
dissimilarLumaMax = ffxMax(dissimilarLumaMax, sampleLuma);
}
}
}
FfxBoolean isRidge = fNucleus > dissimilarLumaMax || fNucleus < dissimilarLumaMin;
if (FFXM_FALSE == isRidge) {
return false;
}
FFXM_UNROLL
for (FfxInt32 i = 0; i < 4; i++) {
if ((mask & uRejectionMasks[i]) == uRejectionMasks[i]) {
return false;
}
}
return true;
}
void ComputeLock(FfxInt32x2 iPxLrPos)
{
if (ComputeThinFeatureConfidence(iPxLrPos))
{
StoreNewLocks(ComputeHrPosFromLrPos(iPxLrPos), 1.f);
}
//ClearResourcesForNextFrame(iPxLrPos);
}
#endif // FFXM_FSR2_LOCK_H

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_lock.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 920d5b937231132469bcb0f2a38d2d80
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

101
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h

@ -0,0 +1,101 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_POSTPROCESS_LOCK_STATUS_H
#define FFXM_FSR2_POSTPROCESS_LOCK_STATUS_H
FfxFloat32x4 WrapShadingChangeLuma(FfxInt32x2 iPxSample)
{
return FfxFloat32x4(LoadMipLuma(iPxSample, LumaMipLevelToUse()), 0, 0, 0);
}
#if FFXM_HALF
FFXM_MIN16_F4 WrapShadingChangeLuma(FFXM_MIN16_I2 iPxSample)
{
return FFXM_MIN16_F4(LoadMipLuma(iPxSample, LumaMipLevelToUse()), 0, 0, 0);
}
#endif
#if FFXM_HALF
DeclareCustomFetchBilinearSamplesMin16(FetchShadingChangeLumaSamples, WrapShadingChangeLuma)
DeclareCustomTextureSampleMin16(ShadingChangeLumaSample, Bilinear, FetchShadingChangeLumaSamples)
#else
DeclareCustomFetchBicubicSamples(FetchShadingChangeLumaSamples, WrapShadingChangeLuma)
DeclareCustomTextureSample(ShadingChangeLumaSample, Lanczos2, FetchShadingChangeLumaSamples)
#endif
FfxFloat32 GetShadingChangeLuma(FfxInt32x2 iPxHrPos, FfxFloat32x2 fUvCoord)
{
FfxFloat32 fShadingChangeLuma = 0;
const FfxFloat32 fDiv = FfxFloat32(FfxInt32(2) << LumaMipLevelToUse());
FfxInt32x2 iMipRenderSize = FfxInt32x2(RenderSize() / fDiv);
fUvCoord = ClampUv(fUvCoord, iMipRenderSize, LumaMipDimensions());
fShadingChangeLuma = Exposure() * exp(FfxFloat32(SampleMipLuma(fUvCoord, LumaMipLevelToUse())));
fShadingChangeLuma = ffxPow(fShadingChangeLuma, 1.0f / 6.0f);
return fShadingChangeLuma;
}
void UpdateLockStatus(const AccumulationPassCommonParams params,
FFXM_PARAMETER_INOUT FfxFloat32 fReactiveFactor, LockState state,
FFXM_PARAMETER_INOUT FfxFloat32x2 fLockStatus,
FFXM_PARAMETER_OUT FfxFloat32 fLockContributionThisFrame,
FFXM_PARAMETER_OUT FfxFloat32 fLuminanceDiff) {
const FfxFloat32 fShadingChangeLuma = GetShadingChangeLuma(params.iPxHrPos, params.fHrUv);
//init temporal shading change factor, init to -1 or so in reproject to know if "true new"?
fLockStatus[LOCK_TEMPORAL_LUMA] = (fLockStatus[LOCK_TEMPORAL_LUMA] == FfxFloat32(0.0f)) ? fShadingChangeLuma : fLockStatus[LOCK_TEMPORAL_LUMA];
FfxFloat32 fPreviousShadingChangeLuma = fLockStatus[LOCK_TEMPORAL_LUMA];
fLuminanceDiff = 1.0f - MinDividedByMax(fPreviousShadingChangeLuma, fShadingChangeLuma);
if (state.NewLock) {
fLockStatus[LOCK_TEMPORAL_LUMA] = fShadingChangeLuma;
fLockStatus[LOCK_LIFETIME_REMAINING] = (fLockStatus[LOCK_LIFETIME_REMAINING] != 0.0f) ? 2.0f : 1.0f;
}
else if(fLockStatus[LOCK_LIFETIME_REMAINING] <= 1.0f) {
fLockStatus[LOCK_TEMPORAL_LUMA] = ffxLerp(fLockStatus[LOCK_TEMPORAL_LUMA], FfxFloat32(fShadingChangeLuma), 0.5f);
}
else {
if (fLuminanceDiff > 0.1f) {
KillLock(fLockStatus);
}
}
fReactiveFactor = ffxMax(fReactiveFactor, ffxSaturate((fLuminanceDiff - 0.1f) * 10.0f));
fLockStatus[LOCK_LIFETIME_REMAINING] *= (1.0f - fReactiveFactor);
fLockStatus[LOCK_LIFETIME_REMAINING] *= ffxSaturate(1.0f - params.fAccumulationMask);
fLockStatus[LOCK_LIFETIME_REMAINING] *= FfxFloat32(params.fDepthClipFactor < 0.1f);
// Compute this frame lock contribution
const FfxFloat32 fLifetimeContribution = ffxSaturate(fLockStatus[LOCK_LIFETIME_REMAINING] - 1.0f);
const FfxFloat32 fShadingChangeContribution = ffxSaturate(MinDividedByMax(fLockStatus[LOCK_TEMPORAL_LUMA], fShadingChangeLuma));
fLockContributionThisFrame = ffxSaturate(ffxSaturate(fLifetimeContribution * 4.0f) * fShadingChangeContribution);
}
#endif //!defined( FFXM_FSR2_POSTPROCESS_LOCK_STATUS_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_postprocess_lock_status.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 976d18e7892c5c444bbcb4d17322fefb
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

91
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_rcas.h

@ -0,0 +1,91 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#define GROUP_SIZE 8
#define FSR_RCAS_DENOISE 1
#include "../ffxm_core.h"
struct RCASOutputs
{
FfxFloat32x3 fUpscaledColor;
};
#if FFXM_HALF
#define USE_FSR_RCASH 1
#else
#define USE_FSR_RCASH 0
#endif
#if USE_FSR_RCASH
#define FSR_RCAS_H 1
FfxFloat16x4 FsrRcasLoadH(FfxInt16x2 p)
{
FfxFloat16x4 fColor = LoadRCAS_Input(p);
fColor.rgb = FfxFloat16x3(PrepareRgb(fColor.rgb, Exposure(), PreExposure()));
return fColor;
}
void FsrRcasInputH(inout FfxFloat16 r,inout FfxFloat16 g,inout FfxFloat16 b)
{
}
#else
#define FSR_RCAS_F 1
FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p)
{
FfxFloat32x4 fColor = LoadRCAS_Input(p);
fColor.rgb = PrepareRgb(fColor.rgb, Exposure(), PreExposure());
return fColor;
}
void FsrRcasInputF(inout FfxFloat32 r, inout FfxFloat32 g, inout FfxFloat32 b) {}
#endif
#include "../fsr1/ffxm_fsr1.h"
void CurrFilter(FFXM_MIN16_U2 pos, FFXM_PARAMETER_INOUT RCASOutputs results)
{
#if USE_FSR_RCASH
FfxFloat16x3 c;
FsrRcasH(c.r, c.g, c.b, pos, RCASConfig());
c = UnprepareRgb(c, FfxFloat16(Exposure()));
#else
FfxFloat32x3 c;
FsrRcasF(c.r, c.g, c.b, pos, RCASConfig());
c = UnprepareRgb(c, Exposure());
#endif
results.fUpscaledColor = c;
}
RCASOutputs RCAS(FfxUInt32x2 gxy)
{
#ifdef FFXM_HLSL
RCASOutputs results = (RCASOutputs)0;
#else
RCASOutputs results;
#endif
CurrFilter(FFXM_MIN16_U2(gxy), results);
return results;
}

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_rcas.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 6113e44b0d068db4c954804a6ce38739
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

155
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reconstruct_dilated_velocity_and_previous_depth.h

@ -0,0 +1,155 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H
#define FFXM_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H
struct ReconstructPrevDepthOutputs
{
FfxFloat32 fDepth;
FfxFloat32x2 fMotionVector;
FfxFloat32 fLuma;
};
void ReconstructPrevDepth(FfxInt32x2 iPxPos, FfxFloat32 fDepth, FfxFloat32x2 fMotionVector, FfxInt32x2 iPxDepthSize)
{
fMotionVector *= FfxFloat32(length(fMotionVector * DisplaySize()) > 0.1f);
FfxFloat32x2 fUv = (iPxPos + FfxFloat32(0.5)) / iPxDepthSize;
FfxFloat32x2 fReprojectedUv = fUv + fMotionVector;
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fReprojectedUv, RenderSize());
// Project current depth into previous frame locations.
// Push to all pixels having some contribution if reprojection is using bilinear logic.
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) {
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex];
FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex];
if (fWeight > fReconstructedDepthBilinearWeightThreshold) {
FfxInt32x2 iStorePos = bilinearInfo.iBasePos + iOffset;
if (IsOnScreen(iStorePos, iPxDepthSize)) {
StoreReconstructedDepth(iStorePos, fDepth);
}
}
}
}
void FindNearestDepth(FFXM_PARAMETER_IN FfxInt32x2 iPxPos, FFXM_PARAMETER_IN FfxInt32x2 iPxSize, FFXM_PARAMETER_OUT FfxFloat32 fNearestDepth, FFXM_PARAMETER_OUT FfxInt32x2 fNearestDepthCoord)
{
const FfxInt32 iSampleCount = 9;
const FfxInt32x2 iSampleOffsets[iSampleCount] = {
FfxInt32x2(+0, +0),
FfxInt32x2(+1, +0),
FfxInt32x2(+0, +1),
FfxInt32x2(+0, -1),
FfxInt32x2(-1, +0),
FfxInt32x2(-1, +1),
FfxInt32x2(+1, +1),
FfxInt32x2(-1, -1),
FfxInt32x2(+1, -1),
};
// pull out the depth loads to allow SC to batch them
FfxFloat32 depth[9];
FfxInt32 iSampleIndex = 0;
FFXM_UNROLL
for (iSampleIndex = 0; iSampleIndex < iSampleCount; ++iSampleIndex) {
FfxInt32x2 iPos = iPxPos + iSampleOffsets[iSampleIndex];
depth[iSampleIndex] = LoadInputDepth(iPos);
}
// find closest depth
fNearestDepthCoord = iPxPos;
fNearestDepth = depth[0];
FFXM_UNROLL
for (iSampleIndex = 1; iSampleIndex < iSampleCount; ++iSampleIndex) {
FfxInt32x2 iPos = iPxPos + iSampleOffsets[iSampleIndex];
if (IsOnScreen(iPos, iPxSize)) {
FfxFloat32 fNdDepth = depth[iSampleIndex];
#if FFXM_FSR2_OPTION_INVERTED_DEPTH
if (fNdDepth > fNearestDepth) {
#else
if (fNdDepth < fNearestDepth) {
#endif
fNearestDepthCoord = iPos;
fNearestDepth = fNdDepth;
}
}
}
}
FfxFloat32 ComputeLockInputLuma(FfxInt32x2 iPxLrPos)
{
//We assume linear data. if non-linear input (sRGB, ...),
//then we should convert to linear first and back to sRGB on output.
FfxFloat32x3 fRgb = ffxMax(FfxFloat32x3(0, 0, 0), LoadInputColor(iPxLrPos));
// Use internal auto exposure for locking logic
fRgb /= PreExposure();
fRgb *= Exposure();
#if FFXM_FSR2_OPTION_HDR_COLOR_INPUT
fRgb = Tonemap(fRgb);
#endif
//compute luma used to lock pixels, if used elsewhere the ffxPow must be moved!
const FfxFloat32 fLockInputLuma = ffxPow(RGBToPerceivedLuma(fRgb), FfxFloat32(1.0 / 6.0));
return fLockInputLuma;
}
ReconstructPrevDepthOutputs ReconstructAndDilate(FfxInt32x2 iPxLrPos)
{
FfxFloat32 fDilatedDepth;
FfxInt32x2 iNearestDepthCoord;
FindNearestDepth(iPxLrPos, RenderSize(), fDilatedDepth, iNearestDepthCoord);
#if FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
FfxInt32x2 iSamplePos = iPxLrPos;
FfxInt32x2 iMotionVectorPos = iNearestDepthCoord;
#else
FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxLrPos);
FfxInt32x2 iMotionVectorPos = ComputeHrPosFromLrPos(iNearestDepthCoord);
#endif
FfxFloat32x2 fDilatedMotionVector = LoadInputMotionVector(iMotionVectorPos);
ReconstructPrevDepthOutputs results;
results.fDepth = fDilatedDepth;
results.fMotionVector = fDilatedMotionVector;
ReconstructPrevDepth(iPxLrPos, fDilatedDepth, fDilatedMotionVector, RenderSize());
FfxFloat32 fLockInputLuma = ComputeLockInputLuma(iPxLrPos);
results.fLuma = fLockInputLuma;
return results;
}
#endif //!defined( FFXM_FSR2_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reconstruct_dilated_velocity_and_previous_depth.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 5e29326796d407b41b4d8a450bbb8fac
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

390
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h

@ -0,0 +1,390 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_REPROJECT_H
#define FFXM_FSR2_REPROJECT_H
#if FFXM_HALF
FFXM_MIN16_F4 WrapHistory(FFXM_MIN16_I2 iPxSample)
{
return FFXM_MIN16_F4(LoadHistory(iPxSample));
}
FFXM_MIN16_F4 SampleHistory(FfxFloat32x2 fUV)
{
return SampleUpscaledHistory(fUV);
}
#else
FfxFloat32x4 WrapHistory(FfxInt32x2 iPxSample)
{
return LoadHistory(iPxSample);
}
FfxFloat32x4 SampleHistory(FfxFloat32x2 fUV)
{
return SampleUpscaledHistory(fUV);
}
#endif
#if FFXM_HALF
#define FFXM_FSR2_REPROJECT_CATMULL_9TAP 0
#define FFXM_FSR2_REPROJECT_LANCZOS_APPROX_9TAP 1
#define FFXM_FSR2_REPROJECT_CATMULL_5TAP 2
#if FFXM_SHADER_QUALITY_OPT_REPROJECT_CATMULL_5TAP
#define FFXM_FSR2_REPROJECT_MODE FFXM_FSR2_REPROJECT_CATMULL_5TAP
#elif FFXM_SHADER_QUALITY_OPT_REPROJECT_CATMULL_9TAP
#define FFXM_FSR2_REPROJECT_MODE FFXM_FSR2_REPROJECT_CATMULL_9TAP
#else // QUALITY
#define FFXM_FSR2_REPROJECT_MODE FFXM_FSR2_REPROJECT_CATMULL_9TAP
#endif
#if (FFXM_FSR2_REPROJECT_MODE == FFXM_FSR2_REPROJECT_CATMULL_9TAP)
struct CatmullRomSamples9Tap
{
// bilinear sampling UV coordinates of the samples
FfxFloat32x2 UV[3];
// weights of the samples
FFXM_MIN16_F2 Weight[3];
// final multiplier (it is faster to multiply 3 RGB values than reweights the 5 weights)
FFXM_MIN16_F FinalMultiplier;
};
CatmullRomSamples9Tap Get2DCatmullRom9Kernel(FfxFloat32x2 uv, FfxFloat32x2 size, in FfxFloat32x2 invSize)
{
CatmullRomSamples9Tap catmullSamples;
FfxFloat32x2 samplePos = uv * size;
FfxFloat32x2 texPos1 = floor(samplePos - 0.5f) + 0.5f;
FfxFloat32x2 f = samplePos - texPos1;
FfxFloat32x2 w0 = f * (-0.5f + f * (1.0f - 0.5f * f));
FfxFloat32x2 w1 = 1.0f + f * f * (-2.5f + 1.5f * f);
FfxFloat32x2 w2 = f * (0.5f + f * (2.0f - 1.5f * f));
FfxFloat32x2 w3 = f * f * (-0.5f + 0.5f * f);
catmullSamples.Weight[0] = FFXM_MIN16_F2(w0);
catmullSamples.Weight[1] = FFXM_MIN16_F2(w1 + w2);
catmullSamples.Weight[2] = FFXM_MIN16_F2(w3);
FfxFloat32x2 offset12 = w2 / (w1 + w2);
// Compute the final UV coordinates we'll use for sampling the texture
catmullSamples.UV[0] = FfxFloat32x2(texPos1 - 1);
catmullSamples.UV[1] = FfxFloat32x2(texPos1 + 2);
catmullSamples.UV[2] = FfxFloat32x2(texPos1 + offset12);
catmullSamples.UV[0] = FfxFloat32x2(catmullSamples.UV[0]*invSize);
catmullSamples.UV[1] = FfxFloat32x2(catmullSamples.UV[1]*invSize);
catmullSamples.UV[2] = FfxFloat32x2(catmullSamples.UV[2]*invSize);
return catmullSamples;
}
FFXM_MIN16_F4 HistorySample(FfxFloat32x2 fUvSample, FfxInt32x2 iTextureSize)
{
FfxFloat32x2 fPxSample = (fUvSample * FfxFloat32x2(iTextureSize)) - FfxFloat32x2(0.5f, 0.5f);
FfxFloat32x2 fTextureSize = FfxFloat32x2(iTextureSize);
FfxFloat32x2 fInvTextureSize = FfxFloat32x2(1.0f, 1.0f) / fTextureSize;
CatmullRomSamples9Tap samples = Get2DCatmullRom9Kernel(fUvSample, fTextureSize, fInvTextureSize);
FFXM_MIN16_F4 fColor = FFXM_MIN16_F4(0.0f, 0.0f, 0.0f, 0.0f);
FFXM_MIN16_F4 fColor00 = SampleHistory(FfxFloat32x2(samples.UV[0]));
fColor += fColor00 * samples.Weight[0].x * samples.Weight[0].y;
FFXM_MIN16_F4 fColor20 = SampleHistory(FfxFloat32x2(samples.UV[2].x, samples.UV[0].y));
fColor += fColor20 * samples.Weight[1].x * samples.Weight[0].y;
fColor += SampleHistory(FfxFloat32x2(samples.UV[1].x, samples.UV[0].y)) * samples.Weight[2].x * samples.Weight[0].y;
FFXM_MIN16_F4 fColor02 = SampleHistory(FfxFloat32x2(samples.UV[0].x, samples.UV[2].y));
fColor += SampleHistory(FfxFloat32x2(samples.UV[0].x, samples.UV[2].y)) * samples.Weight[0].x * samples.Weight[1].y;
FFXM_MIN16_F4 fColor22 = SampleHistory(FfxFloat32x2(samples.UV[2]));
fColor += fColor22 * samples.Weight[1].x * samples.Weight[1].y;
fColor += SampleHistory(FfxFloat32x2(samples.UV[1].x, samples.UV[2].y)) * samples.Weight[2].x * samples.Weight[1].y;
fColor += SampleHistory(FfxFloat32x2(samples.UV[0].x, samples.UV[1].y)) * samples.Weight[0].x * samples.Weight[2].y;
fColor += SampleHistory(FfxFloat32x2(samples.UV[2].x, samples.UV[1].y)) * samples.Weight[1].x * samples.Weight[2].y;
fColor += SampleHistory(FfxFloat32x2(samples.UV[1])) * samples.Weight[2].x * samples.Weight[2].y;
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
const FFXM_MIN16_F4 fDeringingSamples[4] = {fColor00, fColor20, fColor02, fColor22};
FFXM_MIN16_F4 fDeringingMin = fDeringingSamples[0];
FFXM_MIN16_F4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < 4; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColor = clamp(fColor, fDeringingMin, fDeringingMax);
#endif
return fColor;
}
#elif (FFXM_FSR2_REPROJECT_MODE == FFXM_FSR2_REPROJECT_CATMULL_5TAP)
#define ARM_CATMULL_5TAP_SAMPLE_COUNT 5
struct CatmullRomSamples
{
// bilinear sampling UV coordinates of the samples
FfxFloat32x2 UV[ARM_CATMULL_5TAP_SAMPLE_COUNT];
// weights of the samples
FFXM_MIN16_F Weight[ARM_CATMULL_5TAP_SAMPLE_COUNT];
// final multiplier (it is faster to multiply 3 RGB values than reweights the 5 weights)
FFXM_MIN16_F FinalMultiplier;
};
void Bicubic2DCatmullRom(in FfxFloat32x2 uv, in FfxFloat32x2 size, in FfxFloat32x2 invSize, FFXM_PARAMETER_OUT FfxFloat32x2 samples[3], FFXM_PARAMETER_OUT FfxFloat32x2 weights[3])
{
uv *= size;
FfxFloat32x2 tc = floor(uv - 0.5) + 0.5;
FfxFloat32x2 f = uv - tc;
FfxFloat32x2 f2 = f * f;
FfxFloat32x2 f3 = f2 * f;
FfxFloat32x2 w0 = f2 - 0.5 * (f3 + f);
FfxFloat32x2 w1 = 1.5 * f3 - 2.5 * f2 + 1.f;
FfxFloat32x2 w3 = 0.5 * (f3 - f2);
FfxFloat32x2 w2 = 1.f - w0 - w1 - w3;
samples[0] = tc - 1.f;
samples[1] = tc + w2 / (w1 + w2);
samples[2] = tc + 2.f;
samples[0] *= invSize;
samples[1] *= invSize;
samples[2] *= invSize;
weights[0] = w0;
weights[1] = w1 + w2;
weights[2] = w3;
}
CatmullRomSamples GetBicubic2DCatmullRomSamples(FfxFloat32x2 uv, FfxFloat32x2 size, in FfxFloat32x2 invSize)
{
FfxFloat32x2 weights[3];
FfxFloat32x2 samples[3];
Bicubic2DCatmullRom(uv, size, invSize, samples, weights);
CatmullRomSamples crSamples;
// optimized by removing corner samples
crSamples.UV[0] = FfxFloat32x2(samples[1].x, samples[0].y);
crSamples.UV[1] = FfxFloat32x2(samples[0].x, samples[1].y);
crSamples.UV[2] = FfxFloat32x2(samples[1].x, samples[1].y);
crSamples.UV[3] = FfxFloat32x2(samples[2].x, samples[1].y);
crSamples.UV[4] = FfxFloat32x2(samples[1].x, samples[2].y);
crSamples.Weight[0] = FFXM_MIN16_F(weights[1].x * weights[0].y);
crSamples.Weight[1] = FFXM_MIN16_F(weights[0].x * weights[1].y);
crSamples.Weight[2] = FFXM_MIN16_F(weights[1].x * weights[1].y);
crSamples.Weight[3] = FFXM_MIN16_F(weights[2].x * weights[1].y);
crSamples.Weight[4] = FFXM_MIN16_F(weights[1].x * weights[2].y);
// reweight after removing the corners
FFXM_MIN16_F cornerWeights;
cornerWeights = crSamples.Weight[0];
cornerWeights += crSamples.Weight[1];
cornerWeights += crSamples.Weight[2];
cornerWeights += crSamples.Weight[3];
cornerWeights += crSamples.Weight[4];
crSamples.FinalMultiplier = FFXM_MIN16_F(1.f / cornerWeights);
return crSamples;
}
FFXM_MIN16_F4 HistorySample(FfxFloat32x2 fUvSample, FfxInt32x2 iTextureSize)
{
FfxFloat32x2 fTextureSize = FfxFloat32x2(iTextureSize);
FfxFloat32x2 fInvTextureSize = FfxFloat32x2(1.0f, 1.0f) / fTextureSize;
CatmullRomSamples samples = GetBicubic2DCatmullRomSamples(fUvSample, fTextureSize, fInvTextureSize);
FFXM_MIN16_F4 fColor = FFXM_MIN16_F4(0.0f, 0.0f, 0.0f, 0.0f);
fColor = SampleHistory(FfxFloat32x2(samples.UV[0])) * samples.Weight[0];
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
FFXM_MIN16_F4 fDeringingMin = fColor;
FFXM_MIN16_F4 fDeringingMax = fColor;
#endif
for(FfxInt32 iSampleIndex = 1; iSampleIndex < ARM_CATMULL_5TAP_SAMPLE_COUNT; iSampleIndex++)
{
FFXM_MIN16_F4 fSample = SampleHistory(FfxFloat32x2(samples.UV[iSampleIndex])) * samples.Weight[iSampleIndex];
fColor += fSample;
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
fDeringingMin = ffxMin(fDeringingMin, fSample);
fDeringingMax = ffxMax(fDeringingMax, fSample);
#endif
}
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
fColor = clamp(fColor, fDeringingMin, fDeringingMax);
#endif
return fColor;
}
#elif (FFXM_FSR2_REPROJECT_MODE == FFXM_FSR2_REPROJECT_LANCZOS_APPROX_9TAP)
Fetched9TapSamplesMin16 FetchHistorySamples(FfxInt32x2 iPxSample, FfxInt32x2 iTextureSize)
{
Fetched9TapSamplesMin16 Samples;
FfxFloat32x2 iSrcInputUv = FfxFloat32x2(iPxSample) / FfxFloat32x2(iTextureSize);
FfxFloat32x2 unitOffsetUv = FfxFloat32x2(1.0f, 1.0f) / FfxFloat32x2(iTextureSize);
// Collect samples
GatherHistoryColorRGBQuad(FfxFloat32x2(-0.5, -0.5) * unitOffsetUv + iSrcInputUv,
Samples.fColor00, Samples.fColor10, Samples.fColor01, Samples.fColor11);
Samples.fColor20 = WrapHistory(FfxFloat32x2(1, -1) + iPxSample);
Samples.fColor21 = WrapHistory(FfxFloat32x2(1, 0) + iPxSample);
Samples.fColor02 = WrapHistory(FfxFloat32x2(-1, 1) + iPxSample);
Samples.fColor12 = WrapHistory(FfxFloat32x2(0, 1) + iPxSample);
Samples.fColor22 = WrapHistory(FfxFloat32x2(1, 1) + iPxSample);
return Samples;
}
//DeclareCustomFetch9TapSamplesMin16(FetchHistorySamples, WrapHistory)
DeclareCustomTextureSampleMin16(HistorySample, Lanczos2Approx, FetchHistorySamples)
#endif // FFXM_FSR2_REPROJECT_MODE
#else // !FFXM_HALF
#ifndef FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE
#define FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE 0 // Reference
#endif
DeclareCustomFetchBicubicSamples(FetchHistorySamples, WrapHistory)
DeclareCustomTextureSample(HistorySample, FFXM_FSR2_GET_LANCZOS_SAMPLER1D(FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE), FetchHistorySamples)
#endif
FfxFloat32x4 WrapLockStatus(FfxInt32x2 iPxSample)
{
FfxFloat32x4 fSample = FfxFloat32x4(LoadLockStatus(iPxSample), 0.0f, 0.0f);
return fSample;
}
#if FFXM_HALF
FFXM_MIN16_F4 WrapLockStatus(FFXM_MIN16_I2 iPxSample)
{
FFXM_MIN16_F4 fSample = FFXM_MIN16_F4(LoadLockStatus(iPxSample), 0.0, 0.0);
return fSample;
}
#endif
#if FFXM_HALF
DeclareCustomFetchBilinearSamplesMin16(FetchLockStatusSamples, WrapLockStatus)
DeclareCustomTextureSampleMin16(LockStatusSample, Bilinear, FetchLockStatusSamples)
#else
DeclareCustomFetchBilinearSamples(FetchLockStatusSamples, WrapLockStatus)
DeclareCustomTextureSample(LockStatusSample, Bilinear, FetchLockStatusSamples)
#endif
FfxFloat32x2 GetMotionVector(FfxInt32x2 iPxHrPos, FfxFloat32x2 fHrUv)
{
#if FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
FfxFloat32x2 fDilatedMotionVector = LoadDilatedMotionVector(FfxInt32x2(fHrUv * RenderSize()));
#else
FfxFloat32x2 fDilatedMotionVector = LoadInputMotionVector(iPxHrPos);
#endif
return fDilatedMotionVector;
}
FfxBoolean IsUvInside(FfxFloat32x2 fUv)
{
return (fUv.x >= 0.0f && fUv.x <= 1.0f) && (fUv.y >= 0.0f && fUv.y <= 1.0f);
}
void ComputeReprojectedUVs(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat32x2 fReprojectedHrUv, FFXM_PARAMETER_OUT FfxBoolean bIsExistingSample)
{
fReprojectedHrUv = params.fHrUv + params.fMotionVector;
bIsExistingSample = IsUvInside(fReprojectedHrUv);
}
#if !FFXM_HALF
void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat32x3 fHistoryColor, FFXM_PARAMETER_OUT FfxFloat32 fTemporalReactiveFactor, FFXM_PARAMETER_OUT FfxBoolean bInMotionLastFrame)
{
FfxFloat32x4 fHistory = HistorySample(params.fReprojectedHrUv, DisplaySize());
fHistoryColor = PrepareRgb(fHistory.rgb, Exposure(), PreviousFramePreExposure());
#if !FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
fHistoryColor = RGBToYCoCg(fHistoryColor);
#endif
//Compute temporal reactivity info
#if FFXM_SHADER_QUALITY_OPT_SEPARATE_TEMPORAL_REACTIVE
fTemporalReactiveFactor = ffxSaturate(abs(SampleTemporalReactive(params.fReprojectedHrUv)));
#else
fTemporalReactiveFactor = ffxSaturate(abs(fHistory.w));
#endif
bInMotionLastFrame = (fHistory.w < 0.0f);
}
LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat32x2 fReprojectedLockStatus)
{
LockState state = { FFXM_FALSE, FFXM_FALSE };
const FfxFloat32 fNewLockIntensity = LoadNewLocks(params.iPxHrPos);
state.NewLock = fNewLockIntensity > (127.0f / 255.0f);
FfxFloat32 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : 0;
fReprojectedLockStatus = SampleLockStatus(params.fReprojectedHrUv);
if (fReprojectedLockStatus[LOCK_LIFETIME_REMAINING] != FfxFloat32(0.0f)) {
state.WasLockedPrevFrame = true;
}
return state;
}
#else //FFXM_HALF
void ReprojectHistoryColor(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat16x3 fHistoryColor, FFXM_PARAMETER_OUT FfxFloat16 fTemporalReactiveFactor, FFXM_PARAMETER_OUT FfxBoolean bInMotionLastFrame)
{
FfxFloat16x4 fHistory = HistorySample(params.fReprojectedHrUv, DisplaySize());
fHistoryColor = FfxFloat16x3(PrepareRgb(fHistory.rgb, Exposure(), PreviousFramePreExposure()));
#if !FFXM_SHADER_QUALITY_OPT_TONEMAPPED_RGB_PREPARED_INPUT_COLOR
fHistoryColor = RGBToYCoCg(fHistoryColor);
#endif
//Compute temporal reactivity info
#if FFXM_SHADER_QUALITY_OPT_SEPARATE_TEMPORAL_REACTIVE
fTemporalReactiveFactor = FfxFloat16(ffxSaturate(abs(SampleTemporalReactive(params.fReprojectedHrUv))));
#else
fTemporalReactiveFactor = FfxFloat16(ffxSaturate(abs(fHistory.w)));
#endif
bInMotionLastFrame = (fHistory.w < 0.0f);
}
LockState ReprojectHistoryLockStatus(const AccumulationPassCommonParams params, FFXM_PARAMETER_OUT FfxFloat16x2 fReprojectedLockStatus)
{
LockState state = { FFXM_FALSE, FFXM_FALSE };
const FfxFloat16 fNewLockIntensity = FfxFloat16(LoadNewLocks(params.iPxHrPos));
state.NewLock = fNewLockIntensity > (127.0f / 255.0f);
FfxFloat16 fInPlaceLockLifetime = state.NewLock ? fNewLockIntensity : FfxFloat16(0);
fReprojectedLockStatus = FfxFloat16x2(SampleLockStatus(params.fReprojectedHrUv));
if (fReprojectedLockStatus[LOCK_LIFETIME_REMAINING] != FfxFloat16(0.0f)) {
state.WasLockedPrevFrame = true;
}
return state;
}
#endif
#endif //!defined( FFXM_FSR2_REPROJECT_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_reproject.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: b997a83902840b04fbecef298bd4b620
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

100
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_resources.h

@ -0,0 +1,100 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_RESOURCES_H
#define FFXM_FSR2_RESOURCES_H
#if defined(FFXM_CPU) || defined(FFXM_GPU)
#define FFXM_FSR2_RESOURCE_IDENTIFIER_NULL 0
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_OPAQUE_ONLY 1
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_COLOR 2
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_MOTION_VECTORS 3
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_DEPTH 4
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_EXPOSURE 5
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_REACTIVE_MASK 6
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INPUT_TRANSPARENCY_AND_COMPOSITION_MASK 7
#define FFXM_FSR2_RESOURCE_IDENTIFIER_RECONSTRUCTED_PREVIOUS_NEAREST_DEPTH 8
#define FFXM_FSR2_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 9
#define FFXM_FSR2_RESOURCE_IDENTIFIER_DILATED_DEPTH 10
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR 11
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS 12
#define FFXM_FSR2_RESOURCE_IDENTIFIER_NEW_LOCKS 13
#define FFXM_FSR2_RESOURCE_IDENTIFIER_PREPARED_INPUT_COLOR 14
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY 15
#define FFXM_FSR2_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 16
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LANCZOS_LUT 17
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SPD_ATOMIC_COUNT 18
#define FFXM_FSR2_RESOURCE_IDENTIFIER_UPSCALED_OUTPUT 19
#define FFXM_FSR2_RESOURCE_IDENTIFIER_RCAS_INPUT 20
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_1 21
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LOCK_STATUS_2 22
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_1 23
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_UPSCALED_COLOR_2 24
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_REACTIVITY 25
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_TRANSPARENCY_AND_COMPOSITION 26
#define FFXM_FSR2_RESOURCE_IDENTITIER_UPSAMPLE_MAXIMUM_BIAS_LUT 27
#define FFXM_FSR2_RESOURCE_IDENTIFIER_DILATED_REACTIVE_MASKS 28
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE 29 // same as FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0 29
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_1 30
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_2 31
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_3 32
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4 33
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_5 34
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_6 35
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_7 36
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_8 37
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_9 38
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_10 39
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_11 40
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12 41
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DEFAULT_EXPOSURE 42
#define FFXM_FSR2_RESOURCE_IDENTIFIER_AUTO_EXPOSURE 43
#define FFXM_FSR2_RESOURCE_IDENTIFIER_AUTOREACTIVE 44
#define FFXM_FSR2_RESOURCE_IDENTIFIER_PREVIOUS_DILATED_MOTION_VECTORS 45
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_1 46
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_DILATED_MOTION_VECTORS_2 47
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_1 48
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LUMA_HISTORY_2 49
#define FFXM_FSR2_RESOURCE_IDENTIFIER_LOCK_INPUT_LUMA 50
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_TEMPORAL_REACTIVE 51
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_TEMPORAL_REACTIVE_1 52
#define FFXM_FSR2_RESOURCE_IDENTIFIER_INTERNAL_TEMPORAL_REACTIVE_2 53
// Shading change detection mip level setting, value must be in the range [FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_0, FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_12]
#define FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_4
#define FFXM_FSR2_SHADING_CHANGE_MIP_LEVEL (FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE_MIPMAP_SHADING_CHANGE - FFXM_FSR2_RESOURCE_IDENTIFIER_SCENE_LUMINANCE)
#define FFXM_FSR2_RESOURCE_IDENTIFIER_COUNT 54
#define FFXM_FSR2_CONSTANTBUFFER_IDENTIFIER_FSR2 0
#define FFXM_FSR2_CONSTANTBUFFER_IDENTIFIER_SPD 1
#define FFXM_FSR2_CONSTANTBUFFER_IDENTIFIER_RCAS 2
#define FFXM_FSR2_CONSTANTBUFFER_IDENTIFIER_GENREACTIVE 3
#define FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_TONEMAP 1
#define FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP 2
#define FFXM_FSR2_AUTOREACTIVEFLAGS_APPLY_THRESHOLD 4
#define FFXM_FSR2_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX 8
#endif // #if defined(FFXM_CPU) || defined(FFXM_GPU)
#endif //!defined( FFXM_FSR2_RESOURCES_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_resources.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 80c7963a01a0e5c4bb69e6b897267a9b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

699
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_sample.h

@ -0,0 +1,699 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_SAMPLE_H
#define FFXM_FSR2_SAMPLE_H
// suppress warnings
#ifdef FFXM_HLSL
#pragma warning(disable: 4008) // potentially divide by zero
#endif //FFXM_HLSL
struct FetchedBilinearSamples {
FfxFloat32x4 fColor00;
FfxFloat32x4 fColor10;
FfxFloat32x4 fColor01;
FfxFloat32x4 fColor11;
};
struct FetchedBicubicSamples {
FfxFloat32x4 fColor00;
FfxFloat32x4 fColor10;
FfxFloat32x4 fColor20;
FfxFloat32x4 fColor30;
FfxFloat32x4 fColor01;
FfxFloat32x4 fColor11;
FfxFloat32x4 fColor21;
FfxFloat32x4 fColor31;
FfxFloat32x4 fColor02;
FfxFloat32x4 fColor12;
FfxFloat32x4 fColor22;
FfxFloat32x4 fColor32;
FfxFloat32x4 fColor03;
FfxFloat32x4 fColor13;
FfxFloat32x4 fColor23;
FfxFloat32x4 fColor33;
};
#if FFXM_HALF
struct FetchedBilinearSamplesMin16 {
FFXM_MIN16_F4 fColor00;
FFXM_MIN16_F4 fColor10;
FFXM_MIN16_F4 fColor01;
FFXM_MIN16_F4 fColor11;
};
struct FetchedBicubicSamplesMin16 {
FFXM_MIN16_F4 fColor00;
FFXM_MIN16_F4 fColor10;
FFXM_MIN16_F4 fColor20;
FFXM_MIN16_F4 fColor30;
FFXM_MIN16_F4 fColor01;
FFXM_MIN16_F4 fColor11;
FFXM_MIN16_F4 fColor21;
FFXM_MIN16_F4 fColor31;
FFXM_MIN16_F4 fColor02;
FFXM_MIN16_F4 fColor12;
FFXM_MIN16_F4 fColor22;
FFXM_MIN16_F4 fColor32;
FFXM_MIN16_F4 fColor03;
FFXM_MIN16_F4 fColor13;
FFXM_MIN16_F4 fColor23;
FFXM_MIN16_F4 fColor33;
};
struct Fetched9TapSamplesMin16 {
FFXM_MIN16_F4 fColor00;
FFXM_MIN16_F4 fColor10;
FFXM_MIN16_F4 fColor20;
FFXM_MIN16_F4 fColor01;
FFXM_MIN16_F4 fColor11;
FFXM_MIN16_F4 fColor21;
FFXM_MIN16_F4 fColor02;
FFXM_MIN16_F4 fColor12;
FFXM_MIN16_F4 fColor22;
};
#else //FFXM_HALF
#define FetchedBicubicSamplesMin16 FetchedBicubicSamples
#define FetchedBilinearSamplesMin16 FetchedBilinearSamples
#endif //FFXM_HALF
FfxFloat32x4 Linear(FfxFloat32x4 A, FfxFloat32x4 B, FfxFloat32 t)
{
return A + (B - A) * t;
}
FfxFloat32x4 Bilinear(FetchedBilinearSamples BilinearSamples, FfxFloat32x2 fPxFrac)
{
FfxFloat32x4 fColorX0 = Linear(BilinearSamples.fColor00, BilinearSamples.fColor10, fPxFrac.x);
FfxFloat32x4 fColorX1 = Linear(BilinearSamples.fColor01, BilinearSamples.fColor11, fPxFrac.x);
FfxFloat32x4 fColorXY = Linear(fColorX0, fColorX1, fPxFrac.y);
return fColorXY;
}
#if FFXM_HALF
FFXM_MIN16_F4 Linear(FFXM_MIN16_F4 A, FFXM_MIN16_F4 B, FFXM_MIN16_F t)
{
return A + (B - A) * t;
}
FFXM_MIN16_F4 Bilinear(FetchedBilinearSamplesMin16 BilinearSamples, FFXM_MIN16_F2 fPxFrac)
{
FFXM_MIN16_F4 fColorX0 = Linear(BilinearSamples.fColor00, BilinearSamples.fColor10, fPxFrac.x);
FFXM_MIN16_F4 fColorX1 = Linear(BilinearSamples.fColor01, BilinearSamples.fColor11, fPxFrac.x);
FFXM_MIN16_F4 fColorXY = Linear(fColorX0, fColorX1, fPxFrac.y);
return fColorXY;
}
#endif
FfxFloat32 Lanczos2NoClamp(FfxFloat32 x)
{
const FfxFloat32 PI = 3.141592653589793f; // TODO: share SDK constants
return abs(x) < FSR2_EPSILON ? 1.f : (sin(PI * x) / (PI * x)) * (sin(0.5f * PI * x) / (0.5f * PI * x));
}
FfxFloat32 Lanczos2(FfxFloat32 x)
{
x = ffxMin(abs(x), 2.0f);
return Lanczos2NoClamp(x);
}
#if FFXM_HALF
#if 1
FFXM_MIN16_F Lanczos2NoClamp(FFXM_MIN16_F x)
{
const FFXM_MIN16_F PI = FFXM_MIN16_F(3.141592653589793f); // TODO: share SDK constants
return abs(x) < FFXM_MIN16_F(FSR2_EPSILON) ? FFXM_MIN16_F(1.f) : (sin(PI * x) / (PI * x)) * (sin(FFXM_MIN16_F(0.5f) * PI * x) / (FFXM_MIN16_F(0.5f) * PI * x));
}
#endif
FFXM_MIN16_F Lanczos2(FFXM_MIN16_F x)
{
x = ffxMin(abs(x), FFXM_MIN16_F(2.0f));
return FFXM_MIN16_F(Lanczos2NoClamp(x));
}
#endif //FFXM_HALF
// FSR1 lanczos approximation. Input is x*x and must be <= 4.
FfxFloat32 Lanczos2ApproxSqNoClamp(FfxFloat32 x2)
{
FfxFloat32 a = (2.0f / 5.0f) * x2 - 1;
FfxFloat32 b = (1.0f / 4.0f) * x2 - 1;
return ((25.0f / 16.0f) * a * a - (25.0f / 16.0f - 1)) * (b * b);
}
#if FFXM_HALF
FFXM_MIN16_F Lanczos2ApproxSqNoClamp(FFXM_MIN16_F x2)
{
FFXM_MIN16_F a = FFXM_MIN16_F(2.0f / 5.0f) * x2 - FFXM_MIN16_F(1);
FFXM_MIN16_F b = FFXM_MIN16_F(1.0f / 4.0f) * x2 - FFXM_MIN16_F(1);
return (FFXM_MIN16_F(25.0f / 16.0f) * a * a - FFXM_MIN16_F(25.0f / 16.0f - 1)) * (b * b);
}
#endif //FFXM_HALF
FfxFloat32 Lanczos2ApproxSq(FfxFloat32 x2)
{
x2 = ffxMin(x2, 4.0f);
return Lanczos2ApproxSqNoClamp(x2);
}
#if FFXM_HALF
FFXM_MIN16_F Lanczos2ApproxSq(FFXM_MIN16_F x2)
{
x2 = ffxMin(x2, FFXM_MIN16_F(4.0f));
return Lanczos2ApproxSqNoClamp(x2);
}
#endif //FFXM_HALF
FfxFloat32 Lanczos2ApproxNoClamp(FfxFloat32 x)
{
return Lanczos2ApproxSqNoClamp(x * x);
}
#if FFXM_HALF
FFXM_MIN16_F Lanczos2ApproxNoClamp(FFXM_MIN16_F x)
{
return Lanczos2ApproxSqNoClamp(x * x);
}
#endif //FFXM_HALF
FfxFloat32 Lanczos2Approx(FfxFloat32 x)
{
return Lanczos2ApproxSq(x * x);
}
#if FFXM_HALF
FFXM_MIN16_F Lanczos2Approx(FFXM_MIN16_F x)
{
return Lanczos2ApproxSq(x * x);
}
#endif //FFXM_HALF
FfxFloat32 Lanczos2_UseLUT(FfxFloat32 x)
{
return SampleLanczos2Weight(abs(x));
}
#if FFXM_HALF
FFXM_MIN16_F Lanczos2_UseLUT(FFXM_MIN16_F x)
{
return FFXM_MIN16_F(SampleLanczos2Weight(abs(x)));
}
#endif //FFXM_HALF
FfxFloat32x4 Lanczos2_UseLUT(FfxFloat32x4 fColor0, FfxFloat32x4 fColor1, FfxFloat32x4 fColor2, FfxFloat32x4 fColor3, FfxFloat32 t)
{
FfxFloat32 fWeight0 = Lanczos2_UseLUT(-1.f - t);
FfxFloat32 fWeight1 = Lanczos2_UseLUT(-0.f - t);
FfxFloat32 fWeight2 = Lanczos2_UseLUT(+1.f - t);
FfxFloat32 fWeight3 = Lanczos2_UseLUT(+2.f - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
#if FFXM_HALF
FFXM_MIN16_F4 Lanczos2_UseLUT(FFXM_MIN16_F4 fColor0, FFXM_MIN16_F4 fColor1, FFXM_MIN16_F4 fColor2, FFXM_MIN16_F4 fColor3, FFXM_MIN16_F t)
{
FFXM_MIN16_F fWeight0 = Lanczos2_UseLUT(FFXM_MIN16_F(-1.f) - t);
FFXM_MIN16_F fWeight1 = Lanczos2_UseLUT(FFXM_MIN16_F(-0.f) - t);
FFXM_MIN16_F fWeight2 = Lanczos2_UseLUT(FFXM_MIN16_F(+1.f) - t);
FFXM_MIN16_F fWeight3 = Lanczos2_UseLUT(FFXM_MIN16_F(+2.f) - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
#endif
FfxFloat32x4 Lanczos2(FfxFloat32x4 fColor0, FfxFloat32x4 fColor1, FfxFloat32x4 fColor2, FfxFloat32x4 fColor3, FfxFloat32 t)
{
FfxFloat32 fWeight0 = Lanczos2(-1.f - t);
FfxFloat32 fWeight1 = Lanczos2(-0.f - t);
FfxFloat32 fWeight2 = Lanczos2(+1.f - t);
FfxFloat32 fWeight3 = Lanczos2(+2.f - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
FfxFloat32x4 Lanczos2(FetchedBicubicSamples Samples, FfxFloat32x2 fPxFrac)
{
FfxFloat32x4 fColorX0 = Lanczos2(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FfxFloat32x4 fColorX1 = Lanczos2(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FfxFloat32x4 fColorX2 = Lanczos2(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FfxFloat32x4 fColorX3 = Lanczos2(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FfxFloat32x4 fColorXY = Lanczos2(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FfxFloat32x4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FfxFloat32x4 fDeringingMin = fDeringingSamples[0];
FfxFloat32x4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex) {
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#if FFXM_HALF
FFXM_MIN16_F4 Lanczos2(FFXM_MIN16_F4 fColor0, FFXM_MIN16_F4 fColor1, FFXM_MIN16_F4 fColor2, FFXM_MIN16_F4 fColor3, FFXM_MIN16_F t)
{
FFXM_MIN16_F fWeight0 = Lanczos2(FFXM_MIN16_F(-1.f) - t);
FFXM_MIN16_F fWeight1 = Lanczos2(FFXM_MIN16_F(-0.f) - t);
FFXM_MIN16_F fWeight2 = Lanczos2(FFXM_MIN16_F(+1.f) - t);
FFXM_MIN16_F fWeight3 = Lanczos2(FFXM_MIN16_F(+2.f) - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
FFXM_MIN16_F4 Lanczos2(FetchedBicubicSamplesMin16 Samples, FFXM_MIN16_F2 fPxFrac)
{
FFXM_MIN16_F4 fColorX0 = Lanczos2(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FFXM_MIN16_F4 fColorX1 = Lanczos2(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FFXM_MIN16_F4 fColorX2 = Lanczos2(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FFXM_MIN16_F4 fColorX3 = Lanczos2(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FFXM_MIN16_F4 fColorXY = Lanczos2(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FFXM_MIN16_F4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FFXM_MIN16_F4 fDeringingMin = fDeringingSamples[0];
FFXM_MIN16_F4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
FFXM_MIN16_F4 Lanczos2(FFXM_MIN16_F4 fColor0, FFXM_MIN16_F4 fColor1, FFXM_MIN16_F4 fColor2, FFXM_MIN16_F t)
{
FFXM_MIN16_F fWeight0 = Lanczos2(FFXM_MIN16_F(-1.f) - t);
FFXM_MIN16_F fWeight1 = Lanczos2(FFXM_MIN16_F(-0.f) - t);
FFXM_MIN16_F fWeight2 = Lanczos2(FFXM_MIN16_F(+1.f) - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2) / (fWeight0 + fWeight1 + fWeight2);
}
FFXM_MIN16_F4 Lanczos2Approx(FFXM_MIN16_F4 fColor0, FFXM_MIN16_F4 fColor1, FFXM_MIN16_F4 fColor2, FFXM_MIN16_F t)
{
FFXM_MIN16_F fWeight0 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(-1.f) - t);
FFXM_MIN16_F fWeight1 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(-0.f) - t);
FFXM_MIN16_F fWeight2 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(+1.f) - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2) / (fWeight0 + fWeight1 + fWeight2);
}
FFXM_MIN16_F4 Lanczos2Approx(Fetched9TapSamplesMin16 Samples, FFXM_MIN16_F2 fPxFrac)
{
FFXM_MIN16_F4 fColorX0 = Lanczos2Approx(Samples.fColor00, Samples.fColor10, Samples.fColor20, fPxFrac.x);
FFXM_MIN16_F4 fColorX1 = Lanczos2Approx(Samples.fColor01, Samples.fColor11, Samples.fColor21, fPxFrac.x);
FFXM_MIN16_F4 fColorX2 = Lanczos2Approx(Samples.fColor02, Samples.fColor12, Samples.fColor22, fPxFrac.x);
FFXM_MIN16_F4 fColorXY = Lanczos2Approx(fColorX0, fColorX1, fColorX2, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
const FfxInt32 iDeringingSampleCount = 4;
const FFXM_MIN16_F4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FFXM_MIN16_F4 fDeringingMin = fDeringingSamples[0];
FFXM_MIN16_F4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#endif //FFXM_HALF
FfxFloat32x4 Lanczos2LUT(FetchedBicubicSamples Samples, FfxFloat32x2 fPxFrac)
{
FfxFloat32x4 fColorX0 = Lanczos2_UseLUT(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FfxFloat32x4 fColorX1 = Lanczos2_UseLUT(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FfxFloat32x4 fColorX2 = Lanczos2_UseLUT(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FfxFloat32x4 fColorX3 = Lanczos2_UseLUT(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FfxFloat32x4 fColorXY = Lanczos2_UseLUT(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FfxFloat32x4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FfxFloat32x4 fDeringingMin = fDeringingSamples[0];
FfxFloat32x4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex) {
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#if FFXM_HALF
FFXM_MIN16_F4 Lanczos2LUT(FetchedBicubicSamplesMin16 Samples, FFXM_MIN16_F2 fPxFrac)
{
FFXM_MIN16_F4 fColorX0 = Lanczos2_UseLUT(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FFXM_MIN16_F4 fColorX1 = Lanczos2_UseLUT(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FFXM_MIN16_F4 fColorX2 = Lanczos2_UseLUT(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FFXM_MIN16_F4 fColorX3 = Lanczos2_UseLUT(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FFXM_MIN16_F4 fColorXY = Lanczos2_UseLUT(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FFXM_MIN16_F4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FFXM_MIN16_F4 fDeringingMin = fDeringingSamples[0];
FFXM_MIN16_F4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#endif //FFXM_HALF
FfxFloat32x4 Lanczos2Approx(FfxFloat32x4 fColor0, FfxFloat32x4 fColor1, FfxFloat32x4 fColor2, FfxFloat32x4 fColor3, FfxFloat32 t)
{
FfxFloat32 fWeight0 = Lanczos2ApproxNoClamp(-1.f - t);
FfxFloat32 fWeight1 = Lanczos2ApproxNoClamp(-0.f - t);
FfxFloat32 fWeight2 = Lanczos2ApproxNoClamp(+1.f - t);
FfxFloat32 fWeight3 = Lanczos2ApproxNoClamp(+2.f - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
#if FFXM_HALF
FFXM_MIN16_F4 Lanczos2Approx(FFXM_MIN16_F4 fColor0, FFXM_MIN16_F4 fColor1, FFXM_MIN16_F4 fColor2, FFXM_MIN16_F4 fColor3, FFXM_MIN16_F t)
{
FFXM_MIN16_F fWeight0 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(-1.f) - t);
FFXM_MIN16_F fWeight1 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(-0.f) - t);
FFXM_MIN16_F fWeight2 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(+1.f) - t);
FFXM_MIN16_F fWeight3 = Lanczos2ApproxNoClamp(FFXM_MIN16_F(+2.f) - t);
return (fWeight0 * fColor0 + fWeight1 * fColor1 + fWeight2 * fColor2 + fWeight3 * fColor3) / (fWeight0 + fWeight1 + fWeight2 + fWeight3);
}
#endif //FFXM_HALF
FfxFloat32x4 Lanczos2Approx(FetchedBicubicSamples Samples, FfxFloat32x2 fPxFrac)
{
FfxFloat32x4 fColorX0 = Lanczos2Approx(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FfxFloat32x4 fColorX1 = Lanczos2Approx(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FfxFloat32x4 fColorX2 = Lanczos2Approx(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FfxFloat32x4 fColorX3 = Lanczos2Approx(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FfxFloat32x4 fColorXY = Lanczos2Approx(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FfxFloat32x4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FfxFloat32x4 fDeringingMin = fDeringingSamples[0];
FfxFloat32x4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#if FFXM_HALF
FFXM_MIN16_F4 Lanczos2Approx(FetchedBicubicSamplesMin16 Samples, FFXM_MIN16_F2 fPxFrac)
{
FFXM_MIN16_F4 fColorX0 = Lanczos2Approx(Samples.fColor00, Samples.fColor10, Samples.fColor20, Samples.fColor30, fPxFrac.x);
FFXM_MIN16_F4 fColorX1 = Lanczos2Approx(Samples.fColor01, Samples.fColor11, Samples.fColor21, Samples.fColor31, fPxFrac.x);
FFXM_MIN16_F4 fColorX2 = Lanczos2Approx(Samples.fColor02, Samples.fColor12, Samples.fColor22, Samples.fColor32, fPxFrac.x);
FFXM_MIN16_F4 fColorX3 = Lanczos2Approx(Samples.fColor03, Samples.fColor13, Samples.fColor23, Samples.fColor33, fPxFrac.x);
FFXM_MIN16_F4 fColorXY = Lanczos2Approx(fColorX0, fColorX1, fColorX2, fColorX3, fPxFrac.y);
#if !FFXM_SHADER_QUALITY_OPT_DISABLE_DERINGING
// Deringing
// TODO: only use 4 by checking jitter
const FfxInt32 iDeringingSampleCount = 4;
const FFXM_MIN16_F4 fDeringingSamples[4] = {
Samples.fColor11,
Samples.fColor21,
Samples.fColor12,
Samples.fColor22,
};
FFXM_MIN16_F4 fDeringingMin = fDeringingSamples[0];
FFXM_MIN16_F4 fDeringingMax = fDeringingSamples[0];
FFXM_UNROLL
for (FfxInt32 iSampleIndex = 1; iSampleIndex < iDeringingSampleCount; ++iSampleIndex)
{
fDeringingMin = ffxMin(fDeringingMin, fDeringingSamples[iSampleIndex]);
fDeringingMax = ffxMax(fDeringingMax, fDeringingSamples[iSampleIndex]);
}
fColorXY = clamp(fColorXY, fDeringingMin, fDeringingMax);
#endif
return fColorXY;
}
#endif
// Clamp by offset direction. Assuming iPxSample is already in range and iPxOffset is compile time constant.
FfxInt32x2 ClampCoord(FfxInt32x2 iPxSample, FfxInt32x2 iPxOffset, FfxInt32x2 iTextureSize)
{
FfxInt32x2 result = iPxSample + iPxOffset;
result.x = (iPxOffset.x < 0) ? ffxMax(result.x, 0) : result.x;
result.x = (iPxOffset.x > 0) ? ffxMin(result.x, iTextureSize.x - 1) : result.x;
result.y = (iPxOffset.y < 0) ? ffxMax(result.y, 0) : result.y;
result.y = (iPxOffset.y > 0) ? ffxMin(result.y, iTextureSize.y - 1) : result.y;
return result;
}
#if FFXM_HALF
FFXM_MIN16_I2 ClampCoord(FFXM_MIN16_I2 iPxSample, FFXM_MIN16_I2 iPxOffset, FFXM_MIN16_I2 iTextureSize)
{
FFXM_MIN16_I2 result = iPxSample + iPxOffset;
result.x = (iPxOffset.x < FFXM_MIN16_I(0)) ? ffxMax(result.x, FFXM_MIN16_I(0)) : result.x;
result.x = (iPxOffset.x > FFXM_MIN16_I(0)) ? ffxMin(result.x, iTextureSize.x - FFXM_MIN16_I(1)) : result.x;
result.y = (iPxOffset.y < FFXM_MIN16_I(0)) ? ffxMax(result.y, FFXM_MIN16_I(0)) : result.y;
result.y = (iPxOffset.y > FFXM_MIN16_I(0)) ? ffxMin(result.y, iTextureSize.y - FFXM_MIN16_I(1)) : result.y;
return result;
}
#endif //FFXM_HALF
#define DeclareCustomFetchBicubicSamplesWithType(SampleType, TextureType, AddrType, Name, LoadTexture) \
SampleType Name(AddrType iPxSample, AddrType iTextureSize) \
{ \
SampleType Samples; \
\
Samples.fColor00 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, -1), iTextureSize))); \
Samples.fColor10 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, -1), iTextureSize))); \
Samples.fColor20 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, -1), iTextureSize))); \
Samples.fColor30 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+2, -1), iTextureSize))); \
\
Samples.fColor01 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, +0), iTextureSize))); \
Samples.fColor11 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +0), iTextureSize))); \
Samples.fColor21 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +0), iTextureSize))); \
Samples.fColor31 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+2, +0), iTextureSize))); \
\
Samples.fColor02 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, +1), iTextureSize))); \
Samples.fColor12 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +1), iTextureSize))); \
Samples.fColor22 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +1), iTextureSize))); \
Samples.fColor32 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+2, +1), iTextureSize))); \
\
Samples.fColor03 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, +2), iTextureSize))); \
Samples.fColor13 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +2), iTextureSize))); \
Samples.fColor23 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +2), iTextureSize))); \
Samples.fColor33 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+2, +2), iTextureSize))); \
\
return Samples; \
}
#define DeclareCustomFetch9TapSamplesWithType(SampleType, TextureType, AddrType, Name, LoadTexture) \
SampleType Name(AddrType iPxSample, AddrType iTextureSize) \
{ \
SampleType Samples; \
\
Samples.fColor00 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, -1), iTextureSize))); \
Samples.fColor10 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, -1), iTextureSize))); \
Samples.fColor20 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, -1), iTextureSize))); \
\
Samples.fColor01 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, +0), iTextureSize))); \
Samples.fColor11 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +0), iTextureSize))); \
Samples.fColor21 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +0), iTextureSize))); \
\
Samples.fColor02 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(-1, +1), iTextureSize))); \
Samples.fColor12 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +1), iTextureSize))); \
Samples.fColor22 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +1), iTextureSize))); \
\
return Samples; \
}
#define DeclareCustomFetchBicubicSamples(Name, LoadTexture) \
DeclareCustomFetchBicubicSamplesWithType(FetchedBicubicSamples, FfxFloat32x4, FfxInt32x2, Name, LoadTexture)
#define DeclareCustomFetchBicubicSamplesMin16(Name, LoadTexture) \
DeclareCustomFetchBicubicSamplesWithType(FetchedBicubicSamplesMin16, FFXM_MIN16_F4, FfxInt32x2, Name, LoadTexture)
#define DeclareCustomFetch9TapSamplesMin16(Name, LoadTexture) \
DeclareCustomFetch9TapSamplesWithType(Fetched9TapSamplesMin16, FFXM_MIN16_F4, FfxInt32x2, Name, LoadTexture)
#define DeclareCustomFetchBilinearSamplesWithType(SampleType, TextureType,AddrType, Name, LoadTexture) \
SampleType Name(AddrType iPxSample, AddrType iTextureSize) \
{ \
SampleType Samples; \
Samples.fColor00 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +0), iTextureSize))); \
Samples.fColor10 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +0), iTextureSize))); \
Samples.fColor01 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+0, +1), iTextureSize))); \
Samples.fColor11 = TextureType(LoadTexture(ClampCoord(iPxSample, AddrType(+1, +1), iTextureSize))); \
return Samples; \
}
#define DeclareCustomFetchBilinearSamples(Name, LoadTexture) \
DeclareCustomFetchBilinearSamplesWithType(FetchedBilinearSamples, FfxFloat32x4, FfxInt32x2, Name, LoadTexture)
#define DeclareCustomFetchBilinearSamplesMin16(Name, LoadTexture) \
DeclareCustomFetchBilinearSamplesWithType(FetchedBilinearSamplesMin16, FFXM_MIN16_F4, FfxInt32x2, Name, LoadTexture)
// BE CAREFUL: there is some precision issues and (3253, 125) leading to (3252.9989778, 125.001102)
// is common, so iPxSample can "jitter"
#define DeclareCustomTextureSample(Name, InterpolateSamples, FetchSamples) \
FfxFloat32x4 Name(FfxFloat32x2 fUvSample, FfxInt32x2 iTextureSize) \
{ \
FfxFloat32x2 fPxSample = (fUvSample * FfxFloat32x2(iTextureSize)) - FfxFloat32x2(0.5f, 0.5f); \
/* Clamp base coords */ \
fPxSample.x = ffxMax(0.0f, ffxMin(FfxFloat32(iTextureSize.x), fPxSample.x)); \
fPxSample.y = ffxMax(0.0f, ffxMin(FfxFloat32(iTextureSize.y), fPxSample.y)); \
/* */ \
FfxInt32x2 iPxSample = FfxInt32x2(floor(fPxSample)); \
FfxFloat32x2 fPxFrac = ffxFract(fPxSample); \
FfxFloat32x4 fColorXY = FfxFloat32x4(InterpolateSamples(FetchSamples(iPxSample, iTextureSize), fPxFrac)); \
return fColorXY; \
}
#define DeclareCustomTextureSampleMin16(Name, InterpolateSamples, FetchSamples) \
FFXM_MIN16_F4 Name(FfxFloat32x2 fUvSample, FfxInt32x2 iTextureSize) \
{ \
FfxFloat32x2 fPxSample = (fUvSample * FfxFloat32x2(iTextureSize)) - FfxFloat32x2(0.5f, 0.5f); \
/* Clamp base coords */ \
fPxSample.x = ffxMax(0.0f, ffxMin(FfxFloat32(iTextureSize.x), fPxSample.x)); \
fPxSample.y = ffxMax(0.0f, ffxMin(FfxFloat32(iTextureSize.y), fPxSample.y)); \
/* */ \
FfxInt32x2 iPxSample = FfxInt32x2(floor(fPxSample)); \
FFXM_MIN16_F2 fPxFrac = FFXM_MIN16_F2(ffxFract(fPxSample)); \
FFXM_MIN16_F4 fColorXY = FFXM_MIN16_F4(InterpolateSamples(FetchSamples(iPxSample, iTextureSize), fPxFrac)); \
return fColorXY; \
}
#define FFXM_FSR2_CONCAT_ID(x, y) x ## y
#define FFXM_FSR2_CONCAT(x, y) FFXM_FSR2_CONCAT_ID(x, y)
#define FFXM_FSR2_SAMPLER_1D_0 Lanczos2
#define FFXM_FSR2_SAMPLER_1D_1 Lanczos2LUT
#define FFXM_FSR2_SAMPLER_1D_2 Lanczos2Approx
#define FFXM_FSR2_GET_LANCZOS_SAMPLER1D(x) FFXM_FSR2_CONCAT(FFXM_FSR2_SAMPLER_1D_, x)
#endif //!defined( FFXM_FSR2_SAMPLE_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_sample.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: 161ce220c1b38aa41992c3c6e1099300
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

195
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_upsample.h

@ -0,0 +1,195 @@
// Copyright © 2023 Advanced Micro Devices, Inc.
// Copyright © 2024 Arm Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef FFXM_FSR2_UPSAMPLE_H
#define FFXM_FSR2_UPSAMPLE_H
#define FFXM_FSR2_UPSAMPLE_USE_LANCZOS_9_TAP 0
#define FFXM_FSR2_UPSAMPLE_USE_LANCZOS_5_TAP 1
#if FFXM_SHADER_QUALITY_OPT_UPSCALING_LANCZOS_5TAP
#define FFXM_FSR2_UPSAMPLE_KERNEL FFXM_FSR2_UPSAMPLE_USE_LANCZOS_5_TAP
FFXM_STATIC const FfxInt32 iLanczos2SampleCount = 5;
#else
#define FFXM_FSR2_UPSAMPLE_KERNEL FFXM_FSR2_UPSAMPLE_USE_LANCZOS_9_TAP
FFXM_STATIC const FfxUInt32 iLanczos2SampleCount = 16;
#endif
void Deringing(RectificationBox clippingBox, FFXM_PARAMETER_INOUT FfxFloat32x3 fColor)
{
fColor = clamp(fColor, clippingBox.aabbMin, clippingBox.aabbMax);
}
#if FFXM_HALF
void Deringing(RectificationBoxMin16 clippingBox, FFXM_PARAMETER_INOUT FFXM_MIN16_F3 fColor)
{
fColor = clamp(fColor, clippingBox.aabbMin, clippingBox.aabbMax);
}
#endif
FfxFloat32 GetUpsampleLanczosWeight(FfxFloat32x2 fSrcSampleOffset, FfxFloat32 fKernelWeight)
{
FfxFloat32x2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx;
FfxFloat32 fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased));
return fSampleWeight;
}
#if FFXM_HALF
FFXM_MIN16_F GetUpsampleLanczosWeight(FFXM_MIN16_F2 fSrcSampleOffset, FFXM_MIN16_F fKernelWeight)
{
FFXM_MIN16_F2 fSrcSampleOffsetBiased = fSrcSampleOffset * fKernelWeight.xx;
FFXM_MIN16_F fSampleWeight = Lanczos2ApproxSq(dot(fSrcSampleOffsetBiased, fSrcSampleOffsetBiased));
return fSampleWeight;
}
#endif
FfxFloat32 ComputeMaxKernelWeight() {
const FfxFloat32 fKernelSizeBias = 1.0f;
FfxFloat32 fKernelWeight = FfxFloat32(1) + (FfxFloat32(1.0f) / FfxFloat32x2(DownscaleFactor()) - FfxFloat32(1)).x * FfxFloat32(fKernelSizeBias);
return ffxMin(FfxFloat32(1.99f), fKernelWeight);
}
#if FFXM_HALF
FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams params,
FFXM_PARAMETER_INOUT RectificationBoxMin16 clippingBox, FfxFloat32 fReactiveFactor)
#else
FfxFloat32x4 ComputeUpsampledColorAndWeight(const AccumulationPassCommonParams params,
FFXM_PARAMETER_INOUT RectificationBox clippingBox, FfxFloat32 fReactiveFactor)
#endif
{
// We compute a sliced lanczos filter with 2 lobes (other slices are accumulated temporaly)
FfxFloat32x2 fDstOutputPos = FfxFloat32x2(params.iPxHrPos) + FFXM_BROADCAST_FLOAT32X2(0.5f); // Destination resolution output pixel center position
FfxFloat32x2 fSrcOutputPos = fDstOutputPos * DownscaleFactor(); // Source resolution output pixel center position
FfxInt32x2 iSrcInputPos = FfxInt32x2(floor(fSrcOutputPos)); // TODO: what about weird upscale factors...
FfxFloat32x2 fSrcUnjitteredPos = (FfxFloat32x2(iSrcInputPos) + FfxFloat32x2(0.5f, 0.5f)) - Jitter(); // This is the un-jittered position of the sample at offset 0,0
FfxFloat32x2 iSrcInputUv = FfxFloat32x2(fSrcOutputPos) / FfxFloat32x2(MaxRenderSize());
FfxFloat32x2 unitOffsetUv = FfxFloat32x2(1.0f, 1.0f) / FfxFloat32x2(MaxRenderSize());
FFXM_MIN16_F4 fColorAndWeight = FFXM_MIN16_F4(0.0f, 0.0f, 0.0f, 0.0f);
FFXM_MIN16_F2 fBaseSampleOffset = FFXM_MIN16_F2(fSrcUnjitteredPos - fSrcOutputPos);
// Identify how much of each upsampled color to be used for this frame
const FFXM_MIN16_F fKernelReactiveFactor = FFXM_MIN16_F(ffxMax(fReactiveFactor, FfxFloat32(params.bIsNewSample)));
const FFXM_MIN16_F fKernelBiasMax = FFXM_MIN16_F(ComputeMaxKernelWeight() * (1.0f - fKernelReactiveFactor));
const FFXM_MIN16_F fKernelBiasMin = FFXM_MIN16_F(ffxMax(1.0f, ((1.0f + fKernelBiasMax) * 0.3f)));
const FFXM_MIN16_F fKernelBiasFactor = FFXM_MIN16_F(ffxMax(0.0f, ffxMax(0.25f * params.fDepthClipFactor, fKernelReactiveFactor)));
const FFXM_MIN16_F fKernelBias = ffxLerp(fKernelBiasMax, fKernelBiasMin, fKernelBiasFactor);
const FFXM_MIN16_F fRectificationCurveBias = FFXM_MIN16_F(ffxLerp(-2.0f, -3.0f, ffxSaturate(params.fHrVelocity / 50.0f)));
FFXM_MIN16_F2 offsetTL;
offsetTL.x = FFXM_MIN16_F(-1);
offsetTL.y = FFXM_MIN16_F(-1);
FFXM_MIN16_F2 fOffsetTL = offsetTL;
#if FFXM_FSR2_UPSAMPLE_KERNEL == FFXM_FSR2_UPSAMPLE_USE_LANCZOS_9_TAP
FFXM_MIN16_F3 fSamples[iLanczos2SampleCount];
// Collect samples
GatherPreparedInputColorRGBQuad(FfxFloat32x2(-0.5, -0.5) * unitOffsetUv + iSrcInputUv,
fSamples[0], fSamples[1], fSamples[4], fSamples[5]);
fSamples[2] = LoadPreparedInputColor(FfxInt32x2(1, -1) + iSrcInputPos);
fSamples[6] = LoadPreparedInputColor(FfxInt32x2(1, 0) + iSrcInputPos);
fSamples[8] = LoadPreparedInputColor(FfxInt32x2(-1, 1) + iSrcInputPos);
fSamples[9] = LoadPreparedInputColor(FfxInt32x2(0, 1) + iSrcInputPos);
fSamples[10] = LoadPreparedInputColor(FfxInt32x2(1, 1) + iSrcInputPos);
FFXM_UNROLL
for (FfxInt32 row = 0; row < 3; row++)
{
FFXM_UNROLL
for (FfxInt32 col = 0; col < 3; col++)
{
FfxInt32 iSampleIndex = col + (row << 2);
const FfxInt32x2 sampleColRow = FfxInt32x2(col, row);
const FFXM_MIN16_F2 fOffset = fOffsetTL + FFXM_MIN16_F2(sampleColRow);
FFXM_MIN16_F2 fSrcSampleOffset = fBaseSampleOffset + fOffset;
FfxInt32x2 iSrcSamplePos = FfxInt32x2(iSrcInputPos) + FfxInt32x2(offsetTL) + sampleColRow;
FFXM_MIN16_F fSampleWeight = FFXM_MIN16_F(GetUpsampleLanczosWeight(fSrcSampleOffset, fKernelBias));
fColorAndWeight += FFXM_MIN16_F4(fSamples[iSampleIndex] * fSampleWeight, fSampleWeight);
// Update rectification box
{
const FFXM_MIN16_F fSrcSampleOffsetSq = dot(fSrcSampleOffset, fSrcSampleOffset);
const FFXM_MIN16_F fBoxSampleWeight = exp(fRectificationCurveBias * fSrcSampleOffsetSq);
const FfxBoolean bInitialSample = (row == 0) && (col == 0);
RectificationBoxAddSample(bInitialSample, clippingBox, fSamples[iSampleIndex], fBoxSampleWeight);
}
}
}
#elif FFXM_FSR2_UPSAMPLE_KERNEL == FFXM_FSR2_UPSAMPLE_USE_LANCZOS_5_TAP
FFXM_MIN16_F3 fSamples[iLanczos2SampleCount];
// Collect samples
FfxInt32x2 rowCol [iLanczos2SampleCount] = {FfxInt32x2(0, -1), FfxInt32x2(-1, 0), FfxInt32x2(0, 0), FfxInt32x2(1, 0), FfxInt32x2(0, 1)};
fSamples[0] = LoadPreparedInputColor(rowCol[0] + iSrcInputPos);
fSamples[1] = LoadPreparedInputColor(rowCol[1] + iSrcInputPos);
fSamples[2] = LoadPreparedInputColor(rowCol[2] + iSrcInputPos);
fSamples[3] = LoadPreparedInputColor(rowCol[3] + iSrcInputPos);
fSamples[4] = LoadPreparedInputColor(rowCol[4] + iSrcInputPos);
FFXM_UNROLL
for (FfxInt32 idx = 0; idx < iLanczos2SampleCount; idx++)
{
const FfxInt32x2 sampleColRow = rowCol[idx];
const FFXM_MIN16_F2 fOffset = FFXM_MIN16_F2(sampleColRow);
FFXM_MIN16_F2 fSrcSampleOffset = fBaseSampleOffset + fOffset;
FfxInt32x2 iSrcSamplePos = FfxInt32x2(iSrcInputPos) + FfxInt32x2(offsetTL) + sampleColRow;
FFXM_MIN16_F fSampleWeight = FFXM_MIN16_F(GetUpsampleLanczosWeight(fSrcSampleOffset, fKernelBias));
fColorAndWeight += FFXM_MIN16_F4(fSamples[idx] * fSampleWeight, fSampleWeight);
// Update rectification box
{
const FFXM_MIN16_F fSrcSampleOffsetSq = dot(fSrcSampleOffset, fSrcSampleOffset);
const FFXM_MIN16_F fBoxSampleWeight = exp(fRectificationCurveBias * fSrcSampleOffsetSq);
const FfxBoolean bInitialSample = (idx == 0);
RectificationBoxAddSample(bInitialSample, clippingBox, fSamples[idx], fBoxSampleWeight);
}
}
#endif
RectificationBoxComputeVarianceBoxData(clippingBox);
fColorAndWeight.w *= FFXM_MIN16_F(fColorAndWeight.w > FSR2_EPSILON);
if (fColorAndWeight.w > FSR2_EPSILON) {
// Normalize for deringing (we need to compare colors)
fColorAndWeight.xyz = fColorAndWeight.xyz / fColorAndWeight.w;
fColorAndWeight.w = FFXM_MIN16_F(fColorAndWeight.w*fUpsampleLanczosWeightScale);
Deringing(clippingBox, fColorAndWeight.xyz);
}
return fColorAndWeight;
}
#endif //!defined( FFXM_FSR2_UPSAMPLE_H )

67
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/fsr2/ffxm_fsr2_upsample.h.meta

@ -0,0 +1,67 @@
fileFormatVersion: 2
guid: adbae71b3f272394a895f14e3c09e3e2
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude GameCoreScarlett: 1
Exclude GameCoreXboxOne: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude PS5: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/ASR/Shaders/shaders/spd.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc1175974e28a1344bca96b5e00fc1cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save