sksl_gpu.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. STRINGIFY(
  2. // defines built-in functions supported by SkSL when running on a GPU
  3. $genType radians($genType degrees);
  4. $genType sin($genType angle);
  5. $genType cos($genType angle);
  6. $genType tan($genType angle);
  7. $genType asin($genType x);
  8. $genType acos($genType x);
  9. $genType atan($genType y, $genType x);
  10. $genType atan($genType y_over_x);
  11. $genType sinh($genType x);
  12. $genType cosh($genType x);
  13. $genType tanh($genType x);
  14. $genType asinh($genType x);
  15. $genType acosh($genType x);
  16. $genType atanh($genType x);
  17. $genType pow($genType x, $genType y);
  18. $genType exp($genType x);
  19. $genType log($genType x);
  20. $genType exp2($genType x);
  21. $genType log2($genType x);
  22. $genType sqrt($genType x);
  23. $genHType radians($genHType degrees);
  24. $genHType sin($genHType angle);
  25. $genHType cos($genHType angle);
  26. $genHType tan($genHType angle);
  27. $genHType asin($genHType x);
  28. $genHType acos($genHType x);
  29. $genHType atan($genHType y, $genHType x);
  30. $genHType atan($genHType y_over_x);
  31. $genHType sinh($genHType x);
  32. $genHType cosh($genHType x);
  33. $genHType tanh($genHType x);
  34. $genHType asinh($genHType x);
  35. $genHType acosh($genHType x);
  36. $genHType atanh($genHType x);
  37. $genHType pow($genHType x, $genHType y);
  38. $genHType exp($genHType x);
  39. $genHType log($genHType x);
  40. $genHType exp2($genHType x);
  41. $genHType log2($genHType x);
  42. $genHType sqrt($genHType x);
  43. $genType inversesqrt($genType x);
  44. $genType abs($genType x);
  45. $genHType abs($genHType x);
  46. $genIType abs($genIType x);
  47. $genType sign($genType x);
  48. $genHType sign($genHType x);
  49. $genIType sign($genIType x);
  50. $genType floor($genType x);
  51. $genHType floor($genHType x);
  52. $genType trunc($genType x);
  53. $genHType trunc($genHType x);
  54. $genType round($genType x);
  55. $genHType round($genHType x);
  56. $genType roundEven($genType x);
  57. $genHType roundEven($genHType x);
  58. $genType ceil($genType x);
  59. $genHType ceil($genHType x);
  60. $genType fract($genType x);
  61. $genHType fract($genHType x);
  62. $genType mod($genType x, float y);
  63. $genType mod($genType x, $genType y);
  64. $genHType mod($genHType x, half y);
  65. $genHType mod($genHType x, $genType y);
  66. $genType modf($genType x, out $genType i);
  67. $genHType modf($genHType x, out $genHType i);
  68. $genType min($genType x, $genType y);
  69. $genType min($genType x, float y);
  70. $genHType min($genHType x, $genHType y);
  71. $genHType min($genHType x, half y);
  72. $genIType min($genIType x, $genIType y);
  73. $genIType min($genIType x, int y);
  74. $genType max($genType x, $genType y);
  75. $genType max($genType x, float y);
  76. $genHType max($genHType x, $genHType y);
  77. $genHType max($genHType x, half y);
  78. $genIType max($genIType x, $genIType y);
  79. $genIType max($genIType x, int y);
  80. $genType clamp($genType x, $genType minVal, $genType maxVal);
  81. $genType clamp($genType x, float minVal, float maxVal);
  82. $genHType clamp($genHType x, $genHType minVal, $genHType maxVal);
  83. $genHType clamp($genHType x, half minVal, half maxVal);
  84. $genIType clamp($genIType x, $genIType minVal, $genIType maxVal);
  85. $genIType clamp($genIType x, int minVal, int maxVal);
  86. $genType saturate($genType x);
  87. $genHType saturate($genHType x);
  88. $genType mix($genType x, $genType y, $genType a);
  89. $genType mix($genType x, $genType y, float a);
  90. $genHType mix($genHType x, $genHType y, $genHType a);
  91. $genHType mix($genHType x, $genHType y, half a);
  92. $genType mix($genType x, $genType y, $genBType a);
  93. $genIType mix($genIType x, $genIType y, $genBType a);
  94. $genBType mix($genBType x, $genBType y, $genBType a);
  95. $genType step($genType edge, $genType x);
  96. $genType step(float edge, $genType x);
  97. $genHType step($genHType edge, $genHType x);
  98. $genHType step(half edge, $genHType x);
  99. $genType smoothstep($genType edge0, $genType edge1, $genType x);
  100. $genType smoothstep(float edge0, float edge1, $genType x);
  101. $genHType smoothstep($genHType edge0, $genHType edge1, $genHType x);
  102. $genHType smoothstep(half edge0, half edge1, $genHType x);
  103. $genBType isnan($genType x);
  104. $genBType isnan($genDType x);
  105. $genBType isinf($genType x);
  106. $genBType isinf($genDType x);
  107. $genIType floatBitsToInt($genType value);
  108. $genType intBitsTofloat($genIType value);
  109. $genType uintBitsTofloat($genUType value);
  110. $genType fma($genType a, $genType b, $genType c);
  111. $genHType fma($genHType a, $genHType b, $genHType c);
  112. $genDType fma($genDType a, $genDType b, $genDType c);
  113. sk_has_side_effects $genType frexp($genType x, out $genIType exp);
  114. $genType ldexp($genType x, in $genIType exp);
  115. uint packUnorm2x16(float2 v);
  116. uint packSnorm2x16(float2 v);
  117. uint packUnorm4x8(float4 v);
  118. uint packSnorm4x8(float4 v);
  119. float2 unpackUnorm2x16(uint p);
  120. float2 unpackSnorm2x16(uint p);
  121. float4 unpackUnorm4x8(uint p);
  122. float4 unpackSnorm4x8(uint p);
  123. uint2 unpackDouble2x32(double v);
  124. uint packHalf2x16(float2 v);
  125. float2 unpackHalf2x16(uint v);
  126. float length($genType x);
  127. half length($genHType x);
  128. double length($genDType x);
  129. float distance($genType p0, $genType p1);
  130. half distance($genHType p0, $genHType p1);
  131. double distance($genDType p0, $genDType p1);
  132. float dot($genType x, $genType y);
  133. half dot($genHType x, $genHType y);
  134. double dot($genDType x, $genDType y);
  135. float3 cross(float3 x, float3 y);
  136. half3 cross(half3 x, half3 y);
  137. double3 cross(double3 x, double3 y);
  138. $genType normalize($genType x);
  139. $genHType normalize($genHType x);
  140. $genDType normalize($genDType x);
  141. float4 ftransform();
  142. $genType faceforward($genType N, $genType I, $genType Nref);
  143. $genHType faceforward($genHType N, $genHType I, $genHType Nref);
  144. $genDType faceforward($genDType N, $genDType I, $genDType Nref);
  145. $genType reflect($genType I, $genType N);
  146. $genHType reflect($genHType I, $genHType N);
  147. $genDType reflect($genDType I, $genDType N);
  148. $genType refract($genType I, $genType N, float eta);
  149. $genHType refract($genHType I, $genHType N, float eta);
  150. $genDType refract($genDType I, $genDType N, float eta);
  151. $mat matrixCompMult($mat x, $mat y);
  152. float2x2 outerProduct(float2 c, float2 r);
  153. float3x3 outerProduct(float3 c, float3 r);
  154. float4x3 outerProduct(float4 c, float4 r);
  155. float2x3 outerProduct(float3 c, float2 r);
  156. float3x2 outerProduct(float2 c, float3 r);
  157. float2x4 outerProduct(float4 c, float2 r);
  158. float4x2 outerProduct(float2 c, float4 r);
  159. float3x4 outerProduct(float4 c, float3 r);
  160. float4x3 outerProduct(float3 c, float4 r);
  161. half2x2 outerProduct(half2 c, half2 r);
  162. half3x3 outerProduct(half3 c, half3 r);
  163. half4x3 outerProduct(half4 c, half4 r);
  164. half2x3 outerProduct(half3 c, half2 r);
  165. half3x2 outerProduct(half2 c, half3 r);
  166. half2x4 outerProduct(half4 c, half2 r);
  167. half4x2 outerProduct(half2 c, half4 r);
  168. half3x4 outerProduct(half4 c, half3 r);
  169. half4x3 outerProduct(half3 c, half4 r);
  170. float2x2 transpose(float2x2 m);
  171. float3x3 transpose(float3x3 m);
  172. float4x4 transpose(float4x4 m);
  173. float2x3 transpose(float3x2 m);
  174. float3x2 transpose(float2x3 m);
  175. float2x4 transpose(float4x2 m);
  176. float4x2 transpose(float2x4 m);
  177. float3x4 transpose(float4x3 m);
  178. float4x3 transpose(float3x4 m);
  179. half2x2 transpose(half2x2 m);
  180. half3x3 transpose(half3x3 m);
  181. half4x4 transpose(half4x4 m);
  182. half2x3 transpose(half3x2 m);
  183. half3x2 transpose(half2x3 m);
  184. half2x4 transpose(half4x2 m);
  185. half4x2 transpose(half2x4 m);
  186. half3x4 transpose(half4x3 m);
  187. half4x3 transpose(half3x4 m);
  188. float determinant(float2x2 m);
  189. float determinant(float3x3 m);
  190. float determinant(float4x4 m);
  191. half determinant(half2x2 m);
  192. half determinant(half3x3 m);
  193. half determinant(half4x4 m);
  194. float2x2 inverse(float2x2 m);
  195. float3x3 inverse(float3x3 m);
  196. float4x4 inverse(float4x4 m);
  197. half2x2 inverse(half2x2 m);
  198. half3x3 inverse(half3x3 m);
  199. half4x4 inverse(half4x4 m);
  200. $bvec lessThan($vec x, $vec y);
  201. $bvec lessThan($hvec x, $hvec y);
  202. $bvec lessThan($dvec x, $dvec y);
  203. $bvec lessThan($ivec x, $ivec y);
  204. $bvec lessThan($svec x, $svec y);
  205. $bvec lessThan($usvec x, $usvec y);
  206. $bvec lessThan($uvec x, $uvec y);
  207. $bvec lessThanEqual($vec x, $vec y);
  208. $bvec lessThanEqual($hvec x, $hvec y);
  209. $bvec lessThanEqual($dvec x, $dvec y);
  210. $bvec lessThanEqual($ivec x, $ivec y);
  211. $bvec lessThanEqual($uvec x, $uvec y);
  212. $bvec lessThanEqual($svec x, $svec y);
  213. $bvec lessThanEqual($usvec x, $usvec y);
  214. $bvec greaterThan($vec x, $vec y);
  215. $bvec greaterThan($hvec x, $hvec y);
  216. $bvec greaterThan($dvec x, $dvec y);
  217. $bvec greaterThan($ivec x, $ivec y);
  218. $bvec greaterThan($uvec x, $uvec y);
  219. $bvec greaterThan($svec x, $svec y);
  220. $bvec greaterThan($usvec x, $usvec y);
  221. $bvec greaterThanEqual($vec x, $vec y);
  222. $bvec greaterThanEqual($hvec x, $hvec y);
  223. $bvec greaterThanEqual($dvec x, $dvec y);
  224. $bvec greaterThanEqual($ivec x, $ivec y);
  225. $bvec greaterThanEqual($uvec x, $uvec y);
  226. $bvec greaterThanEqual($svec x, $svec y);
  227. $bvec greaterThanEqual($usvec x, $usvec y);
  228. $bvec equal($vec x, $vec y);
  229. $bvec equal($hvec x, $hvec y);
  230. $bvec equal($dvec x, $dvec y);
  231. $bvec equal($ivec x, $ivec y);
  232. $bvec equal($uvec x, $uvec y);
  233. $bvec equal($svec x, $svec y);
  234. $bvec equal($usvec x, $usvec y);
  235. $bvec equal($bvec x, $bvec y);
  236. $bvec notEqual($vec x, $vec y);
  237. $bvec notEqual($hvec x, $hvec y);
  238. $bvec notEqual($dvec x, $dvec y);
  239. $bvec notEqual($ivec x, $ivec y);
  240. $bvec notEqual($uvec x, $uvec y);
  241. $bvec notEqual($svec x, $svec y);
  242. $bvec notEqual($usvec x, $usvec y);
  243. $bvec notEqual($bvec x, $bvec y);
  244. bool any($bvec x);
  245. bool all($bvec x);
  246. $bvec not($bvec x);
  247. $genIType bitCount($genIType value);
  248. $genIType bitCount($genUType value);
  249. $genIType findLSB($genIType value);
  250. $genIType findLSB($genUType value);
  251. $genIType findMSB($genIType value);
  252. $genIType findMSB($genUType value);
  253. int2 textureSize($gsampler2DRect sampler);
  254. half4 texture($gsampler1D sampler, float P);
  255. half4 texture($gsampler1D sampler, float P, float bias);
  256. half4 texture($gsampler2D sampler, float2 P);
  257. // The above currently only expand to handle the float/fixed case. So we also declare this integer
  258. // version of texture().
  259. int4 texture(isampler2D sampler, float2 P);
  260. half4 texture(samplerExternalOES sampler, float2 P, float bias);
  261. half4 texture(samplerExternalOES sampler, float2 P);
  262. half4 texture($gsampler2DRect sampler, float2 P);
  263. half4 texture($gsampler2DRect sampler, float3 P);
  264. // Currently we do not support the generic types of loading subpassInput so we have some explicit
  265. // versions that we currently use
  266. float4 subpassLoad(subpassInput subpass);
  267. float4 subpassLoad(subpassInputMS subpass, int sample);
  268. half4 texture($gsampler1D sampler, float2 P);
  269. half4 texture($gsampler1D sampler, float2 P, float bias);
  270. half4 texture($gsampler2D sampler, float3 P);
  271. half4 texture($gsampler2D sampler, float3 P, float bias);
  272. float4 imageLoad(image2D image, int2 P);
  273. int4 imageLoad(iimage2D image, int2 P);
  274. $genType dFdx($genType p);
  275. $genType dFdy($genType p);
  276. $genHType dFdx($genHType p);
  277. $genHType dFdy($genHType p);
  278. $genType fwidth($genType p);
  279. $genHType fwidth($genHType p);
  280. float interpolateAtSample(float interpolant, int sample);
  281. float2 interpolateAtSample(float2 interpolant, int sample);
  282. float3 interpolateAtSample(float3 interpolant, int sample);
  283. float4 interpolateAtSample(float4 interpolant, int sample);
  284. float interpolateAtOffset(float interpolant, float2 offset);
  285. float2 interpolateAtOffset(float2 interpolant, float2 offset);
  286. float3 interpolateAtOffset(float3 interpolant, float2 offset);
  287. float4 interpolateAtOffset(float4 interpolant, float2 offset);
  288. )