NIS_Main.glsl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // The MIT License(MIT)
  2. //
  3. // Copyright(c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. // this software and associated documentation files(the "Software"), to deal in
  7. // the Software without restriction, including without limitation the rights to
  8. // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of
  9. // the Software, and to permit persons to whom the Software is furnished to do so,
  10. // subject to the following conditions :
  11. //
  12. // The above copyright notice and this permission notice shall be included in all
  13. // copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
  18. // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #version 450
  22. #extension GL_ARB_separate_shader_objects : enable
  23. #extension GL_ARB_shading_language_420pack : enable
  24. #extension GL_GOOGLE_include_directive : enable
  25. #extension GL_EXT_shader_16bit_storage : require
  26. #extension GL_EXT_shader_explicit_arithmetic_types : require
  27. #define NIS_GLSL 1
  28. #ifndef NIS_SCALER
  29. #define NIS_SCALER 1
  30. #endif
  31. layout(set=0,binding=0) uniform const_buffer
  32. {
  33. float kDetectRatio;
  34. float kDetectThres;
  35. float kMinContrastRatio;
  36. float kRatioNorm;
  37. float kContrastBoost;
  38. float kEps;
  39. float kSharpStartY;
  40. float kSharpScaleY;
  41. float kSharpStrengthMin;
  42. float kSharpStrengthScale;
  43. float kSharpLimitMin;
  44. float kSharpLimitScale;
  45. float kScaleX;
  46. float kScaleY;
  47. float kDstNormX;
  48. float kDstNormY;
  49. float kSrcNormX;
  50. float kSrcNormY;
  51. uint kInputViewportOriginX;
  52. uint kInputViewportOriginY;
  53. uint kInputViewportWidth;
  54. uint kInputViewportHeight;
  55. uint kOutputViewportOriginX;
  56. uint kOutputViewportOriginY;
  57. uint kOutputViewportWidth;
  58. uint kOutputViewportHeight;
  59. float reserved0;
  60. float reserved1;
  61. };
  62. layout(set=0,binding=1) uniform sampler samplerLinearClamp;
  63. layout(set=0,binding=2) uniform texture2D in_texture;
  64. layout(set=0,binding=3) uniform writeonly image2D out_texture;
  65. #if NIS_SCALER
  66. layout(set=0,binding=4) uniform texture2D coef_scaler;
  67. layout(set=0,binding=5) uniform texture2D coef_usm;
  68. #endif
  69. #include "NIS_Scaler.h"
  70. layout(local_size_x=NIS_THREAD_GROUP_SIZE) in;
  71. void main()
  72. {
  73. #if NIS_SCALER
  74. NVScaler(gl_WorkGroupID.xy, gl_LocalInvocationID.x);
  75. #else
  76. NVSharpen(gl_WorkGroupID.xy, gl_LocalInvocationID.x);
  77. #endif
  78. }