| // Reduced set of intrinsics that are available to public SkSL (RuntimeEffect and Interpreter) |
| |
| // See "The OpenGL ES Shading Language, Version 1.00, Section 8" |
| // For all of the TODO comments, refer to skbug.com/10913 |
| |
| // 8.1 : Angle and Trigonometry Functions |
| float radians(float deg) { return deg * 0.0174532925; } |
| float2 radians(float2 deg) { return deg * 0.0174532925; } |
| float3 radians(float3 deg) { return deg * 0.0174532925; } |
| float4 radians(float4 deg) { return deg * 0.0174532925; } |
| |
| float degrees(float rad) { return rad * 57.2957795; } |
| float2 degrees(float2 rad) { return rad * 57.2957795; } |
| float3 degrees(float3 rad) { return rad * 57.2957795; } |
| float4 degrees(float4 rad) { return rad * 57.2957795; } |
| |
| $genType sin($genType angle); |
| $genHType sin($genHType angle); |
| $genType cos($genType angle); |
| $genHType cos($genHType angle); |
| $genType tan($genType angle); |
| $genHType tan($genHType angle); |
| // TODO: asin(x) |
| // TODO: acos(y) |
| // TODO: atan(y, x) |
| $genType atan($genType y_over_x); |
| $genHType atan($genHType y_over_x); |
| |
| // 8.2 : Exponential Functions |
| $genType pow($genType x, $genType y); |
| $genHType pow($genHType x, $genHType y); |
| // TODO: exp |
| // TODO: log |
| // TODO: exp2 |
| // TODO: log2 |
| $genType sqrt($genType x); |
| $genHType sqrt($genHType x); |
| // TODO: inversesqrt |
| |
| // 8.3 : Common Functions |
| $genType abs($genType x); |
| $genHType abs($genHType x); |
| // TODO: sign(x) |
| $genType floor($genType x); |
| $genHType floor($genHType x); |
| $genType ceil($genType x); |
| $genHType ceil($genHType x); |
| $genType fract($genType x); |
| $genHType fract($genHType x); |
| // TODO: mod(x, y) |
| |
| $genType min($genType x, $genType y); |
| $genType min($genType x, float y); |
| $genHType min($genHType x, $genHType y); |
| $genHType min($genHType x, half y); |
| $genType max($genType x, $genType y); |
| $genType max($genType x, float y); |
| $genHType max($genHType x, $genHType y); |
| $genHType max($genHType x, half y); |
| $genType clamp($genType x, $genType minVal, $genType maxVal); |
| $genType clamp($genType x, float minVal, float maxVal); |
| $genHType clamp($genHType x, $genHType minVal, $genHType maxVal); |
| $genHType clamp($genHType x, half minVal, half maxVal); |
| $genType mix($genType x, $genType y, $genType a); |
| $genType mix($genType x, $genType y, float a); |
| $genHType mix($genHType x, $genHType y, $genHType a); |
| $genHType mix($genHType x, $genHType y, half a); |
| // TODO: step(edge, x) |
| // TODO: smoothstep(edge0, edge1, x) |
| |
| // SkSL Extension to GLSL: |
| $genType saturate($genType x); |
| $genHType saturate($genHType x); |
| |
| // 8.4 : Geometric Functions |
| float length($genType x); |
| half length($genHType x); |
| |
| float distance(float2 a, float2 b) { return length(a - b); } |
| float distance(float3 a, float3 b) { return length(a - b); } |
| float distance(float4 a, float4 b) { return length(a - b); } |
| |
| float dot($genType x, $genType y); |
| half dot($genHType x, $genHType y); |
| |
| float3 cross(float3 a, float3 b) { |
| return float3(a.y * b.z - a.z * b.y, |
| a.z * b.x - a.x * b.z, |
| a.x * b.y - a.y * b.x); |
| } |
| |
| $genType normalize($genType x); |
| $genHType normalize($genHType x); |
| // TODO: faceforward(N, I, Nref) |
| // TODO: reflect(I, N) |
| // TODO: refract(I, N, eta) |
| |
| // 8.5 : Matrix Functions |
| // TODO: matrixCompMult(x, y) |
| |
| // Not supported until GLSL 1.40. Poly-filled by SkSL: |
| float2x2 inverse(float2x2 m); |
| float3x3 inverse(float3x3 m); |
| float4x4 inverse(float4x4 m); |
| half2x2 inverse(half2x2 m); |
| half3x3 inverse(half3x3 m); |
| half4x4 inverse(half4x4 m); |
| |
| // 8.6 : Vector Relational Functions |
| $bvec lessThan($vec x, $vec y); |
| $bvec lessThan($hvec x, $hvec y); |
| $bvec lessThanEqual($vec x, $vec y); |
| $bvec lessThanEqual($hvec x, $hvec y); |
| $bvec greaterThan($vec x, $vec y); |
| $bvec greaterThan($hvec x, $hvec y); |
| $bvec greaterThanEqual($vec x, $vec y); |
| $bvec greaterThanEqual($hvec x, $hvec y); |
| $bvec equal($vec x, $vec y); |
| $bvec equal($hvec x, $hvec y); |
| $bvec equal($bvec x, $bvec y); |
| $bvec notEqual($vec x, $vec y); |
| $bvec notEqual($hvec x, $hvec y); |
| $bvec notEqual($bvec x, $bvec y); |
| |
| bool any($bvec x); |
| bool all($bvec x); |
| $bvec not($bvec x); |
| |
| // Miscellaneous SkSL intrinsics that are not part of GLSL: |
| |
| // The max() guards against division by zero when the incoming color is transparent black |
| half4 unpremul (half4 color) { return half4 (color.rgb / max(color.a, 0.0001), color.a); } |
| float4 unpremul_float(float4 color) { return float4(color.rgb / max(color.a, 0.0001), color.a); } |