Fsr.ankiprog 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma anki mutator SHARPEN 0 1
  6. #pragma anki mutator FSR_QUALITY 0 1
  7. #pragma anki start comp
  8. #include <AnKi/Shaders/Functions.glsl>
  9. layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
  10. layout(set = 0, binding = 1) uniform texture2D u_tex;
  11. layout(set = 0, binding = 2) writeonly uniform image2D u_outImg;
  12. layout(push_constant, std430) uniform b_pc
  13. {
  14. UVec4 u_fsrConsts0;
  15. UVec4 u_fsrConsts1;
  16. UVec4 u_fsrConsts2;
  17. UVec4 u_fsrConsts3;
  18. UVec2 u_viewportSize;
  19. UVec2 u_padding;
  20. };
  21. // FSR begin
  22. #define A_GPU 1
  23. #define A_GLSL 1
  24. #define A_HALF 1
  25. #include <ThirdParty/FidelityFX/ffx_a.h>
  26. #if SHARPEN
  27. # define FSR_RCAS_H 1
  28. AH4 FsrRcasLoadH(ASW2 p)
  29. {
  30. return AH4(texelFetch(sampler2D(u_tex, u_linearAnyClampSampler), ASU2(p), 0));
  31. }
  32. void FsrRcasInputH(inout AH1 r, inout AH1 g, inout AH1 b)
  33. {
  34. }
  35. #else // !SHARPEN
  36. # define FSR_EASU_H 1
  37. AH4 FsrEasuRH(AF2 p)
  38. {
  39. return AH4(textureGather(sampler2D(u_tex, u_linearAnyClampSampler), p, 0));
  40. }
  41. AH4 FsrEasuGH(AF2 p)
  42. {
  43. return AH4(textureGather(sampler2D(u_tex, u_linearAnyClampSampler), p, 1));
  44. }
  45. AH4 FsrEasuBH(AF2 p)
  46. {
  47. return AH4(textureGather(sampler2D(u_tex, u_linearAnyClampSampler), p, 2));
  48. }
  49. AH3 FsrEasuSampleH(AF2 p)
  50. {
  51. return AH3(textureLod(u_tex, u_linearAnyClampSampler, p, 0.0).xyz);
  52. }
  53. #endif
  54. #include <ThirdParty/FidelityFX/ffx_fsr1.h>
  55. // FSR end
  56. layout(local_size_x = 8, local_size_y = 8) in;
  57. void main()
  58. {
  59. if(skipOutOfBoundsInvocations(UVec2(8u), u_viewportSize))
  60. {
  61. return;
  62. }
  63. HVec3 color;
  64. #if SHARPEN
  65. FsrRcasH(color.r, color.g, color.b, gl_GlobalInvocationID.xy, u_fsrConsts0);
  66. #elif FSR_QUALITY == 0
  67. FsrEasuL(color, gl_GlobalInvocationID.xy, u_fsrConsts0, u_fsrConsts1, u_fsrConsts2, u_fsrConsts3);
  68. #else
  69. FsrEasuH(color, gl_GlobalInvocationID.xy, u_fsrConsts0, u_fsrConsts1, u_fsrConsts2, u_fsrConsts3);
  70. #endif
  71. imageStore(u_outImg, IVec2(gl_GlobalInvocationID.xy), Vec4(color, 0.0));
  72. }
  73. #pragma anki end