blob: bd6a514a1bac123835493e6dd5232189d328188e [file] [log] [blame]
// Reduced set of intrinsics that are available to public SkSL (RuntimeEffect and Interpreter)
// See "The OpenGL ES Shading Language, Version 1.00, Section 8"
// 8.1 : Angle and Trigonometry Functions
$genType radians($genType degrees);
$genHType radians($genHType degrees);
$genType degrees($genType radians);
$genHType degrees($genHType radians);
$genType sin($genType angle);
$genHType sin($genHType angle);
$genType cos($genType angle);
$genHType cos($genHType angle);
$genType tan($genType angle);
$genHType tan($genHType angle);
$genType asin($genType x);
$genHType asin($genHType x);
$genType acos($genType x);
$genHType acos($genHType x);
$genType atan($genType y, $genType x);
$genHType atan($genHType y, $genHType 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);
$genType exp($genType x);
$genHType exp($genHType x);
$genType log($genType x);
$genHType log($genHType x);
$genType exp2($genType x);
$genHType exp2($genHType x);
$genType log2($genType x);
$genHType log2($genHType x);
$genType sqrt($genType x);
$genHType sqrt($genHType x);
$genType inversesqrt($genType x);
$genHType inversesqrt($genHType x);
// 8.3 : Common Functions
$genType abs($genType x);
$genHType abs($genHType x);
$genType sign($genType x);
$genHType sign($genHType 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);
$genType mod($genType x, float y);
$genType mod($genType x, $genType y);
$genHType mod($genHType x, half y);
$genHType mod($genHType x, $genHType 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 saturate($genType x); // SkSL extension
$genHType saturate($genHType x); // SkSL extension
$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);
$genType step($genType edge, $genType x);
$genType step(float edge, $genType x);
$genHType step($genHType edge, $genHType x);
$genHType step(half edge, $genHType x);
$genType smoothstep($genType edge0, $genType edge1, $genType x);
$genType smoothstep(float edge0, float edge1, $genType x);
$genHType smoothstep($genHType edge0, $genHType edge1, $genHType x);
$genHType smoothstep(half edge0, half edge1, $genHType x);
// 8.4 : Geometric Functions
float length($genType x);
half length($genHType x);
float distance($genType p0, $genType p1);
half distance($genHType p0, $genHType p1);
float dot($genType x, $genType y);
half dot($genHType x, $genHType y);
float3 cross(float3 x, float3 y);
half3 cross(half3 x, half3 y);
$genType normalize($genType x);
$genHType normalize($genHType x);
$genType faceforward($genType N, $genType I, $genType Nref);
$genHType faceforward($genHType N, $genHType I, $genHType Nref);
$genType reflect($genType I, $genType N);
$genHType reflect($genHType I, $genHType N);
$genType refract($genType I, $genType N, float eta);
$genHType refract($genHType I, $genHType N, half eta);
// 8.5 : Matrix Functions
$squareMat matrixCompMult($squareMat x, $squareMat y);
$squareHMat matrixCompMult($squareHMat x, $squareHMat y);
// Not supported until GLSL 1.40. Poly-filled by SkSL:
$squareMat inverse($squareMat m);
$squareHMat inverse($squareHMat m);
// 8.6 : Vector Relational Functions
$bvec lessThan($vec x, $vec y);
$bvec lessThan($hvec x, $hvec y);
$bvec lessThan($ivec x, $ivec y);
$bvec lessThanEqual($vec x, $vec y);
$bvec lessThanEqual($hvec x, $hvec y);
$bvec lessThanEqual($ivec x, $ivec y);
$bvec greaterThan($vec x, $vec y);
$bvec greaterThan($hvec x, $hvec y);
$bvec greaterThan($ivec x, $ivec y);
$bvec greaterThanEqual($vec x, $vec y);
$bvec greaterThanEqual($hvec x, $hvec y);
$bvec greaterThanEqual($ivec x, $ivec y);
$bvec equal($vec x, $vec y);
$bvec equal($hvec x, $hvec y);
$bvec equal($ivec x, $ivec y);
$bvec equal($bvec x, $bvec y);
$bvec notEqual($vec x, $vec y);
$bvec notEqual($hvec x, $hvec y);
$bvec notEqual($ivec x, $ivec 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(float4 color) { return float4(color.rgb / max(color.a, 0.0001), color.a); }