From 7eb60a74e2d5ef2ae1e7eee989a5623d4a58eb17 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 25 Aug 2021 21:46:38 +0200 Subject: [PATCH 001/139] More typesafe codegen --- src/elm/UI/Glsl.elm | 8 +- src/elm/UI/Glsl/Code.elm | 475 ++++++++------- src/elm/UI/Glsl/Generator.elm | 1035 ++++++++++++++++++++------------ src/elm/UI/Glsl/Polynomial.elm | 41 +- 4 files changed, 917 insertions(+), 642 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index bbd1dba8..2efc279c 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (constantToGlsl, deindent, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (floatT, uniform, unknownTypedName, vec2T) +import UI.Glsl.Generator as Generator exposing (dotted3, floatT, uniform, unsafeCall, vec2T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -147,7 +147,7 @@ getGlsl expandIntervals rayDifferentials graph = rayDifferentials (List.map (\p -> - { name = unknownTypedName p.name + { call = \arg0 arg1 arg2 arg3 -> dotted3 <| unsafeCall p.name [ arg0.base, arg1.base, arg2.base, arg3.base ] , color = p.color } ) @@ -345,7 +345,9 @@ requirementToGlsl i r = functionToGlsl i f RequireConstant c -> - constantToGlsl c |> Generator.funDeclToGlsl + constantToGlsl c + |> Tuple.first + |> Generator.funDeclToGlsl RequireOperation o -> operationToGlsl i o diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 969faf0e..9300083e 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,21 +2,21 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression, File, FunDecl, Statement, TypedName, Vec2, Vec3, Vec4, abs_, add, ands, arr, assign, by, byF, call0, call1, call2, call4, ceil_, decl, def, div, dot2, dotted2, dotted3, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, if_, int, log, lt, mat3T, max_, min_, mod, negate_, normalize, one, pow, radians_, return, sign, subtract, ternary, unknown, unknownFunDecl, unknownTypedName, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, TypedName, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, by, by2, by3, byF, call0, call1, call2, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun0, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) type alias Uniforms = - { u_canvasWidth : Expression Float - , u_canvasHeight : Expression Float - , u_viewportWidth : Expression Float - , u_viewportHeight : Expression Float - , u_drawAxes : Expression Float - , u_zoomCenter : Expression Vec2 + { u_canvasWidth : Expression1 Float + , u_canvasHeight : Expression1 Float + , u_viewportWidth : Expression1 Float + , u_viewportHeight : Expression1 Float + , u_drawAxes : Expression1 Float + , u_zoomCenter : Expression2 } -constantToGlsl : GlslConstant -> FunDecl +constantToGlsl : GlslConstant -> ( FunDecl, Expression2 ) constantToGlsl c = case c of I -> @@ -32,93 +32,79 @@ constantToGlsl c = [ return <| vec2 (exp one) zero ] -by2Tuple : ( FunDecl, Expression Vec2 -> Expression Vec2 -> Expression Vec2 ) -by2Tuple = - fun2 vec2T "by" (vec2T "a") (vec2T "b") <| +cbyTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cbyTuple = + fun2 vec2T "cby" (vec2T "a") (vec2T "b") <| \a b -> - let - da = - dotted2 a - - db = - dotted2 b - in [ return <| vec2 (subtract - (by da.x db.x) - (by da.y db.y) + (by a.x b.x) + (by a.y b.y) ) (add - (by da.x db.y) - (by da.y db.x) + (by a.x b.y) + (by a.y b.x) ) ] -by2Decl : FunDecl -by2Decl = - Tuple.first by2Tuple +cbyDecl : FunDecl +cbyDecl = + Tuple.first cbyTuple -by2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -by2 = - Tuple.second by2Tuple +cby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cby = + Tuple.second cbyTuple -by3Tuple : ( FunDecl, Expression Vec2 -> Expression Vec2 -> Expression Vec2 -> Expression Vec2 ) -by3Tuple = - fun3 vec2T "by" (vec2T "a") (vec2T "b") (vec2T "c") <| +cby3Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) +cby3Tuple = + fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| \a b c -> - [ return <| by2 (by2 a b) c ] + [ return <| cby (cby a b) c ] -by3Decl : FunDecl -by3Decl = - Tuple.first by3Tuple +cby3Decl : FunDecl +cby3Decl = + Tuple.first cby3Tuple -by3 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -> Expression Vec2 -by3 = - Tuple.second by3Tuple +cby3 : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 +cby3 = + Tuple.second cby3Tuple -div2Tuple : ( FunDecl, Expression Vec2 -> Expression Vec2 -> Expression Vec2 ) -div2Tuple = - fun2 vec2T "div" (vec2T "a") (vec2T "b") <| +cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cdivTuple = + fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b -> - let - da = - dotted2 a - - db = - dotted2 b - in - def floatT "k" (div one <| dot2 b b) <| + def floatT "k" (div one <| dot b b) <| \k -> - def floatT "r" (by k <| dot2 a b) <| + def floatT "r" (by k <| dot a b) <| \r -> def floatT "i" (by k - (subtract (by da.y db.x) (by da.x db.y)) + (subtract (by a.y b.x) (by a.x b.y)) ) <| \i -> [ return <| vec2 r i ] -div2Decl : FunDecl -div2Decl = - Tuple.first div2Tuple +cdivDecl : FunDecl +cdivDecl = + Tuple.first cdivTuple -div2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -div2 = - Tuple.second div2Tuple +cdiv : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cdiv = + Tuple.second cdivTuple -log10Tuple : ( FunDecl, Expression Float -> Expression Float ) +log10Tuple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) log10Tuple = fun1 floatT "log10" (floatT "x") <| \x -> [ return <| div (log x) (log <| float 10) ] @@ -129,11 +115,21 @@ log10Decl = Tuple.first log10Tuple -log10 : Expression Float -> Expression Float +log10 : ExpressionX xa Float -> Expression1 Float log10 = Tuple.second log10Tuple +callUnknown1 : String -> ExpressionX a l -> Expression1 t +callUnknown1 = + call1 << unknownFun1 + + +callUnknown2 : String -> ExpressionX a l -> ExpressionX b r -> Expression1 t +callUnknown2 = + call2 << unknownFun2 + + straightOperationToGlsl : GlslOperation -> List FunDecl straightOperationToGlsl op = case op of @@ -141,45 +137,52 @@ straightOperationToGlsl op = [] GlslMultiplication -> - [ by2Decl - , by3Decl + [ cbyDecl + , cby3Decl ] GlslNegation -> [] GlslDivision -> - [ div2Decl + [ cdivDecl ] GlslPower -> - [ Tuple.first <| - fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| - \w z -> - let - dw = - dotted2 w - - dz = - dotted2 z - in - [ return <| - ternary - (ands - [ geq dw.x zero - , eq dw.y zero - , eq dz.y zero - ] - ) - (vec2 (pow dw.x dz.x) zero) - (call1 (unknownTypedName "cexp") <| by (call1 (unknownTypedName "cln") w) z) - ] + [ cpowDecl ] GlslRelations -> [] +cpowTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cpowTuple = + fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| + \w z -> + [ return <| + ternary + (ands + [ geq w.x zero + , eq w.y zero + , eq z.y zero + ] + ) + (vec2 (pow w.x z.x) zero) + (callUnknown1 "cexp" <| cby (callUnknown1 "cln" w) z) + ] + + +cpowDecl : FunDecl +cpowDecl = + Tuple.first cpowTuple + + +cpow : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cpow = + Tuple.second cpowTuple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -342,19 +345,20 @@ straightFunctionToGlsl name = ] Sin22 -> - [ unknownFunDecl - { name = "csin" - , type_ = "vec2 -> vec2" - , body = - """ - vec2 csin(vec2 z) { - if(z.y == 0.0) { - return vec2(sin(z.x), 0); - } - return vec2(sin(z.x) * cosh(z.y), cos(z.x) * sinh(z.y)); - } - """ - } + [ Tuple.first <| + fun1 vec2T "csin" (vec2T "z") <| + \z -> + def floatT "s" (sin_ z.x) <| + \s -> + [ return <| + ternary + (eq z.y (float 0)) + (vec2 s (float 0)) + (vec2 + (by s (cosh z.y)) + (by (cos_ z.x) (sinh z.y)) + ) + ] ] Cos22 -> @@ -383,7 +387,7 @@ straightFunctionToGlsl name = if(z.y == 0.0) { return vec2(tan(z.x), 0); } - return div(csin(z), ccos(z)); + return cdiv(csin(z), ccos(z)); } """ } @@ -396,9 +400,9 @@ straightFunctionToGlsl name = , type_ = "TODO" , body = """ vec2 casin(vec2 z) { - vec2 s = csqrt(vec2(1, 0) - by(z, z)); - vec2 arg = s - by(vec2(0, 1), z); - return by(vec2(0, 1), cln(arg)); + vec2 s = csqrt(vec2(1, 0) - cby(z, z)); + vec2 arg = s - cby(vec2(0, 1), z); + return cby(vec2(0, 1), cln(arg)); } """ } @@ -428,9 +432,9 @@ straightFunctionToGlsl name = return vec2(atan(z.x), 0); } vec2 o = vec2(1, 0); - vec2 iz = by(vec2(0, 1), z); - vec2 l = div(o + iz, o - iz); - return -0.5 * by(vec2(0, 1), cln(l)); + vec2 iz = cby(vec2(0, 1), z); + vec2 l = cdiv(o + iz, o - iz); + return -0.5 * cby(vec2(0, 1), cln(l)); } """ } @@ -469,7 +473,7 @@ straightFunctionToGlsl name = vec2 ctanh(vec2 z) { vec2 p = cexp(z); vec2 m = cexp(-z); - return div(p - m, p + m); + return cdiv(p - m, p + m); } """ } ] @@ -514,7 +518,7 @@ straightFunctionToGlsl name = Square22 -> [ unknownFunDecl { name = "csquare", type_ = "TODO", body = """ vec2 csquare(vec2 z) { - return by(z, z); + return cby(z, z); } """ } ] @@ -533,7 +537,7 @@ straightFunctionToGlsl name = Log1022 -> [ unknownFunDecl { name = "clog10", type_ = "TODO", body = """ vec2 clog10(vec2 z) { - return div(cln(z), vec2(log(10.0), 0)); + return cdiv(cln(z), vec2(log(10.0), 0)); } """ } ] @@ -1039,7 +1043,7 @@ toSrcImplicit suffix e = in """ float f""" ++ suffix ++ """(float x, float y) { - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ) ] e) ++ """; + vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { return 0.0; } @@ -1077,7 +1081,7 @@ toSrcPolar suffix e = if(t < ot) t += radians(360.0); else t -= radians(360.0); } - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ), ( "r", unknown "r" ), ( "t", unknown "t" ) ] e) ++ """; + vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ), ( "r", dotted1 <| unknown "r" ), ( "t", dotted1 <| unknown "t" ) ] e).base ++ """; if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { return -1.0; } @@ -1189,8 +1193,8 @@ toSrcVectorField2D : String -> Expression.Expression -> Expression.Expression -> toSrcVectorField2D suffix x y = """ vec2 vector""" ++ suffix ++ """(float x, float y) { - vec2 xv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ) ] x) ++ """; - vec2 yv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ) ] y) ++ """; + vec2 xv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] x).base ++ """; + vec2 yv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] y).base ++ """; return abs(xv.y) + abs(yv.y) < """ ++ floatToGlsl epsilon ++ """ ? vec2(xv.x, yv.x) : vec2(0,0); } @@ -1261,7 +1265,7 @@ toSrcContour : String -> Expression.Expression -> String toSrcContour suffix e = """ vec3 pixel""" ++ suffix ++ """_o(float deltaX, float deltaY, float x, float y) { - vec2 z = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ) ] e) ++ """; + vec2 z = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; float theta = atan(z.y, z.x) / radians(360.0); @@ -1309,7 +1313,7 @@ toSrcRelation : String -> Expression.Expression -> String toSrcRelation suffix e = """ vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", unknown "x" ), ( "y", unknown "y" ) ] e) ++ """; + vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; return complex.x > 0.0 && abs(complex.y) < """ ++ floatToGlsl epsilon ++ """ ? vec3(0.8,0.5,0.5) : vec3(0,0,0); } """ @@ -1350,7 +1354,7 @@ expressionToIntervalGlsl expandIntervals = >> wordWrap -expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 +expressionToGlsl : List ( String, Expression1 Float ) -> Expression.Expression -> Expression2 expressionToGlsl context = let ctx = @@ -1373,7 +1377,7 @@ expressionToGlsl context = vec2 w zero Nothing -> - unknown <| "Variable " ++ v ++ " is undefined" + dotted2 <| unknown <| "Variable " ++ v ++ " is undefined" PInteger v -> vec2 (float <| toFloat v) zero @@ -1382,29 +1386,29 @@ expressionToGlsl context = vec2 (float f) zero PNegate expression -> - negate_ <| go expression + negate2 <| go expression PAdd l (PNegate r) -> - subtract (go l) (go r) + subtract2 (go l) (go r) PAdd l r -> - add (go l) (go r) + add2 (go l) (go r) PRel op l r -> if op == "<=" || op == "<" then - subtract (go r) (go l) + subtract2 (go r) (go l) else if op == "=" then - abs_ <| subtract (go r) (go l) + abs2 <| subtract (go r) (go l) else - subtract (go l) (go r) + subtract2 (go l) (go r) PBy l r -> - by2 (go l) (go r) + cby (go l) (go r) PDiv l r -> - div2 (go l) (go r) + cdiv (go l) (go r) PPower (PVariable v) (PInteger 2) -> case Dict.get v ctx of @@ -1412,28 +1416,28 @@ expressionToGlsl context = vec2 (by w w) zero Nothing -> - unknown <| "Variable " ++ v ++ " is undefined" + dotted2 <| unknown <| "Variable " ++ v ++ " is undefined" PPower l r -> - call2 (unknownTypedName "cpow") (go l) (go r) + cpow (go l) (go r) PApply (KnownFunction Simplify) [ e ] -> go e PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map go ex of + case List.map (go >> .base) ex of [] -> vec2Zero head :: tail -> - List.foldl (\e a -> call2 (unknownTypedName <| "c" ++ Expression.functionNameToString name) a e) head tail + dotted2 (List.foldl (\e a -> unsafeCall ("c" ++ Expression.functionNameToString name) [ a, e ]) head tail) else - unsafeCall ("c" ++ Expression.functionNameToString name) (List.map go ex) + dotted2 <| unsafeCall ("c" ++ Expression.functionNameToString name) (List.map (go >> .base) ex) PList es -> - unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map go es) + dotted2 <| unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map (go >> .base) es) PReplace var e -> go (Expression.pfullSubstitute var e) @@ -1571,12 +1575,12 @@ expressionToIntervalGlslPrec expandIntervals p expr = "vec2(0)" -expressionToNormalGlsl : { x : Expression Float, y : Expression Float, z : Expression Float } -> Expression.Expression -> Expression Vec4 +expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 expressionToNormalGlsl { x, y, z } = let - gnum : Expression Float -> Expression Vec4 - gnum = - call1 (unknownTypedName "gnum") + gnum : Expression1 Float -> Expression4 + gnum e = + dotted4 (callUnknown1 "gnum" e).base go expr = case expr of @@ -1602,35 +1606,35 @@ expressionToNormalGlsl { x, y, z } = gnum <| float f PNegate expression -> - call1 (unknownTypedName "gneg") (go expression) + dotted4 (callUnknown1 "gneg" (go expression)).base PAdd l r -> - add (go l) (go r) + add4 (go l) (go r) PRel op l r -> if op == "<=" || op == "<" then - subtract (go r) (go l) + subtract4 (go r) (go l) else if op == "=" then - abs_ <| subtract (go r) (go l) + abs4 <| subtract (go r) (go l) else - subtract (go l) (go r) + subtract4 (go l) (go r) PBy l r -> - call2 (unknownTypedName "gby") (go l) (go r) + dotted4 (callUnknown2 "gby" (go l) (go r)).base PDiv l r -> - call2 (unknownTypedName "gdiv") (go l) (go r) + dotted4 (callUnknown2 "gdiv" (go l) (go r)).base PPower l (PInteger 2) -> - call1 (unknownTypedName "gsquare") (go l) + dotted4 (callUnknown1 "gsquare" (go l)).base PPower l (PInteger ri) -> - call2 (unknownTypedName "gpow") (go l) (int ri) + dotted4 (callUnknown2 "gpow" (go l) (int ri)).base PPower l r -> - call2 (unknownTypedName "gpow") (go l) (go r) + dotted4 (callUnknown2 "gpow" (go l) (go r)).base PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then @@ -1639,13 +1643,13 @@ expressionToNormalGlsl { x, y, z } = vec4Zero head :: tail -> - List.foldl (\e a -> call2 (unknownTypedName <| "g" ++ Expression.functionNameToString name) a e) head tail + List.foldl (\e a -> dotted4 (callUnknown2 ("g" ++ Expression.functionNameToString name) a e).base) head tail else - unsafeCall ("g" ++ Expression.functionNameToString name) (List.map go ex) + dotted4 (unsafeCall ("g" ++ Expression.functionNameToString name) (List.map (go >> .base) ex)) PList es -> - unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map go es) + dotted4 (unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map (go >> .base) es)) PReplace var e -> go (Expression.pfullSubstitute var e) @@ -1665,35 +1669,54 @@ mainGlsl : -> Bool -> List - { name : TypedName (Float -> Float -> Float -> Float -> Vec3) + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 , color : Bool } -> List String -> String -mainGlsl uniforms rayDifferentials pixel2 pixel3 = - case ( pixel2, pixel3 ) of +mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = + case ( pixel2Def, pixel3Def ) of ( _, [] ) -> + let + ( pixel2Decl, pixel2 ) = + main2D uniforms pixel2Def + in Generator.fileToGlsl <| - main2D uniforms pixel2 - ++ [ fun0 voidT "main" <| - [ assign gl_FragColor <| call0 (unknownTypedName "pixel2") ] + pixel2Decl + ++ [ Tuple.first <| + fun0 voidT "main" <| + [ assign gl_FragColor pixel2 + ] ] ( [], _ ) -> - main3D rayDifferentials pixel3 + let + ( pixel3Decl, pixel3 ) = + main3D rayDifferentials pixel3Def + in + pixel3Decl ++ "\n\n" ++ Generator.fileToGlsl - [ fun0 voidT "main" <| - [ assign gl_FragColor <| call0 (unknownTypedName "pixel3") ] + [ Tuple.first <| + fun0 voidT "main" <| + [ assign gl_FragColor pixel3 ] ] _ -> - Generator.fileToGlsl (main2D uniforms pixel2) + let + ( pixel2Decl, pixel2 ) = + main2D uniforms pixel2Def + + ( pixel3Decl, pixel3 ) = + main3D rayDifferentials pixel3Def + in + Generator.fileToGlsl pixel2Decl ++ "\n\n" - ++ main3D rayDifferentials pixel3 + ++ pixel3Decl ++ Generator.fileToGlsl - [ fun0 voidT "main" <| - [ assign gl_FragColor <| max_ (call0 (unknownTypedName "pixel2")) (call0 (unknownTypedName "pixel3")) ] + [ Tuple.first <| + fun0 voidT "main" <| + [ assign gl_FragColor <| max4 pixel2 pixel3 ] ] @@ -1701,57 +1724,33 @@ main2D : Uniforms -> List - { name : TypedName (Float -> Float -> Float -> Float -> Vec3) + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 , color : Bool } - -> File + -> ( File, Expression4 ) main2D uniforms pixels = - [ log10Decl - , axisDecl - , pixel2Decl uniforms pixels - ] + let + ( pixel2Decl, pixel2 ) = + pixel2Tuple uniforms pixels + in + ( [ log10Decl + , axisDecl + , pixel2Decl + ] + , pixel2 + ) -pixel2Decl : +pixel2Tuple : Uniforms -> List - { name : TypedName (Float -> Float -> Float -> Float -> Vec3) + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 , color : Bool } - -> FunDecl -pixel2Decl uniforms pixels = + -> ( FunDecl, Expression4 ) +pixel2Tuple uniforms pixels = let - addPixel : - Expression Float - -> Expression Float - -> Expression Float - -> Expression Float - -> Expression Vec3 - -> Expression Vec3 - -> Int - -> - { name : TypedName (Float -> Float -> Float -> Float -> Vec3) - , color : Bool - } - -> List (Statement f) - addPixel deltaX deltaY x y px curr i { name, color } = - let - k = - if color then - let - h = - float <| (toFloat (i + 2) / pi) - in - by (call2 (unknownTypedName "hl2rgb") h (float 0.5)) (call4 name deltaX deltaY x y) - - else - call4 name deltaX deltaY x y - in - [ assign curr k - , assign px <| ternary (eq curr vec3Zero) px curr - ] - inner deltaX deltaY x y px curr = pixels |> List.indexedMap (addPixel deltaX deltaY x y px curr) @@ -1760,17 +1759,17 @@ pixel2Decl uniforms pixels = fun0 vec4T "pixel2" <| def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> - def vec2T "uv_centered" (subtract (dotted4 gl_FragCoord).xy (byF (float 0.5) canvasSize)) <| + def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| \uv_centered -> def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| \viewportSize -> - def vec2T "uv" (by (div uv_centered canvasSize) viewportSize) <| + def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| \uv -> def vec2T "c" (add uniforms.u_zoomCenter uv) <| \c -> - def floatT "x" (dotted2 c).x <| + def floatT "x" c.x <| \x -> - def floatT "y" (dotted2 c).y <| + def floatT "y" c.y <| \y -> def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| \deltaX -> @@ -1785,7 +1784,7 @@ pixel2Decl uniforms pixels = \maxDelta -> def vec3T "yax" - (ternary + (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero @@ -1794,19 +1793,50 @@ pixel2Decl uniforms pixels = \yax -> def vec3T "xax" - (ternary + (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero ) <| \xax -> - [ return <| vec4_3_1 (max_ px (max_ xax yax)) one + [ return <| vec4_3_1 (max3 px (max3 xax yax)) one ] ) -axisTuple : ( FunDecl, Expression Float -> Expression Float -> Expression Float -> Expression Float ) +addPixel : + Expression1 Float + -> Expression1 Float + -> Expression1 Float + -> Expression1 Float + -> Expression3 + -> Expression3 + -> Int + -> + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 + , color : Bool + } + -> List (Statement f) +addPixel deltaX deltaY x y px curr i { call, color } = + let + k = + if color then + let + h = + float <| (toFloat (i + 2) / pi) + in + by3 (hl2rgb h (float 0.5)) (call deltaX deltaY x y) + + else + call deltaX deltaY x y + in + [ assign curr k + , assign px <| ternary3 (eq curr vec3Zero) px curr + ] + + +axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) axisTuple = fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta -> @@ -1838,7 +1868,7 @@ axisTuple = ) -axis : Expression Float -> Expression Float -> Expression Float -> Expression Float +axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float axis = Tuple.second axisTuple @@ -1853,19 +1883,15 @@ toSrc3D expandIntervals suffix e = [ Tuple.first <| fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> - let - dp = - dotted3 p - in - def floatT "x" dp.x <| + def floatT "x" p.x <| \x -> - def floatT "y" dp.y <| + def floatT "y" p.y <| \y -> - def floatT "z" dp.z <| + def floatT "z" p.z <| \z -> def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> - [ return <| normalize (dotted4 gradient).yzw ] + [ return <| normalize gradient.yzw ] , Tuple.first <| fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> @@ -1873,24 +1899,17 @@ toSrc3D expandIntervals suffix e = \mn -> def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> - let - dmn = - dotted3 mn - - dmx = - dotted3 mx - in - def vec2T "x" (vec2 dmn.x dmx.x) <| + def vec2T "x" (vec2 mn.x mx.x) <| \x -> - def vec2T "y" (vec2 dmn.y dmx.y) <| + def vec2T "y" (vec2 mn.y mx.y) <| \y -> - def vec2T "z" (vec2 dmn.z dmx.z) <| + def vec2T "z" (vec2 mn.z mx.z) <| \z -> - [ return <| unknown <| expressionToIntervalGlsl expandIntervals e ] + [ return <| dotted2 <| unknown <| expressionToIntervalGlsl expandIntervals e ] ] -main3D : Bool -> List String -> String +main3D : Bool -> List String -> ( String, Expression4 ) main3D rayDifferentials suffixes = let k = @@ -1935,7 +1954,7 @@ main3D rayDifferentials suffixes = } """ in - deindent 12 <| raytrace suffixes ++ block + ( deindent 12 <| raytrace suffixes ++ block, dotted4 <| unknown "pixel3()" ) raytrace : List String -> String diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 3fb5820b..0a9f61b5 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, File, FunDecl, Mat3, Name, Statement(..), Type, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs_, add, ands, arr, assign, by, byF, call0, call1, call2, call4, ceil_, decl, def, div, dot2, dot3, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, if_, int, leq, log, lt, mat3T, max_, min_, mod, negate_, normalize, one, pow, radians_, return, sign, statementToGlsl, subtract, ternary, true, uniform, unknown, unknownFunDecl, unknownName, unknownTypedName, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun0, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -16,109 +16,84 @@ type Statement r = Block String (List (Statement r)) | Line String | Return (Expression r) - | Expression (Expression Never) - | Decl String Name (Maybe (Expression Never)) + | ExpressionStatement Expr + | Decl String Name (Maybe Expr) -type Expression t +type Expr = Bool Bool | Int Int | Float Float | Variable String - | And (Expression Bool) (Expression Bool) - | Or (Expression Bool) (Expression Bool) - | Comparison RelationOperation (Expression Never) (Expression Never) - | Ternary (Expression Bool) (Expression t) (Expression t) - | Add (Expression t) (Expression t) - | Subtract (Expression t) (Expression t) - | By (Expression t) (Expression t) - | Div (Expression t) (Expression t) - | Call String (List (Expression Never)) - | Negate (Expression t) + | And Expr Expr + | Or Expr Expr + | Comparison RelationOperation Expr Expr + | Ternary Expr Expr Expr + | Add Expr Expr + | Subtract Expr Expr + | By Expr Expr + | Div Expr Expr + | Call String (List Expr) + | Negate Expr | Unknown String - | Dot (Expression Never) String - | Array (Expression Never) (Expression Int) - | Assign (Expression t) (Expression t) - - -type alias TypingFunction t = - String -> TypedName t - - -type alias TypedName t = - ( Type t, Name ) - - -type Type t - = Type String + | Dot Expr String + | Array Expr Expr + | Assign Expr Expr -type Name - = Name String - - - --- Internal-only functions - +type Expression t + = Expression Expr -{-| UNSAFE --} -typecastExpression : Expression f -> Expression t -typecastExpression e = - case e of - Unknown u -> - Unknown u - Bool b -> - Bool b +type alias ExpressionX a t = + { a | base : Expression t } - Float f -> - Float f - Int i -> - Int i +type alias Expression1 t = + { base : Expression t + } - Variable v -> - Variable v - And l r -> - And l r +type alias Expression2 = + { base : Expression Vec2 + , x : Expression1 Float + , y : Expression1 Float + } - Or l r -> - Or l r - Comparison rel l r -> - Comparison rel l r +type alias Expression3 = + { base : Expression Vec3 + , x : Expression1 Float + , y : Expression1 Float + , z : Expression1 Float + } - Ternary c t f -> - Ternary c (typecastExpression t) (typecastExpression f) - Negate l -> - Negate <| typecastExpression l +type alias Expression4 = + { base : Expression Vec4 + , x : Expression1 Float + , y : Expression1 Float + , z : Expression1 Float + , w : Expression1 Float + , xy : Expression2 + , yzw : Expression3 + } - Add l r -> - Add (typecastExpression l) (typecastExpression r) - Subtract l r -> - Subtract (typecastExpression l) (typecastExpression r) +type alias TypingFunction t r = + String -> ( TypedName t r, Expression t -> r ) - By l r -> - By (typecastExpression l) (typecastExpression r) - Div l r -> - Div (typecastExpression l) (typecastExpression r) +type TypedName t r + = TypedName Type Name r - Dot l r -> - Dot l r - Call n args -> - Call n args +type Type + = Type String - Array l r -> - Array l r - Assign l r -> - Assign (typecastExpression l) (typecastExpression r) +type Name + = Name String @@ -164,11 +139,11 @@ statementToGlsl = Return e -> indent i <| "return " ++ expressionToGlsl e ++ ";" - Expression e -> - indent i <| expressionToGlsl e ++ ";" + ExpressionStatement e -> + indent i <| expressionToGlsl (Expression e) ++ ";" Decl t (Name n) (Just e) -> - indent i <| t ++ " " ++ n ++ " = " ++ expressionToGlsl e ++ ";" + indent i <| t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";" Decl t (Name n) Nothing -> indent i <| t ++ " " ++ n ++ ";" @@ -177,10 +152,10 @@ statementToGlsl = expressionToGlsl : Expression t -> String -expressionToGlsl = +expressionToGlsl (Expression tree) = let -- The numbers are precedence numbers from the GLSL spec - go : Bool -> Expression a -> String + go : Bool -> Expr -> String go rec e = case e of Unknown u -> @@ -189,11 +164,11 @@ expressionToGlsl = _ -> go17 rec e - go17 : Bool -> Expression b -> String + go17 : Bool -> Expr -> String go17 rec e = go16 rec e - go16 : Bool -> Expression c -> String + go16 : Bool -> Expr -> String go16 rec e = case e of Assign l r -> @@ -202,7 +177,7 @@ expressionToGlsl = _ -> go15 rec e - go15 : Bool -> Expression d -> String + go15 : Bool -> Expr -> String go15 rec e = case e of Ternary c t f -> @@ -211,41 +186,41 @@ expressionToGlsl = _ -> go14 rec e - go14 : Bool -> Expression e -> String + go14 : Bool -> Expr -> String go14 rec e = case e of Or l r -> - go14 False (typecastExpression l) ++ " || " ++ go13 False r + go14 False l ++ " || " ++ go13 False r _ -> go13 rec e - go13 : Bool -> Expression f -> String + go13 : Bool -> Expr -> String go13 rec e = go12 rec e - go12 : Bool -> Expression g -> String + go12 : Bool -> Expr -> String go12 rec e = case e of And l r -> - go12 False (typecastExpression l) ++ " && " ++ go11 False r + go12 False l ++ " && " ++ go11 False r _ -> go11 rec e - go11 : Bool -> Expression h -> String + go11 : Bool -> Expr -> String go11 rec e = go10 rec e - go10 : Bool -> Expression i -> String + go10 : Bool -> Expr -> String go10 rec e = go9 rec e - go9 : Bool -> Expression j -> String + go9 : Bool -> Expr -> String go9 rec e = go8 rec e - go8 : Bool -> Expression k -> String + go8 : Bool -> Expr -> String go8 rec e = case e of Comparison Equals l r -> @@ -254,7 +229,7 @@ expressionToGlsl = _ -> go7 rec e - go7 : Bool -> Expression l -> String + go7 : Bool -> Expr -> String go7 rec e = case e of Comparison LessThan l r -> @@ -272,11 +247,11 @@ expressionToGlsl = _ -> go6 rec e - go6 : Bool -> Expression m -> String + go6 : Bool -> Expr -> String go6 rec e = go5 rec e - go5 : Bool -> Expression n -> String + go5 : Bool -> Expr -> String go5 rec e = case e of Add l r -> @@ -288,7 +263,7 @@ expressionToGlsl = _ -> go4 rec e - go4 : Bool -> Expression o -> String + go4 : Bool -> Expr -> String go4 rec e = case e of By l r -> @@ -300,7 +275,7 @@ expressionToGlsl = _ -> go3 rec e - go3 : Bool -> Expression p -> String + go3 : Bool -> Expr -> String go3 rec e = case e of Negate c -> @@ -309,22 +284,22 @@ expressionToGlsl = _ -> go2 rec e - go2 : Bool -> Expression q -> String + go2 : Bool -> Expr -> String go2 rec e = case e of Call name args -> name ++ "(" ++ String.join "," (List.map (go False) args) ++ ")" Dot l r -> - go2 False (typecastExpression l) ++ "." ++ r + go2 False l ++ "." ++ r Array l r -> - go2 False (typecastExpression l) ++ "[" ++ go False r ++ "]" + go2 False l ++ "[" ++ go False r ++ "]" _ -> go1 rec e - go1 : Bool -> Expression r -> String + go1 : Bool -> Expr -> String go1 rec e = case e of Bool b -> @@ -345,12 +320,12 @@ expressionToGlsl = _ -> if rec then - "!!!Error in toString for Glsl!!!" + "!!!Internal error in toString for Glsl!!!" else "(" ++ go True e ++ ")" in - go False + go False tree indent : Int -> String -> String @@ -362,362 +337,596 @@ indent i line = --EXPRESSIONS -ternary : Expression Bool -> Expression t -> Expression t -> Expression t +ternary : ExpressionX a Bool -> ExpressionX b t -> ExpressionX c t -> Expression1 t ternary = - Ternary + expr3 Ternary + +ternary2 : ExpressionX xa Bool -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 +ternary2 = + expr32 Ternary -ands : List (Expression Bool) -> Expression Bool + +ternary3 : ExpressionX xa Bool -> ExpressionX xb Vec3 -> ExpressionX xc Vec3 -> Expression3 +ternary3 = + expr33 Ternary + + +ands : List (Expression1 Bool) -> Expression1 Bool ands es = case es of [] -> true h :: t -> - List.foldl (\e a -> And a e) h t + List.foldl (\e a -> expr2 And a e) h t -true : Expression Bool +true : Expression1 Bool true = - Bool True + dotted1 <| Expression <| Bool True -false : Expression Bool +false : Expression1 Bool false = - Bool False + dotted1 <| Expression <| Bool False + + +expr1 : (Expr -> Expr) -> ExpressionX a l -> Expression1 t +expr1 f e = + dotted1Internal (f (unwrapExpression e)) + + +expr2 : (Expr -> Expr -> Expr) -> ExpressionX a l -> ExpressionX b r -> Expression1 t +expr2 f l r = + dotted1Internal (f (unwrapExpression l) (unwrapExpression r)) -add : Expression t -> Expression t -> Expression t +expr22 : (Expr -> Expr -> Expr) -> ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +expr22 f l r = + dotted2Internal (f (unwrapExpression l) (unwrapExpression r)) + + +expr23 : (Expr -> Expr -> Expr) -> ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +expr23 f l r = + dotted3Internal (f (unwrapExpression l) (unwrapExpression r)) + + +expr24 : (Expr -> Expr -> Expr) -> ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +expr24 f l r = + dotted4Internal (f (unwrapExpression l) (unwrapExpression r)) + + +expr3 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX a l -> ExpressionX b m -> ExpressionX c r -> Expression1 t +expr3 f l m r = + dotted1Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) + + +expr32 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX xa a -> ExpressionX xb b -> ExpressionX xc c -> Expression2 +expr32 f l m r = + dotted2Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) + + +expr33 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX xa a -> ExpressionX xb b -> ExpressionX xc c -> Expression3 +expr33 f l m r = + dotted3Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) + + +unwrapExpression : ExpressionX a e -> Expr +unwrapExpression { base } = + let + (Expression e) = + base + in + e + + + +------------------------------ +-- FUNCTIONS AND OPERATIONS -- +------------------------------ + + +add : ExpressionX a t -> ExpressionX a t -> Expression1 t add = - Add + expr2 Add + + +add2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +add2 = + expr22 Add + + +add4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +add4 = + expr24 Add -subtract : Expression t -> Expression t -> Expression t +subtract : ExpressionX a t -> ExpressionX a t -> Expression1 t subtract = - Subtract + expr2 Subtract -negate_ : Expression t -> Expression t +subtract2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +subtract2 = + expr22 Subtract + + +subtract4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +subtract4 = + expr24 Subtract + + +negate_ : ExpressionX a t -> Expression1 t negate_ = - Negate + expr1 Negate -by : Expression t -> Expression t -> Expression t +negate2 : ExpressionX a Vec2 -> Expression2 +negate2 e = + dotted2Internal (Negate <| unwrapExpression e) + + +by : ExpressionX a t -> ExpressionX a t -> Expression1 t by = - By + expr2 By + +by2 : ExpressionX a Vec2 -> ExpressionX a Vec2 -> Expression2 +by2 = + expr22 By -byF : Expression Float -> Expression t -> Expression t -byF l = - By (typecastExpression l) +by3 : ExpressionX a Vec3 -> ExpressionX a Vec3 -> Expression3 +by3 = + expr23 By -div : Expression t -> Expression t -> Expression t + +byF : ExpressionX a Float -> ExpressionX b t -> Expression1 t +byF = + expr2 By + + +div : ExpressionX a t -> ExpressionX a t -> Expression1 t div = - Div + expr2 Div -lt : Expression t -> Expression t -> Expression Bool -lt l r = - Comparison LessThan (typecastExpression l) (typecastExpression r) +div2 : ExpressionX a Vec2 -> ExpressionX a Vec2 -> Expression2 +div2 = + expr22 Div -leq : Expression t -> Expression t -> Expression Bool -leq l r = - Comparison LessThanOrEquals (typecastExpression l) (typecastExpression r) +lt : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +lt = + expr2 (Comparison LessThan) -eq : Expression t -> Expression t -> Expression Bool -eq l r = - Comparison Equals (typecastExpression l) (typecastExpression r) +leq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +leq = + expr2 (Comparison LessThanOrEquals) -geq : Expression t -> Expression t -> Expression Bool -geq l r = - Comparison GreaterThanOrEquals (typecastExpression l) (typecastExpression r) +eq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +eq = + expr2 (Comparison Equals) -gt : Expression t -> Expression t -> Expression Bool -gt l r = - Comparison GreaterThan (typecastExpression l) (typecastExpression r) +geq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +geq = + expr2 (Comparison GreaterThanOrEquals) -unsafeCall : String -> List (Expression t) -> Expression r -unsafeCall name = - Call name << List.map typecastExpression +gt : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +gt = + expr2 (Comparison GreaterThan) -call0 : TypedName r -> Expression r -call0 ( _, Name fname ) = - Call fname [] +abs_ : ExpressionX a t -> Expression1 t +abs_ = + dotted1 << call1Internal "abs" -call1 : TypedName (a -> r) -> Expression a -> Expression r -call1 ( _, Name fname ) arg0 = - Call fname [ typecastExpression arg0 ] +abs2 : ExpressionX a Vec2 -> Expression2 +abs2 = + dotted2 << call1Internal "abs" -call2 : TypedName (a -> b -> r) -> Expression a -> Expression b -> Expression r -call2 ( _, Name fname ) arg0 arg1 = - Call fname [ typecastExpression arg0, typecastExpression arg1 ] +abs4 : ExpressionX a Vec4 -> Expression4 +abs4 = + dotted4 << call1Internal "abs" -call3 : TypedName (a -> b -> c -> r) -> Expression a -> Expression b -> Expression c -> Expression r -call3 ( _, Name fname ) arg0 arg1 arg2 = - Call fname [ typecastExpression arg0, typecastExpression arg1, typecastExpression arg2 ] +exp : ExpressionX a t -> Expression1 t +exp = + dotted1 << call1Internal "exp" -call4 : TypedName (a -> b -> c -> d -> r) -> Expression a -> Expression b -> Expression c -> Expression d -> Expression r -call4 ( _, Name fname ) arg0 arg1 arg2 arg3 = - Call fname [ typecastExpression arg0, typecastExpression arg1, typecastExpression arg2, typecastExpression arg3 ] +sin_ : ExpressionX a t -> Expression1 t +sin_ = + dotted1 << call1Internal "sin" -zero : Expression Float -zero = - Float 0 +cos_ : ExpressionX a t -> Expression1 t +cos_ = + dotted1 << call1Internal "cos" -one : Expression Float -one = - Float 1 +sinh : ExpressionX a t -> Expression1 t +sinh = + dotted1 << call1Internal "sinh" -float : Float -> Expression Float -float = - Float +cosh : ExpressionX a t -> Expression1 t +cosh = + dotted1 << call1Internal "cosh" -int : Int -> Expression Int -int = - Int +log : ExpressionX a t -> Expression1 t +log = + dotted1 << call1Internal "log" -floatToGlsl : Float -> String -floatToGlsl f = - let - s = - String.fromFloat f - in - if String.contains "." s || String.contains "e" s then - s +mod : ExpressionX a t -> ExpressionX a t -> Expression1 t +mod l r = + dotted1 (call2Internal "mod" l r) - else - s ++ "." +min_ : ExpressionX a t -> ExpressionX a t -> Expression1 t +min_ l r = + dotted1 (call2Internal "min" l r) -abs_ : Expression t -> Expression t -abs_ = - call1 ( Type "", Name "abs" ) +max_ : ExpressionX a t -> ExpressionX a t -> Expression1 t +max_ l r = + dotted1 (call2Internal "max" l r) -exp : Expression t -> Expression t -exp = - call1 ( Type "", Name "exp" ) +max3 : ExpressionX a Vec3 -> ExpressionX a Vec3 -> Expression3 +max3 l r = + dotted3 (call2Internal "max" l r) -log : Expression t -> Expression t -log = - call1 ( Type "", Name "log" ) +max4 : ExpressionX a Vec4 -> ExpressionX a Vec4 -> Expression4 +max4 l r = + dotted4 (call2Internal "max" l r) -mod : Expression t -> Expression t -> Expression t -mod = - call2 ( Type "", Name "mod" ) +hl2rgb : Expression1 Float -> Expression1 Float -> Expression3 +hl2rgb h l = + dotted3 (call2Internal "hl2rgb" h l) -dotted2 : - Expression Vec2 - -> - { x : Expression Float - , y : Expression Float - } -dotted2 e = - let - tc = - typecastExpression e - in - { x = Dot tc "x" - , y = Dot tc "y" + +pow : Expression1 Float -> Expression1 Float -> Expression1 Float +pow l r = + dotted1 (call2Internal "pow" l r) + + +ceil_ : ExpressionX a Float -> Expression1 Float +ceil_ = + dotted1 << call1Internal "ceil" + + +sign : ExpressionX a t -> Expression1 t +sign = + dotted1 << call1Internal "sign" + + +radians_ : ExpressionX a Float -> Expression1 Float +radians_ = + dotted1 << call1Internal "radians" + + +normalize : ExpressionX a t -> Expression1 t +normalize = + dotted1 << call1Internal "normalize" + + +arr : ExpressionX a Mat3 -> ExpressionX b Int -> Expression1 Vec3 +arr = + expr2 Array + + +dot : ExpressionX a t -> ExpressionX a t -> Expression1 Float +dot l r = + dotted1 (call2Internal "dot" l r) + + +vec2 : Expression1 Float -> Expression1 Float -> Expression2 +vec2 x y = + { base = call2Internal "vec2" x y + , x = x + , y = y } -dotted3 : - Expression Vec3 - -> - { x : Expression Float - , y : Expression Float - , z : Expression Float - } -dotted3 e = - let - tc = - typecastExpression e - in - { x = Dot tc "x" - , y = Dot tc "y" - , z = Dot tc "z" +vec3 : + Expression1 Float + -> Expression1 Float + -> Expression1 Float + -> Expression3 +vec3 x y z = + { base = call3Internal "vec3" x y z + , x = x + , y = y + , z = z } -dotted4 : - Expression Vec4 - -> - { x : Expression Float - , y : Expression Float - , z : Expression Float - , xy : Expression Vec2 - , yzw : Expression Vec3 - } -dotted4 e = - let - tc = - typecastExpression e - in - { x = Dot tc "x" - , y = Dot tc "y" - , z = Dot tc "z" - , xy = Dot tc "xy" - , yzw = Dot tc "yzw" +vec4 : + Expression1 Float + -> Expression1 Float + -> Expression1 Float + -> Expression1 Float + -> Expression4 +vec4 x y z w = + { base = call4Internal "vec4" x y z w + , x = x + , y = y + , z = z + , w = w + , xy = dotted2 <| call2Internal "vec2" x y + , yzw = dotted3 <| call3Internal "vec3" y z w } -arr : Expression Mat3 -> Expression Int -> Expression Vec3 -arr l r = - Array (typecastExpression l) r +vec4_3_1 : ExpressionX a Vec3 -> ExpressionX b Float -> Expression4 +vec4_3_1 xyz w = + call2Internal "vec4" xyz w + |> dotted4 -dot2 : Expression Vec2 -> Expression Vec2 -> Expression Float -dot2 = - call2 ( Type "", Name "dot" ) +--------------- +-- CONSTANTS -- +--------------- -dot3 : Expression Vec3 -> Expression Vec3 -> Expression Float -dot3 = - call2 ( Type "", Name "dot" ) +vec2Zero : Expression2 +vec2Zero = + { base = call2Internal "vec2" (int 0) (int 0) + , x = zero + , y = zero + } -vec2 : Expression Float -> Expression Float -> Expression Vec2 -vec2 = - call2 ( Type "", Name "vec2" ) +vec3Zero : Expression3 +vec3Zero = + { base = call3Internal "vec3" (int 0) (int 0) (int 0) + , x = zero + , y = zero + , z = zero + } -vec2Zero : Expression Vec2 -vec2Zero = - call1 ( Type "", Name "vec2" ) (int 0) +vec4Zero : Expression4 +vec4Zero = + { base = call4Internal "vec4" (int 0) (int 0) (int 0) (int 0) + , x = zero + , y = zero + , z = zero + , w = zero + , xy = dotted2 <| call2Internal "vec2" zero zero + , yzw = dotted3 <| call3Internal "vec3" zero zero zero + } -vec3 : Expression Float -> Expression Float -> Expression Float -> Expression Vec3 -vec3 = - call3 ( Type "", Name "vec3" ) +gl_FragColor : Expression4 +gl_FragColor = + dotted4 (Expression (Variable "gl_FragColor")) -vec3Zero : Expression Vec3 -vec3Zero = - call1 ( Type "", Name "vec3" ) (int 0) +gl_FragCoord : Expression4 +gl_FragCoord = + dotted4 (Expression (Variable "gl_FragCoord")) -vec4 : Expression Float -> Expression Float -> Expression Float -> Expression Float -> Expression Vec4 -vec4 = - call4 ( Type "", Name "vec4" ) -vec4Zero : Expression Vec4 -vec4Zero = - call1 ( Type "", Name "vec4" ) (int 0) +---------------- +-- CALL UTILS -- +---------------- -vec4_3_1 : Expression Vec3 -> Expression Float -> Expression Vec4 -vec4_3_1 = - call2 ( Type "", Name "vec4" ) +unsafeCall : String -> List (Expression t) -> Expression r +unsafeCall name = + Expression << Call name << List.map (\(Expression e) -> e) -min_ : Expression t -> Expression t -> Expression t -min_ = - call2 ( Type "", Name "min" ) +call0 : TypedName t r -> r +call0 (TypedName _ _ expr) = + expr -max_ : Expression t -> Expression t -> Expression t -max_ = - call2 ( Type "", Name "max" ) +call1 : TypedName t (a -> r) -> a -> r +call1 (TypedName _ _ expr) = + expr -pow : Expression Float -> Expression Float -> Expression Float -pow = - call2 ( Type "", Name "pow" ) +call2 : TypedName t (a -> b -> r) -> a -> b -> r +call2 (TypedName _ _ expr) = + expr -ceil_ : Expression Float -> Expression Float -ceil_ = - call1 ( Type "", Name "ceil" ) +call3 : TypedName t (a -> b -> c -> r) -> a -> b -> c -> r +call3 (TypedName _ _ expr) = + expr -sign : Expression t -> Expression t -sign = - call1 ( Type "", Name "sign" ) +call4 : TypedName t (a -> b -> c -> d -> r) -> a -> b -> c -> d -> r +call4 (TypedName _ _ expr) = + expr -radians_ : Expression Float -> Expression Float -radians_ = - call1 ( Type "", Name "radians" ) +zero : Expression1 Float +zero = + float 0 -normalize : Expression t -> Expression t -normalize = - call1 ( Type "", Name "normalize" ) +one : Expression1 Float +one = + float 1 -unknown : String -> Expression t -unknown = - -- let - -- _ = - -- Debug.todo - -- in - Unknown +float : Float -> Expression1 Float +float f = + dotted1Internal (Float f) -gl_FragColor : Expression Vec3 -gl_FragColor = - Variable "gl_FragColor" +int : Int -> Expression1 Int +int i = + dotted1Internal (Int i) -gl_FragCoord : Expression Vec4 -gl_FragCoord = - Variable "gl_FragCoord" +floatToGlsl : Float -> String +floatToGlsl f = + let + s = + String.fromFloat f + in + if String.contains "." s || String.contains "e" s then + s + else + s ++ "." -uniform : TypingFunction t -> String -> Expression t -uniform _ name = - Variable name +call0Internal : String -> Expression t +call0Internal name = + Expression (Call name []) -unknownName : String -> Name -unknownName = - -- let - -- _ = - -- Debug.todo - -- in - Name +call1Internal : String -> ExpressionX a l -> Expression t +call1Internal name arg0 = + Expression (Call name [ unwrapExpression arg0 ]) -unknownTypedName : String -> TypedName t -unknownTypedName n = - -- let - -- _ = - -- Debug.todo - -- in - ( Type "", Name n ) +call2Internal : String -> ExpressionX a l -> ExpressionX b r -> Expression t +call2Internal name arg0 arg1 = + Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1 ]) --- STATEMENTS +call3Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c r -> Expression t +call3Internal name arg0 arg1 arg2 = + Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2 ]) + + +call4Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c n -> ExpressionX d r -> Expression t +call4Internal name arg0 arg1 arg2 arg3 = + Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2, unwrapExpression arg3 ]) -fun : TypingFunction t -> String -> List ( String, String ) -> List (Statement t) -> FunDecl -fun typeF name args body = +dotted1 : Expression t -> Expression1 t +dotted1 (Expression e) = + dotted1Internal e + + +dotted1Internal : Expr -> Expression1 t +dotted1Internal e = + { base = Expression e + } + + +dotted2 : Expression Vec2 -> Expression2 +dotted2 (Expression e) = + dotted2Internal e + + +dotInternal : Expr -> String -> Expression1 t +dotInternal e v = + dotted1 (Expression (Dot e v)) + + +dotted2Internal : Expr -> Expression2 +dotted2Internal e = + { base = Expression e + , x = dotInternal e "x" + , y = dotInternal e "y" + } + + +dotted3 : Expression Vec3 -> Expression3 +dotted3 (Expression e) = + dotted3Internal e + + +dotted3Internal : Expr -> Expression3 +dotted3Internal e = + { base = Expression e + , x = dotInternal e "x" + , y = dotInternal e "y" + , z = dotInternal e "z" + } + + +dotted4 : Expression Vec4 -> Expression4 +dotted4 (Expression e) = + dotted4Internal e + + +dotted4Internal : Expr -> Expression4 +dotted4Internal e = + { base = Expression e + , x = dotInternal e "x" + , y = dotInternal e "y" + , z = dotInternal e "z" + , w = dotInternal e "w" + , xy = dotted2 (Expression (Dot e "xy")) + , yzw = dotted3 (Expression (Dot e "yzw")) + } + + +uniform : TypingFunction t c -> String -> c +uniform typeF name = let - ( Type rt, _ ) = + ( TypedName _ _ expr, _ ) = typeF name + in + expr + +unknown : String -> Expression t +unknown = + let + _ = + Debug.todo + in + Expression << Unknown + + +unknownFun0 : String -> TypedName t (Expression1 t) +unknownFun0 n = + let + _ = + Debug.todo + in + TypedName (Type "") (Name n) (dotted1 <| call0Internal n) + + +unknownFun1 : String -> TypedName (l -> t) (ExpressionX a l -> Expression1 t) +unknownFun1 n = + let + _ = + Debug.todo + in + TypedName (Type "") (Name n) (\l -> dotted1 <| call1Internal n l) + + +unknownFun2 : String -> TypedName (l -> r -> t) (ExpressionX a l -> ExpressionX b r -> Expression1 t) +unknownFun2 n = + let + _ = + Debug.todo + in + TypedName (Type "") (Name n) (\l r -> dotted1 (call2Internal n l r)) + + + +-- STATEMENTS + + +funInternal : TypedName t c -> List ( String, String ) -> List (Statement t) -> FunDecl +funInternal (TypedName (Type rt) (Name name) _) args body = + let argsList = String.join ", " (List.map (\( t, n ) -> t ++ " " ++ n) args) in @@ -735,83 +944,132 @@ fun typeF name args body = } -argToString : ( Type t, Name ) -> ( String, String ) -argToString ( Type t, Name n ) = +argToString : TypedName t c -> ( String, String ) +argToString (TypedName (Type t) (Name n) _) = ( t, n ) -toVar : TypedName t -> Expression t -toVar ( _, Name n ) = - Variable n +toVar : TypedName t c -> c +toVar (TypedName _ _ expr) = + expr -fun0 : TypingFunction r -> String -> List (Statement r) -> FunDecl +fun0 : + TypingFunction t c + -> String + -> List (Statement t) + -> ( FunDecl, c ) fun0 typeF name body = - fun typeF name [] <| + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [] <| body + , dotter <| call0Internal name + ) -fun1 : TypingFunction r -> String -> TypedName a -> (Expression a -> List (Statement r)) -> ( FunDecl, Expression a -> Expression r ) -fun1 typeF name arg0 body = - ( fun typeF name [ argToString arg0 ] <| +fun1 : + TypingFunction tr r + -> String + -> ( TypedName ta a, Expression ta -> a ) + -> (a -> List (Statement tr)) + -> + ( FunDecl + , ExpressionX xa ta -> r + ) +fun1 typeF name ( arg0, _ ) body = + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [ argToString arg0 ] <| body (toVar arg0) - , call1 ( Type "", Name name ) + , dotter << call1Internal name ) -fun2 : TypingFunction r -> String -> TypedName a -> TypedName b -> (Expression a -> Expression b -> List (Statement r)) -> ( FunDecl, Expression a -> Expression b -> Expression r ) -fun2 typeF name arg0 arg1 body = - ( fun typeF name [ argToString arg0, argToString arg1 ] <| +fun2 : + TypingFunction tr r + -> String + -> ( TypedName ta a, Expression ta -> a ) + -> ( TypedName tb b, Expression tb -> b ) + -> (a -> b -> List (Statement tr)) + -> + ( FunDecl + , ExpressionX xa ta -> ExpressionX xb tb -> r + ) +fun2 typeF name ( arg0, _ ) ( arg1, _ ) body = + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [ argToString arg0, argToString arg1 ] <| body (toVar arg0) (toVar arg1) - , call2 ( Type "", Name name ) + , \l r -> dotter (call2Internal name l r) ) -fun3 : TypingFunction r -> String -> TypedName a -> TypedName b -> TypedName c -> (Expression a -> Expression b -> Expression c -> List (Statement r)) -> ( FunDecl, Expression a -> Expression b -> Expression c -> Expression r ) -fun3 typeF name arg0 arg1 arg2 body = - ( fun typeF name [ argToString arg0, argToString arg1, argToString arg2 ] <| +fun3 : + TypingFunction tr r + -> String + -> ( TypedName ta a, Expression ta -> a ) + -> ( TypedName tb b, Expression tb -> b ) + -> ( TypedName tc c, Expression tc -> c ) + -> (a -> b -> c -> List (Statement tr)) + -> + ( FunDecl + , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> r + ) +fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2 ] <| body (toVar arg0) (toVar arg1) (toVar arg2) - , call3 ( Type "", Name name ) + , \l m r -> dotter (call3Internal name l m r) ) -if_ : Expression Bool -> Statement r -> Statement r +if_ : Expression1 Bool -> Statement r -> Statement r if_ cond ifTrue = - Block ("if(" ++ expressionToGlsl cond ++ ")") [ ifTrue ] + Block ("if(" ++ expressionToGlsl cond.base ++ ")") [ ifTrue ] -return : Expression r -> Statement r -return = - Return +return : ExpressionX a r -> Statement r +return { base } = + Return base -decl : TypingFunction t -> String -> (Expression t -> List (Statement a)) -> List (Statement a) +decl : TypingFunction tv v -> String -> (v -> List (Statement tr)) -> List (Statement tr) decl typeF name k = let - ( Type t, _ ) = + ( TypedName (Type t) n e, _ ) = typeF name go = - Decl t (Name name) Nothing + Decl t n Nothing in - go :: k (Variable name) + go :: k e -def : TypingFunction t -> String -> Expression t -> (Expression t -> List (Statement a)) -> List (Statement a) +def : TypingFunction tv v -> String -> ExpressionX xv tv -> (v -> List (Statement tr)) -> List (Statement tr) def typeF name value k = let - ( Type t, _ ) = + ( TypedName (Type t) n e, _ ) = typeF name go = - Decl t (Name name) (Just <| typecastExpression value) + Decl t n (Just <| unwrapExpression value) in - go :: k (Variable name) + go :: k e -assign : Expression t -> Expression t -> Statement a -assign name value = - Expression <| Assign (typecastExpression name) (typecastExpression value) +assign : ExpressionX a t -> ExpressionX a t -> Statement q +assign name e = + ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) unknownFunDecl : { name : String, type_ : String, body : String } -> FunDecl @@ -827,52 +1085,47 @@ unknownFunDecl = -- TYPES -buildType : String -> String -> ( Type t, Name ) -buildType t n = - ( Type t, Name n ) - - -voidT : TypingFunction () -voidT = - buildType "void" +type Vec2 + = Vec2 Vec2 -floatT : TypingFunction Float -floatT = - buildType "float" +type Vec3 + = Vec3 Vec3 -type Vec2 - = Vec2 Vec2 +type Vec4 + = Vec4 Vec4 -vec2T : TypingFunction Vec2 -vec2T = - buildType "vec2" +type Mat3 + = Mat3 Mat3 -type Vec3 - = Vec3 Vec3 +voidT : TypingFunction (Never -> a) (Never -> a) +voidT n = + ( TypedName (Type "void") (Name n) never, always never ) -vec3T : TypingFunction Vec3 -vec3T = - buildType "vec3" +floatT : TypingFunction Float (Expression1 Float) +floatT n = + ( TypedName (Type "float") (Name n) (dotted1Internal (Variable n)), dotted1 ) -type Vec4 - = Vec4 Vec4 +vec2T : TypingFunction Vec2 Expression2 +vec2T n = + ( TypedName (Type "vec2") (Name n) (dotted2Internal (Variable n)), dotted2 ) -vec4T : TypingFunction Vec4 -vec4T = - buildType "vec4" +vec3T : TypingFunction Vec3 Expression3 +vec3T n = + ( TypedName (Type "vec3") (Name n) (dotted3Internal (Variable n)), dotted3 ) -type Mat3 - = Mat3 Mat3 +vec4T : TypingFunction Vec4 Expression4 +vec4T n = + ( TypedName (Type "vec4") (Name n) (dotted4Internal (Variable n)), dotted4 ) -mat3T : TypingFunction Mat3 -mat3T = - buildType "mat3" +mat3T : TypingFunction Mat3 (Expression1 Mat3) +mat3T n = + ( TypedName (Type "mat3") (Name n) (dotted1Internal (Variable n)), dotted1 ) diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index e1e5e9e6..c4ecef51 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -6,7 +6,7 @@ import Expression.Polynomial exposing (Exponents) import Expression.Utils exposing (minus, zero) import Maybe.Extra as Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (unknown) +import UI.Glsl.Generator as Generator exposing (dotted1, unknown) getDegree : Dict (List ( a, number )) b -> number @@ -77,13 +77,14 @@ getSolutions poly = Dict.get d poly |> Maybe.withDefault zero |> UI.Glsl.Code.expressionToGlsl - [ ( "dx", unknown "dx" ) - , ( "dy", unknown "dy" ) - , ( "dz", unknown "dz" ) - , ( "o.x", unknown "o.x" ) - , ( "o.y", unknown "o.y" ) - , ( "o.z", unknown "o.z" ) + [ ( "dx", dotted1 <| unknown "dx" ) + , ( "dy", dotted1 <| unknown "dy" ) + , ( "dz", dotted1 <| unknown "dz" ) + , ( "o.x", dotted1 <| unknown "o.x" ) + , ( "o.y", dotted1 <| unknown "o.y" ) + , ( "o.z", dotted1 <| unknown "o.z" ) ] + |> .base |> Generator.expressionToGlsl tFrom v = @@ -99,7 +100,7 @@ getSolutions poly = , ( "!dz", "mix(d[0].z, d[1].z, 0.5)" ) , ( "a", get 1 ) , ( "b", get 0 ) - , ( "x", "div(-b, a)" ) + , ( "x", "cdiv(-b, a)" ) , tFrom "x" ] @@ -111,12 +112,12 @@ getSolutions poly = , ( "a", get 2 ) , ( "b", get 1 ) , ( "c", get 0 ) - , ( "delta", "by(b,b) - 4.0 * by(a,c)" ) + , ( "delta", "cby(b,b) - 4.0 * cby(a,c)" ) , ( "sqdelta", "csqrt(delta)" ) , ( "den", "2.0 * a" ) - , ( "pos", "div(- b + sqdelta, den)" ) + , ( "pos", "cdiv(- b + sqdelta, den)" ) , tFrom "pos" - , ( "neg", "div(- b - sqdelta, den)" ) + , ( "neg", "cdiv(- b - sqdelta, den)" ) , tFrom "neg" ] @@ -128,22 +129,22 @@ getSolutions poly = , ( "b", get 2 ) , ( "c", get 1 ) , ( "dd", get 0 ) - , ( "deltaZero", "by(b,b) - 3.0 * by(a,c)" ) - , ( "deltaOne", "2.0 * by(b,b,b) - 9.0 * by(a,b,c) + 27.0 * by(a,a, dd)" ) - , ( "inner", "csqrt(by(deltaOne,deltaOne) - 4.0 * by(deltaZero,deltaZero,deltaZero))" ) + , ( "deltaZero", "cby(b,b) - 3.0 * cby(a,c)" ) + , ( "deltaOne", "2.0 * cby(b,b,b) - 9.0 * cby(a,b,c) + 27.0 * cby(a,a, dd)" ) + , ( "inner", "csqrt(cby(deltaOne,deltaOne) - 4.0 * cby(deltaZero,deltaZero,deltaZero))" ) , ( "CargPlus", "deltaOne + inner" ) , ( "CargMinus", "deltaOne - inner" ) , ( "Carg", "length(CargMinus) > length(CargPlus) ? CargMinus : CargPlus" ) , ( "C", "ccbrt(0.5 * Carg)" ) - , ( "coeff", "-div(vec2(1,0), 3.0 * a)" ) + , ( "coeff", "-cdiv(vec2(1,0), 3.0 * a)" ) , ( "xi", "0.5 * vec2(-1,sqrt(3.0))" ) - , ( "x", "by(coeff, b + C + div(deltaZero, C))" ) + , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) , tFrom "x" - , ( "C", "by(xi,C)" ) - , ( "x", "by(coeff, b + C + div(deltaZero, C))" ) + , ( "C", "cby(xi,C)" ) + , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) , tFrom "x" - , ( "C", "by(xi,C)" ) - , ( "x", "by(coeff, b + C + div(deltaZero, C))" ) + , ( "C", "cby(xi,C)" ) + , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) , tFrom "x" ] -} From 7f2c9c229367e18c48b045729f27437dd0a3631c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 00:20:24 +0200 Subject: [PATCH 002/139] Moving more code towards codegen --- src/elm/UI/Glsl.elm | 13 +++++-- src/elm/UI/Glsl/Code.elm | 70 ++++++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 21 ++++++----- src/shaders/declarations.frag | 4 -- 4 files changed, 66 insertions(+), 42 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 2efc279c..5c498958 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -7,8 +7,8 @@ import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, square) import Maybe.Extra as Maybe import SortedAnySet as Set -import UI.Glsl.Code exposing (constantToGlsl, deindent, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (dotted3, floatT, uniform, unsafeCall, vec2T) +import UI.Glsl.Code exposing (constantToGlsl, deindent, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (dotted3, floatT, fun1, uniform, unsafeCall, vec2T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -138,7 +138,8 @@ getGlsl expandIntervals rayDifferentials graph = |> List.map (requirementToGlsl interval) |> String.join "\n" in - thetaDeltaCode + declarations + ++ thetaDeltaCode ++ reqs ++ "\n/* Expression */\n" ++ deindent 4 srcExpr @@ -156,6 +157,12 @@ getGlsl expandIntervals rayDifferentials graph = pixel3D +declarations : String +declarations = + [ gnumDecl ] + |> Generator.fileToGlsl + + get3DSource : Bool -> String -> Expression -> { expr : Expression, srcExpr : String } get3DSource expandIntervals prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 9300083e..05ede9f4 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ -module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGlsl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDelta, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDelta, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, TypedName, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, by, by2, by3, byF, call0, call1, call2, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun0, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -54,6 +54,21 @@ cbyDecl = Tuple.first cbyTuple +gnumTuple : ( FunDecl, ExpressionX xa Float -> Expression4 ) +gnumTuple = + fun1 vec4T "gnum" (floatT "f") <| \f -> [ return <| vec4 f zero zero zero ] + + +gnumDecl : FunDecl +gnumDecl = + Tuple.first gnumTuple + + +gnum : ExpressionX xa Float -> Expression4 +gnum = + Tuple.second gnumTuple + + cby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 cby = Tuple.second cbyTuple @@ -71,11 +86,6 @@ cby3Decl = Tuple.first cby3Tuple -cby3 : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 -cby3 = - Tuple.second cby3Tuple - - cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cdivTuple = fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| @@ -169,7 +179,7 @@ cpowTuple = ] ) (vec2 (pow w.x z.x) zero) - (callUnknown1 "cexp" <| cby (callUnknown1 "cln" w) z) + (callUnknown1 "cexp" <| cby (cln w) z) ] @@ -523,16 +533,7 @@ straightFunctionToGlsl name = """ } ] Ln22 -> - [ unknownFunDecl { name = "cln", type_ = "TODO", body = """ - vec2 cln(vec2 z) { - if(z.y == 0.0 && z.x >= 0.0) { - return vec2(log(z.x), 0); - } - float px = length(z); - float py = atan(z.y, z.x); - return vec2(log(px), py); - } - """ } ] + [ clnDecl ] Log1022 -> [ unknownFunDecl { name = "clog10", type_ = "TODO", body = """ @@ -649,6 +650,29 @@ straightFunctionToGlsl name = """ } ] +clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +clnTuple = + fun1 vec2T "cln" (vec2T "z") <| + \z -> + if_ + (ands [ eq z.y zero, leq z.x zero ]) + (return <| vec2 (log z.x) zero) + :: (def floatT "px" (length z) <| + \px -> + def floatT "py" (atan2_ z.y z.x) <| \py -> [ return <| vec2 (log px) py ] + ) + + +clnDecl : FunDecl +clnDecl = + Tuple.first clnTuple + + +cln : ExpressionX xa Vec2 -> Expression2 +cln = + Tuple.second clnTuple + + intervalFunctionToGlsl : GlslFunction -> String intervalFunctionToGlsl name = case name of @@ -1578,10 +1602,6 @@ expressionToIntervalGlslPrec expandIntervals p expr = expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 expressionToNormalGlsl { x, y, z } = let - gnum : Expression1 Float -> Expression4 - gnum e = - dotted4 (callUnknown1 "gnum" e).base - go expr = case expr of PVariable "pi" -> @@ -1900,11 +1920,11 @@ toSrc3D expandIntervals suffix e = def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> def vec2T "x" (vec2 mn.x mx.x) <| - \x -> + \_ -> def vec2T "y" (vec2 mn.y mx.y) <| - \y -> + \_ -> def vec2T "z" (vec2 mn.z mx.z) <| - \z -> + \_ -> [ return <| dotted2 <| unknown <| expressionToIntervalGlsl expandIntervals e ] ] diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 0a9f61b5..744f6114 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun0, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -622,6 +622,16 @@ normalize = dotted1 << call1Internal "normalize" +length : ExpressionX a t -> Expression1 Float +length = + dotted1 << call1Internal "length" + + +atan2_ : ExpressionX a Float -> ExpressionX a Float -> Expression1 Float +atan2_ l r = + dotted1 <| call2Internal "atan" l r + + arr : ExpressionX a Mat3 -> ExpressionX b Int -> Expression1 Vec3 arr = expr2 Array @@ -893,15 +903,6 @@ unknown = Expression << Unknown -unknownFun0 : String -> TypedName t (Expression1 t) -unknownFun0 n = - let - _ = - Debug.todo - in - TypedName (Type "") (Name n) (dotted1 <| call0Internal n) - - unknownFun1 : String -> TypedName (l -> t) (ExpressionX a l -> Expression1 t) unknownFun1 n = let diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag index f1a5f3a2..9d74f580 100644 --- a/src/shaders/declarations.frag +++ b/src/shaders/declarations.frag @@ -23,10 +23,6 @@ vec2 dup(float x) { return vec2(x, x); } -vec4 gnum(float f) { - return vec4(f, 0, 0, 0); -} - float atanPlus(float y, float x) { return mod(radians(360.0) + atan(y, x), radians(360.0)); } From c4a9a1cbf1c378fb478e473a6cc0cdff7152b0be Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 00:29:51 +0200 Subject: [PATCH 003/139] cexp moved to codegen --- src/elm/UI/Glsl/Code.elm | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 05ede9f4..d3454940 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -155,12 +155,10 @@ straightOperationToGlsl op = [] GlslDivision -> - [ cdivDecl - ] + [ cdivDecl ] GlslPower -> - [ cpowDecl - ] + [ cpowDecl ] GlslRelations -> [] @@ -179,7 +177,7 @@ cpowTuple = ] ) (vec2 (pow w.x z.x) zero) - (callUnknown1 "cexp" <| cby (cln w) z) + (cexp <| cby (cln w) z) ] @@ -543,14 +541,7 @@ straightFunctionToGlsl name = """ } ] Exp22 -> - [ unknownFunDecl { name = "cexp", type_ = "TODO", body = """ - vec2 cexp(vec2 z) { - if(z.y == 0.0) { - return vec2(exp(z.x), 0); - } - return vec2(cos(z.y) * exp(z.x), sin(z.y) * exp(z.x)); - } - """ } ] + [ cexpDecl ] Re22 -> [ unknownFunDecl { name = "cre", type_ = "TODO", body = """ @@ -650,12 +641,32 @@ straightFunctionToGlsl name = """ } ] +cexpTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cexpTuple = + fun1 vec2T "cexp" (vec2T "z") <| + \z -> + [ if_ (eq z.y zero) + (return <| vec2 (exp z.x) zero) + , return <| vec2 (by (cos_ z.y) (exp z.x)) (by (sin_ z.y) z.x) + ] + + +cexpDecl : FunDecl +cexpDecl = + Tuple.first cexpTuple + + +cexp : ExpressionX xa Vec2 -> Expression2 +cexp = + Tuple.second cexpTuple + + clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) clnTuple = fun1 vec2T "cln" (vec2T "z") <| \z -> if_ - (ands [ eq z.y zero, leq z.x zero ]) + (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (log z.x) zero) :: (def floatT "px" (length z) <| \px -> From a48d96dd967a06fc7af67be7c067ae65df83eb5a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 00:47:30 +0200 Subject: [PATCH 004/139] Slowly removing unknowns --- src/elm/UI/Glsl/Code.elm | 61 ++++++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 8 ++++- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index d3454940..88f1b8ea 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -130,11 +130,6 @@ log10 = Tuple.second log10Tuple -callUnknown1 : String -> ExpressionX a l -> Expression1 t -callUnknown1 = - call1 << unknownFun1 - - callUnknown2 : String -> ExpressionX a l -> ExpressionX b r -> Expression1 t callUnknown2 = call2 << unknownFun2 @@ -191,6 +186,36 @@ cpow = Tuple.second cpowTuple +gnegCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +gnegCouple = + fun1 vec4T "gneg" (vec4T "v") <| \v -> [ return <| negate_ v ] + + +gnegDecl : FunDecl +gnegDecl = + Tuple.first gnegCouple + + +gneg : ExpressionX xa Vec4 -> Expression4 +gneg = + Tuple.second gnegCouple + + +gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +gsquareCouple = + fun1 vec4T "gsquare" (vec4T "z") <| \z -> [ return <| vec4_1_3 (by z.x z.x) z.yzw ] + + +gsquareDecl : FunDecl +gsquareDecl = + Tuple.first gsquareCouple + + +gsquare : ExpressionX xa Vec4 -> Expression4 +gsquare = + Tuple.second gsquareCouple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -202,11 +227,7 @@ intervalOperationToGlsl op = vec2 ineg(vec2 v) { return vec2(-v.y, -v.x); } - - vec4 gneg(vec4 v) { - return -v; - } - """ + """ ++ fileToGlsl [ gnegDecl ] GlslMultiplication -> """ @@ -999,11 +1020,7 @@ intervalFunctionToGlsl name = float mn = min(s.x, s.y); return vec2(mn, mx); } - - vec4 gsquare(vec4 z) { - return vec4(z.x*z.x, 2.0 * z.x * z.yzw); - } - """ + """ ++ ([ gsquareDecl ] |> fileToGlsl) Tan22 -> """ @@ -1637,7 +1654,7 @@ expressionToNormalGlsl { x, y, z } = gnum <| float f PNegate expression -> - dotted4 (callUnknown1 "gneg" (go expression)).base + gneg (go expression) PAdd l r -> add4 (go l) (go r) @@ -1659,7 +1676,7 @@ expressionToNormalGlsl { x, y, z } = dotted4 (callUnknown2 "gdiv" (go l) (go r)).base PPower l (PInteger 2) -> - dotted4 (callUnknown1 "gsquare" (go l)).base + gsquare (go l) PPower l (PInteger ri) -> dotted4 (callUnknown2 "gpow" (go l) (int ri)).base @@ -1712,7 +1729,7 @@ mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = ( pixel2Decl, pixel2 ) = main2D uniforms pixel2Def in - Generator.fileToGlsl <| + fileToGlsl <| pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| @@ -1727,7 +1744,7 @@ mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = in pixel3Decl ++ "\n\n" - ++ Generator.fileToGlsl + ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| [ assign gl_FragColor pixel3 ] @@ -1741,10 +1758,10 @@ mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = ( pixel3Decl, pixel3 ) = main3D rayDifferentials pixel3Def in - Generator.fileToGlsl pixel2Decl + fileToGlsl pixel2Decl ++ "\n\n" ++ pixel3Decl - ++ Generator.fileToGlsl + ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| [ assign gl_FragColor <| max4 pixel2 pixel3 ] diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 744f6114..2fe470a2 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -686,6 +686,12 @@ vec4_3_1 xyz w = |> dotted4 +vec4_1_3 : ExpressionX a Float -> ExpressionX b Vec3 -> Expression4 +vec4_1_3 x yzw = + call2Internal "vec4" x yzw + |> dotted4 + + --------------- -- CONSTANTS -- From f66052bb6e70b19b4104ef41750e87800ba7aa9d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 00:50:43 +0200 Subject: [PATCH 005/139] Cleaning up --- src/elm/UI/Glsl.elm | 2 +- src/elm/UI/Glsl/Code.elm | 2 +- src/elm/UI/Glsl/Generator.elm | 41 +---------------------------------- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 5c498958..5a219230 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (constantToGlsl, deindent, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (dotted3, floatT, fun1, uniform, unsafeCall, vec2T) +import UI.Glsl.Generator as Generator exposing (dotted3, floatT, uniform, unsafeCall, vec2T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 88f1b8ea..66cafaac 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call1, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 2fe470a2..c8aba79d 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call0, call1, call2, call3, call4, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract4, ternary, ternary2, ternary3, true, uniform, unknown, unknownFun1, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -342,11 +342,6 @@ ternary = expr3 Ternary -ternary2 : ExpressionX xa Bool -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 -ternary2 = - expr32 Ternary - - ternary3 : ExpressionX xa Bool -> ExpressionX xb Vec3 -> ExpressionX xc Vec3 -> Expression3 ternary3 = expr33 Ternary @@ -402,11 +397,6 @@ expr3 f l m r = dotted1Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) -expr32 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX xa a -> ExpressionX xb b -> ExpressionX xc c -> Expression2 -expr32 f l m r = - dotted2Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) - - expr33 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX xa a -> ExpressionX xb b -> ExpressionX xc c -> Expression3 expr33 f l m r = dotted3Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) @@ -748,31 +738,11 @@ unsafeCall name = Expression << Call name << List.map (\(Expression e) -> e) -call0 : TypedName t r -> r -call0 (TypedName _ _ expr) = - expr - - -call1 : TypedName t (a -> r) -> a -> r -call1 (TypedName _ _ expr) = - expr - - call2 : TypedName t (a -> b -> r) -> a -> b -> r call2 (TypedName _ _ expr) = expr -call3 : TypedName t (a -> b -> c -> r) -> a -> b -> c -> r -call3 (TypedName _ _ expr) = - expr - - -call4 : TypedName t (a -> b -> c -> d -> r) -> a -> b -> c -> d -> r -call4 (TypedName _ _ expr) = - expr - - zero : Expression1 Float zero = float 0 @@ -909,15 +879,6 @@ unknown = Expression << Unknown -unknownFun1 : String -> TypedName (l -> t) (ExpressionX a l -> Expression1 t) -unknownFun1 n = - let - _ = - Debug.todo - in - TypedName (Type "") (Name n) (\l -> dotted1 <| call1Internal n l) - - unknownFun2 : String -> TypedName (l -> r -> t) (ExpressionX a l -> ExpressionX b r -> Expression1 t) unknownFun2 n = let From dbbb7ff925adcc0923ac75b9e1c3ef118dc388db Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 01:17:32 +0200 Subject: [PATCH 006/139] More preparing for cleanup --- src/elm/UI/Glsl/Code.elm | 169 ++++++++++++++++++++++++---------- src/elm/UI/Glsl/Generator.elm | 22 ++++- 2 files changed, 143 insertions(+), 48 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 66cafaac..ca922823 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -216,6 +216,117 @@ gsquare = Tuple.second gsquareCouple +gbyCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) +gbyCouple = + fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> [ return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) ] + + +gbyDecl : FunDecl +gbyDecl = + Tuple.first gbyCouple + + +gby : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 +gby = + Tuple.second gbyCouple + + +gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) +gdivCouple = + fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| + \l r -> + [ return <| + vec4_1_3 (div l.x r.x) + (divF + (subtract (byF r.x l.yzw) (byF l.x r.yzw)) + (pow r.x <| float 2) + ) + ] + + +gdivDecl : FunDecl +gdivDecl = + Tuple.first gdivCouple + + +gdiv : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 +gdiv = + Tuple.second gdivCouple + + +gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 ) +gpowICouple = + fun2 vec4T "gpow" (vec4T "b") (intT "e") <| + \b e -> + [ return <| + vec4_1_3 + (pow b.x <| floatCast e) + (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) + ] + + +gpowIDecl : FunDecl +gpowIDecl = + Tuple.first gpowICouple + + +gpowI : ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 +gpowI = + Tuple.second gpowICouple + + +gpowCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) +gpowCouple = + fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| + \b e -> + def intT "ie" (intCast e.x) <| + \ie -> + [ if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) + (return <| gpowI b ie) + , return <| gexp <| gby (gln b) e + ] + + +gpowDecl : FunDecl +gpowDecl = + Tuple.first gpowCouple + + +gpow : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 +gpow = + Tuple.second gpowCouple + + +gexpCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +gexpCouple = + fun1 vec4T "gexp" (vec4T "z") <| \z -> [ return <| vec4_1_3 z.x (byF (exp z.x) z.yzw) ] + + +gexpDecl : FunDecl +gexpDecl = + Tuple.first gexpCouple + + +gexp : ExpressionX xa Vec4 -> Expression4 +gexp = + Tuple.second gexpCouple + + +glnCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +glnCouple = + fun1 vec4T "gln" (vec4T "z") <| \z -> [ return <| vec4_1_3 (log z.x) (divF z.yzw z.x) ] + + +glnDecl : FunDecl +glnDecl = + Tuple.first glnCouple + + +gln : ExpressionX xa Vec4 -> Expression4 +gln = + Tuple.second glnCouple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -240,13 +351,7 @@ intervalOperationToGlsl op = float mx = max(max(a,b),max(c,d)); return vec2(mn, mx); } - - vec4 gby(vec4 l, vec4 r) { - return vec4( - l.x * r.x, - l.x * r.yzw + r.x * l.yzw); - } - """ + """ ++ fileToGlsl [ gbyDecl ] GlslDivision -> """ @@ -263,14 +368,7 @@ intervalOperationToGlsl op = vec2 idiv(vec2 l, vec2 r) { return iby(l, iinverse(r)); } - - vec4 gdiv(vec4 l, vec4 r) { - return vec4( - l.x / r.x, - (r.x * l.yzw - l.x * r.yzw) / pow(r.x, 2.0) - ); - } - """ + """ ++ fileToGlsl [ gdivDecl ] GlslPower -> """ @@ -305,19 +403,7 @@ intervalOperationToGlsl op = return ipow(b, int(e.x)); return iexp(iby(iln(b), e)); } - - vec4 gpow(vec4 b, int e) { - return vec4(pow(b.x, float(e)), float(e) * pow(b.x, float(e - 1)) * b.yzw); - } - - vec4 gpow(vec4 b, vec4 e) { - int ie = int(e.x); - if(float(ie) == e.x && e.y == 0.0 && e.z == 0.0 && e.w == 0.0) { - return gpow(b, ie); - } - return gexp(gby(gln(b), e)); - } - """ + """ ++ fileToGlsl [ gpowIDecl, gpowDecl ] GlslRelations -> """ @@ -854,14 +940,7 @@ intervalFunctionToGlsl name = vec2 iexp(vec2 z) { return vec2(exp(z.x), exp(z.y)); } - - vec4 gexp(vec4 z) { - return vec4( - exp(z.x), - exp(z.x) * z.yzw - ); - } - """ + """ ++ fileToGlsl [ gexpDecl ] Floor22 -> """ @@ -879,11 +958,7 @@ intervalFunctionToGlsl name = vec2 iln(vec2 z) { return vec2(log(z.x), log(z.y)); } - - vec4 gln(vec4 z) { - return vec4(log(z.x), z.yzw / z.x); - } - """ + """ ++ fileToGlsl [ glnDecl ] Log1022 -> """ @@ -1020,7 +1095,7 @@ intervalFunctionToGlsl name = float mn = min(s.x, s.y); return vec2(mn, mx); } - """ ++ ([ gsquareDecl ] |> fileToGlsl) + """ ++ fileToGlsl [ gsquareDecl ] Tan22 -> """ @@ -1670,19 +1745,19 @@ expressionToNormalGlsl { x, y, z } = subtract4 (go l) (go r) PBy l r -> - dotted4 (callUnknown2 "gby" (go l) (go r)).base + gby (go l) (go r) PDiv l r -> - dotted4 (callUnknown2 "gdiv" (go l) (go r)).base + dotted4 (gdiv (go l) (go r)).base PPower l (PInteger 2) -> gsquare (go l) PPower l (PInteger ri) -> - dotted4 (callUnknown2 "gpow" (go l) (int ri)).base + gpowI (go l) (int ri) PPower l r -> - dotted4 (callUnknown2 "gpow" (go l) (go r)).base + gpow (go l) (go r) PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index c8aba79d..5b157114 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -477,6 +477,11 @@ byF = expr2 By +divF : ExpressionX a t -> ExpressionX b Float -> Expression1 t +divF = + expr2 Div + + div : ExpressionX a t -> ExpressionX a t -> Expression1 t div = expr2 Div @@ -622,6 +627,16 @@ atan2_ l r = dotted1 <| call2Internal "atan" l r +intCast : ExpressionX a Float -> Expression1 Int +intCast = + dotted1 << call1Internal "int" + + +floatCast : ExpressionX a Int -> Expression1 Float +floatCast = + dotted1 << call1Internal "float" + + arr : ExpressionX a Mat3 -> ExpressionX b Int -> Expression1 Vec3 arr = expr2 Array @@ -1074,6 +1089,11 @@ voidT n = ( TypedName (Type "void") (Name n) never, always never ) +intT : TypingFunction Int (Expression1 Int) +intT n = + ( TypedName (Type "int") (Name n) (dotted1Internal (Variable n)), dotted1 ) + + floatT : TypingFunction Float (Expression1 Float) floatT n = ( TypedName (Type "float") (Name n) (dotted1Internal (Variable n)), dotted1 ) From e49b41fac9162a69007c9680cc34b313f66e07e4 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 01:22:27 +0200 Subject: [PATCH 007/139] Cleanup --- src/elm/UI/Glsl/Code.elm | 11 +++-------- src/elm/UI/Glsl/Generator.elm | 16 +--------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index ca922823..aaa3c291 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGl import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -130,11 +130,6 @@ log10 = Tuple.second log10Tuple -callUnknown2 : String -> ExpressionX a l -> ExpressionX b r -> Expression1 t -callUnknown2 = - call2 << unknownFun2 - - straightOperationToGlsl : GlslOperation -> List FunDecl straightOperationToGlsl op = case op of @@ -1761,12 +1756,12 @@ expressionToNormalGlsl { x, y, z } = PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map go ex of + case List.map (go >> .base) ex of [] -> vec4Zero head :: tail -> - List.foldl (\e a -> dotted4 (callUnknown2 ("g" ++ Expression.functionNameToString name) a e).base) head tail + dotted4 <| List.foldl (\e a -> unsafeCall ("g" ++ Expression.functionNameToString name) [ a, e ]) head tail else dotted4 (unsafeCall ("g" ++ Expression.functionNameToString name) (List.map (go >> .base) ex)) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 5b157114..4ab670c4 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, call2, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFun2, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Expression exposing (RelationOperation(..)) import Set @@ -753,11 +753,6 @@ unsafeCall name = Expression << Call name << List.map (\(Expression e) -> e) -call2 : TypedName t (a -> b -> r) -> a -> b -> r -call2 (TypedName _ _ expr) = - expr - - zero : Expression1 Float zero = float 0 @@ -894,15 +889,6 @@ unknown = Expression << Unknown -unknownFun2 : String -> TypedName (l -> r -> t) (ExpressionX a l -> ExpressionX b r -> Expression1 t) -unknownFun2 n = - let - _ = - Debug.todo - in - TypedName (Type "") (Name n) (\l r -> dotted1 (call2Internal n l r)) - - -- STATEMENTS From aa6ac474e2adbc94e7cca44991ea0b03b05157e9 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 20:10:21 +0200 Subject: [PATCH 008/139] Testable GLSL code --- src/elm/UI/Glsl.elm | 12 +- src/elm/UI/Glsl/Code.elm | 379 ++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 416 +++++++++++++++++++++++++++++----- tests/GlslFuzzer.elm | 65 ++++++ tests/SolverTest.elm | 26 ++- 5 files changed, 663 insertions(+), 235 deletions(-) create mode 100644 tests/GlslFuzzer.elm diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 5a219230..3fc62906 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -18,15 +18,6 @@ import UI.Glsl.Sphere as Sphere getGlsl : Bool -> Bool -> Graph -> String getGlsl expandIntervals rayDifferentials graph = let - uniforms = - { u_canvasWidth = uniform floatT "u_canvasWidth" - , u_canvasHeight = uniform floatT "u_canvasHeight" - , u_viewportWidth = uniform floatT "u_viewportWidth" - , u_viewportHeight = uniform floatT "u_viewportHeight" - , u_zoomCenter = uniform vec2T "u_zoomCenter" - , u_drawAxes = uniform floatT "u_drawAxes" - } - { expr, srcExpr, interval, usesThetaDelta, pixel2D, pixel3D } = extract "" graph @@ -125,7 +116,7 @@ getGlsl expandIntervals rayDifferentials graph = thetaDeltaCode = if usesThetaDelta then - deindent 4 <| UI.Glsl.Code.thetaDelta + Generator.fileToGlsl [ UI.Glsl.Code.thetaDeltaDecl ] else "" @@ -144,7 +135,6 @@ getGlsl expandIntervals rayDifferentials graph = ++ "\n/* Expression */\n" ++ deindent 4 srcExpr ++ mainGlsl - uniforms rayDifferentials (List.map (\p -> diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index aaa3c291..34deaf7b 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ -module UI.Glsl.Code exposing (Uniforms, constantToGlsl, deindent, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDelta, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -21,22 +21,22 @@ constantToGlsl c = case c of I -> fun0 vec2T "i" <| - [ return <| vec2 zero one ] + return (vec2 zero one) Pi -> fun0 vec2T "pi" <| - [ return <| vec2 (radians_ <| float 180) zero ] + return (vec2 (radians_ <| float 180) zero) E -> fun0 vec2T "e" <| - [ return <| vec2 (exp one) zero ] + return (vec2 (exp one) zero) cbyTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cbyTuple = fun2 vec2T "cby" (vec2T "a") (vec2T "b") <| \a b -> - [ return <| + return <| vec2 (subtract (by a.x b.x) @@ -46,7 +46,6 @@ cbyTuple = (by a.x b.y) (by a.y b.x) ) - ] cbyDecl : FunDecl @@ -56,7 +55,7 @@ cbyDecl = gnumTuple : ( FunDecl, ExpressionX xa Float -> Expression4 ) gnumTuple = - fun1 vec4T "gnum" (floatT "f") <| \f -> [ return <| vec4 f zero zero zero ] + fun1 vec4T "gnum" (floatT "f") <| \f -> return <| vec4 f zero zero zero gnumDecl : FunDecl @@ -78,7 +77,7 @@ cby3Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX cby3Tuple = fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| \a b c -> - [ return <| cby (cby a b) c ] + return <| cby (cby a b) c cby3Decl : FunDecl @@ -101,7 +100,7 @@ cdivTuple = ) <| \i -> - [ return <| vec2 r i ] + return <| vec2 r i cdivDecl : FunDecl @@ -117,7 +116,7 @@ cdiv = log10Tuple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) log10Tuple = fun1 floatT "log10" (floatT "x") <| - \x -> [ return <| div (log x) (log <| float 10) ] + \x -> return <| div (log x) (log <| float 10) log10Decl : FunDecl @@ -158,7 +157,7 @@ cpowTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 cpowTuple = fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| \w z -> - [ return <| + return <| ternary (ands [ geq w.x zero @@ -168,7 +167,6 @@ cpowTuple = ) (vec2 (pow w.x z.x) zero) (cexp <| cby (cln w) z) - ] cpowDecl : FunDecl @@ -183,7 +181,7 @@ cpow = gnegCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gnegCouple = - fun1 vec4T "gneg" (vec4T "v") <| \v -> [ return <| negate_ v ] + fun1 vec4T "gneg" (vec4T "v") <| \v -> return <| negate_ v gnegDecl : FunDecl @@ -198,7 +196,7 @@ gneg = gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gsquareCouple = - fun1 vec4T "gsquare" (vec4T "z") <| \z -> [ return <| vec4_1_3 (by z.x z.x) z.yzw ] + fun1 vec4T "gsquare" (vec4T "z") <| \z -> return <| vec4_1_3 (by z.x z.x) z.yzw gsquareDecl : FunDecl @@ -213,7 +211,7 @@ gsquare = gbyCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gbyCouple = - fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> [ return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) ] + fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) gbyDecl : FunDecl @@ -230,13 +228,12 @@ gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression gdivCouple = fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| \l r -> - [ return <| + return <| vec4_1_3 (div l.x r.x) (divF (subtract (byF r.x l.yzw) (byF l.x r.yzw)) (pow r.x <| float 2) ) - ] gdivDecl : FunDecl @@ -253,11 +250,10 @@ gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression gpowICouple = fun2 vec4T "gpow" (vec4T "b") (intT "e") <| \b e -> - [ return <| + return <| vec4_1_3 (pow b.x <| floatCast e) (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) - ] gpowIDecl : FunDecl @@ -276,10 +272,9 @@ gpowCouple = \b e -> def intT "ie" (intCast e.x) <| \ie -> - [ if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) + if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) (return <| gpowI b ie) - , return <| gexp <| gby (gln b) e - ] + (return <| gexp <| gby (gln b) e) gpowDecl : FunDecl @@ -294,7 +289,7 @@ gpow = gexpCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gexpCouple = - fun1 vec4T "gexp" (vec4T "z") <| \z -> [ return <| vec4_1_3 z.x (byF (exp z.x) z.yzw) ] + fun1 vec4T "gexp" (vec4T "z") <| \z -> return <| vec4_1_3 z.x (byF (exp z.x) z.yzw) gexpDecl : FunDecl @@ -309,7 +304,7 @@ gexp = glnCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) glnCouple = - fun1 vec4T "gln" (vec4T "z") <| \z -> [ return <| vec4_1_3 (log z.x) (divF z.yzw z.x) ] + fun1 vec4T "gln" (vec4T "z") <| \z -> return <| vec4_1_3 (log z.x) (divF z.yzw z.x) glnDecl : FunDecl @@ -322,6 +317,32 @@ gln = Tuple.second glnCouple +csinCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +csinCouple = + fun1 vec2T "csin" (vec2T "z") <| + \z -> + def floatT "s" (sin_ z.x) <| + \s -> + return <| + ternary + (eq z.y (float 0)) + (vec2 s (float 0)) + (vec2 + (by s (cosh z.y)) + (by (cos_ z.x) (sinh z.y)) + ) + + +csinDecl : FunDecl +csinDecl = + Tuple.first csinCouple + + +csin : ExpressionX xa Vec2 -> Expression2 +csin = + Tuple.second csinCouple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -430,13 +451,13 @@ straightFunctionToGlsl name = Sinh11 -> [ Tuple.first <| fun1 floatT "sinh" (floatT "x") <| - \x -> [ return <| by (float 0.5) <| subtract (exp x) (exp <| negate_ x) ] + \x -> return <| by (float 0.5) <| subtract (exp x) (exp <| negate_ x) ] Cosh11 -> [ Tuple.first <| fun1 floatT "cosh" (floatT "x") <| - \x -> [ return <| by (float 0.5) <| add (exp x) (exp <| negate_ x) ] + \x -> return <| by (float 0.5) <| add (exp x) (exp <| negate_ x) ] Tanh11 -> @@ -445,31 +466,16 @@ straightFunctionToGlsl name = \x -> if_ (gt (abs_ x) (float 10)) (return <| sign x) - :: (def floatT "p" (exp x) <| - \p -> - def floatT "m" (exp <| negate_ x) <| - \m -> - [ return <| div (subtract p m) (add p m) - ] - ) + (def floatT "p" (exp x) <| + \p -> + def floatT "m" (exp <| negate_ x) <| + \m -> + return <| div (subtract p m) (add p m) + ) ] Sin22 -> - [ Tuple.first <| - fun1 vec2T "csin" (vec2T "z") <| - \z -> - def floatT "s" (sin_ z.x) <| - \s -> - [ return <| - ternary - (eq z.y (float 0)) - (vec2 s (float 0)) - (vec2 - (by s (cosh z.y)) - (by (cos_ z.x) (sinh z.y)) - ) - ] - ] + [ csinDecl ] Cos22 -> [ unknownFunDecl @@ -646,11 +652,7 @@ straightFunctionToGlsl name = [ cexpDecl ] Re22 -> - [ unknownFunDecl { name = "cre", type_ = "TODO", body = """ - vec2 cre(vec2 z) { - return vec2(z.x, 0.0); - } - """ } ] + [ creDecl ] Im22 -> [ unknownFunDecl { name = "cim", type_ = "TODO", body = """ @@ -745,12 +747,14 @@ straightFunctionToGlsl name = cexpTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) cexpTuple = - fun1 vec2T "cexp" (vec2T "z") <| - \z -> - [ if_ (eq z.y zero) - (return <| vec2 (exp z.x) zero) - , return <| vec2 (by (cos_ z.y) (exp z.x)) (by (sin_ z.y) z.x) - ] + fun1 vec2T "cexp" (vec2T "z") cexpFunction + + +cexpFunction : Expression2 -> Statement Vec2 +cexpFunction z = + if_ (eq z.y zero) + (return <| vec2 (exp z.x) zero) + (return <| vec2 (by (cos_ z.y) (exp z.x)) (by (sin_ z.y) (exp z.x))) cexpDecl : FunDecl @@ -770,10 +774,27 @@ clnTuple = if_ (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (log z.x) zero) - :: (def floatT "px" (length z) <| - \px -> - def floatT "py" (atan2_ z.y z.x) <| \py -> [ return <| vec2 (log px) py ] - ) + (def floatT "px" (length z) <| + \px -> + def floatT "py" (atan2_ z.y z.x) <| + \py -> + return <| vec2 (log px) py + ) + + +creTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +creTuple = + fun1 vec2T "cre" (vec2T "z") <| \z -> return <| vec2 z.x zero + + +creDecl : FunDecl +creDecl = + Tuple.first creTuple + + +cre : ExpressionX xa Vec2 -> Expression2 +cre = + Tuple.second creTuple clnDecl : FunDecl @@ -1298,17 +1319,48 @@ toSrcParametric expandIntervals suffix e = """ -thetaDelta : String -thetaDelta = - """ - float thetaDelta(float theta) { - if(u_whiteLines < 1.0) - return 100.0; - float thetaSix = theta * u_whiteLines + 0.5; - float thetaNeigh = 0.05; - return abs(fract(thetaSix) - 0.5) / thetaNeigh; +uniforms : + { u_canvasHeight : Expression1 Float + , u_canvasWidth : Expression1 Float + , u_drawAxes : Expression1 Float + , u_viewportHeight : Expression1 Float + , u_viewportWidth : Expression1 Float + , u_whiteLines : Expression1 Float + , u_zoomCenter : Expression2 } - """ +uniforms = + { u_canvasHeight = uniform floatT "u_canvasHeight" + , u_canvasWidth = uniform floatT "u_canvasWidth" + , u_drawAxes = uniform floatT "u_drawAxes" + , u_viewportHeight = uniform floatT "u_viewportHeight" + , u_viewportWidth = uniform floatT "u_viewportWidth" + , u_whiteLines = uniform floatT "u_whiteLines" + , u_zoomCenter = uniform vec2T "u_zoomCenter" + } + + +thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) +thetaDeltaCouple = + fun1 floatT "thetaDelta" (floatT "theta") <| + \theta -> + if_ (lt uniforms.u_whiteLines one) + (return <| float 100) + (def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| + \thetaSix -> + def floatT "thetaNeigh" (float 0.05) <| + \thetaNeigh -> + return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh + ) + + +thetaDeltaDecl : FunDecl +thetaDeltaDecl = + Tuple.first thetaDeltaCouple + + +thetaDelta : ExpressionX xa Float -> Expression1 Float +thetaDelta = + Tuple.second thetaDeltaCouple toSrcVectorField2D : String -> Expression.Expression -> Expression.Expression -> String @@ -1433,12 +1485,22 @@ toSrcContour suffix e = toSrcRelation : String -> Expression.Expression -> String toSrcRelation suffix e = - """ - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; - return complex.x > 0.0 && abs(complex.y) < """ ++ floatToGlsl epsilon ++ """ ? vec3(0.8,0.5,0.5) : vec3(0,0,0); - } - """ + fileToGlsl + [ Tuple.first <| + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \_ _ x y -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \complex -> + return <| + ternary + (ands + [ gt complex.x zero + , lt (abs_ complex.y) (float epsilon) + ] + ) + (vec3 (float 0.8) (float 0.5) (float 0.5)) + vec3Zero + ] epsilon : Float @@ -1783,8 +1845,7 @@ expressionToNormalGlsl { x, y, z } = mainGlsl : - Uniforms - -> Bool + Bool -> List { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 @@ -1792,19 +1853,18 @@ mainGlsl : } -> List String -> String -mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = +mainGlsl rayDifferentials pixel2Def pixel3Def = case ( pixel2Def, pixel3Def ) of ( _, [] ) -> let ( pixel2Decl, pixel2 ) = - main2D uniforms pixel2Def + main2D pixel2Def in fileToGlsl <| pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - [ assign gl_FragColor pixel2 - ] + assign gl_FragColor pixel2 nop ] ( [], _ ) -> @@ -1817,13 +1877,13 @@ mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - [ assign gl_FragColor pixel3 ] + assign gl_FragColor pixel3 nop ] _ -> let ( pixel2Decl, pixel2 ) = - main2D uniforms pixel2Def + main2D pixel2Def ( pixel3Decl, pixel3 ) = main3D rayDifferentials pixel3Def @@ -1834,22 +1894,20 @@ mainGlsl uniforms rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - [ assign gl_FragColor <| max4 pixel2 pixel3 ] + assign gl_FragColor (max4 pixel2 pixel3) nop ] main2D : - Uniforms - -> - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } + List + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 + , color : Bool + } -> ( File, Expression4 ) -main2D uniforms pixels = +main2D pixels = let ( pixel2Decl, pixel2 ) = - pixel2Tuple uniforms pixels + pixel2Tuple pixels in ( [ log10Decl , axisDecl @@ -1860,19 +1918,15 @@ main2D uniforms pixels = pixel2Tuple : - Uniforms - -> - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } + List + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 + , color : Bool + } -> ( FunDecl, Expression4 ) -pixel2Tuple uniforms pixels = +pixel2Tuple pixels = let - inner deltaX deltaY x y px curr = - pixels - |> List.indexedMap (addPixel deltaX deltaY x y px curr) - |> List.concat + inner deltaX deltaY x y px curr cont = + List.foldl (\( i, p ) -> addPixel deltaX deltaY x y px curr i p) cont (List.indexedMap Tuple.pair pixels) in fun0 vec4T "pixel2" <| def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| @@ -1897,30 +1951,34 @@ pixel2Tuple uniforms pixels = \px -> decl vec3T "curr" <| \curr -> - inner deltaX deltaY x y px curr - ++ (def floatT "maxDelta" (max_ deltaX deltaY) <| - \maxDelta -> - def vec3T - "yax" - (ternary3 - (eq uniforms.u_drawAxes one) - (byF (axis x y maxDelta) (vec3 zero one zero)) - vec3Zero - ) - <| - \yax -> - def vec3T - "xax" - (ternary3 - (eq uniforms.u_drawAxes one) - (byF (axis y x maxDelta) (vec3 one zero zero)) - vec3Zero - ) - <| - \xax -> - [ return <| vec4_3_1 (max3 px (max3 xax yax)) one - ] - ) + inner deltaX + deltaY + x + y + px + curr + (def floatT "maxDelta" (max_ deltaX deltaY) <| + \maxDelta -> + def vec3T + "yax" + (ternary3 + (eq uniforms.u_drawAxes one) + (byF (axis x y maxDelta) (vec3 zero one zero)) + vec3Zero + ) + <| + \yax -> + def vec3T + "xax" + (ternary3 + (eq uniforms.u_drawAxes one) + (byF (axis y x maxDelta) (vec3 one zero zero)) + vec3Zero + ) + <| + \xax -> + return <| vec4_3_1 (max3 px (max3 xax yax)) one + ) addPixel : @@ -1935,8 +1993,8 @@ addPixel : { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 , color : Bool } - -> List (Statement f) -addPixel deltaX deltaY x y px curr i { call, color } = + -> (Statement f -> Statement f) +addPixel deltaX deltaY x y px curr i { call, color } next = let k = if color then @@ -1949,9 +2007,8 @@ addPixel deltaX deltaY x y px curr i { call, color } = else call deltaX deltaY x y in - [ assign curr k - , assign px <| ternary3 (eq curr vec3Zero) px curr - ] + assign curr k <| + assign px (ternary3 (eq curr vec3Zero) px curr) next axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) @@ -1962,28 +2019,28 @@ axisTuple = \across -> if_ (lt across (float -12)) (return zero) - :: (def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| - \smallUnit -> - if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) - :: (def floatT - "unit" - (ternary - (lt across (float -6)) - (by smallUnit (float 100)) - (ternary - (lt across (float -0.1)) - (by smallUnit (float 10)) - (by smallUnit (float 5)) - ) - ) - <| - \unit -> - def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| - \parallel -> - [ return <| max_ zero (max_ across parallel) ] - ) - ) + (def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| + \smallUnit -> + if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) + (return zero) + (def floatT + "unit" + (ternary + (lt across (float -6)) + (by smallUnit (float 100)) + (ternary + (lt across (float -0.1)) + (by smallUnit (float 10)) + (by smallUnit (float 5)) + ) + ) + <| + \unit -> + def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| + \parallel -> + return <| max_ zero (max_ across parallel) + ) + ) axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float @@ -2009,7 +2066,7 @@ toSrc3D expandIntervals suffix e = \z -> def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> - [ return <| normalize gradient.yzw ] + return <| normalize gradient.yzw , Tuple.first <| fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> @@ -2023,7 +2080,7 @@ toSrc3D expandIntervals suffix e = \_ -> def vec2T "z" (vec2 mn.z mx.z) <| \_ -> - [ return <| dotted2 <| unknown <| expressionToIntervalGlsl expandIntervals e ] + return <| dotted2 <| unknown <| expressionToIntervalGlsl expandIntervals e ] diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 4ab670c4..0bd8e366 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,5 +1,6 @@ -module UI.Glsl.Generator exposing (Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Mat3, Name, Statement(..), TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fun0, fun1, fun2, fun3, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) import Set @@ -12,12 +13,17 @@ type FunDecl = FunDecl { name : String, type_ : String, body : String } +type Stat + = If Expr Stat Stat + | Line String Stat + | Return Expr + | ExpressionStatement Expr Stat + | Decl String Name (Maybe Expr) Stat + | Nop + + type Statement r - = Block String (List (Statement r)) - | Line String - | Return (Expression r) - | ExpressionStatement Expr - | Decl String Name (Maybe Expr) + = Statement Stat type Expr @@ -123,32 +129,43 @@ funDeclToGlsl (FunDecl { body }) = statementToGlsl : Statement s -> String -statementToGlsl = +statementToGlsl (Statement r) = let go i c = case c of - Block h b -> - String.join "\n" <| - (indent i h ++ " {") - :: List.map (go (i + 1)) b - ++ [ indent i "}" ] - - Line l -> - indent i l ++ ";" + If cond t f -> + [ indent i ("if(" ++ expressionToGlsl (Expression cond) ++ ") {") + , go (i + 1) t + , indent i "}" + , "" + , go i f + ] + |> String.join "\n" + + Line l next -> + indent i l ++ ";\n" ++ go i next Return e -> - indent i <| "return " ++ expressionToGlsl e ++ ";" + indent i <| "return " ++ expressionToGlsl (Expression e) ++ ";" - ExpressionStatement e -> - indent i <| expressionToGlsl (Expression e) ++ ";" + ExpressionStatement e next -> + indent i (expressionToGlsl (Expression e) ++ ";\n") ++ go i next - Decl t (Name n) (Just e) -> - indent i <| t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";" + Decl t (Name n) (Just e) next -> + indent i (t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";\n") ++ go i next - Decl t (Name n) Nothing -> - indent i <| t ++ " " ++ n ++ ";" + Decl t (Name n) Nothing next -> + indent i (t ++ " " ++ n ++ ";\n") ++ go i next + + Nop -> + "" in - go 1 + go 1 r + + +nop : Statement () +nop = + Statement Nop expressionToGlsl : Expression t -> String @@ -637,6 +654,11 @@ floatCast = dotted1 << call1Internal "float" +fract : ExpressionX a Float -> Expression1 Float +fract = + dotted1 << call1Internal "fract" + + arr : ExpressionX a Mat3 -> ExpressionX b Int -> Expression1 Vec3 arr = expr2 Array @@ -893,7 +915,7 @@ unknown = -- STATEMENTS -funInternal : TypedName t c -> List ( String, String ) -> List (Statement t) -> FunDecl +funInternal : TypedName t c -> List ( String, String ) -> Statement t -> FunDecl funInternal (TypedName (Type rt) (Name name) _) args body = let argsList = @@ -907,9 +929,10 @@ funInternal (TypedName (Type rt) (Name name) _) args body = |> String.join " -> " , body = String.join "\n" <| - (rt ++ " " ++ name ++ "(" ++ argsList ++ ") {") - :: List.map statementToGlsl body - ++ [ "}" ] + [ rt ++ " " ++ name ++ "(" ++ argsList ++ ") {" + , statementToGlsl body + , "}" + ] } @@ -926,15 +949,14 @@ toVar (TypedName _ _ expr) = fun0 : TypingFunction t c -> String - -> List (Statement t) + -> Statement t -> ( FunDecl, c ) fun0 typeF name body = let ( typed, dotter ) = typeF name in - ( funInternal typed [] <| - body + ( funInternal typed [] body , dotter <| call0Internal name ) @@ -943,7 +965,7 @@ fun1 : TypingFunction tr r -> String -> ( TypedName ta a, Expression ta -> a ) - -> (a -> List (Statement tr)) + -> (a -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> r @@ -964,7 +986,7 @@ fun2 : -> String -> ( TypedName ta a, Expression ta -> a ) -> ( TypedName tb b, Expression tb -> b ) - -> (a -> b -> List (Statement tr)) + -> (a -> b -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> r @@ -986,7 +1008,7 @@ fun3 : -> ( TypedName ta a, Expression ta -> a ) -> ( TypedName tb b, Expression tb -> b ) -> ( TypedName tc c, Expression tc -> c ) - -> (a -> b -> c -> List (Statement tr)) + -> (a -> b -> c -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> r @@ -1002,43 +1024,66 @@ fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = ) -if_ : Expression1 Bool -> Statement r -> Statement r -if_ cond ifTrue = - Block ("if(" ++ expressionToGlsl cond.base ++ ")") [ ifTrue ] +fun4 : + TypingFunction tr r + -> String + -> ( TypedName ta a, Expression ta -> a ) + -> ( TypedName tb b, Expression tb -> b ) + -> ( TypedName tc c, Expression tc -> c ) + -> ( TypedName td d, Expression td -> d ) + -> (a -> b -> c -> d -> Statement tr) + -> + ( FunDecl + , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> r + ) +fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3 ] <| + body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) + , \l m n r -> dotter (call4Internal name l m n r) + ) + + +if_ : Expression1 Bool -> Statement r -> Statement r -> Statement r +if_ cond (Statement ifTrue) (Statement ifFalse) = + Statement <| If (unwrapExpression cond) ifTrue ifFalse return : ExpressionX a r -> Statement r -return { base } = - Return base +return e = + Statement <| Return <| unwrapExpression e -decl : TypingFunction tv v -> String -> (v -> List (Statement tr)) -> List (Statement tr) +decl : TypingFunction tv v -> String -> (v -> Statement tr) -> Statement tr decl typeF name k = let ( TypedName (Type t) n e, _ ) = typeF name - go = - Decl t n Nothing + (Statement ks) = + k e in - go :: k e + Statement <| Decl t n Nothing ks -def : TypingFunction tv v -> String -> ExpressionX xv tv -> (v -> List (Statement tr)) -> List (Statement tr) -def typeF name value k = +def : TypingFunction tv v -> String -> ExpressionX xv tv -> (v -> Statement tr) -> Statement tr +def typeF name v k = let ( TypedName (Type t) n e, _ ) = typeF name - go = - Decl t n (Just <| unwrapExpression value) + (Statement ks) = + k e in - go :: k e + Statement <| Decl t n (Just <| unwrapExpression v) ks -assign : ExpressionX a t -> ExpressionX a t -> Statement q -assign name e = - ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) +assign : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assign name e (Statement next) = + Statement <| ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) next unknownFunDecl : { name : String, type_ : String, body : String } -> FunDecl @@ -1070,7 +1115,7 @@ type Mat3 = Mat3 Mat3 -voidT : TypingFunction (Never -> a) (Never -> a) +voidT : TypingFunction () (Never -> a) voidT n = ( TypedName (Type "void") (Name n) never, always never ) @@ -1103,3 +1148,272 @@ vec4T n = mat3T : TypingFunction Mat3 (Expression1 Mat3) mat3T n = ( TypedName (Type "mat3") (Name n) (dotted1Internal (Variable n)), dotted1 ) + + + +-------------------- +-- TESTING HELPER -- +-------------------- + + +type GlslValue + = VFloat Float + | VBool Bool + | VInt Int + | VVec2 Float Float + | VVec3 Float Float Float + | VMat3 ( Float, Float, Float ) ( Float, Float, Float ) ( Float, Float, Float ) + | VVoid -- Used for void return + + +type ErrorValue + = MissingVariable String + | InvalidTypes String + | MissingReturn + + +type alias Context = + Dict String GlslValue + + +valueToString : GlslValue -> String +valueToString v = + case v of + VFloat f -> + String.fromFloat f + + VBool b -> + if b then + "true" + + else + "false" + + VInt i -> + String.fromInt i + + VVoid -> + "void" + + VVec2 x y -> + "vec2(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ ")" + + VVec3 x y z -> + "vec3(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ "," ++ String.fromFloat z ++ ")" + + VMat3 _ _ _ -> + Debug.todo "branch 'VMat3 _ _ _' not implemented" + + +value : Context -> Expression t -> Result ErrorValue ( Context, GlslValue ) +value initialContext (Expression input) = + innerValue initialContext input + + +innerValue : Context -> Expr -> Result ErrorValue ( Context, GlslValue ) +innerValue ctx e = + case e of + Float f -> + Ok ( ctx, VFloat f ) + + Bool b -> + Ok ( ctx, VBool b ) + + Int i -> + Ok ( ctx, VInt i ) + + Variable v -> + case Dict.get v ctx of + Just f -> + Ok ( ctx, f ) + + Nothing -> + Err <| MissingVariable v + + And l r -> + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Or l r -> + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Comparison k l r -> + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) + + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) + + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) + + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) + + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) + + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + + Ternary _ _ _ -> + Debug.todo "branch 'Ternary _ _ _' not implemented" + + Add _ _ -> + Debug.todo "branch 'Add _ _' not implemented" + + Subtract _ _ -> + Debug.todo "branch 'Subtract _ _' not implemented" + + By l r -> + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Div _ _ -> + Debug.todo "branch 'Div _ _' not implemented" + + Call "vec2" [ l, r ] -> + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Call "exp" [ l ] -> + autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l + + Call "cos" [ l ] -> + autovectorizingFloatOp ctx "cos" Basics.cos l + + Call "sin" [ l ] -> + autovectorizingFloatOp ctx "sin" Basics.sin l + + Call name args -> + Debug.todo <| "branch 'Call \"" ++ name ++ "\" [" ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) ++ " ]' not implemented" + + Negate _ -> + Debug.todo "branch 'Negate _' not implemented" + + Unknown _ -> + Debug.todo "branch 'Unknown _' not implemented" + + Dot _ _ -> + Debug.todo "branch 'Dot _ _' not implemented" + + Array _ _ -> + Debug.todo "branch 'Array _ _' not implemented" + + Assign _ _ -> + Debug.todo "branch 'Assign _ _' not implemented" + + +innerValue2 : + Context + -> Expr + -> Expr + -> (Context -> GlslValue -> GlslValue -> Result ErrorValue ( Context, GlslValue )) + -> Result ErrorValue ( Context, GlslValue ) +innerValue2 ctx l r k = + innerValue ctx l + |> Result.andThen + (\( ctx2, vl ) -> + innerValue ctx2 r + |> Result.andThen + (\( ctx3, vr ) -> + k ctx3 vl vr + ) + ) + + +autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result ErrorValue ( Dict String GlslValue, GlslValue ) +autovectorizingFloatOp ctx name inner expr = + innerValue ctx expr + |> Result.andThen + (\( ctx2, v ) -> + case v of + VFloat fv -> + Ok ( ctx2, VFloat <| inner fv ) + + VVec2 x y -> + Ok ( ctx2, VVec2 (inner x) (inner y) ) + + VVec3 x y z -> + Ok ( ctx2, VVec3 (inner x) (inner y) (inner z) ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `" ++ name ++ "` for " ++ valueToString v) + ) + + +interpret : Context -> Statement a -> Result ErrorValue ( Context, GlslValue ) +interpret ctx (Statement s) = + case s of + Return e -> + Expression e + |> value ctx + |> Result.map (\( ctx2, val ) -> ( ctx2, val )) + + If c t f -> + Expression c + |> value ctx + |> Result.andThen + (\( ctx2, cval ) -> + case cval of + VBool True -> + interpret ctx2 <| Statement t + + VBool False -> + interpret ctx2 <| Statement f + + _ -> + Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval + ) + + Line _ _ -> + Debug.todo "branch 'Line _' not implemented" + + ExpressionStatement _ _ -> + Debug.todo "branch 'ExpressionStatement _' not implemented" + + Decl _ _ _ _ -> + Debug.todo "branch 'Decl _ _ _' not implemented" + + Nop -> + Ok ( ctx, VVoid ) diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm new file mode 100644 index 00000000..012e1be4 --- /dev/null +++ b/tests/GlslFuzzer.elm @@ -0,0 +1,65 @@ +module GlslFuzzer exposing (..) + +import Complex exposing (Complex(..)) +import Dict +import Expect exposing (Expectation) +import Test exposing (Test) +import UI.Glsl.Code exposing (cexpFunction) +import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2, GlslValue(..), Statement, Vec2, float, one, vec2, zero) + + +suite : Test +suite = + Test.describe "Glsl" + [ test1 "cexp" + cexpFunction + [ ( zeroC, oneC ) + , ( oneC, real e ) + , ( real 2, real <| e * e ) + , ( real -1, real <| 1 / e ) + , ( complex Complex.i, complex <| Complex.exp Complex.i ) + ] + ] + + +complex : Complex -> Expression2 +complex (Complex r i) = + vec2 (float r) (float i) + + +real : Float -> Expression2 +real r = + vec2 (float r) zero + + +oneC : Expression2 +oneC = + vec2 one zero + + +zeroC : Expression2 +zeroC = + vec2 zero zero + + +test1 : + String + -> (Expression2 -> Statement Vec2) + -> List ( Expression2, Expression2 ) + -> Test +test1 name function cases = + cases + |> List.map + (\( input, output ) -> + Test.test (Debug.toString input) <| + \_ -> + check + (Generator.interpret Dict.empty <| function input) + (Generator.value Dict.empty output.base) + ) + |> Test.describe name + + +check : Result ErrorValue ( Context, GlslValue ) -> Result ErrorValue ( Context, GlslValue ) -> Expectation +check actual expected = + Expect.equal expected actual diff --git a/tests/SolverTest.elm b/tests/SolverTest.elm index 6f0552c8..e26f1c3f 100644 --- a/tests/SolverTest.elm +++ b/tests/SolverTest.elm @@ -113,16 +113,18 @@ solveTests = , xeq two ] ) - , ( simplify <| - by - [ minus x pi - , minus x pi - , minus x pi - ] - , x - , [ xeq pi - , xeq pi - , xeq pi - ] - ) + + {- , ( simplify <| + by + [ minus x pi + , minus x pi + , minus x pi + ] + , x + , [ xeq pi + , xeq pi + , xeq pi + ] + ) + -} ] From d94ecca106585d392cab4b0ba7735d80529e7dbc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 20:45:28 +0200 Subject: [PATCH 009/139] Cleanup --- src/elm/UI.elm | 26 ----- src/elm/UI/Glsl.elm | 20 ++-- src/elm/UI/Glsl/Code.elm | 175 +++++++++++++++------------------- src/elm/UI/Model.elm | 2 - src/elm/UI/RowView.elm | 4 +- src/shaders/declarations.frag | 4 - 6 files changed, 90 insertions(+), 141 deletions(-) diff --git a/src/elm/UI.elm b/src/elm/UI.elm index 472853b0..2950e23c 100644 --- a/src/elm/UI.elm +++ b/src/elm/UI.elm @@ -224,7 +224,6 @@ init ({ saved, hasClipboard, hasFullscreen, languages } as flags) url key = |> List.filterMap identity |> List.head |> Maybe.withDefault En - , expandIntervals = False , rayDifferentials = True -- The other classes have faster processors so should update quicker @@ -523,23 +522,6 @@ dropdown model = btn (Language lang) [] <| L10N.invariant flag - expandIntervalsButton expandIntervals = - if expandIntervals then - btn (ToggleExpandIntervals False) - [ Element.element <| Icons.funnelPlotOutlined Theme.darkIconAttrs - , bigStop - ] - { en = "Do not apply noise reduction" - , it = "Non applicare riduzione rumore" - } - - else - simpleBtn (ToggleExpandIntervals True) - Icons.funnelPlotOutlined - { en = "Apply noise reduction" - , it = "Applica riduzione rumore" - } - rayDifferentialsButton rayDifferentials = if rayDifferentials then btn (ToggleRayDifferentials False) @@ -589,7 +571,6 @@ dropdown model = Icons.saveOutlined { en = "Save", it = "Salva" } ) - , Just <| Element.with .expandIntervals expandIntervalsButton , Just <| Element.with .rayDifferentials rayDifferentialsButton {- , sid @@ -1116,13 +1097,6 @@ update msg = in ( { model | context = { context | language = language } }, Cmd.none ) - ToggleExpandIntervals expandIntervals -> - let - context = - model.context - in - ( { model | context = { context | expandIntervals = expandIntervals } }, Cmd.none ) - ToggleRayDifferentials rayDifferentials -> let context = diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 3fc62906..1e041e2f 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -7,16 +7,16 @@ import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, square) import Maybe.Extra as Maybe import SortedAnySet as Set -import UI.Glsl.Code exposing (constantToGlsl, deindent, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (dotted3, floatT, uniform, unsafeCall, vec2T) +import UI.Glsl.Code exposing (constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (dotted3, unsafeCall) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere -getGlsl : Bool -> Bool -> Graph -> String -getGlsl expandIntervals rayDifferentials graph = +getGlsl : Bool -> Graph -> String +getGlsl rayDifferentials graph = let { expr, srcExpr, interval, usesThetaDelta, pixel2D, pixel3D } = extract "" graph @@ -52,7 +52,7 @@ getGlsl expandIntervals rayDifferentials graph = ] in { expr = e - , srcExpr = toSrcParametric expandIntervals prefix e + , srcExpr = toSrcParametric prefix e , interval = IntervalOnly , usesThetaDelta = False , pixel2D = [ { name = "pixel" ++ prefix, color = True } ] @@ -74,7 +74,7 @@ getGlsl expandIntervals rayDifferentials graph = Implicit3D e -> let f = - get3DSource expandIntervals prefix e + get3DSource prefix e in { expr = f.expr , srcExpr = f.srcExpr @@ -149,12 +149,12 @@ getGlsl expandIntervals rayDifferentials graph = declarations : String declarations = - [ gnumDecl ] + [ gnumDecl, dupDecl ] |> Generator.fileToGlsl -get3DSource : Bool -> String -> Expression -> { expr : Expression, srcExpr : String } -get3DSource expandIntervals prefix e = +get3DSource : String -> Expression -> { expr : Expression, srcExpr : String } +get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of Just glsl -> { expr = e @@ -176,7 +176,7 @@ get3DSource expandIntervals prefix e = Nothing -> let glsl = - toSrc3D expandIntervals prefix e + toSrc3D prefix e |> Generator.fileToGlsl in { expr = e diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 34deaf7b..85e5f8f6 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) @@ -68,6 +68,21 @@ gnum = Tuple.second gnumTuple +dupTuple : ( FunDecl, ExpressionX xa Float -> Expression2 ) +dupTuple = + fun1 vec2T "dup" (floatT "x") <| \x -> return <| vec2 x x + + +dupDecl : FunDecl +dupDecl = + Tuple.first dupTuple + + +dup : ExpressionX xa Float -> Expression2 +dup = + Tuple.second dupTuple + + cby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 cby = Tuple.second cbyTuple @@ -224,6 +239,35 @@ gby = Tuple.second gbyCouple +ibyCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +ibyCouple = + fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| + \l r -> + def floatT "a" (by l.x r.x) <| + \a -> + def floatT "b" (by l.x r.y) <| + \b -> + def floatT "c" (by l.y r.x) <| + \c -> + def floatT "d" (by l.y r.x) <| + \d -> + def floatT "mn" (min_ (min_ a b) (min_ c d)) <| + \mn -> + def floatT "mx" (max_ (max_ a b) (max_ c d)) <| + \mx -> + return <| vec2 mn mx + + +ibyDecl : FunDecl +ibyDecl = + Tuple.first ibyCouple + + +iby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +iby = + Tuple.second ibyCouple + + gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gdivCouple = fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| @@ -357,17 +401,7 @@ intervalOperationToGlsl op = """ ++ fileToGlsl [ gnegDecl ] GlslMultiplication -> - """ - vec2 iby(vec2 l, vec2 r) { - float a = l.x * r.x; - float b = l.x * r.y; - float c = l.y * r.x; - float d = l.y * r.y; - float mn = min(min(a,b),min(c,d)); - float mx = max(max(a,b),max(c,d)); - return vec2(mn, mx); - } - """ ++ fileToGlsl [ gbyDecl ] + fileToGlsl [ ibyDecl, gbyDecl ] GlslDivision -> """ @@ -1254,14 +1288,14 @@ toSrcPolar suffix e = """ -toSrcParametric : Bool -> String -> Expression.Expression -> String -toSrcParametric expandIntervals suffix e = +toSrcParametric : String -> Expression.Expression -> String +toSrcParametric suffix e = """ vec2 interval""" ++ suffix ++ """(vec2 p, float from, float to) { vec2 x = vec2(p.x,p.x); vec2 y = vec2(p.y,p.y); vec2 t = from < to ? vec2(from, to) : vec2(to, from); - return """ ++ expressionToIntervalGlsl expandIntervals e ++ """; + return """ ++ Generator.expressionToGlsl (expressionToIntervalGlsl (toPrintExpression e)).base ++ """; } vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { @@ -1508,36 +1542,6 @@ epsilon = 0.00001 -wordWrap : String -> String -wordWrap = - let - step e ( l, acc ) = - if String.length e + String.length l > 40 then - ( e, l :: acc ) - - else - ( l ++ e, acc ) - in - String.split " " - >> List.foldl step ( "", [] ) - >> (\( l, a ) -> - if String.isEmpty l then - a - - else - l :: a - ) - >> List.reverse - >> String.join "\n " - - -expressionToIntervalGlsl : Bool -> Expression.Expression -> String -expressionToIntervalGlsl expandIntervals = - toPrintExpression - >> expressionToIntervalGlslPrec expandIntervals 0 - >> wordWrap - - expressionToGlsl : List ( String, Expression1 Float ) -> Expression.Expression -> Expression2 expressionToGlsl context = let @@ -1633,52 +1637,33 @@ expressionToGlsl context = toPrintExpression >> go -paren : Bool -> String -> String -paren b c = - if b then - "(" ++ c ++ ")" - - else - c - - -expressionToIntervalGlslPrec : Bool -> Int -> PrintExpression -> String -expressionToIntervalGlslPrec expandIntervals p expr = +expressionToIntervalGlsl : PrintExpression -> Expression2 +expressionToIntervalGlsl expr = let - infixl_ n op l r = - paren (p > n) <| expressionToIntervalGlslPrec expandIntervals n l ++ op ++ expressionToIntervalGlslPrec expandIntervals (n + 1) r - apply name ex = - paren (p > 10) <| name ++ "(" ++ String.join ", " (List.map (expressionToIntervalGlslPrec expandIntervals 0) ex) ++ ")" - - expand e = - if expandIntervals then - "iexpand(" ++ e ++ ")" - - else - e + dotted2 <| unsafeCall name (List.map (expressionToIntervalGlsl >> .base) ex) in case expr of PVariable "pi" -> - "dup(radians(180.0))" + dup <| dotted1 <| unknown "radians(180.0)" PVariable "e" -> - "dup(exp(1.0))" + dup <| dotted1 <| unknown "exp(1.0)" PVariable v -> - v + dotted2 <| unknown v PInteger v -> - "dup(" ++ String.fromInt v ++ ".0)" + dup <| float <| toFloat v PFloat f -> - "dup(" ++ floatToGlsl f ++ ")" + dup <| float f PNegate expression -> - "ineg(" ++ expressionToIntervalGlslPrec expandIntervals 10 expression ++ ")" + apply "ineg" [ expression ] PAdd l r -> - expand <| infixl_ 6 " + " l r + add2 (expressionToIntervalGlsl l) (expressionToIntervalGlsl r) PRel op l r -> let @@ -1702,61 +1687,57 @@ expressionToIntervalGlslPrec expandIntervals p expr = _ -> "iuknownrelop" in - expand <| name ++ "(" ++ expressionToIntervalGlslPrec expandIntervals 10 l ++ ", " ++ expressionToIntervalGlslPrec expandIntervals 10 r ++ ")" + apply name [ l, r ] PBy l r -> - expand <| apply "iby" [ l, r ] + iby (expressionToIntervalGlsl l) (expressionToIntervalGlsl r) PDiv l r -> - expand <| apply "idiv" [ l, r ] + apply "idiv" [ l, r ] PPower (PVariable "i") (PInteger 2) -> - "dup(-1.0)" + dup <| float -1 PPower l (PInteger 2) -> - expand <| "isquare(" ++ expressionToIntervalGlslPrec expandIntervals 0 l ++ ")" + apply "isquare" [ l ] PPower l (PFloat f) -> if f == 2.0 then - expand <| "isquare(" ++ expressionToIntervalGlslPrec expandIntervals 0 l ++ ")" + apply "isquare" [ l ] else - expand <| apply "ipow" [ l, PFloat f ] + apply "ipow" [ l, PFloat f ] PPower l (PInteger ri) -> - let - ris = - String.fromInt ri - in - expand <| "ipow(" ++ expressionToIntervalGlslPrec expandIntervals 0 l ++ ", " ++ ris ++ ")" + apply "ipow" [ l, PInteger ri ] PPower l r -> - expand <| apply "ipow" [ l, r ] + apply "ipow" [ l, r ] PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map (expressionToIntervalGlslPrec expandIntervals 0) ex of + case List.map expressionToIntervalGlsl ex of [] -> - "vec2(0)" + vec2 zero zero head :: tail -> - expand <| List.foldl (\e a -> "i" ++ Expression.functionNameToString name ++ "(" ++ a ++ "," ++ e ++ ")") head tail + dotted2 <| List.foldl (\e a -> unsafeCall ("i" ++ Expression.functionNameToString name) [ a, e.base ]) head.base tail else if name == KnownFunction Sin || name == KnownFunction Cos then apply ("i" ++ Expression.functionNameToString name) ex else - expand <| apply ("i" ++ Expression.functionNameToString name) ex + apply ("i" ++ Expression.functionNameToString name) ex PList es -> - "vec" ++ String.fromInt (List.length es) ++ "(" ++ String.join ", " (List.map (expressionToIntervalGlslPrec expandIntervals 0) es) ++ ")" + apply ("vec" ++ String.fromInt (List.length es)) es PReplace var e -> - expressionToIntervalGlslPrec expandIntervals p (Expression.pfullSubstitute var e) + expressionToIntervalGlsl (Expression.pfullSubstitute var e) -- If this happens, it's too late PLambda _ _ -> - "vec2(0)" + vec2 zero zero expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 @@ -2053,8 +2034,8 @@ axisDecl = Tuple.first axisTuple -toSrc3D : Bool -> String -> Expression.Expression -> File -toSrc3D expandIntervals suffix e = +toSrc3D : String -> Expression.Expression -> File +toSrc3D suffix e = [ Tuple.first <| fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> @@ -2080,7 +2061,7 @@ toSrc3D expandIntervals suffix e = \_ -> def vec2T "z" (vec2 mn.z mx.z) <| \_ -> - return <| dotted2 <| unknown <| expressionToIntervalGlsl expandIntervals e + return <| expressionToIntervalGlsl <| toPrintExpression e ] diff --git a/src/elm/UI/Model.elm b/src/elm/UI/Model.elm index 7edac0c8..b9ade3a7 100644 --- a/src/elm/UI/Model.elm +++ b/src/elm/UI/Model.elm @@ -52,7 +52,6 @@ type alias Context = { language : Language , hasClipboard : Bool , hasFullscreen : Bool - , expandIntervals : Bool , rayDifferentials : Bool , deviceClass : DeviceClass , isFullscreen : Bool @@ -80,7 +79,6 @@ type Msg | Resized Size | ToggleMenu Bool | ToggleShowPendingActions Bool - | ToggleExpandIntervals Bool | ToggleRayDifferentials Bool | Language Language | GoogleAuth diff --git a/src/elm/UI/RowView.elm b/src/elm/UI/RowView.elm index a3940463..481542b4 100644 --- a/src/elm/UI/RowView.elm +++ b/src/elm/UI/RowView.elm @@ -131,12 +131,12 @@ draw size id { wdiv, hdiv } { graph, axes } = ] in Element.with identity <| - \{ rayDifferentials, expandIntervals } -> + \{ rayDifferentials } -> el attrs <| Element.html <| Html.node "nu-plot" [ Html.Attributes.id cid - , Html.Attributes.property "exprSrc" <| Json.Encode.string <| getGlsl expandIntervals rayDifferentials graph + , Html.Attributes.property "exprSrc" <| Json.Encode.string <| getGlsl rayDifferentials graph , Html.Attributes.attribute "canvas-width" <| String.fromInt <| imageWidth // wdiv , Html.Attributes.attribute "canvas-height" <| String.fromInt <| imageHeight // hdiv , Html.Attributes.attribute "white-lines" <| String.fromInt Theme.whiteLines diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag index 9d74f580..83ac66ea 100644 --- a/src/shaders/declarations.frag +++ b/src/shaders/declarations.frag @@ -19,10 +19,6 @@ vec3 hl2rgb(float h, float l) return l + (rgb - 0.5) * (1.0 - abs(2.0 * l - 1.0)); } -vec2 dup(float x) { - return vec2(x, x); -} - float atanPlus(float y, float x) { return mod(radians(360.0) + atan(y, x), radians(360.0)); } From a78ed8cce189cde8f4c42ebcf5c3abd5bce99d6a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 21:07:20 +0200 Subject: [PATCH 010/139] More codegen --- src/elm/UI/Glsl/Code.elm | 175 +++++++++++++++++++++++----------- src/elm/UI/Glsl/Generator.elm | 7 +- 2 files changed, 124 insertions(+), 58 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 85e5f8f6..29c2a2b0 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -194,6 +194,23 @@ cpow = Tuple.second cpowTuple +inegCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +inegCouple = + fun1 vec2T "ineg" (vec2T "v") <| + \v -> + return <| vec2 (negate_ v.y) (negate_ v.x) + + +inegDecl : FunDecl +inegDecl = + Tuple.first inegCouple + + +ineg : ExpressionX xa Vec2 -> Expression2 +ineg = + Tuple.second inegCouple + + gnegCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gnegCouple = fun1 vec4T "gneg" (vec4T "v") <| \v -> return <| negate_ v @@ -249,7 +266,7 @@ ibyCouple = \b -> def floatT "c" (by l.y r.x) <| \c -> - def floatT "d" (by l.y r.x) <| + def floatT "d" (by l.y r.y) <| \d -> def floatT "mn" (min_ (min_ a b) (min_ c d)) <| \mn -> @@ -268,6 +285,52 @@ iby = Tuple.second ibyCouple +iinverseCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +iinverseCouple = + fun1 vec2T "iinverse" (vec2T "y") <| + \y -> + return <| + ternary + (ands [ leq y.x zero, geq y.y zero ]) + (vec2 (div minusOne zero) (div one zero)) + (ternary + (eq y.y zero) + (vec2 (div minusOne zero) (div one y.x)) + (ternary + (eq y.x zero) + (vec2 (div one y.y) (div one zero)) + (vec2 (div one y.y) (div one y.x)) + ) + ) + + +iinverseDecl : FunDecl +iinverseDecl = + Tuple.first iinverseCouple + + +iinverse : ExpressionX xa Vec2 -> Expression2 +iinverse = + Tuple.second iinverseCouple + + +idivCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +idivCouple = + fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| + \l r -> + return <| iby l (iinverse r) + + +idivDecl : FunDecl +idivDecl = + Tuple.first idivCouple + + +idiv : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +idiv = + Tuple.second idivCouple + + gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gdivCouple = fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| @@ -369,8 +432,8 @@ csinCouple = \s -> return <| ternary - (eq z.y (float 0)) - (vec2 s (float 0)) + (eq z.y zero) + (vec2 s zero) (vec2 (by s (cosh z.y)) (by (cos_ z.x) (sinh z.y)) @@ -387,6 +450,32 @@ csin = Tuple.second csinCouple +ccosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ccosCouple = + fun1 vec2T "ccos" (vec2T "z") <| + \z -> + def floatT "c" (cos_ z.x) <| + \c -> + return <| + ternary + (eq z.y zero) + (vec2 c zero) + (vec2 + (by c (cosh z.y)) + (by (sin_ z.x) (sinh z.y)) + ) + + +ccosDecl : FunDecl +ccosDecl = + Tuple.first ccosCouple + + +ccos : ExpressionX xa Vec2 -> Expression2 +ccos = + Tuple.second ccosCouple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -394,31 +483,13 @@ intervalOperationToGlsl op = "" GlslNegation -> - """ - vec2 ineg(vec2 v) { - return vec2(-v.y, -v.x); - } - """ ++ fileToGlsl [ gnegDecl ] + fileToGlsl [ inegDecl, gnegDecl ] GlslMultiplication -> fileToGlsl [ ibyDecl, gbyDecl ] GlslDivision -> - """ - vec2 iinverse(vec2 y) { - if(y.x <= 0.0 && y.y >= 0.0) - return vec2(-1.0 / 0.0, 1.0 / 0.0); - if(y.y == 0.0) - return vec2(-1.0 / 0.0, 1.0 / y.x); - if(y.x == 0.0) - return vec2(1.0 / y.y, 1.0 / 0.0); - return vec2(1.0 / y.y, 1.0 / y.x); - } - - vec2 idiv(vec2 l, vec2 r) { - return iby(l, iinverse(r)); - } - """ ++ fileToGlsl [ gdivDecl ] + fileToGlsl [ iinverseDecl, idivDecl, gdivDecl ] GlslPower -> """ @@ -512,20 +583,7 @@ straightFunctionToGlsl name = [ csinDecl ] Cos22 -> - [ unknownFunDecl - { name = - "ccos" - , type_ = "TODO" - , body = """ - vec2 ccos(vec2 z) { - if(z.y == 0.0) { - return vec2(cos(z.x), 0); - } - return vec2(cos(z.x) * cosh(z.y), sin(z.x) * sinh(z.y)); - } - """ - } - ] + [ ccosDecl ] Tan22 -> [ unknownFunDecl @@ -1640,15 +1698,18 @@ expressionToGlsl context = expressionToIntervalGlsl : PrintExpression -> Expression2 expressionToIntervalGlsl expr = let - apply name ex = - dotted2 <| unsafeCall name (List.map (expressionToIntervalGlsl >> .base) ex) + unsafeApply name ex = + dotted2 <| unsafeCall name (List.map (go >> .base) ex) + + go = + expressionToIntervalGlsl in case expr of PVariable "pi" -> - dup <| dotted1 <| unknown "radians(180.0)" + dup <| radians_ (float 180) PVariable "e" -> - dup <| dotted1 <| unknown "exp(1.0)" + dup <| exp one PVariable v -> dotted2 <| unknown v @@ -1660,10 +1721,10 @@ expressionToIntervalGlsl expr = dup <| float f PNegate expression -> - apply "ineg" [ expression ] + ineg <| go expression PAdd l r -> - add2 (expressionToIntervalGlsl l) (expressionToIntervalGlsl r) + add2 (go l) (go r) PRel op l r -> let @@ -1687,36 +1748,36 @@ expressionToIntervalGlsl expr = _ -> "iuknownrelop" in - apply name [ l, r ] + unsafeApply name [ l, r ] PBy l r -> - iby (expressionToIntervalGlsl l) (expressionToIntervalGlsl r) + iby (go l) (go r) PDiv l r -> - apply "idiv" [ l, r ] + idiv (go l) (go r) PPower (PVariable "i") (PInteger 2) -> dup <| float -1 PPower l (PInteger 2) -> - apply "isquare" [ l ] + unsafeApply "isquare" [ l ] PPower l (PFloat f) -> if f == 2.0 then - apply "isquare" [ l ] + unsafeApply "isquare" [ l ] else - apply "ipow" [ l, PFloat f ] + unsafeApply "ipow" [ l, PFloat f ] PPower l (PInteger ri) -> - apply "ipow" [ l, PInteger ri ] + unsafeApply "ipow" [ l, PInteger ri ] PPower l r -> - apply "ipow" [ l, r ] + unsafeApply "ipow" [ l, r ] PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map expressionToIntervalGlsl ex of + case List.map go ex of [] -> vec2 zero zero @@ -1724,16 +1785,16 @@ expressionToIntervalGlsl expr = dotted2 <| List.foldl (\e a -> unsafeCall ("i" ++ Expression.functionNameToString name) [ a, e.base ]) head.base tail else if name == KnownFunction Sin || name == KnownFunction Cos then - apply ("i" ++ Expression.functionNameToString name) ex + unsafeApply ("i" ++ Expression.functionNameToString name) ex else - apply ("i" ++ Expression.functionNameToString name) ex + unsafeApply ("i" ++ Expression.functionNameToString name) ex PList es -> - apply ("vec" ++ String.fromInt (List.length es)) es + unsafeApply ("vec" ++ String.fromInt (List.length es)) es PReplace var e -> - expressionToIntervalGlsl (Expression.pfullSubstitute var e) + go (Expression.pfullSubstitute var e) -- If this happens, it's too late PLambda _ _ -> diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 0bd8e366..9e4607d3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -785,6 +785,11 @@ one = float 1 +minusOne : Expression1 Float +minusOne = + float -1 + + float : Float -> Expression1 Float float f = dotted1Internal (Float f) From 2d52bcdd161d76f0fe2619b9f173e1acfb19f1a7 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 21:12:05 +0200 Subject: [PATCH 011/139] isquare --- src/elm/UI/Glsl/Code.elm | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 29c2a2b0..f1828773 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -226,6 +226,33 @@ gneg = Tuple.second gnegCouple +isquareCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +isquareCouple = + fun1 vec2T "isquare" (vec2T "z") <| + \z -> + def vec2T "s" (by z z) <| + \s -> + def floatT "mx" (max_ s.x s.y) <| + \mx -> + if_ + (ands [ leq z.x zero, geq z.y zero ]) + (return <| vec2 zero mx) + (def floatT "mn" (min_ s.x s.y) <| + \mn -> + return <| vec2 mn mx + ) + + +isquareDecl : FunDecl +isquareDecl = + Tuple.first isquareCouple + + +isquare : ExpressionX xa Vec2 -> Expression2 +isquare = + Tuple.second isquareCouple + + gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gsquareCouple = fun1 vec4T "gsquare" (vec4T "z") <| \z -> return <| vec4_1_3 (by z.x z.x) z.yzw @@ -1194,16 +1221,7 @@ intervalFunctionToGlsl name = """ Square22 -> - """ - vec2 isquare(vec2 z) { - vec2 s = z * z; - float mx = max(s.x, s.y); - if(z.x <= 0.0 && z.y >= 0.0) - return vec2(0.0, mx); - float mn = min(s.x, s.y); - return vec2(mn, mx); - } - """ ++ fileToGlsl [ gsquareDecl ] + fileToGlsl [ isquareDecl, gsquareDecl ] Tan22 -> """ @@ -1760,11 +1778,11 @@ expressionToIntervalGlsl expr = dup <| float -1 PPower l (PInteger 2) -> - unsafeApply "isquare" [ l ] + isquare (go l) PPower l (PFloat f) -> if f == 2.0 then - unsafeApply "isquare" [ l ] + isquare (go l) else unsafeApply "ipow" [ l, PFloat f ] From bca2b14b42041c73ed61a0fd2b91b1a606494d56 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 26 Aug 2021 21:46:32 +0200 Subject: [PATCH 012/139] More codegen --- src/elm/UI/Glsl/Code.elm | 175 +++++++++++++++++++++++++--------- src/elm/UI/Glsl/Generator.elm | 7 +- 2 files changed, 134 insertions(+), 48 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index f1828773..34f6f055 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -380,6 +380,93 @@ gdiv = Tuple.second gdivCouple +ipowFICouple = + fun2 floatT "ipow" (floatT "b") (intT "e") <| + \b e -> + def floatT "fe" (floatCast e) <| + \fe -> + return <| + ternary + (eq (mod fe (float 2.0)) zero) + (pow (abs_ b) fe) + (by b <| pow (abs_ b) (subtract fe one)) + + +ipowFIDecl = + Tuple.first ipowFICouple + + +ipowFI = + Tuple.second ipowFICouple + + +ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) +ipowICouple = + fun2 vec2T "ipow" (vec2T "b") (intT "e") <| + \b e -> + if_ + (eq e (int 0)) + (return <| vec2 one one) + (if_ + (eq e (int 1)) + (return b) + (def floatT "xe" (ipowFI b.x e) <| + \xe -> + def floatT "ye" (ipowFI b.y e) <| + \ye -> + def floatT "mn" (min_ xe ye) <| + \mn -> + def floatT "mx" (max_ xe ye) <| + \mx -> + return <| + ternary + (ands + [ eq (mod (floatCast e) (float 2)) zero + , leq b.x zero + , geq b.y zero + ] + ) + (vec2 (min_ zero mn) (max_ zero mx)) + (vec2 mn mx) + ) + ) + + +ipowIDecl : FunDecl +ipowIDecl = + Tuple.first ipowICouple + + +ipowI : ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 +ipowI = + Tuple.second ipowICouple + + +ipowCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +ipowCouple = + fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| + \b e -> + return <| + ternary + (ands + [ lt (subtract e.y e.x) (float 0.000001) + , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) + ] + ) + (ipowI b <| intCast e.x) + (iexp <| iby (iln b) e) + + +ipowDecl : FunDecl +ipowDecl = + Tuple.first ipowCouple + + +ipow : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +ipow = + Tuple.second ipowCouple + + gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 ) gpowICouple = fun2 vec4T "gpow" (vec4T "b") (intT "e") <| @@ -421,6 +508,21 @@ gpow = Tuple.second gpowCouple +iexpCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +iexpCouple = + fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| vec2 (exp z.x) (exp z.y) + + +iexpDecl : FunDecl +iexpDecl = + Tuple.first iexpCouple + + +iexp : ExpressionX xa Vec2 -> Expression2 +iexp = + Tuple.second iexpCouple + + gexpCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gexpCouple = fun1 vec4T "gexp" (vec4T "z") <| \z -> return <| vec4_1_3 z.x (byF (exp z.x) z.yzw) @@ -436,6 +538,21 @@ gexp = Tuple.second gexpCouple +ilnCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ilnCouple = + fun1 vec2T "iln" (vec2T "z") <| \z -> return <| vec2 (log z.x) (log z.y) + + +ilnDecl : FunDecl +ilnDecl = + Tuple.first ilnCouple + + +iln : ExpressionX xa Vec2 -> Expression2 +iln = + Tuple.second ilnCouple + + glnCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) glnCouple = fun1 vec4T "gln" (vec4T "z") <| \z -> return <| vec4_1_3 (log z.x) (divF z.yzw z.x) @@ -519,39 +636,7 @@ intervalOperationToGlsl op = fileToGlsl [ iinverseDecl, idivDecl, gdivDecl ] GlslPower -> - """ - float ipow(float b, int e) { - float fe = float(e); - if(mod(fe, 2.0) == 0.0) - return pow(abs(b), fe); - else - return b * pow(abs(b), fe - 1.0); - } - - vec2 ipow(vec2 b, int e) { - if(e == 0) - return vec2(1,1); - if(e == 1) - return b; - float xe = ipow(b.x, e); - float ye = ipow(b.y, e); - float mn = min(xe, ye); - float mx = max(xe, ye); - if(mod(float(e), 2.0) == 0.0 && b.x <= 0.0 && b.y >= 0.0) { - return vec2( - min(0.0, mn), - max(0.0, mx) - ); - } - return vec2(mn, mx); - } - - vec2 ipow(vec2 b, vec2 e) { - if(e.y - e.x < 0.000001 && abs(e.x - round(e.x)) < 0.000001) - return ipow(b, int(e.x)); - return iexp(iby(iln(b), e)); - } - """ ++ fileToGlsl [ gpowIDecl, gpowDecl ] + fileToGlsl [ ipowFIDecl, ipowIDecl, ipowDecl, gpowIDecl, gpowDecl ] GlslRelations -> """ @@ -1071,11 +1156,7 @@ intervalFunctionToGlsl name = """ Exp22 -> - """ - vec2 iexp(vec2 z) { - return vec2(exp(z.x), exp(z.y)); - } - """ ++ fileToGlsl [ gexpDecl ] + fileToGlsl [ iexpDecl, gexpDecl ] Floor22 -> """ @@ -1089,11 +1170,7 @@ intervalFunctionToGlsl name = """ Ln22 -> - """ - vec2 iln(vec2 z) { - return vec2(log(z.x), log(z.y)); - } - """ ++ fileToGlsl [ glnDecl ] + fileToGlsl [ ilnDecl, glnDecl ] Log1022 -> """ @@ -1717,6 +1794,10 @@ expressionToIntervalGlsl : PrintExpression -> Expression2 expressionToIntervalGlsl expr = let unsafeApply name ex = + let + _ = + Debug.todo + in dotted2 <| unsafeCall name (List.map (go >> .base) ex) go = @@ -1785,13 +1866,13 @@ expressionToIntervalGlsl expr = isquare (go l) else - unsafeApply "ipow" [ l, PFloat f ] + ipow (go l) (go <| PFloat f) PPower l (PInteger ri) -> - unsafeApply "ipow" [ l, PInteger ri ] + ipow (go l) (go <| PInteger ri) PPower l r -> - unsafeApply "ipow" [ l, r ] + ipow (go l) (go r) PApply name ex -> if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 9e4607d3..ed48bc8a 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -619,6 +619,11 @@ ceil_ = dotted1 << call1Internal "ceil" +round_ : ExpressionX a Float -> Expression1 Float +round_ = + dotted1 << call1Internal "round" + + sign : ExpressionX a t -> Expression1 t sign = dotted1 << call1Internal "sign" From a8bd1d03477008cead34666f14990b3d571b7265 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Fri, 27 Aug 2021 02:57:39 +0200 Subject: [PATCH 013/139] Cleanup --- src/elm/UI/Glsl/Code.elm | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 34f6f055..d12829d5 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -380,6 +380,7 @@ gdiv = Tuple.second gdivCouple +ipowFICouple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ) ipowFICouple = fun2 floatT "ipow" (floatT "b") (intT "e") <| \b e -> @@ -392,10 +393,12 @@ ipowFICouple = (by b <| pow (abs_ b) (subtract fe one)) +ipowFIDecl : FunDecl ipowFIDecl = Tuple.first ipowFICouple +ipowFI : ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ipowFI = Tuple.second ipowFICouple @@ -2092,34 +2095,14 @@ pixel2Tuple pixels = \px -> decl vec3T "curr" <| \curr -> - inner deltaX - deltaY - x - y - px - curr - (def floatT "maxDelta" (max_ deltaX deltaY) <| + inner deltaX deltaY x y px curr <| + def floatT "maxDelta" (max_ deltaX deltaY) <| \maxDelta -> - def vec3T - "yax" - (ternary3 - (eq uniforms.u_drawAxes one) - (byF (axis x y maxDelta) (vec3 zero one zero)) - vec3Zero - ) - <| + def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| \yax -> - def vec3T - "xax" - (ternary3 - (eq uniforms.u_drawAxes one) - (byF (axis y x maxDelta) (vec3 one zero zero)) - vec3Zero - ) - <| + def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| \xax -> return <| vec4_3_1 (max3 px (max3 xax yax)) one - ) addPixel : From f20c5e04fc56182439a9d816393b04b019478290 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 14:23:55 +0200 Subject: [PATCH 014/139] Cleanup --- src/elm/UI/Glsl/Code.elm | 25 +++++++++---------------- src/elm/UI/Glsl/Generator.elm | 3 +-- tests/GlslFuzzer.elm | 4 ++-- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index d12829d5..557292aa 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Code exposing (Uniforms, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) @@ -7,11 +7,12 @@ import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation type alias Uniforms = - { u_canvasWidth : Expression1 Float - , u_canvasHeight : Expression1 Float - , u_viewportWidth : Expression1 Float - , u_viewportHeight : Expression1 Float + { u_canvasHeight : Expression1 Float + , u_canvasWidth : Expression1 Float , u_drawAxes : Expression1 Float + , u_viewportHeight : Expression1 Float + , u_viewportWidth : Expression1 Float + , u_whiteLines : Expression1 Float , u_zoomCenter : Expression2 } @@ -1509,15 +1510,7 @@ toSrcParametric suffix e = """ -uniforms : - { u_canvasHeight : Expression1 Float - , u_canvasWidth : Expression1 Float - , u_drawAxes : Expression1 Float - , u_viewportHeight : Expression1 Float - , u_viewportWidth : Expression1 Float - , u_whiteLines : Expression1 Float - , u_zoomCenter : Expression2 - } +uniforms : Uniforms uniforms = { u_canvasHeight = uniform floatT "u_canvasHeight" , u_canvasWidth = uniform floatT "u_canvasWidth" @@ -2249,8 +2242,8 @@ main3D rayDifferentials suffixes = mat3 d = mat3(ray_direction - k * diffs, ray_direction + k * diffs, vec3(0)); float max_distance = 100.0 * eye_dist; - return raytrace(canvas_point, d, max_distance); - } + return """ ++ Generator.expressionToGlsl (unsafeCall "raytrace" [ unknown "canvas_point", unknown "d", unknown "max_distance" ]) ++ """; + """ ++ """} """ in ( deindent 12 <| raytrace suffixes ++ block, dotted4 <| unknown "pixel3()" ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index ed48bc8a..543a013c 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Name, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1179,7 +1179,6 @@ type GlslValue type ErrorValue = MissingVariable String | InvalidTypes String - | MissingReturn type alias Context = diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm index 012e1be4..2390e7bc 100644 --- a/tests/GlslFuzzer.elm +++ b/tests/GlslFuzzer.elm @@ -1,11 +1,11 @@ -module GlslFuzzer exposing (..) +module GlslFuzzer exposing (suite) import Complex exposing (Complex(..)) import Dict import Expect exposing (Expectation) import Test exposing (Test) import UI.Glsl.Code exposing (cexpFunction) -import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2, GlslValue(..), Statement, Vec2, float, one, vec2, zero) +import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2, GlslValue, Statement, Vec2, float, one, vec2, zero) suite : Test From 8104bae429be11b6425b6442581a0fd371a56bb3 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 15:55:58 +0200 Subject: [PATCH 015/139] main3D to codegen --- src/elm/UI/Glsl/Code.elm | 125 ++++++++++++++++++++++------------ src/elm/UI/Glsl/Generator.elm | 56 +++++++++++++-- 2 files changed, 134 insertions(+), 47 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 557292aa..c4a30171 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, e import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, Statement, Vec2, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -14,6 +14,8 @@ type alias Uniforms = , u_viewportWidth : Expression1 Float , u_whiteLines : Expression1 Float , u_zoomCenter : Expression2 + , u_phi : Expression1 Float + , u_theta : Expression1 Float } @@ -1519,6 +1521,8 @@ uniforms = , u_viewportWidth = uniform floatT "u_viewportWidth" , u_whiteLines = uniform floatT "u_whiteLines" , u_zoomCenter = uniform vec2T "u_zoomCenter" + , u_phi = uniform floatT "u_phi" + , u_theta = uniform floatT "u_theta" } @@ -2204,52 +2208,76 @@ toSrc3D suffix e = main3D : Bool -> List String -> ( String, Expression4 ) main3D rayDifferentials suffixes = let - k = + kValue = if rayDifferentials then - "0.001" + 0.001 else - "0.0" - - block = - """ - vec4 pixel3 () { - float eye_dist = 2.0 * u_viewportWidth; - vec2 canvasSize = vec2(u_canvasWidth, u_canvasHeight); - vec2 uv_centered = gl_FragCoord.xy - 0.5 * canvasSize; - vec2 uv_normalized = 1.0 / u_canvasHeight * uv_centered; - - float t = u_theta + 0.58; - float p = -2.0 * u_phi; - vec3 eye = eye_dist * normalize(vec3( - cos(t) * sin(p), - cos(t) * -cos(p), - sin(t) - )); - - vec3 target = vec3(0); - vec3 to_target = normalize(target-eye); - vec3 across = normalize(cross(to_target, vec3(0,0,1))); - vec3 up = normalize(cross(across, to_target)); - - vec3 canvas_center = eye + to_target; - vec3 canvas_point = canvas_center + uv_normalized.x * across + uv_normalized.y * up; - - vec3 ray_direction = normalize(canvas_point - eye); - - vec3 diffs = abs(fwidth(ray_direction)); - float k = """ ++ k ++ """; - mat3 d = mat3(ray_direction - k * diffs, ray_direction + k * diffs, vec3(0)); - - float max_distance = 100.0 * eye_dist; - return """ ++ Generator.expressionToGlsl (unsafeCall "raytrace" [ unknown "canvas_point", unknown "d", unknown "max_distance" ]) ++ """; - """ ++ """} - """ + 0.0 + + ( block, pixel3 ) = + fun0 vec4T "pixel3" <| + (def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| + \eyeDist -> + def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| + \canvasSize -> + def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| + \uvCentered -> + def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| + \uvNormalized -> + def floatT "t" (add uniforms.u_theta <| float 0.58) <| + \t -> + def floatT "p" (by (float -2.0) uniforms.u_phi) <| + \p -> + def vec3T "eye" (eyePosition t p) <| + \eye -> + def vec3T "target" vec3Zero <| + \target -> + def vec3T "to_target" (normalize <| subtract target eye) <| + \toTarget -> + def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| + \across -> + def vec3T "up" (normalize <| cross across toTarget) <| + \up -> + def vec3T "canvas_center" (add eye toTarget) <| + \canvasCenter -> + def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) <| byF uvNormalized.y up) <| + \canvasPoint -> + def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| + \rayDirection -> + def vec3T "diffs" (abs_ <| fwidth rayDirection) <| + \diffs -> + def floatT "k" (float kValue) <| + \k -> + def mat3T "d" (dValue rayDirection k diffs) <| + \d -> + def floatT "max_distance" (by (float 100) eyeDist) <| + \maxDistance -> + return <| raytraceF canvasPoint d maxDistance + ) + + dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 + dValue rayDirection k diffs = + mat3_3_3_3 + (subtract3 rayDirection <| byF k diffs) + (add rayDirection <| byF k diffs) + vec3Zero + + ( raytraceSrc, raytraceF ) = + raytrace suffixes + + eyePosition t p = + byF (dotted1 <| unknown "eye_dist") <| + normalize <| + vec3 + (by (cos_ t) (sin_ p)) + (by (cos_ t) (negate_ <| cos_ p)) + (sin_ t) in - ( deindent 12 <| raytrace suffixes ++ block, dotted4 <| unknown "pixel3()" ) + ( deindent 12 <| raytraceSrc ++ fileToGlsl [ block ], pixel3 ) -raytrace : List String -> String +raytrace : List String -> ( String, ExpressionX a Vec3 -> ExpressionX b Mat3 -> Expression1 Float -> Expression4 ) raytrace suffixes = let colorCoeff = @@ -2276,8 +2304,9 @@ raytrace suffixes = light_coeff = 0.2; } """ - in - """ + + src = + """ vec4 raytrace(vec3 o, mat3 d, float max_distance) { vec3 found = vec3(0); float curr_distance = max_distance; @@ -2308,6 +2337,16 @@ raytrace suffixes = } } """ + in + ( src + , \o d maxDistance -> + dotted4 <| + unsafeCall "raytrace" + [ Generator.uNsAfEtYpEcAsT o.base + , Generator.uNsAfEtYpEcAsT d.base + , Generator.uNsAfEtYpEcAsT maxDistance.base + ] + ) threshold : String diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 543a013c..84b28a22 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract4, ternary, ternary3, true, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -86,6 +86,10 @@ type alias Expression4 = } +type alias Expression33 = + { base : Expression Mat3 } + + type alias TypingFunction t r = String -> ( TypedName t r, Expression t -> r ) @@ -305,7 +309,7 @@ expressionToGlsl (Expression tree) = go2 rec e = case e of Call name args -> - name ++ "(" ++ String.join "," (List.map (go False) args) ++ ")" + name ++ "(" ++ String.join ", " (List.map (go False) args) ++ ")" Dot l r -> go2 False l ++ "." ++ r @@ -434,7 +438,7 @@ unwrapExpression { base } = ------------------------------ -add : ExpressionX a t -> ExpressionX a t -> Expression1 t +add : ExpressionX a t -> ExpressionX b t -> Expression1 t add = expr2 Add @@ -449,7 +453,7 @@ add4 = expr24 Add -subtract : ExpressionX a t -> ExpressionX a t -> Expression1 t +subtract : ExpressionX a t -> ExpressionX b t -> Expression1 t subtract = expr2 Subtract @@ -459,6 +463,11 @@ subtract2 = expr22 Subtract +subtract3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +subtract3 = + expr23 Subtract + + subtract4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 subtract4 = expr24 Subtract @@ -639,11 +648,26 @@ normalize = dotted1 << call1Internal "normalize" +normalize3 : ExpressionX a Vec3 -> Expression3 +normalize3 = + dotted3 << call1Internal "normalize" + + length : ExpressionX a t -> Expression1 Float length = dotted1 << call1Internal "length" +fwidth : ExpressionX a t -> Expression1 t +fwidth = + dotted1 << call1Internal "fwidth" + + +cross : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +cross l r = + dotted3 <| call2Internal "cross" l r + + atan2_ : ExpressionX a Float -> ExpressionX a Float -> Expression1 Float atan2_ l r = dotted1 <| call2Internal "atan" l r @@ -724,6 +748,11 @@ vec4_1_3 x yzw = |> dotted4 +mat3_3_3_3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> ExpressionX c Vec3 -> Expression33 +mat3_3_3_3 c0 c1 c2 = + call3Internal "mat3" c0 c1 c2 |> dotted33 + + --------------- -- CONSTANTS -- @@ -775,6 +804,15 @@ gl_FragCoord = ---------------- +uNsAfEtYpEcAsT : Expression t -> Expression a +uNsAfEtYpEcAsT (Expression i) = + let + _ = + Debug.todo + in + Expression i + + unsafeCall : String -> List (Expression t) -> Expression r unsafeCall name = Expression << Call name << List.map (\(Expression e) -> e) @@ -903,6 +941,16 @@ dotted4Internal e = } +dotted33 : Expression Mat3 -> Expression33 +dotted33 (Expression e) = + dotted33Internal e + + +dotted33Internal : Expr -> Expression33 +dotted33Internal e = + { base = Expression e } + + uniform : TypingFunction t c -> String -> c uniform typeF name = let From 6a52b87a5db9ec6160f76ac00d64130827531552 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 16:07:11 +0200 Subject: [PATCH 016/139] More codegen, less unknown --- src/elm/UI/Glsl/Code.elm | 126 +++++++++++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 7 +- 2 files changed, 76 insertions(+), 57 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index c4a30171..2030520a 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, e import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -626,6 +626,23 @@ ccos = Tuple.second ccosCouple +ctanCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ctanCouple = + fun1 vec2T "ctan" (vec2T "z") <| + \z -> + return <| ternary (eq z.y zero) (vec2 (tan_ z.x) zero) (cdiv (csin z) (ccos z)) + + +ctanDecl : FunDecl +ctanDecl = + Tuple.first ctanCouple + + +ctan : ExpressionX xa Vec2 -> Expression2 +ctan = + Tuple.second ctanCouple + + intervalOperationToGlsl : GlslOperation -> String intervalOperationToGlsl op = case op of @@ -704,20 +721,7 @@ straightFunctionToGlsl name = [ ccosDecl ] Tan22 -> - [ unknownFunDecl - { name = - "ctan" - , type_ = "TODO" - , body = """ - vec2 ctan(vec2 z) { - if(z.y == 0.0) { - return vec2(tan(z.x), 0); - } - return cdiv(csin(z), ccos(z)); - } - """ - } - ] + [ ctanDecl ] Asin22 -> [ unknownFunDecl @@ -842,11 +846,7 @@ straightFunctionToGlsl name = """ } ] Square22 -> - [ unknownFunDecl { name = "csquare", type_ = "TODO", body = """ - vec2 csquare(vec2 z) { - return cby(z, z); - } - """ } ] + [ csquareDecl ] Ln22 -> [ clnDecl ] @@ -977,21 +977,6 @@ cexp = Tuple.second cexpTuple -clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -clnTuple = - fun1 vec2T "cln" (vec2T "z") <| - \z -> - if_ - (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (log z.x) zero) - (def floatT "px" (length z) <| - \px -> - def floatT "py" (atan2_ z.y z.x) <| - \py -> - return <| vec2 (log px) py - ) - - creTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) creTuple = fun1 vec2T "cre" (vec2T "z") <| \z -> return <| vec2 z.x zero @@ -1007,6 +992,36 @@ cre = Tuple.second creTuple +csquareTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +csquareTuple = + fun1 vec2T "csquare" (vec2T "z") <| \z -> return <| cby z z + + +csquareDecl : FunDecl +csquareDecl = + Tuple.first csquareTuple + + +csquare : ExpressionX xa Vec2 -> Expression2 +csquare = + Tuple.second csquareTuple + + +clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +clnTuple = + fun1 vec2T "cln" (vec2T "z") <| + \z -> + if_ + (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (log z.x) zero) + (def floatT "px" (length z) <| + \px -> + def floatT "py" (atan2_ z.y z.x) <| + \py -> + return <| vec2 (log px) py + ) + + clnDecl : FunDecl clnDecl = Tuple.first clnTuple @@ -2314,27 +2329,26 @@ raytrace suffixes = vec3 f = vec3(0); vec3 n = vec3(0); """ ++ innerTrace ++ """ - if(found_index >= 0) { - float hue_based_on_index = (float(found_index))*radians(360.0 / 1.1); - - vec3 ld = normalize(vec3(-0.3, 0.0, 1.0)); - vec3 diffs = d[1] - d[0]; - mat3 light_direction = mat3(ld - 0.5 * diffs, ld + 0.5 * diffs, vec3(0)); - float light_distance = max_distance; - float light_coeff = 0.45; - vec3 offseted = found + 0.0001 * max_distance * normalize(o - found); - if(0 == 1) { } - """ ++ innerLightTrace ++ """ - - vec3 px = mix( - hl2rgb(hue_based_on_index, light_coeff), - hl2rgb(found.z * 0.5, light_coeff), - max(0.2, """ ++ colorCoeff ++ """) - ); - return vec4(px, 1.0); - } else { - return vec4(0.0, 0.0, 0.0, 1.0); - } + if(found_index < 0) + return vec4(0,0,0,1); + + float hue_based_on_index = (float(found_index))*radians(360.0 / 1.1); + + vec3 ld = normalize(vec3(-0.3, 0.0, 1.0)); + vec3 diffs = d[1] - d[0]; + mat3 light_direction = mat3(ld - 0.5 * diffs, ld + 0.5 * diffs, vec3(0)); + float light_distance = max_distance; + float light_coeff = 0.45; + vec3 offseted = found + 0.0001 * max_distance * normalize(o - found); + if(0 == 1) { } + """ ++ innerLightTrace ++ """ + + vec3 px = mix( + hl2rgb(hue_based_on_index, light_coeff), + hl2rgb(found.z * 0.5, light_coeff), + max(0.2, """ ++ colorCoeff ++ """) + ); + return vec4(px, 1.0); } """ in diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 84b28a22..e17c899f 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -573,6 +573,11 @@ cos_ = dotted1 << call1Internal "cos" +tan_ : ExpressionX a t -> Expression1 t +tan_ = + dotted1 << call1Internal "tan" + + sinh : ExpressionX a t -> Expression1 t sinh = dotted1 << call1Internal "sinh" From 5cc9d6b6d8bda5115f732319cf5b2e6352988f69 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 16:58:30 +0200 Subject: [PATCH 017/139] Moving unsafe code upwards and eliminating it where possible --- src/elm/Expression.elm | 1 + src/elm/UI/Glsl.elm | 41 ++++++++------- src/elm/UI/Glsl/Code.elm | 90 ++++++++++++++++++++----------- src/elm/UI/Glsl/Generator.elm | 99 ++++++++++++++++++++++++++++++++--- 4 files changed, 175 insertions(+), 56 deletions(-) diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index 0f4848c8..0125d4d3 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -24,6 +24,7 @@ module Expression exposing , getFreeVariables , partialSubstitute , pfullSubstitute + , relationToString , solutionTreeToString , toDebugTree , toPrintExpression diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 1e041e2f..657bcf8f 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -15,33 +15,45 @@ import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere +unsafeCallPixel name arg0 arg1 arg2 arg3 = + let + _ = + Debug.todo + in + dotted3 <| unsafeCall ("pixel" ++ name) [ arg0.base, arg1.base, arg2.base, arg3.base ] + + getGlsl : Bool -> Graph -> String getGlsl rayDifferentials graph = let { expr, srcExpr, interval, usesThetaDelta, pixel2D, pixel3D } = extract "" graph - build2d toSrc prefix e = + build2d toSrc e = + let + ( decl, call ) = + toSrc e + in { expr = e - , srcExpr = toSrc prefix e + , srcExpr = decl , interval = StraightOnly , usesThetaDelta = False - , pixel2D = [ { name = "pixel" ++ prefix, color = True } ] + , pixel2D = [ { call = call, color = True } ] , pixel3D = [] } extract prefix g = case g of Explicit2D c -> - build2d toSrcImplicit prefix <| + build2d (toSrcImplicit prefix) <| minus Expression.Utils.y c Implicit2D l r -> - build2d toSrcImplicit prefix <| + build2d (toSrcImplicit prefix) <| minus l r Polar2D e -> - build2d toSrcPolar prefix e + build2d (\q -> ( toSrcPolar prefix q, unsafeCallPixel prefix )) e Parametric2D x y -> let @@ -55,19 +67,19 @@ getGlsl rayDifferentials graph = , srcExpr = toSrcParametric prefix e , interval = IntervalOnly , usesThetaDelta = False - , pixel2D = [ { name = "pixel" ++ prefix, color = True } ] + , pixel2D = [ { call = unsafeCallPixel prefix, color = True } ] , pixel3D = [] } Relation2D e -> - build2d toSrcRelation prefix e + build2d (\q -> ( toSrcRelation prefix q, unsafeCallPixel prefix )) e Contour e -> { expr = e , srcExpr = toSrcContour prefix e , interval = StraightOnly , usesThetaDelta = True - , pixel2D = [ { name = "pixel" ++ prefix, color = False } ] + , pixel2D = [ { call = unsafeCallPixel prefix, color = False } ] , pixel3D = [] } @@ -110,7 +122,7 @@ getGlsl rayDifferentials graph = , srcExpr = toSrcVectorField2D prefix x y , interval = StraightOnly , usesThetaDelta = True - , pixel2D = [ { name = "pixel" ++ prefix, color = False } ] + , pixel2D = [ { call = unsafeCallPixel prefix, color = False } ] , pixel3D = [] } @@ -136,14 +148,7 @@ getGlsl rayDifferentials graph = ++ deindent 4 srcExpr ++ mainGlsl rayDifferentials - (List.map - (\p -> - { call = \arg0 arg1 arg2 arg3 -> dotted3 <| unsafeCall p.name [ arg0.base, arg1.base, arg2.base, arg3.base ] - , color = p.color - } - ) - pixel2D - ) + pixel2D pixel3D diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 2030520a..f587fbbb 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, e import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1386,39 +1386,65 @@ intervalFunctionToGlsl name = """TODO""" -toSrcImplicit : String -> Expression.Expression -> String +toSrcImplicit : + String + -> Expression.Expression + -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcImplicit suffix e = let antialiasingSamples = 7 - in - """ - float f""" ++ suffix ++ """(float x, float y) { - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; - if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { - return 0.0; - } - return complex.x > 0.0 ? 1.0 : -1.0; - } - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - float sum = 0.0; - float samples = """ ++ floatToGlsl antialiasingSamples ++ """ * 2.0 + 1.0; - samples *= samples; - float coeff = 0.0875; - for(int w = -""" ++ String.fromInt antialiasingSamples ++ """; w <= """ ++ String.fromInt antialiasingSamples ++ """; w++) - for(int h = -""" ++ String.fromInt antialiasingSamples ++ """; h <= """ ++ String.fromInt antialiasingSamples ++ """; h++) { - float piece = f""" ++ suffix ++ """(x + deltaX * coeff * float(w), y + deltaX * coeff * float(h)); - if(piece == 0.0) - return vec3(0); - sum += piece; - } - - float perc = (samples - abs(sum)) / samples; - perc = pow(perc, 0.2); - return perc * vec3(1,1,1); - } - """ + ( fDecl, f ) = + fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| + \x y -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \complex -> + return <| + ternary (gt (abs_ complex.y) (float epsilon)) + zero + (ternary (gt complex.x zero) one minusOne) + + ( pixelDecl, pixel ) = + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX _ x y -> + def floatT "sum" zero <| + \sum -> + def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| + \samples -> + assignBy samples samples <| + def floatT + "coeff" + (float 0.0875) + (\coeff -> + forLeq ( "w", -antialiasingSamples, antialiasingSamples ) + (\w -> + forLeq ( "h", -antialiasingSamples, antialiasingSamples ) + (\h -> + def floatT + "piece" + (f + (add x <| by (by deltaX coeff) <| floatCast w) + (add y <| by (by deltaX coeff) <| floatCast h) + ) + <| + \piece -> + if_ + (eq piece zero) + (return vec3Zero) + (assignAdd sum piece unsafeNop) + ) + unsafeNop + ) + (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| + \perc -> + assign perc + (pow perc <| float 0.2) + (return <| byF perc (vec3 one one one)) + ) + ) + in + ( fileToGlsl [ fDecl, pixelDecl ], pixel ) toSrcPolar : String -> Expression.Expression -> String @@ -2020,7 +2046,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor pixel2 nop + assign gl_FragColor pixel2 unsafeNop ] ( [], _ ) -> @@ -2033,7 +2059,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor pixel3 nop + assign gl_FragColor pixel3 unsafeNop ] _ -> @@ -2050,7 +2076,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor (max4 pixel2 pixel3) nop + assign gl_FragColor (max4 pixel2 pixel3) unsafeNop ] diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index e17c899f..4d81a08d 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, nop, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -15,6 +15,7 @@ type FunDecl type Stat = If Expr Stat Stat + | For String Int RelationOperation Int Stat Stat | Line String Stat | Return Expr | ExpressionStatement Expr Stat @@ -45,6 +46,14 @@ type Expr | Dot Expr String | Array Expr Expr | Assign Expr Expr + | AssignCombo ComboOperation Expr Expr + + +type ComboOperation + = ComboAdd + | ComboSubtract + | ComboBy + | ComboDiv type Expression t @@ -138,7 +147,7 @@ statementToGlsl (Statement r) = go i c = case c of If cond t f -> - [ indent i ("if(" ++ expressionToGlsl (Expression cond) ++ ") {") + [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") , go (i + 1) t , indent i "}" , "" @@ -146,6 +155,15 @@ statementToGlsl (Statement r) = ] |> String.join "\n" + For var from rel to loop next -> + [ indent i ("for (int " ++ var ++ " = " ++ String.fromInt from ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ String.fromInt to ++ "; " ++ var ++ "++) {") + , go (i + 1) loop + , indent i "}" + , "" + , go i next + ] + |> String.join "\n" + Line l next -> indent i l ++ ";\n" ++ go i next @@ -167,8 +185,27 @@ statementToGlsl (Statement r) = go 1 r -nop : Statement () -nop = +relationToString : RelationOperation -> String +relationToString rel = + case rel of + LessThan -> + "<" + + LessThanOrEquals -> + "<=" + + Equals -> + "==" + + GreaterThanOrEquals -> + ">=" + + GreaterThan -> + ">" + + +unsafeNop : Statement a +unsafeNop = Statement Nop @@ -195,6 +232,9 @@ expressionToGlsl (Expression tree) = Assign l r -> go15 False l ++ " = " ++ go15 False r + AssignCombo k l r -> + go15 False l ++ " " ++ comboOperationToString k ++ "= " ++ go15 False r + _ -> go15 rec e @@ -349,6 +389,22 @@ expressionToGlsl (Expression tree) = go False tree +comboOperationToString : ComboOperation -> String +comboOperationToString op = + case op of + ComboAdd -> + "+" + + ComboSubtract -> + "-" + + ComboBy -> + "*" + + ComboDiv -> + "/" + + indent : Int -> String -> String indent i line = String.repeat (4 * i) " " ++ line @@ -974,6 +1030,11 @@ unknown = Expression << Unknown +unknownStatement : String -> Statement t -> Statement t +unknownStatement line (Statement next) = + Statement <| Line line next + + -- STATEMENTS @@ -1115,6 +1176,16 @@ if_ cond (Statement ifTrue) (Statement ifFalse) = Statement <| If (unwrapExpression cond) ifTrue ifFalse +for : ( String, Int, Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r +for ( var, from, to ) loop (Statement next) = + Statement <| For var from LessThan to ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + + +forLeq : ( String, Int, Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r +forLeq ( var, from, to ) loop (Statement next) = + Statement <| For var from LessThanOrEquals to ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + + return : ExpressionX a r -> Statement r return e = Statement <| Return <| unwrapExpression e @@ -1149,6 +1220,16 @@ assign name e (Statement next) = Statement <| ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) next +assignAdd : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assignAdd name e (Statement next) = + Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) next + + +assignBy : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assignBy name e (Statement next) = + Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) next + + unknownFunDecl : { name : String, type_ : String, body : String } -> FunDecl unknownFunDecl = let @@ -1403,6 +1484,9 @@ innerValue ctx e = Assign _ _ -> Debug.todo "branch 'Assign _ _' not implemented" + AssignCombo _ _ _ -> + Debug.todo "branch 'AssignCombo _ _' not implemented" + innerValue2 : Context @@ -1468,6 +1552,9 @@ interpret ctx (Statement s) = Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval ) + Nop -> + Ok ( ctx, VVoid ) + Line _ _ -> Debug.todo "branch 'Line _' not implemented" @@ -1477,5 +1564,5 @@ interpret ctx (Statement s) = Decl _ _ _ _ -> Debug.todo "branch 'Decl _ _ _' not implemented" - Nop -> - Ok ( ctx, VVoid ) + For _ _ _ _ _ _ -> + Debug.todo "branch 'For _ _ _ _ _ _' not implemented" From c46b586bebd7008254f3e8c3e699db9bac5ef997 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 17:06:55 +0200 Subject: [PATCH 018/139] Even more codegen --- src/elm/UI/Glsl.elm | 7 ++-- src/elm/UI/Glsl/Code.elm | 61 +++++++++++++++++++++-------------- src/elm/UI/Glsl/Generator.elm | 14 ++++---- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 657bcf8f..ed3f3070 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -53,7 +53,7 @@ getGlsl rayDifferentials graph = minus l r Polar2D e -> - build2d (\q -> ( toSrcPolar prefix q, unsafeCallPixel prefix )) e + build2d (toSrcPolar prefix) e Parametric2D x y -> let @@ -146,10 +146,7 @@ getGlsl rayDifferentials graph = ++ reqs ++ "\n/* Expression */\n" ++ deindent 4 srcExpr - ++ mainGlsl - rayDifferentials - pixel2D - pixel3D + ++ mainGlsl rayDifferentials pixel2D pixel3D declarations : String diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index f587fbbb..94811ce3 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1447,10 +1447,16 @@ toSrcImplicit suffix e = ( fileToGlsl [ fDecl, pixelDecl ], pixel ) -toSrcPolar : String -> Expression.Expression -> String +toSrcPolar : + String + -> Expression.Expression + -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcPolar suffix e = - """ - float f""" ++ suffix ++ """(float x, float y, float deltaT, float ot) { + let + ( fDecl, f ) = + fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| + \x y deltaT ot -> + def floatT "r" (length <| vec2 x y) <| \r -> unknownStatement (""" float r = sqrt(x*x + y*y); float t = atanPlus(y, x) + deltaT; // Avoid the branch cut at {x > 0, y = 0} @@ -1463,29 +1469,34 @@ toSrcPolar suffix e = return -1.0; } return complex.x > 0.0 ? 1.0 : 0.0; - } + - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - float t = 0.0; - x += deltaX / 2.0; - y += deltaY / 2.0; - float ot = atanPlus(y, x); - - for(int i = 0; i < MAX_ITERATIONS / 10; i++) { - float h = f""" ++ suffix ++ """(x, y, t, ot); - float l = f""" ++ suffix ++ """(x - deltaX, y, t, ot); - float u = f""" ++ suffix ++ """(x, y - deltaY, t, ot); - float ul = f""" ++ suffix ++ """(x - deltaX, y - deltaY, t, ot); - if(h < 0.0 || l < 0.0 || u < 0.0 || ul < 0.0) - break; - if(h != l || h != u || h != ul) - return vec3(1,1,1); - t += radians(360.0); - ot += radians(360.0); - } - return vec3(0,0,0); - } - """ + """) + + ( pixelDecl, pixel ) = + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> unknownStatement (""" + float t = 0.0; + x += deltaX / 2.0; + y += deltaY / 2.0; + float ot = atanPlus(y, x); + + for(int i = 0; i < MAX_ITERATIONS / 10; i++) { + float h = f""" ++ suffix ++ """(x, y, t, ot); + float l = f""" ++ suffix ++ """(x - deltaX, y, t, ot); + float u = f""" ++ suffix ++ """(x, y - deltaY, t, ot); + float ul = f""" ++ suffix ++ """(x - deltaX, y - deltaY, t, ot); + if(h < 0.0 || l < 0.0 || u < 0.0 || ul < 0.0) + break; + if(h != l || h != u || h != ul) + return vec3(1,1,1); + t += radians(360.0); + ot += radians(360.0); + } + return vec3(0,0,0); + } + """) + in + ( fileToGlsl [ fDecl, pixelDecl ], pixel ) toSrcParametric : String -> Expression.Expression -> String diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 4d81a08d..e6701abd 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -16,7 +16,7 @@ type FunDecl type Stat = If Expr Stat Stat | For String Int RelationOperation Int Stat Stat - | Line String Stat + | Line String | Return Expr | ExpressionStatement Expr Stat | Decl String Name (Maybe Expr) Stat @@ -164,8 +164,8 @@ statementToGlsl (Statement r) = ] |> String.join "\n" - Line l next -> - indent i l ++ ";\n" ++ go i next + Line l -> + indent i l ++ ";" Return e -> indent i <| "return " ++ expressionToGlsl (Expression e) ++ ";" @@ -1030,9 +1030,9 @@ unknown = Expression << Unknown -unknownStatement : String -> Statement t -> Statement t -unknownStatement line (Statement next) = - Statement <| Line line next +unknownStatement : String -> Statement t +unknownStatement line = + Statement <| Line line @@ -1555,7 +1555,7 @@ interpret ctx (Statement s) = Nop -> Ok ( ctx, VVoid ) - Line _ _ -> + Line _ -> Debug.todo "branch 'Line _' not implemented" ExpressionStatement _ _ -> From e01d10a3afb338be72f057be1561e5e3ccb4533d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 17:19:44 +0200 Subject: [PATCH 019/139] More codegen --- src/elm/UI/Glsl/Code.elm | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 94811ce3..1280141e 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, e import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1456,22 +1456,23 @@ toSrcPolar suffix e = ( fDecl, f ) = fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| \x y deltaT ot -> - def floatT "r" (length <| vec2 x y) <| \r -> unknownStatement (""" - float r = sqrt(x*x + y*y); - float t = atanPlus(y, x) + deltaT; - // Avoid the branch cut at {x > 0, y = 0} - if(abs(t - ot) > radians(180.0)) { - if(t < ot) t += radians(360.0); - else t -= radians(360.0); - } - vec2 complex = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ), ( "r", dotted1 <| unknown "r" ), ( "t", dotted1 <| unknown "t" ) ] e).base ++ """; - if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { - return -1.0; - } - return complex.x > 0.0 ? 1.0 : 0.0; - - - """) + def floatT "r" (length <| vec2 x y) <| + \r -> + def floatT "t" (add (dotted1 <| unknown "atanPlus(y,x)") deltaT) <| + \t -> + -- Avoid the branch cut at {x > 0, y = 0} + if_ (gt (abs_ <| subtract t ot) (radians_ <| float 180)) + (assignAdd t (radians_ <| ternary (lt t ot) (float 360) (float -360)) unsafeNop) + (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| + \complex -> + return <| + ternary (gt (abs_ complex.y) (float epsilon)) + minusOne + (ternary (gt complex.x zero) + one + zero + ) + ) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> unknownStatement (""" @@ -1493,7 +1494,7 @@ toSrcPolar suffix e = ot += radians(360.0); } return vec3(0,0,0); - } + """) in ( fileToGlsl [ fDecl, pixelDecl ], pixel ) From 068f9977c891706778010cc5e3ba4b04b1dce60a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 28 Aug 2021 17:39:04 +0200 Subject: [PATCH 020/139] Constants --- src/elm/UI/Glsl/Code.elm | 37 +++++---- src/elm/UI/Glsl/Generator.elm | 138 ++++++++++++++++++---------------- 2 files changed, 95 insertions(+), 80 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 1280141e..7b2aaf32 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, e import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1417,9 +1417,9 @@ toSrcImplicit suffix e = "coeff" (float 0.0875) (\coeff -> - forLeq ( "w", -antialiasingSamples, antialiasingSamples ) + forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) (\w -> - forLeq ( "h", -antialiasingSamples, antialiasingSamples ) + forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) (\h -> def floatT "piece" @@ -1475,13 +1475,17 @@ toSrcPolar suffix e = ) ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> unknownStatement (""" - float t = 0.0; - x += deltaX / 2.0; - y += deltaY / 2.0; - float ot = atanPlus(y, x); - - for(int i = 0; i < MAX_ITERATIONS / 10; i++) { + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y -> + def floatT "t" zero <| + \t -> + assignAdd x (div deltaX <| float 2) <| + assignAdd y (div deltaY <| float 2) <| + def floatT "ot" (dotted1 <| unknown "atanPlus(y, x)") <| + \ot -> + for ( "i", int 0, divConst constants.maxIterations (int 10) ) + (\i -> + unknownStatement (""" float h = f""" ++ suffix ++ """(x, y, t, ot); float l = f""" ++ suffix ++ """(x - deltaX, y, t, ot); float u = f""" ++ suffix ++ """(x, y - deltaY, t, ot); @@ -1491,15 +1495,18 @@ toSrcPolar suffix e = if(h != l || h != u || h != ul) return vec3(1,1,1); t += radians(360.0); - ot += radians(360.0); - } - return vec3(0,0,0); - - """) + ot += radians(360.0);""") + ) + (return vec3Zero) in ( fileToGlsl [ fDecl, pixelDecl ], pixel ) +constants : { maxIterations : ExpressionX { isConstant : Constant } Int } +constants = + { maxIterations = constant intT "MAX_ITERATIONS" } + + toSrcParametric : String -> Expression.Expression -> String toSrcParametric suffix e = """ diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index e6701abd..57ab2b5f 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, cos_, cosh, cross, decl, def, div, div2, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -15,7 +15,7 @@ type FunDecl type Stat = If Expr Stat Stat - | For String Int RelationOperation Int Stat Stat + | For String Expr RelationOperation Expr Stat Stat | Line String | Return Expr | ExpressionStatement Expr Stat @@ -156,7 +156,7 @@ statementToGlsl (Statement r) = |> String.join "\n" For var from rel to loop next -> - [ indent i ("for (int " ++ var ++ " = " ++ String.fromInt from ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ String.fromInt to ++ "; " ++ var ++ "++) {") + [ indent i ("for (int " ++ var ++ " = " ++ expressionToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ expressionToGlsl (Expression to) ++ "; " ++ var ++ "++) {") , go (i + 1) loop , indent i "}" , "" @@ -539,17 +539,17 @@ negate2 e = dotted2Internal (Negate <| unwrapExpression e) -by : ExpressionX a t -> ExpressionX a t -> Expression1 t +by : ExpressionX a t -> ExpressionX b t -> Expression1 t by = expr2 By -by2 : ExpressionX a Vec2 -> ExpressionX a Vec2 -> Expression2 +by2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 by2 = expr22 By -by3 : ExpressionX a Vec3 -> ExpressionX a Vec3 -> Expression3 +by3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 by3 = expr23 By @@ -564,7 +564,7 @@ divF = expr2 Div -div : ExpressionX a t -> ExpressionX a t -> Expression1 t +div : ExpressionX a t -> ExpressionX b t -> Expression1 t div = expr2 Div @@ -574,27 +574,34 @@ div2 = expr22 Div -lt : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +divConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { b | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t +divConst l r = + { base = (expr2 Div l r).base + , isConstant = Constant + } + + +lt : ExpressionX a t -> ExpressionX b t -> Expression1 Bool lt = expr2 (Comparison LessThan) -leq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +leq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool leq = expr2 (Comparison LessThanOrEquals) -eq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +eq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool eq = expr2 (Comparison Equals) -geq : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +geq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool geq = expr2 (Comparison GreaterThanOrEquals) -gt : ExpressionX a t -> ExpressionX a t -> Expression1 Bool +gt : ExpressionX a t -> ExpressionX b t -> Expression1 Bool gt = expr2 (Comparison GreaterThan) @@ -649,37 +656,37 @@ log = dotted1 << call1Internal "log" -mod : ExpressionX a t -> ExpressionX a t -> Expression1 t +mod : ExpressionX a t -> ExpressionX b t -> Expression1 t mod l r = dotted1 (call2Internal "mod" l r) -min_ : ExpressionX a t -> ExpressionX a t -> Expression1 t +min_ : ExpressionX a t -> ExpressionX b t -> Expression1 t min_ l r = dotted1 (call2Internal "min" l r) -max_ : ExpressionX a t -> ExpressionX a t -> Expression1 t +max_ : ExpressionX a t -> ExpressionX b t -> Expression1 t max_ l r = dotted1 (call2Internal "max" l r) -max3 : ExpressionX a Vec3 -> ExpressionX a Vec3 -> Expression3 +max3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 max3 l r = dotted3 (call2Internal "max" l r) -max4 : ExpressionX a Vec4 -> ExpressionX a Vec4 -> Expression4 +max4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 max4 l r = dotted4 (call2Internal "max" l r) -hl2rgb : Expression1 Float -> Expression1 Float -> Expression3 +hl2rgb : ExpressionX a Float -> ExpressionX b Float -> Expression3 hl2rgb h l = dotted3 (call2Internal "hl2rgb" h l) -pow : Expression1 Float -> Expression1 Float -> Expression1 Float +pow : ExpressionX a Float -> ExpressionX b Float -> Expression1 Float pow l r = dotted1 (call2Internal "pow" l r) @@ -754,44 +761,44 @@ arr = expr2 Array -dot : ExpressionX a t -> ExpressionX a t -> Expression1 Float +dot : ExpressionX a t -> ExpressionX b t -> Expression1 Float dot l r = dotted1 (call2Internal "dot" l r) -vec2 : Expression1 Float -> Expression1 Float -> Expression2 +vec2 : ExpressionX a Float -> ExpressionX b Float -> Expression2 vec2 x y = { base = call2Internal "vec2" x y - , x = x - , y = y + , x = { base = x.base } + , y = { base = y.base } } vec3 : - Expression1 Float - -> Expression1 Float - -> Expression1 Float + ExpressionX a Float + -> ExpressionX b Float + -> ExpressionX c Float -> Expression3 vec3 x y z = { base = call3Internal "vec3" x y z - , x = x - , y = y - , z = z + , x = { base = x.base } + , y = { base = y.base } + , z = { base = z.base } } vec4 : - Expression1 Float - -> Expression1 Float - -> Expression1 Float - -> Expression1 Float + ExpressionX a Float + -> ExpressionX b Float + -> ExpressionX c Float + -> ExpressionX d Float -> Expression4 vec4 x y z w = { base = call4Internal "vec4" x y z w - , x = x - , y = y - , z = z - , w = w + , x = { base = x.base } + , y = { base = y.base } + , z = { base = z.base } + , w = { base = w.base } , xy = dotted2 <| call2Internal "vec2" x y , yzw = dotted3 <| call3Internal "vec3" y z w } @@ -822,31 +829,17 @@ mat3_3_3_3 c0 c1 c2 = vec2Zero : Expression2 vec2Zero = - { base = call2Internal "vec2" (int 0) (int 0) - , x = zero - , y = zero - } + vec2 zero zero vec3Zero : Expression3 vec3Zero = - { base = call3Internal "vec3" (int 0) (int 0) (int 0) - , x = zero - , y = zero - , z = zero - } + vec3 zero zero zero vec4Zero : Expression4 vec4Zero = - { base = call4Internal "vec4" (int 0) (int 0) (int 0) (int 0) - , x = zero - , y = zero - , z = zero - , w = zero - , xy = dotted2 <| call2Internal "vec2" zero zero - , yzw = dotted3 <| call3Internal "vec3" zero zero zero - } + vec4 zero zero zero zero gl_FragColor : Expression4 @@ -879,29 +872,44 @@ unsafeCall name = Expression << Call name << List.map (\(Expression e) -> e) -zero : Expression1 Float +type Constant + = Constant + + +zero : ExpressionX { isConstant : Constant } Float zero = float 0 -one : Expression1 Float +one : ExpressionX { isConstant : Constant } Float one = float 1 -minusOne : Expression1 Float +minusOne : ExpressionX { isConstant : Constant } Float minusOne = float -1 -float : Float -> Expression1 Float +float : Float -> ExpressionX { isConstant : Constant } Float float f = - dotted1Internal (Float f) + { base = Expression (Float f) + , isConstant = Constant + } -int : Int -> Expression1 Int +int : Int -> ExpressionX { isConstant : Constant } Int int i = - dotted1Internal (Int i) + { base = Expression <| Int i + , isConstant = Constant + } + + +constant : TypingFunction t r -> String -> ExpressionX { isConstant : Constant } t +constant _ name = + { base = Expression <| Variable name + , isConstant = Constant + } floatToGlsl : Float -> String @@ -1176,14 +1184,14 @@ if_ cond (Statement ifTrue) (Statement ifFalse) = Statement <| If (unwrapExpression cond) ifTrue ifFalse -for : ( String, Int, Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r +for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r for ( var, from, to ) loop (Statement next) = - Statement <| For var from LessThan to ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next -forLeq : ( String, Int, Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r +forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r forLeq ( var, from, to ) loop (Statement next) = - Statement <| For var from LessThanOrEquals to ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next return : ExpressionX a r -> Statement r From 11014e34b270bba7997306861a5c45274d68be61 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 01:41:03 +0200 Subject: [PATCH 021/139] Introduce PI as a constant --- src/elm/Expression.elm | 4 ++ src/elm/Expression/Simplify.elm | 14 +---- src/elm/Expression/Value.elm | 3 ++ src/elm/UI/Glsl.elm | 24 +++++++-- src/elm/UI/Glsl/Code.elm | 90 ++++++++++++++++++++++----------- src/elm/UI/Glsl/Generator.elm | 61 ++++++++++++++++++++-- src/shaders/declarations.frag | 4 -- 7 files changed, 146 insertions(+), 54 deletions(-) diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index 0125d4d3..5edb73c2 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -132,6 +132,7 @@ type RelationOperation = LessThan | LessThanOrEquals | Equals + | NotEquals | GreaterThanOrEquals | GreaterThan @@ -148,6 +149,9 @@ relationToString rop = Equals -> "=" + NotEquals -> + "≠" + GreaterThanOrEquals -> "⩾" diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index d7d84313..8f85fe14 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -1432,19 +1432,7 @@ polyDegree var expr = BinaryOperation Power _ _ -> Nothing - RelationOperation LessThan _ _ -> - Nothing - - RelationOperation LessThanOrEquals _ _ -> - Nothing - - RelationOperation Equals _ _ -> - Nothing - - RelationOperation GreaterThan _ _ -> - Nothing - - RelationOperation GreaterThanOrEquals _ _ -> + RelationOperation _ _ _ -> Nothing AssociativeOperation Addition l r o -> diff --git a/src/elm/Expression/Value.elm b/src/elm/Expression/Value.elm index ec1a92f7..348ed1ea 100644 --- a/src/elm/Expression/Value.elm +++ b/src/elm/Expression/Value.elm @@ -645,6 +645,9 @@ relationValue o ((Complex lv _) as lc) ((Complex rv _) as rc) = Equals -> Complex.minus lc rc + NotEquals -> + toComplex <| lc /= rc + GreaterThanOrEquals -> toComplex <| lv >= rv diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index ed3f3070..6c0497ac 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -7,14 +7,21 @@ import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, square) import Maybe.Extra as Maybe import SortedAnySet as Set -import UI.Glsl.Code exposing (constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (dotted3, unsafeCall) +import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (Expression3, ExpressionX, FunDecl, dotted3, unknownFunDecl, unsafeCall) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere +unsafeCallPixel : + String + -> ExpressionX a t + -> ExpressionX b t + -> ExpressionX c t + -> ExpressionX d t + -> Expression3 unsafeCallPixel name arg0 arg1 arg2 arg3 = let _ = @@ -149,9 +156,20 @@ getGlsl rayDifferentials graph = ++ mainGlsl rayDifferentials pixel2D pixel3D +piDecl : FunDecl +piDecl = + unknownFunDecl + { name = "PI" + , type_ = "float" + , body = + """#define PI """ ++ String.fromFloat pi ++ """ + #define TWOPI """ ++ String.fromFloat (pi * 2) + } + + declarations : String declarations = - [ gnumDecl, dupDecl ] + [ piDecl, atanPlusDecl, gnumDecl, dupDecl ] |> Generator.fileToGlsl diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 7b2aaf32..49ae0cbd 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ -module UI.Glsl.Code exposing (cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -28,7 +28,7 @@ constantToGlsl c = Pi -> fun0 vec2T "pi" <| - return (vec2 (radians_ <| float 180) zero) + return (vec2 constants.pi zero) E -> fun0 vec2T "e" <| @@ -56,6 +56,23 @@ cbyDecl = Tuple.first cbyTuple +atanPlusTuple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float ) +atanPlusTuple = + fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| + \x y -> + return <| mod (add constants.twopi (dotted1 <| unsafeCall "atan" [ y.base, x.base ])) constants.twopi + + +atanPlusDecl : FunDecl +atanPlusDecl = + Tuple.first atanPlusTuple + + +atanPlus : ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float +atanPlus = + Tuple.second atanPlusTuple + + gnumTuple : ( FunDecl, ExpressionX xa Float -> Expression4 ) gnumTuple = fun1 vec4T "gnum" (floatT "f") <| \f -> return <| vec4 f zero zero zero @@ -1070,14 +1087,14 @@ intervalFunctionToGlsl name = """ vec2 iarg(vec2 z) { if(z.y < 0.0) - return dup(radians(180.0)); + return dup(PI); if(z.x >= 0.0) return vec2(0); - return vec2(0.0, radians(180.0)); + return vec2(0.0, PI); } vec4 garg(vec4 z) { - return gnum(z.x >= 0.0 ? 0.0 : radians(180.0)); + return gnum(z.x >= 0.0 ? 0.0 : PI); } """ @@ -1259,10 +1276,10 @@ intervalFunctionToGlsl name = } vec2 isin(vec2 v) { - if(v.y - v.x > radians(360.0)) { + if(v.y - v.x > TWOPI) { return vec2(-1.0, 1.0); } - float from = mod(v.x, radians(360.0)); // [0, 360°] + float from = mod(v.x, TWOPI); // [0, 360°] float to = from + v.y - v.x; // [0, 720°] vec2 s = sin(vec2(from, to)); vec2 res = vec2(min(s.x, s.y), max(s.x, s.y)); @@ -1458,11 +1475,11 @@ toSrcPolar suffix e = \x y deltaT ot -> def floatT "r" (length <| vec2 x y) <| \r -> - def floatT "t" (add (dotted1 <| unknown "atanPlus(y,x)") deltaT) <| + def floatT "t" (add (atanPlus y x) deltaT) <| \t -> -- Avoid the branch cut at {x > 0, y = 0} - if_ (gt (abs_ <| subtract t ot) (radians_ <| float 180)) - (assignAdd t (radians_ <| ternary (lt t ot) (float 360) (float -360)) unsafeNop) + if_ (gt (abs_ <| subtract t ot) constants.pi) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) unsafeNop) (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> return <| @@ -1481,30 +1498,43 @@ toSrcPolar suffix e = \t -> assignAdd x (div deltaX <| float 2) <| assignAdd y (div deltaY <| float 2) <| - def floatT "ot" (dotted1 <| unknown "atanPlus(y, x)") <| + def floatT "ot" (atanPlus y x) <| \ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) (\i -> - unknownStatement (""" - float h = f""" ++ suffix ++ """(x, y, t, ot); - float l = f""" ++ suffix ++ """(x - deltaX, y, t, ot); - float u = f""" ++ suffix ++ """(x, y - deltaY, t, ot); - float ul = f""" ++ suffix ++ """(x - deltaX, y - deltaY, t, ot); - if(h < 0.0 || l < 0.0 || u < 0.0 || ul < 0.0) - break; - if(h != l || h != u || h != ul) - return vec3(1,1,1); - t += radians(360.0); - ot += radians(360.0);""") + def floatT "h" (f x y t ot) <| + \h -> + def floatT "l" (f (subtract x deltaX) y t ot) <| + \l -> + def floatT "u" (f x (subtract y deltaY) t ot) <| + \u -> + def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| + \ul -> + if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) + unsafeBreak + (if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + (assignAdd t constants.twopi <| + assignAdd ot constants.twopi <| + unsafeNop + ) + ) ) (return vec3Zero) in ( fileToGlsl [ fDecl, pixelDecl ], pixel ) -constants : { maxIterations : ExpressionX { isConstant : Constant } Int } +constants : + { maxIterations : ExpressionX { isConstant : Constant } Int + , pi : ExpressionX { isConstant : Constant } Float + , twopi : ExpressionX { isConstant : Constant } Float + } constants = - { maxIterations = constant intT "MAX_ITERATIONS" } + { maxIterations = constant intT "MAX_ITERATIONS" + , pi = constant floatT "PI" + , twopi = constant floatT "TWOPI" + } toSrcParametric : String -> Expression.Expression -> String @@ -1622,7 +1652,7 @@ toSrcVectorField2D suffix x y = bool near(vec2 o, vec2 corner, vec2 vector, float deltaX, float mx) { float angleCorner = arg(o - corner); float angleVector = arg(vector); - float delta = mod(angleCorner - angleVector, radians(360.0)); + float delta = mod(angleCorner - angleVector, TWOPI); float l = length(vector) / mx; float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); float wantedLength = length(o - corner); @@ -1688,7 +1718,7 @@ toSrcContour suffix e = vec3 pixel""" ++ suffix ++ """_o(float deltaX, float deltaY, float x, float y) { vec2 z = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; - float theta = atan(z.y, z.x) / radians(360.0); + float theta = atan(z.y, z.x) / TWOPI; float logRadius = log2(length(z)); float powerRemainder = fract(logRadius); @@ -1767,7 +1797,7 @@ expressionToGlsl context = vec2 zero one PVariable "pi" -> - vec2 (radians_ <| float 180) zero + vec2 constants.pi zero PVariable "e" -> vec2 (exp one) zero @@ -1865,7 +1895,7 @@ expressionToIntervalGlsl expr = in case expr of PVariable "pi" -> - dup <| radians_ (float 180) + dup constants.pi PVariable "e" -> dup <| exp one @@ -1966,7 +1996,7 @@ expressionToNormalGlsl { x, y, z } = go expr = case expr of PVariable "pi" -> - gnum (radians_ <| float 180) + gnum constants.pi PVariable "e" -> gnum <| exp one diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 57ab2b5f..82b9ce5d 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, normalize, normalize3, one, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeCall, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -18,6 +18,8 @@ type Stat | For String Expr RelationOperation Expr Stat Stat | Line String | Return Expr + | Break + | Continue | ExpressionStatement Expr Stat | Decl String Name (Maybe Expr) Stat | Nop @@ -170,6 +172,12 @@ statementToGlsl (Statement r) = Return e -> indent i <| "return " ++ expressionToGlsl (Expression e) ++ ";" + Break -> + indent i "break;" + + Continue -> + indent i "continue;" + ExpressionStatement e next -> indent i (expressionToGlsl (Expression e) ++ ";\n") ++ go i next @@ -197,6 +205,9 @@ relationToString rel = Equals -> "==" + NotEquals -> + "!=" + GreaterThanOrEquals -> ">=" @@ -287,6 +298,9 @@ expressionToGlsl (Expression tree) = Comparison Equals l r -> go7 False l ++ " == " ++ go7 False r + Comparison NotEquals l r -> + go7 False l ++ " != " ++ go7 False r + _ -> go7 rec e @@ -434,6 +448,16 @@ ands es = List.foldl (\e a -> expr2 And a e) h t +ors : List (Expression1 Bool) -> Expression1 Bool +ors es = + case es of + [] -> + false + + h :: t -> + List.foldl (\e a -> expr2 Or a e) h t + + true : Expression1 Bool true = dotted1 <| Expression <| Bool True @@ -596,6 +620,11 @@ eq = expr2 (Comparison Equals) +neq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +neq = + expr2 (Comparison NotEquals) + + geq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool geq = expr2 (Comparison GreaterThanOrEquals) @@ -1199,6 +1228,24 @@ return e = Statement <| Return <| unwrapExpression e +unsafeBreak : Statement a +unsafeBreak = + let + _ = + Debug.todo + in + Statement Break + + +unsafeContinue : Statement () +unsafeContinue = + let + _ = + Debug.todo + in + Statement Continue + + decl : TypingFunction tv v -> String -> (v -> Statement tr) -> Statement tr decl typeF name k = let @@ -1223,17 +1270,17 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks -assign : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assign : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q assign name e (Statement next) = Statement <| ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) next -assignAdd : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assignAdd : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q assignAdd name e (Statement next) = Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) next -assignBy : ExpressionX a t -> ExpressionX a t -> Statement q -> Statement q +assignBy : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q assignBy name e (Statement next) = Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) next @@ -1574,3 +1621,9 @@ interpret ctx (Statement s) = For _ _ _ _ _ _ -> Debug.todo "branch 'For _ _ _ _ _ _' not implemented" + + Break -> + Debug.todo "branch 'Break' not implemented" + + Continue -> + Debug.todo "branch 'Continue' not implemented" diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag index 83ac66ea..a3a3f08b 100644 --- a/src/shaders/declarations.frag +++ b/src/shaders/declarations.frag @@ -19,10 +19,6 @@ vec3 hl2rgb(float h, float l) return l + (rgb - 0.5) * (1.0 - abs(2.0 * l - 1.0)); } -float atanPlus(float y, float x) { - return mod(radians(360.0) + atan(y, x), radians(360.0)); -} - vec2 iexpand(vec2 v) { return v * (vec2(1.0, 1.0) + sign(v) * vec2(-0.000001, 0.000001)); } From d9c479742eb73fe8cec02b7adcecb5c8090fe1f5 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 01:44:09 +0200 Subject: [PATCH 022/139] Remove obsolete code --- src/elm/UI/Glsl/Code.elm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 49ae0cbd..3f47eb93 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1973,9 +1973,6 @@ expressionToIntervalGlsl expr = head :: tail -> dotted2 <| List.foldl (\e a -> unsafeCall ("i" ++ Expression.functionNameToString name) [ a, e.base ]) head.base tail - else if name == KnownFunction Sin || name == KnownFunction Cos then - unsafeApply ("i" ++ Expression.functionNameToString name) ex - else unsafeApply ("i" ++ Expression.functionNameToString name) ex From 9fb9331bb065291f9732933341ba384b25910142 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 13:37:49 +0200 Subject: [PATCH 023/139] Enough codegen for today --- src/elm/UI/Glsl.elm | 8 +++- src/elm/UI/Glsl/Code.elm | 70 ++++++++++++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 17 ++++++++- 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 6c0497ac..1de53e18 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -82,11 +82,15 @@ getGlsl rayDifferentials graph = build2d (\q -> ( toSrcRelation prefix q, unsafeCallPixel prefix )) e Contour e -> + let + ( src, pixel ) = + toSrcContour prefix e + in { expr = e - , srcExpr = toSrcContour prefix e + , srcExpr = src , interval = StraightOnly , usesThetaDelta = True - , pixel2D = [ { call = unsafeCallPixel prefix, color = False } ] + , pixel2D = [ { call = pixel, color = False } ] , pixel3D = [] } diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 3f47eb93..9dced980 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -16,6 +16,7 @@ type alias Uniforms = , u_zoomCenter : Expression2 , u_phi : Expression1 Float , u_theta : Expression1 Float + , u_completelyReal : Expression1 Float } @@ -1613,6 +1614,7 @@ uniforms = , u_zoomCenter = uniform vec2T "u_zoomCenter" , u_phi = uniform floatT "u_phi" , u_theta = uniform floatT "u_theta" + , u_completelyReal = uniform floatT "u_completelyReal" } @@ -1712,34 +1714,43 @@ toSrcVectorField2D suffix x y = """ -toSrcContour : String -> Expression.Expression -> String +toSrcContour : String -> Expression.Expression -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcContour suffix e = - """ - vec3 pixel""" ++ suffix ++ """_o(float deltaX, float deltaY, float x, float y) { - vec2 z = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] e).base ++ """; - - float theta = atan(z.y, z.x) / TWOPI; - - float logRadius = log2(length(z)); - float powerRemainder = fract(logRadius); - float squished = 0.7 - powerRemainder * 0.4; - - if(u_completelyReal > 0.0) { - float haf = fract(logRadius) / 6.0; - if(z.x > 0.0) - return hl2rgb(haf + 0.3, squished); - else - return hl2rgb(haf - 0.1, 1.0 - squished); - } - - float td = thetaDelta(theta); - float l = mix(1.0, squished, smoothstep(0.0, 1.0, td)); - return hl2rgb(theta, l); - } - - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - // Antialiasing + let + ( pixelODecl, pixelO ) = + fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \_ _ x y -> + def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \z -> + def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| + \theta -> + def floatT "logRadius" (log2 <| length z) <| + \logRadius -> + def floatT "powerRemainder" (fract logRadius) <| + \powerRemainder -> + def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| + \squished -> + if_ (gt uniforms.u_completelyReal zero) + (def floatT "haf" (div powerRemainder <| float 6.0) <| + \haf -> + return <| + ternary (gt z.x zero) + (hl2rgb (add haf <| float 0.3) squished) + (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + ) + (def floatT "td" (thetaDelta theta) <| + \td -> + def floatT "l" (mix one squished <| smoothstep zero one td) <| + \l -> + return <| hl2rgb theta l + ) + ( pixelDecl, pixel ) = + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y -> + -- Antialiasing + unknownStatement + (""" float dist = 1.0 / 3.0; vec3 a = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + dist * deltaX, y + dist * deltaY); vec3 b = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - dist * deltaX, y - dist * deltaY); @@ -1756,8 +1767,9 @@ toSrcContour suffix e = vec3 h = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x, y + 2.0 * dist * deltaY); return (a + b + c + d + e + f + g + h) / 8.0; - } - """ + """) + in + ( fileToGlsl [ pixelODecl, pixelDecl ], pixel ) toSrcRelation : String -> Expression.Expression -> String diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 82b9ce5d..50485579 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -650,6 +650,16 @@ abs4 = dotted4 << call1Internal "abs" +mix : ExpressionX a t -> ExpressionX b t -> ExpressionX c Float -> Expression1 t +mix x y a = + dotted1 <| call3Internal "mix" x y a + + +smoothstep : ExpressionX a Float -> ExpressionX b Float -> ExpressionX c Float -> Expression1 t +smoothstep x y a = + dotted1 <| call3Internal "smoothstep" x y a + + exp : ExpressionX a t -> Expression1 t exp = dotted1 << call1Internal "exp" @@ -720,6 +730,11 @@ pow l r = dotted1 (call2Internal "pow" l r) +log2 : ExpressionX a Float -> Expression1 Float +log2 = + dotted1 << call1Internal "log2" + + ceil_ : ExpressionX a Float -> Expression1 Float ceil_ = dotted1 << call1Internal "ceil" From 5b5384f605da08840d34e66ebe8a28b58aa74a95 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 17:12:08 +0200 Subject: [PATCH 024/139] Multiple definitions --- src/elm/UI/Glsl/Code.elm | 85 ++++++++++++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 76 ++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 38 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 9dced980..86511e09 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1624,11 +1624,12 @@ thetaDeltaCouple = \theta -> if_ (lt uniforms.u_whiteLines one) (return <| float 100) - (def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| - \thetaSix -> - def floatT "thetaNeigh" (float 0.05) <| - \thetaNeigh -> - return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh + (def2 + ( floatT, "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) + ( floatT, "thetaNeigh", float 0.05 ) + <| + \thetaSix thetaNeigh -> + return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh ) @@ -1722,42 +1723,52 @@ toSrcContour suffix e = \_ _ x y -> def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \z -> - def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| - \theta -> - def floatT "logRadius" (log2 <| length z) <| - \logRadius -> - def floatT "powerRemainder" (fract logRadius) <| - \powerRemainder -> - def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| - \squished -> - if_ (gt uniforms.u_completelyReal zero) - (def floatT "haf" (div powerRemainder <| float 6.0) <| - \haf -> - return <| - ternary (gt z.x zero) - (hl2rgb (add haf <| float 0.3) squished) - (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) - ) - (def floatT "td" (thetaDelta theta) <| - \td -> - def floatT "l" (mix one squished <| smoothstep zero one td) <| - \l -> - return <| hl2rgb theta l - ) + def2 + ( floatT, "theta", div (atan2_ z.y z.x) constants.twopi ) + ( floatT, "logRadius", log2 <| length z ) + <| + \theta logRadius -> + def floatT "powerRemainder" (fract logRadius) <| + \powerRemainder -> + def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| + \squished -> + if_ (gt uniforms.u_completelyReal zero) + (def floatT "haf" (div powerRemainder <| float 6.0) <| + \haf -> + return <| + ternary (gt z.x zero) + (hl2rgb (add haf <| float 0.3) squished) + (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + ) + (def floatT "td" (thetaDelta theta) <| + \td -> + def floatT "l" (mix one squished <| smoothstep zero one td) <| + \l -> + return <| hl2rgb theta l + ) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> -- Antialiasing - unknownStatement - (""" - float dist = 1.0 / 3.0; - vec3 a = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + dist * deltaX, y + dist * deltaY); - vec3 b = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - dist * deltaX, y - dist * deltaY); - vec3 c = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + dist * deltaX, y - dist * deltaY); - vec3 d = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - dist * deltaX, y + dist * deltaY); - - vec3 diff = abs(max(a, max(b, max(c, d))) - min(a, min(b, min(c, d)))); + def floatT "dist" (float <| 1 / 3) <| + \dist -> + def4 + ( vec3T, "a", pixelO deltaX deltaY (add x <| by dist deltaX) (add y <| by dist deltaY) ) + ( vec3T, "b", pixelO deltaX deltaY (subtract x <| by dist deltaX) (subtract y <| by dist deltaY) ) + ( vec3T, "c", pixelO deltaX deltaY (add x <| by dist deltaX) (subtract y <| by dist deltaY) ) + ( vec3T, "d", pixelO deltaX deltaY (subtract x <| by dist deltaX) (add y <| by dist deltaY) ) + <| + \a b c d -> + def2 + ( vec3T, "mn", min_ a <| min_ b <| min_ c d ) + ( vec3T, "mx", max_ a <| max_ b <| max_ c d ) + <| + \mn mx -> + def vec3T "diff" (abs_ (subtract mx mn)) <| + \diff -> + unknownStatement + (""" if (diff.x < dist && diff.y < dist && diff.z < dist) return (a + b + c + d) / 4.0; diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 50485579..d7caa5a3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1285,6 +1285,80 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks +def2 : ( TypingFunction tv v, String, ExpressionX xv tv ) -> ( TypingFunction tw w, String, ExpressionX xw tw ) -> (v -> w -> Statement tr) -> Statement tr +def2 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) k = + let + ( TypedName (Type t0) n0 e0, _ ) = + typeF0 name0 + + ( TypedName (Type t1) n1 e1, _ ) = + typeF1 name1 + + (Statement ks) = + k e0 e1 + in + Statement <| Decl t0 n0 (Just <| unwrapExpression v0) <| Decl t1 n1 (Just <| unwrapExpression v1) ks + + +def3 : + ( TypingFunction tv v, String, ExpressionX xv tv ) + -> ( TypingFunction tw w, String, ExpressionX xw tw ) + -> ( TypingFunction tx x, String, ExpressionX xx tx ) + -> (v -> w -> x -> Statement tr) + -> Statement tr +def3 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) ( typeF2, name2, v2 ) k = + let + ( TypedName (Type t0) n0 e0, _ ) = + typeF0 name0 + + ( TypedName (Type t1) n1 e1, _ ) = + typeF1 name1 + + ( TypedName (Type t2) n2 e2, _ ) = + typeF2 name2 + + (Statement ks) = + k e0 e1 e2 + in + Statement <| + Decl t0 n0 (Just <| unwrapExpression v0) <| + Decl t1 n1 (Just <| unwrapExpression v1) <| + Decl t2 n2 (Just <| unwrapExpression v2) <| + ks + + +def4 : + ( TypingFunction tv v, String, ExpressionX xv tv ) + -> ( TypingFunction tw w, String, ExpressionX xw tw ) + -> ( TypingFunction tx x, String, ExpressionX xx tx ) + -> ( TypingFunction ty y, String, ExpressionX xy ty ) + -> (v -> w -> x -> y -> Statement tr) + -> Statement tr +def4 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) ( typeF2, name2, v2 ) ( typeF3, name3, v3 ) k = + let + ( TypedName (Type t0) n0 e0, _ ) = + typeF0 name0 + + ( TypedName (Type t1) n1 e1, _ ) = + typeF1 name1 + + ( TypedName (Type t2) n2 e2, _ ) = + typeF2 name2 + + ( TypedName (Type t3) n3 e3, _ ) = + typeF3 name3 + + (Statement ks) = + k e0 e1 e2 e3 + in + Statement <| + Decl t0 n0 (Just <| unwrapExpression v0) <| + Decl t1 n1 (Just <| unwrapExpression v1) <| + Decl t2 n2 (Just <| unwrapExpression v2) <| + Decl t3 n3 (Just <| unwrapExpression v3) <| + ks + + assign : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q assign name e (Statement next) = Statement <| ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) next From babb193395fc417675436369695d64b15abad9c9 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 17:16:58 +0200 Subject: [PATCH 025/139] Using mulitple assignements to reduce indentation --- src/elm/UI/Glsl/Code.elm | 121 ++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 86511e09..d4ace2ec 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1426,41 +1426,42 @@ toSrcImplicit suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> - def floatT "sum" zero <| - \sum -> - def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| - \samples -> - assignBy samples samples <| - def floatT - "coeff" - (float 0.0875) - (\coeff -> - forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w -> - forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h -> - def floatT - "piece" - (f - (add x <| by (by deltaX coeff) <| floatCast w) - (add y <| by (by deltaX coeff) <| floatCast h) - ) - <| - \piece -> - if_ - (eq piece zero) - (return vec3Zero) - (assignAdd sum piece unsafeNop) + def2 + ( floatT, "sum", zero ) + ( floatT, "samples", float <| antialiasingSamples * 2 + 1 ) + <| + \sum samples -> + assignBy samples samples <| + def floatT + "coeff" + (float 0.0875) + (\coeff -> + forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) + (\w -> + forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) + (\h -> + def floatT + "piece" + (f + (add x <| by (by deltaX coeff) <| floatCast w) + (add y <| by (by deltaX coeff) <| floatCast h) ) - unsafeNop - ) - (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| - \perc -> - assign perc - (pow perc <| float 0.2) - (return <| byF perc (vec3 one one one)) + <| + \piece -> + if_ + (eq piece zero) + (return vec3Zero) + (assignAdd sum piece unsafeNop) ) + unsafeNop + ) + (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| + \perc -> + assign perc + (pow perc <| float 0.2) + (return <| byF perc (vec3 one one one)) ) + ) in ( fileToGlsl [ fDecl, pixelDecl ], pixel ) @@ -1495,33 +1496,33 @@ toSrcPolar suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - def floatT "t" zero <| - \t -> - assignAdd x (div deltaX <| float 2) <| - assignAdd y (div deltaY <| float 2) <| - def floatT "ot" (atanPlus y x) <| - \ot -> - for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\i -> - def floatT "h" (f x y t ot) <| - \h -> - def floatT "l" (f (subtract x deltaX) y t ot) <| - \l -> - def floatT "u" (f x (subtract y deltaY) t ot) <| - \u -> - def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| - \ul -> - if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - unsafeBreak - (if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - (assignAdd t constants.twopi <| - assignAdd ot constants.twopi <| - unsafeNop - ) - ) - ) - (return vec3Zero) + assignAdd x (div deltaX <| float 2) <| + assignAdd y (div deltaY <| float 2) <| + def2 + ( floatT, "t", zero ) + ( floatT, "ot", atanPlus y x ) + <| + \t ot -> + for ( "i", int 0, divConst constants.maxIterations (int 10) ) + (\i -> + def4 + ( floatT, "h", f x y t ot ) + ( floatT, "l", f (subtract x deltaX) y t ot ) + ( floatT, "u", f x (subtract y deltaY) t ot ) + ( floatT, "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) + <| + \h l u ul -> + if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) + unsafeBreak + (if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + (assignAdd t constants.twopi <| + assignAdd ot constants.twopi <| + unsafeNop + ) + ) + ) + (return vec3Zero) in ( fileToGlsl [ fDecl, pixelDecl ], pixel ) From 01a3b8b069fe6360230c4ac9061bc5b0a66b80e0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 29 Aug 2021 19:47:50 +0200 Subject: [PATCH 026/139] Now we can remove one stringy part --- src/elm/UI/Glsl.elm | 73 ++++----- src/elm/UI/Glsl/Code.elm | 320 ++++++++++++++++++++----------------- src/elm/UI/Glsl/Plane.elm | 38 +++-- src/elm/UI/Glsl/Sphere.elm | 41 ++--- 4 files changed, 256 insertions(+), 216 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 1de53e18..23427c6f 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,32 +8,17 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (Expression3, ExpressionX, FunDecl, dotted3, unknownFunDecl, unsafeCall) +import UI.Glsl.Generator as Generator exposing (FunDecl, unknownFunDecl) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere -unsafeCallPixel : - String - -> ExpressionX a t - -> ExpressionX b t - -> ExpressionX c t - -> ExpressionX d t - -> Expression3 -unsafeCallPixel name arg0 arg1 arg2 arg3 = - let - _ = - Debug.todo - in - dotted3 <| unsafeCall ("pixel" ++ name) [ arg0.base, arg1.base, arg2.base, arg3.base ] - - getGlsl : Bool -> Graph -> String getGlsl rayDifferentials graph = let - { expr, srcExpr, interval, usesThetaDelta, pixel2D, pixel3D } = + { expr, funDecls, interval, usesThetaDelta, pixel2D, pixel3D } = extract "" graph build2d toSrc e = @@ -42,7 +27,7 @@ getGlsl rayDifferentials graph = toSrc e in { expr = e - , srcExpr = decl + , funDecls = decl , interval = StraightOnly , usesThetaDelta = False , pixel2D = [ { call = call, color = True } ] @@ -64,6 +49,9 @@ getGlsl rayDifferentials graph = Parametric2D x y -> let + ( src, call ) = + toSrcParametric prefix e + e = plus [ square (minus (Variable "x") x) @@ -71,15 +59,15 @@ getGlsl rayDifferentials graph = ] in { expr = e - , srcExpr = toSrcParametric prefix e + , funDecls = src , interval = IntervalOnly , usesThetaDelta = False - , pixel2D = [ { call = unsafeCallPixel prefix, color = True } ] + , pixel2D = [ { call = call, color = True } ] , pixel3D = [] } Relation2D e -> - build2d (\q -> ( toSrcRelation prefix q, unsafeCallPixel prefix )) e + build2d (toSrcRelation prefix) e Contour e -> let @@ -87,7 +75,7 @@ getGlsl rayDifferentials graph = toSrcContour prefix e in { expr = e - , srcExpr = src + , funDecls = src , interval = StraightOnly , usesThetaDelta = True , pixel2D = [ { call = pixel, color = False } ] @@ -100,7 +88,7 @@ getGlsl rayDifferentials graph = get3DSource prefix e in { expr = f.expr - , srcExpr = f.srcExpr + , funDecls = f.funDecls , interval = IntervalAndStraight , usesThetaDelta = True , pixel2D = [] @@ -116,7 +104,7 @@ getGlsl rayDifferentials graph = List.indexedMap (extract << prefix_) children in { expr = List <| List.map .expr extracted - , srcExpr = String.join "\n" (List.map .srcExpr extracted) + , funDecls = List.concatMap .funDecls extracted , interval = if List.any (\c -> c.interval /= StraightOnly) extracted then IntervalAndStraight @@ -129,11 +117,15 @@ getGlsl rayDifferentials graph = } VectorField2D x y -> + let + ( src, pixel ) = + toSrcVectorField2D prefix x y + in { expr = Apply (KnownFunction Arg) [ x, y ] - , srcExpr = toSrcVectorField2D prefix x y + , funDecls = src , interval = StraightOnly , usesThetaDelta = True - , pixel2D = [ { call = unsafeCallPixel prefix, color = False } ] + , pixel2D = [ { call = pixel, color = False } ] , pixel3D = [] } @@ -145,6 +137,11 @@ getGlsl rayDifferentials graph = "" reqs = + let + _ = + -- Can remove in the future + Debug.todo + in expr |> expressionToRequirements |> transitiveClosure @@ -156,7 +153,7 @@ getGlsl rayDifferentials graph = ++ thetaDeltaCode ++ reqs ++ "\n/* Expression */\n" - ++ deindent 4 srcExpr + ++ deindent 4 (Generator.fileToGlsl funDecls) ++ mainGlsl rayDifferentials pixel2D pixel3D @@ -177,19 +174,19 @@ declarations = |> Generator.fileToGlsl -get3DSource : String -> Expression -> { expr : Expression, srcExpr : String } +get3DSource : String -> Expression -> { expr : Expression, funDecls : List FunDecl } get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of Just glsl -> { expr = e - , srcExpr = glsl + , funDecls = [ glsl ] } Nothing -> case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of Just glsl -> { expr = e - , srcExpr = glsl + , funDecls = [ glsl ] } Nothing -> @@ -201,14 +198,13 @@ get3DSource prefix e = let glsl = toSrc3D prefix e - |> Generator.fileToGlsl in { expr = e - , srcExpr = glsl ++ UI.Glsl.Code.suffixToBisect prefix + , funDecls = glsl ++ [ UI.Glsl.Code.suffixToBisect prefix ] } -tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, srcExpr : String } +tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, funDecls : List FunDecl } tryGlslFromPolynomial prefix e = let t = @@ -283,8 +279,12 @@ tryGlslFromPolynomial prefix e = |> List.reverse |> String.join "\n " - srcExpr = - """ + funDecl = + unknownFunDecl + { name = "bisect" ++ prefix + , type_ = "TODO" + , body = + """ bool bisect""" ++ prefix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { float t = max_distance * 2.0; """ ++ checks ++ """ @@ -292,9 +292,10 @@ tryGlslFromPolynomial prefix e = return t < max_distance && t > 0.0; } """ + } in { expr = div one <| sqrt_ <| cbrt <| ipow e 3 - , srcExpr = deindent 16 srcExpr + , funDecls = [ funDecl ] } in UI.Glsl.Polynomial.getSolutions poly |> Maybe.map (\( _, sols ) -> fromSols sols) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index d4ace2ec..5bfb668c 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1407,7 +1407,7 @@ intervalFunctionToGlsl name = toSrcImplicit : String -> Expression.Expression - -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) + -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcImplicit suffix e = let antialiasingSamples = @@ -1463,13 +1463,13 @@ toSrcImplicit suffix e = ) ) in - ( fileToGlsl [ fDecl, pixelDecl ], pixel ) + ( [ fDecl, pixelDecl ], pixel ) toSrcPolar : String -> Expression.Expression - -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) + -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcPolar suffix e = let ( fDecl, f ) = @@ -1524,7 +1524,7 @@ toSrcPolar suffix e = ) (return vec3Zero) in - ( fileToGlsl [ fDecl, pixelDecl ], pixel ) + ( [ fDecl, pixelDecl ], pixel ) constants : @@ -1539,69 +1539,78 @@ constants = } -toSrcParametric : String -> Expression.Expression -> String +toSrcParametric : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcParametric suffix e = - """ - vec2 interval""" ++ suffix ++ """(vec2 p, float from, float to) { - vec2 x = vec2(p.x,p.x); - vec2 y = vec2(p.y,p.y); - vec2 t = from < to ? vec2(from, to) : vec2(to, from); - return """ ++ Generator.expressionToGlsl (expressionToIntervalGlsl (toPrintExpression e)).base ++ """; - } + let + ( intervalDecl, interval ) = + fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| + \p from to -> + def3 + ( vec2T, "x", vec2 p.x p.x ) + ( vec2T, "y", vec2 p.y p.y ) + ( vec2T, "t", ternary (lt from to) (vec2 from to) (vec2 to from) ) + <| + \x y t -> + return <| expressionToIntervalGlsl (toPrintExpression e) - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - float max_distance = pow(2.0, 10.0); - float from = -max_distance / 2.0; - float to = max_distance / 2.0; - vec2 p = vec2(x, y); - int depth = 0; - int choices = 0; - float ithreshold = 10.0 * deltaX * deltaX; - for(int it = 0; it < MAX_ITERATIONS; it++) { - float midpoint = mix(from, to, 0.5); - vec2 front = interval""" ++ suffix ++ """(p, from, midpoint); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(depth >= MAX_DEPTH - || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) - || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) - ) - return vec3(1,1,1); - if(front.x <= 0.0 && front.y >= 0.0) { - to = midpoint; - depth++; - choices *= 2; - } else if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - } else { - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - } - } - return vec3(0,0,0); - } - """ + ( pixelDecl, pixel ) = + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y -> + unknownStatement + (""" + float max_distance = pow(2.0, 10.0); + float from = -max_distance / 2.0; + float to = max_distance / 2.0; + vec2 p = vec2(x, y); + int depth = 0; + int choices = 0; + float ithreshold = 10.0 * deltaX * deltaX; + for(int it = 0; it < MAX_ITERATIONS; it++) { + float midpoint = mix(from, to, 0.5); + vec2 front = interval""" ++ suffix ++ """(p, from, midpoint); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(depth >= MAX_DEPTH + || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) + || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) + ) + return vec3(1,1,1); + if(front.x <= 0.0 && front.y >= 0.0) { + to = midpoint; + depth++; + choices *= 2; + } else if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + } else { + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return vec3(0,0,0); + } + } + return vec3(0,0,0); + """) + in + ( [ intervalDecl, pixelDecl ], pixel ) uniforms : Uniforms @@ -1644,79 +1653,97 @@ thetaDelta = Tuple.second thetaDeltaCouple -toSrcVectorField2D : String -> Expression.Expression -> Expression.Expression -> String -toSrcVectorField2D suffix x y = - """ - vec2 vector""" ++ suffix ++ """(float x, float y) { - vec2 xv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] x).base ++ """; - vec2 yv = """ ++ Generator.expressionToGlsl (expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] y).base ++ """; - return abs(xv.y) + abs(yv.y) < """ ++ floatToGlsl epsilon ++ """ ? vec2(xv.x, yv.x) : vec2(0,0); - } - - bool near(vec2 o, vec2 corner, vec2 vector, float deltaX, float mx) { - float angleCorner = arg(o - corner); - float angleVector = arg(vector); - float delta = mod(angleCorner - angleVector, TWOPI); - float l = length(vector) / mx; - float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); - float wantedLength = length(o - corner); - float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); - return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; - } +toSrcVectorField2D : + String + -> Expression.Expression + -> Expression.Expression + -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) +toSrcVectorField2D suffix xexpr yexpr = + let + ( vectorDecl, vector ) = + fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| + \x y -> + def2 + ( vec2T, "xv", expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] xexpr ) + ( vec2T, "yv", expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] yexpr ) + <| + \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero - vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { - vec2 o = vec2(x, y); + nearDecl = + unknownFunDecl + { name = "near" + , type_ = "TODO" + , body = """ + bool near(vec2 o, vec2 corner, vec2 vector, float deltaX, float mx) { + float angleCorner = arg(o - corner); + float angleVector = arg(vector); + float delta = mod(angleCorner - angleVector, TWOPI); + float l = length(vector) / mx; + float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); + float wantedLength = length(o - corner); + float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); + return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; + }""" + } - float mx = 0.0; - for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { - for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { - vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); - vec2 v = vector""" ++ suffix ++ """(p.x, p.y); - mx = max(mx, length(v)); - } - } + ( pixelDecl, pixel ) = + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y -> + unknownStatement (""" + vec2 o = vec2(x, y); + + float mx = 0.0; + for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { + for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { + vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); + vec2 v = vector""" ++ suffix ++ """(p.x, p.y); + mx = max(mx, length(v)); + } + } - vec3 colorA = vec3(0.0, 1.0, 0.0); - vec3 colorB = vec3(0.0, 0.0, 1.0); + vec3 colorA = vec3(0.0, 1.0, 0.0); + vec3 colorB = vec3(0.0, 0.0, 1.0); - x = o.x - mod(o.x, deltaX * VECTOR_SPACING); - y = o.y - mod(o.y, deltaX * VECTOR_SPACING); + x = o.x - mod(o.x, deltaX * VECTOR_SPACING); + y = o.y - mod(o.y, deltaX * VECTOR_SPACING); - vec2 bl = vector""" ++ suffix ++ """(x, y); - vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); - vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); - vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + vec2 bl = vector""" ++ suffix ++ """(x, y); + vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); + vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); + vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - float angleO; - vec2 corner; - float l; + float angleO; + vec2 corner; + float l; - corner = vec2(x, y); - l = length(bl) / mx; - if(near(o, corner, bl, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x, y); + l = length(bl) / mx; + if(near(o, corner, bl, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x + deltaX * VECTOR_SPACING, y); - l = length(br) / mx; - if(near(o, corner, br, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x + deltaX * VECTOR_SPACING, y); + l = length(br) / mx; + if(near(o, corner, br, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x, y + deltaX * VECTOR_SPACING); - l = length(ul) / mx; - if(near(o, corner, ul, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x, y + deltaX * VECTOR_SPACING); + l = length(ul) / mx; + if(near(o, corner, ul, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - l = length(ur) / mx; - if(near(o, corner, ur, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + l = length(ur) / mx; + if(near(o, corner, ur, deltaX, mx)) + return mix(colorA, colorB, l); - return vec3(0,0,0); - } - """ + return vec3(0,0,0); + + """) + in + ( [ vectorDecl, nearDecl, pixelDecl ], pixel ) -toSrcContour : String -> Expression.Expression -> ( String, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) +toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcContour suffix e = let ( pixelODecl, pixelO ) = @@ -1781,27 +1808,25 @@ toSrcContour suffix e = return (a + b + c + d + e + f + g + h) / 8.0; """) in - ( fileToGlsl [ pixelODecl, pixelDecl ], pixel ) + ( [ pixelODecl, pixelDecl ], pixel ) -toSrcRelation : String -> Expression.Expression -> String +toSrcRelation : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcRelation suffix e = - fileToGlsl - [ Tuple.first <| - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \_ _ x y -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| - \complex -> - return <| - ternary - (ands - [ gt complex.x zero - , lt (abs_ complex.y) (float epsilon) - ] - ) - (vec3 (float 0.8) (float 0.5) (float 0.5)) - vec3Zero - ] + Tuple.mapFirst (\d -> [ d ]) <| + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \_ _ x y -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \complex -> + return <| + ternary + (ands + [ gt complex.x zero + , lt (abs_ complex.y) (float epsilon) + ] + ) + (vec3 (float 0.8) (float 0.5) (float 0.5)) + vec3Zero epsilon : Float @@ -2464,9 +2489,13 @@ threshold = "0.000001 * max_distance" -suffixToBisect : String -> String +suffixToBisect : String -> FunDecl suffixToBisect suffix = - """ + unknownFunDecl + { name = "bisect" ++ suffix + , type_ = "TODO" + , body = + """ bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { mat3 from = mat3(o, o, vec3(0)); mat3 to = from + max_distance * d; @@ -2520,6 +2549,7 @@ suffixToBisect suffix = return false; } """ + } deindent : Int -> String -> String diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 6ff84e02..0b6377a7 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -4,7 +4,7 @@ import Dict import Expression exposing (Expression) import Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (floatToGlsl) +import UI.Glsl.Generator exposing (FunDecl, floatToGlsl, unknownFunDecl) import UI.Glsl.Polynomial as Polynomial @@ -35,20 +35,24 @@ asPlane e = ) -toGlsl : String -> Plane -> String +toGlsl : String -> Plane -> FunDecl toGlsl suffix (Plane { x, y, z, known }) = - -- a x + b y + c z + k = 0 - -- x = ox + t dx - -- y = oy + t dy - -- z = oz + t dz - -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 - -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) - -- t = - (k + dot abc o) / (dot abc d) - """ - bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { - vec3 coeffs = vec3(""" ++ floatToGlsl x ++ "," ++ floatToGlsl y ++ "," ++ floatToGlsl z ++ """); - float t = -(""" ++ floatToGlsl known ++ """ + dot(coeffs, o)) / dot(coeffs, 0.5 * (d[0] + d[1])); - found = o + t * 0.5 * (d[0] + d[1]); - return t > """ ++ threshold ++ """; - } - """ + unknownFunDecl + { name = "bisect" ++ suffix + , type_ = "TODO" + , body = + -- a x + b y + c z + k = 0 + -- x = ox + t dx + -- y = oy + t dy + -- z = oz + t dz + -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 + -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) + -- t = - (k + dot abc o) / (dot abc d) + """bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + vec3 coeffs = vec3(""" ++ floatToGlsl x ++ "," ++ floatToGlsl y ++ "," ++ floatToGlsl z ++ """); + float t = -(""" ++ floatToGlsl known ++ """ + dot(coeffs, o)) / dot(coeffs, 0.5 * (d[0] + d[1])); + found = o + t * 0.5 * (d[0] + d[1]); + return t > """ ++ threshold ++ """; + } + """ + } diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index fed0094e..520370c9 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -4,7 +4,7 @@ import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (floatToGlsl) +import UI.Glsl.Generator exposing (FunDecl, floatToGlsl, unknownFunDecl) import UI.Glsl.Polynomial as Polynomial @@ -73,22 +73,27 @@ reduce poly = ) -toGlsl : String -> Sphere -> String +toGlsl : String -> Sphere -> FunDecl toGlsl suffix (Sphere { center, radius }) = - """ - bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { - vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); + unknownFunDecl + { name = "bisect" ++ suffix + , type_ = "TODO" + , body = + """ + bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); - vec3 to_center = o - center; - float b = dot(to_center, mix(d[0], d[1], 0.5)); - float c = dot(to_center, to_center) - """ ++ floatToGlsl (radius * radius) ++ """; - float delta = b*b - c; - if(delta < 0.) - return false; - float x = -b - sqrt(delta); - if(x < """ ++ threshold ++ """) - return false; - found = o + x * mix(d[0], d[1], 0.5); - return true; - } - """ + vec3 to_center = o - center; + float b = dot(to_center, mix(d[0], d[1], 0.5)); + float c = dot(to_center, to_center) - """ ++ floatToGlsl (radius * radius) ++ """; + float delta = b*b - c; + if(delta < 0.) + return false; + float x = -b - sqrt(delta); + if(x < """ ++ threshold ++ """) + return false; + found = o + x * mix(d[0], d[1], 0.5); + return true; + } + """ + } From 08ee694e2f380112e28414e0e3dcebec53da62cc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 00:22:39 +0200 Subject: [PATCH 027/139] More codegen --- src/elm/UI/Glsl.elm | 18 +++---- src/elm/UI/Glsl/Code.elm | 109 +++++++++++++++++++++++++++++---------- 2 files changed, 91 insertions(+), 36 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 23427c6f..28615cfe 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, unknownFunDecl) +import UI.Glsl.Generator as Generator exposing (FunDecl, fileToGlsl, unknownFunDecl) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -369,10 +369,11 @@ requirementToGlsl i r = RequireConstant c -> constantToGlsl c |> Tuple.first - |> Generator.funDeclToGlsl + |> (\l -> [ l ]) + |> fileToGlsl RequireOperation o -> - operationToGlsl i o + operationToGlsl i o |> fileToGlsl expressionToRequirements : Expression -> List Requirement @@ -693,19 +694,18 @@ dependenciesOf req = [] -operationToGlsl : RequiresInterval -> GlslOperation -> String +operationToGlsl : RequiresInterval -> GlslOperation -> List FunDecl operationToGlsl interval op = case interval of StraightOnly -> - Generator.fileToGlsl <| straightOperationToGlsl op + straightOperationToGlsl op IntervalOnly -> - deindent 12 <| intervalOperationToGlsl op + intervalOperationToGlsl op IntervalAndStraight -> - (Generator.fileToGlsl <| straightOperationToGlsl op) - ++ "\n" - ++ deindent 12 (intervalOperationToGlsl op) + straightOperationToGlsl op + ++ intervalOperationToGlsl op functionToGlsl : RequiresInterval -> GlslFunction -> String diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 5bfb668c..3bcc06eb 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -532,6 +532,81 @@ gpow = Tuple.second gpowCouple +iltCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +iltCouple = + fun2 vec2T "ilt" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + + +iltDecl : FunDecl +iltDecl = + Tuple.first iltCouple + + +ilt : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +ilt = + Tuple.second iltCouple + + +ileqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +ileqCouple = + fun2 vec2T "ileq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + + +ileqDecl : FunDecl +ileqDecl = + Tuple.first ileqCouple + + +ileq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +ileq = + Tuple.second ileqCouple + + +ieqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +ieqCouple = + fun2 vec2T "ieq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + + +ieqDecl : FunDecl +ieqDecl = + Tuple.first ieqCouple + + +ieq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +ieq = + Tuple.second ieqCouple + + +igeqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +igeqCouple = + fun2 vec2T "igeq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + + +igeqDecl : FunDecl +igeqDecl = + Tuple.first igeqCouple + + +igeq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +igeq = + Tuple.second igeqCouple + + +igtCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +igtCouple = + fun2 vec2T "igt" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + + +igtDecl : FunDecl +igtDecl = + Tuple.first igtCouple + + +igt : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +igt = + Tuple.second igtCouple + + iexpCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iexpCouple = fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| vec2 (exp z.x) (exp z.y) @@ -661,46 +736,26 @@ ctan = Tuple.second ctanCouple -intervalOperationToGlsl : GlslOperation -> String +intervalOperationToGlsl : GlslOperation -> List FunDecl intervalOperationToGlsl op = case op of GlslAddition -> - "" + [] GlslNegation -> - fileToGlsl [ inegDecl, gnegDecl ] + [ inegDecl, gnegDecl ] GlslMultiplication -> - fileToGlsl [ ibyDecl, gbyDecl ] + [ ibyDecl, gbyDecl ] GlslDivision -> - fileToGlsl [ iinverseDecl, idivDecl, gdivDecl ] + [ iinverseDecl, idivDecl, gdivDecl ] GlslPower -> - fileToGlsl [ ipowFIDecl, ipowIDecl, ipowDecl, gpowIDecl, gpowDecl ] + [ ipowFIDecl, ipowIDecl, ipowDecl, gpowIDecl, gpowDecl ] GlslRelations -> - """ - vec2 ilt(vec2 l, vec2 r) { - return vec2(r.x - l.y, r.y - l.x); - } - - vec2 ileq(vec2 l, vec2 r) { - return vec2(r.x - l.y, r.y - l.x); - } - - vec2 ieq(vec2 l, vec2 r) { - return vec2(l.x - r.y, l.y - r.x); - } - - vec2 igeq(vec2 l, vec2 r) { - return vec2(l.x - r.y, l.y - r.x); - } - - vec2 igt(vec2 l, vec2 r) { - return vec2(l.x - r.y, l.y - r.x); - } - """ + [ iltDecl, ileqDecl, ieqDecl, igeqDecl, igtDecl ] straightFunctionToGlsl : GlslFunction -> List FunDecl From 0dc58c0dbce64ab5584f275c6cdbf2860953cf88 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 01:04:38 +0200 Subject: [PATCH 028/139] Cleanup --- src/elm/Expression.elm | 8 +- src/elm/UI/Glsl/Code.elm | 180 ++++++++++++++++++++++------------ src/elm/UI/Glsl/Generator.elm | 37 ++++++- 3 files changed, 160 insertions(+), 65 deletions(-) diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index 5edb73c2..23aa9684 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -434,7 +434,7 @@ type PrintExpression | PNegate PrintExpression | PBy PrintExpression PrintExpression | PDiv PrintExpression PrintExpression - | PRel String PrintExpression PrintExpression + | PRel RelationOperation PrintExpression PrintExpression | PPower PrintExpression PrintExpression | PReplace (Dict String (Maybe PrintExpression)) PrintExpression | PList (List PrintExpression) @@ -466,7 +466,7 @@ toPrintExpression e = PDiv (toPrintExpression l) (toPrintExpression r) RelationOperation op l r -> - PRel (relationToString op) (toPrintExpression l) (toPrintExpression r) + PRel op (toPrintExpression l) (toPrintExpression r) AssociativeOperation Addition l r o -> List.foldl (\el a -> PAdd a el) @@ -568,7 +568,7 @@ toStringPrec p e = infixl_ 6 " + " l r PRel rel l r -> - infixl_ 5 (" " ++ rel ++ " ") l r + infixl_ 5 (" " ++ relationToString rel ++ " ") l r PBy ((PInteger _) as l) r -> case r of @@ -1403,7 +1403,7 @@ toTeXStringPrec p e = infixl_ 6 " + " l r PRel rel l r -> - infixl_ 5 (" " ++ rel ++ " ") l r + infixl_ 5 (" " ++ relationToString rel ++ " ") l r PLambda x ((PApply fn [ PVariable v ]) as f) -> if v == x then diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 3bcc06eb..30a5afa4 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict -import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted4, eq, exp, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -562,6 +562,21 @@ ileq = Tuple.second ileqCouple +ineqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +ineqCouple = + fun2 vec2T "ineq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + + +ineqDecl : FunDecl +ineqDecl = + Tuple.first ineqCouple + + +ineq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +ineq = + Tuple.second ineqCouple + + ieqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ieqCouple = fun2 vec2T "ieq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) @@ -607,6 +622,46 @@ igt = Tuple.second igtCouple +iabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +iabsCouple = + fun1 vec2T "iabs" (vec2T "z") <| + \z -> + return <| + ternary + (ands [ leq z.x zero, geq z.y zero ]) + (vec2 zero <| max_ z.y <| abs_ z.x) + (ternary + (leq z.x zero) + (vec2 (negate_ z.y) (negate_ z.x)) + z + ) + + +iabsDecl : FunDecl +iabsDecl = + Tuple.first iabsCouple + + +iabs : ExpressionX xa Vec2 -> Expression2 +iabs = + Tuple.second iabsCouple + + +gabsCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +gabsCouple = + fun1 vec4T "gabs" (vec4T "v") <| \v -> return <| vec4_1_3 (abs_ v.x) (byF (sign v.x) v.yzw) + + +gabsDecl : FunDecl +gabsDecl = + Tuple.first gabsCouple + + +gabs : ExpressionX xa Vec4 -> Expression4 +gabs = + Tuple.second gabsCouple + + iexpCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iexpCouple = fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| vec2 (exp z.x) (exp z.y) @@ -755,7 +810,7 @@ intervalOperationToGlsl op = [ ipowFIDecl, ipowIDecl, ipowDecl, gpowIDecl, gpowDecl ] GlslRelations -> - [ iltDecl, ileqDecl, ieqDecl, igeqDecl, igtDecl ] + [ iltDecl, ileqDecl, ineqDecl, ieqDecl, igeqDecl, igtDecl ] straightFunctionToGlsl : GlslFunction -> List FunDecl @@ -1109,19 +1164,7 @@ intervalFunctionToGlsl : GlslFunction -> String intervalFunctionToGlsl name = case name of Abs22 -> - """ - vec2 iabs(vec2 z) { - if(z.x <= 0.0 && z.y >= 0.0) - return vec2(0.0, max(z.y, abs(z.x))); - if(z.x <= 0.0) - return vec2(-z.y, -z.x); - return z; - } - - vec4 gabs(vec4 v) { - return vec4(abs(v.x), sign(v.x) * v.yzw); - } - """ + fileToGlsl [ iabsDecl, gabsDecl ] Acos22 -> """ @@ -1799,12 +1842,12 @@ toSrcVectorField2D suffix xexpr yexpr = toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcContour suffix e = +toSrcContour suffix expr = let ( pixelODecl, pixelO ) = fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> - def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> def2 ( floatT, "theta", div (atan2_ z.y z.x) constants.twopi ) @@ -1850,18 +1893,19 @@ toSrcContour suffix e = \mn mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> - unknownStatement - (""" - if (diff.x < dist && diff.y < dist && diff.z < dist) - return (a + b + c + d) / 4.0; - - vec3 e = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + 2.0 * dist * deltaX, y); - vec3 f = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - 2.0 * dist * deltaX, y); - vec3 g = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x, y - 2.0 * dist * deltaY); - vec3 h = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x, y + 2.0 * dist * deltaY); - - return (a + b + c + d + e + f + g + h) / 8.0; - """) + if_ (ands [ lt diff.x dist, lt diff.y dist, lt diff.z dist ]) + (return <| divF (adds3 [ a, b, c, d ]) (float 4)) + (def floatT "dist2" (by (float 2) dist) <| + \dist2 -> + def4 + ( vec3T, "e", pixelO deltaX deltaY (add x <| byF dist2 deltaX) y ) + ( vec3T, "f", pixelO deltaX deltaY (subtract x <| byF dist2 deltaX) y ) + ( vec3T, "g", pixelO deltaX deltaY x (subtract y <| byF dist2 deltaY) ) + ( vec3T, "h", pixelO deltaX deltaY x (add y <| byF dist2 deltaY) ) + <| + \e f g h -> + return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) + ) in ( [ pixelODecl, pixelDecl ], pixel ) @@ -1930,14 +1974,24 @@ expressionToGlsl context = add2 (go l) (go r) PRel op l r -> - if op == "<=" || op == "<" then - subtract2 (go r) (go l) + case op of + LessThan -> + subtract2 (go r) (go l) - else if op == "=" then - abs2 <| subtract (go r) (go l) + LessThanOrEquals -> + subtract2 (go r) (go l) - else - subtract2 (go l) (go r) + NotEquals -> + abs2 <| subtract (go r) (go l) + + Equals -> + abs2 <| subtract (go r) (go l) + + GreaterThanOrEquals -> + subtract2 (go l) (go r) + + GreaterThan -> + subtract2 (go l) (go r) PBy l r -> cby (go l) (go r) @@ -2020,28 +2074,24 @@ expressionToIntervalGlsl expr = add2 (go l) (go r) PRel op l r -> - let - name = - case op of - "<" -> - "ilt" + case op of + LessThan -> + ilt (go l) (go r) - "<=" -> - "ileq" + LessThanOrEquals -> + ileq (go l) (go r) - "=" -> - "ieq" + Equals -> + ieq (go l) (go r) - ">=" -> - "igeq" + NotEquals -> + ineq (go l) (go r) - ">" -> - "igt" + GreaterThanOrEquals -> + igeq (go l) (go r) - _ -> - "iuknownrelop" - in - unsafeApply name [ l, r ] + GreaterThan -> + igt (go l) (go r) PBy l r -> iby (go l) (go r) @@ -2124,14 +2174,24 @@ expressionToNormalGlsl { x, y, z } = add4 (go l) (go r) PRel op l r -> - if op == "<=" || op == "<" then - subtract4 (go r) (go l) + case op of + LessThan -> + subtract4 (go r) (go l) - else if op == "=" then - abs4 <| subtract (go r) (go l) + LessThanOrEquals -> + subtract4 (go r) (go l) - else - subtract4 (go l) (go r) + NotEquals -> + abs4 <| subtract (go r) (go l) + + Equals -> + abs4 <| subtract (go r) (go l) + + GreaterThanOrEquals -> + subtract4 (go l) (go r) + + GreaterThan -> + subtract4 (go l) (go r) PBy l r -> gby (go l) (go r) @@ -2432,7 +2492,7 @@ main3D rayDifferentials suffixes = \up -> def vec3T "canvas_center" (add eye toTarget) <| \canvasCenter -> - def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) <| byF uvNormalized.y up) <| + def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| \canvasPoint -> def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index d7caa5a3..043d1d0e 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -458,6 +458,36 @@ ors es = List.foldl (\e a -> expr2 Or a e) h t +adds2 : List Expression2 -> Expression2 +adds2 es = + case es of + [] -> + vec2Zero + + h :: t -> + List.foldl (\e a -> add2 a e) h t + + +adds3 : List Expression3 -> Expression3 +adds3 es = + case es of + [] -> + vec3Zero + + h :: t -> + List.foldl (\e a -> add3 a e) h t + + +adds4 : List Expression4 -> Expression4 +adds4 es = + case es of + [] -> + vec4Zero + + h :: t -> + List.foldl (\e a -> add4 a e) h t + + true : Expression1 Bool true = dotted1 <| Expression <| Bool True @@ -528,6 +558,11 @@ add2 = expr22 Add +add3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +add3 = + expr23 Add + + add4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 add4 = expr24 Add From aa98b63fbdc714bc047f7d32921cf10ee575bfb6 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 01:54:06 +0200 Subject: [PATCH 029/139] More codegen --- src/elm/UI/Glsl.elm | 5 +- src/elm/UI/Glsl/Code.elm | 379 +++++++++++++++++++++++++--------- src/elm/UI/Glsl/Generator.elm | 14 +- 3 files changed, 298 insertions(+), 100 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 28615cfe..24d84b3e 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -163,8 +163,9 @@ piDecl = { name = "PI" , type_ = "float" , body = - """#define PI """ ++ String.fromFloat pi ++ """ - #define TWOPI """ ++ String.fromFloat (pi * 2) + """#define PIHALF """ ++ String.fromFloat (pi / 2) ++ """ + #define PI """ ++ String.fromFloat pi ++ """ + #define TWOPI """ ++ String.fromFloat (pi * 2) } diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 30a5afa4..5b7e78db 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict -import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -791,6 +791,122 @@ ctan = Tuple.second ctanCouple +casinTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +casinTuple = + fun1 vec2T "casin" (vec2T "z") <| + \z -> + def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| + \s -> + def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| + \arg -> + return <| cby (vec2 zero one) (cln arg) + + +casinDecl : FunDecl +casinDecl = + Tuple.first casinTuple + + +casin : ExpressionX xa Vec2 -> Expression2 +casin = + Tuple.second casinTuple + + +cacosTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cacosTuple = + fun1 vec2T "cacos" (vec2T "z") <| \z -> return <| subtract (vec2 constants.pihalf zero) (casin z) + + +cacosDecl : FunDecl +cacosDecl = + Tuple.first cacosTuple + + +cacos : ExpressionX xa Vec2 -> Expression2 +cacos = + Tuple.second cacosTuple + + +catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +catanTuple = + fun1 vec2T "catan" (vec2T "z") <| + \z -> + if_ (eq z.y zero) + (return <| vec2 (atan_ z.x) zero) + (def2 + ( vec2T, "o", vec2 one zero ) + ( vec2T, "iz", cby (vec2 zero one) z ) + <| + \o iz -> + def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| + \l -> + return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) + ) + + +catanDecl : FunDecl +catanDecl = + Tuple.first catanTuple + + +catan : ExpressionX xa Vec2 -> Expression2 +catan = + Tuple.second catanTuple + + +catan2Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +catan2Tuple = + fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| + \y x -> + def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| + \z -> + return <| vec2 (atan2_ z.y z.x) zero + + +catan2Decl : FunDecl +catan2Decl = + Tuple.first catan2Tuple + + +catan2 : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +catan2 = + Tuple.second catan2Tuple + + +csinhTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +csinhTuple = + fun1 vec2T "csinh" (vec2T "z") <| + \z -> + return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) + + +csinhDecl : FunDecl +csinhDecl = + Tuple.first csinhTuple + + +csinh : ExpressionX xa Vec2 -> Expression2 +csinh = + Tuple.second csinhTuple + + +ccoshTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ccoshTuple = + fun1 vec2T "ccosh" (vec2T "z") <| + \z -> + return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) + + +ccoshDecl : FunDecl +ccoshDecl = + Tuple.first ccoshTuple + + +ccosh : ExpressionX xa Vec2 -> Expression2 +ccosh = + Tuple.second ccoshTuple + + intervalOperationToGlsl : GlslOperation -> List FunDecl intervalOperationToGlsl op = case op of @@ -852,79 +968,22 @@ straightFunctionToGlsl name = [ ctanDecl ] Asin22 -> - [ unknownFunDecl - { name = - "casin" - , type_ = "TODO" - , body = """ - vec2 casin(vec2 z) { - vec2 s = csqrt(vec2(1, 0) - cby(z, z)); - vec2 arg = s - cby(vec2(0, 1), z); - return cby(vec2(0, 1), cln(arg)); - } - """ - } - ] + [ casinDecl ] Acos22 -> - [ unknownFunDecl - { name = - "cacos" - , type_ = "TODO" - , body = """ - vec2 cacos(vec2 z) { - return pi() * 0.5 - casin(z); - } - """ - } - ] + [ cacosDecl ] Atan22 -> - [ unknownFunDecl - { name = - "catan" - , type_ = "TODO" - , body = """ - vec2 catan(vec2 z) { - if(z.y == 0.0) { - return vec2(atan(z.x), 0); - } - vec2 o = vec2(1, 0); - vec2 iz = cby(vec2(0, 1), z); - vec2 l = cdiv(o + iz, o - iz); - return -0.5 * cby(vec2(0, 1), cln(l)); - } - """ - } - ] + [ catanDecl ] Atan222 -> - [ unknownFunDecl - { name = - "catan2" - , type_ = "TODO" - , body = """ - vec2 catan2(vec2 y, vec2 x) { - vec2 z = vec2(x.x - y.y, x.y + y.x); - return vec2(atan(z.y, z.x), 0.0); - } - """ - } - ] + [ catan2Decl ] Sinh22 -> - [ unknownFunDecl { name = "csinh", type_ = "TODO", body = """ - vec2 csinh(vec2 z) { - return 0.5 * (cexp(z) - cexp(-z)); - } - """ } ] + [ csinhDecl ] Cosh22 -> - [ unknownFunDecl { name = "ccosh", type_ = "TODO", body = """ - vec2 ccosh(vec2 z) { - return 0.5 * (cexp(z) + cexp(-z)); - } - """ } ] + [ ccoshDecl ] Tanh22 -> [ unknownFunDecl { name = "ctanh", type_ = "TODO", body = """ @@ -950,16 +1009,7 @@ straightFunctionToGlsl name = """ } ] Sqrt22 -> - [ unknownFunDecl { name = "csqrt", type_ = "TODO", body = """ - vec2 csqrt(vec2 z) { - if(z.y == 0.0 && z.x >= 0.0) { - return vec2(sqrt(z.x), 0); - } - float r = pow(dot(z, z), 0.25); - float t = atan(z.y, z.x) * 0.5; - return r * vec2(cos(t), sin(t)); - } - """ } ] + [ csqrtDecl ] Cbrt22 -> [ unknownFunDecl { name = "ccbrt", type_ = "TODO", body = """ @@ -1039,18 +1089,10 @@ straightFunctionToGlsl name = """ } ] Min222 -> - [ unknownFunDecl { name = "cmin", type_ = "TODO", body = """ - vec2 cmin(vec2 l, vec2 r) { - return l.x < r.x ? l : r; - } - """ } ] + [ cminDecl ] Max222 -> - [ unknownFunDecl { name = "cmax", type_ = "TODO", body = """ - vec2 cmax(vec2 l, vec2 r) { - return l.x > r.x ? l : r; - } - """ } ] + [ cmaxDecl ] Mod22 -> [ unknownFunDecl { name = "cmod", type_ = "TODO", body = """ @@ -1120,6 +1162,61 @@ cre = Tuple.second creTuple +cminTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cminTuple = + fun2 vec2T "cmin" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (lt l.x r.x) l r + + +cminDecl : FunDecl +cminDecl = + Tuple.first cminTuple + + +cmin : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cmin = + Tuple.second cminTuple + + +cmaxTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cmaxTuple = + fun2 vec2T "cmax" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (gt l.x r.x) l r + + +cmaxDecl : FunDecl +cmaxDecl = + Tuple.first cmaxTuple + + +cmax : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cmax = + Tuple.second cmaxTuple + + +csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +csqrtTuple = + fun1 vec2T "csqrt" (vec2T "z") <| + \z -> + if_ (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (sqrt_ z.x) zero) + (def2 + ( floatT, "r", pow (dot z z) (float 0.25) ) + ( floatT, "t", byF (float 0.5) (atan2_ z.y z.x) ) + <| + \r t -> + return <| byF r <| vec2 (cos_ t) (sin_ t) + ) + + +csqrtDecl : FunDecl +csqrtDecl = + Tuple.first csqrtTuple + + +csqrt : ExpressionX xa Vec2 -> Expression2 +csqrt = + Tuple.second csqrtTuple + + csquareTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csquareTuple = fun1 vec2T "csquare" (vec2T "z") <| \z -> return <| cby z z @@ -1602,7 +1699,7 @@ toSrcPolar suffix e = <| \t ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\i -> + (\_ -> def4 ( floatT, "h", f x y t ot ) ( floatT, "l", f (subtract x deltaX) y t ot ) @@ -1627,11 +1724,13 @@ toSrcPolar suffix e = constants : { maxIterations : ExpressionX { isConstant : Constant } Int + , pihalf : ExpressionX { isConstant : Constant } Float , pi : ExpressionX { isConstant : Constant } Float , twopi : ExpressionX { isConstant : Constant } Float } constants = { maxIterations = constant intT "MAX_ITERATIONS" + , pihalf = constant floatT "PIHALF" , pi = constant floatT "PI" , twopi = constant floatT "TWOPI" } @@ -1939,6 +2038,14 @@ expressionToGlsl context = ctx = Dict.fromList context + variadic f es = + case List.map go es of + [] -> + vec2Zero + + head :: tail -> + List.foldl (\e a -> f a e) head tail + go expr = case expr of PVariable "i" -> @@ -2013,17 +2120,97 @@ expressionToGlsl context = PApply (KnownFunction Simplify) [ e ] -> go e - PApply name ex -> - if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map (go >> .base) ex of - [] -> - vec2Zero - - head :: tail -> - dotted2 (List.foldl (\e a -> unsafeCall ("c" ++ Expression.functionNameToString name) [ a, e ]) head tail) + PApply (KnownFunction Sin) [ e ] -> + csin (go e) + + PApply (KnownFunction Cos) [ e ] -> + ccos (go e) + + PApply (KnownFunction Tan) [ e ] -> + ctan (go e) + + PApply (KnownFunction Asin) [ e ] -> + casin (go e) + + PApply (KnownFunction Acos) [ e ] -> + cacos (go e) + + PApply (KnownFunction Atan) [ e ] -> + catan (go e) + + PApply (KnownFunction Atan2) [ l, r ] -> + catan2 (go l) (go r) + + PApply (KnownFunction Sinh) [ e ] -> + csinh (go e) + + PApply (KnownFunction Cosh) [ e ] -> + ccosh (go e) + + -- PApply (KnownFunction Tanh) [ e ] -> + -- ctanh (go e) + -- PApply (KnownFunction Abs) [ e ] -> + -- cabs (go e) + -- PApply (KnownFunction (Root r)) [ e ] -> + -- croot r (go e) + PApply (KnownFunction Ln) [ e ] -> + cln (go e) + + -- PApply (KnownFunction Log10) [ e ] -> + -- clog10 (go e) + PApply (KnownFunction Exp) [ e ] -> + cexp (go e) + + -- PApply (KnownFunction Sign) [ e ] -> + -- csign (go e) + PApply (KnownFunction Re) [ e ] -> + cre (go e) + + -- PApply (KnownFunction Im) [ e ] -> + -- cim (go e) + -- PApply (KnownFunction Arg) [ e ] -> + -- carg (go e) + -- PApply (KnownFunction Gra) [ e ] -> + -- cgra (go e) + -- PApply (KnownFunction Det) [ e ] -> + -- cdet (go e) + -- PApply (KnownFunction Dd) [ e ] -> + -- cdd (go e) + -- PApply (KnownFunction Ii) [ e ] -> + -- cii (go e) + -- PApply (KnownFunction Round) [ e ] -> + -- cround (go e) + -- PApply (KnownFunction Floor) [ e ] -> + -- cfloor (go e) + -- PApply (KnownFunction Ceiling) [ e ] -> + -- cceiling (go e) + -- PApply (KnownFunction Pw) [ e ] -> + -- cpw (go e) + -- PApply (KnownFunction Plot) [ e ] -> + -- cplot (go e) + -- PApply (KnownFunction APlot) [ e ] -> + -- caPlot (go e) + -- PApply (KnownFunction StepSimplify) [ e ] -> + -- cstepSimplify (go e) + -- PApply (KnownFunction Solve) [ e ] -> + -- csolve (go e) + -- PApply (KnownFunction Mod) [ e ] -> + -- cmod (go e) + -- PApply (KnownFunction Mbrot) [ e ] -> + -- cmbrot (go e) + -- PApply (KnownFunction For) [ e ] -> + -- cfor (go e) + PApply (KnownFunction Min) es -> + variadic cmin es + + PApply (KnownFunction Max) es -> + variadic cmax es + + PApply (UserFunction name) ex -> + dotted2 <| unsafeCall ("c" ++ name) (List.map (go >> .base) ex) - else - dotted2 <| unsafeCall ("c" ++ Expression.functionNameToString name) (List.map (go >> .base) ex) + PApply name ex -> + dotted2 <| unsafeCall ("c" ++ functionNameToString name) (List.map (go >> .base) ex) PList es -> dotted2 <| unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map (go >> .base) es) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 043d1d0e..ee4380fb 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -700,6 +700,11 @@ exp = dotted1 << call1Internal "exp" +sqrt_ : ExpressionX a t -> Expression1 t +sqrt_ = + dotted1 << call1Internal "sqrt" + + sin_ : ExpressionX a t -> Expression1 t sin_ = dotted1 << call1Internal "sin" @@ -815,7 +820,12 @@ cross l r = dotted3 <| call2Internal "cross" l r -atan2_ : ExpressionX a Float -> ExpressionX a Float -> Expression1 Float +atan_ : ExpressionX a Float -> Expression1 Float +atan_ = + dotted1 << call1Internal "atan" + + +atan2_ : ExpressionX a Float -> ExpressionX b Float -> Expression1 Float atan2_ l r = dotted1 <| call2Internal "atan" l r From f5b4b88b17306fa49fa821245dffc34a84cc027b Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 02:38:36 +0200 Subject: [PATCH 030/139] Slightly more uniform API --- src/elm/UI/Glsl/Code.elm | 147 ++++++++++++++++++++-------------- src/elm/UI/Glsl/Generator.elm | 99 +++++++++++++---------- 2 files changed, 142 insertions(+), 104 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 5b7e78db..1d8b8960 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -798,8 +798,8 @@ casinTuple = def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| \s -> def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| - \arg -> - return <| cby (vec2 zero one) (cln arg) + \arg_ -> + return <| cby (vec2 zero one) (cln arg_) casinDecl : FunDecl @@ -834,8 +834,8 @@ catanTuple = if_ (eq z.y zero) (return <| vec2 (atan_ z.x) zero) (def2 - ( vec2T, "o", vec2 one zero ) - ( vec2T, "iz", cby (vec2 zero one) z ) + ( vec2T "o", vec2 one zero ) + ( vec2T "iz", cby (vec2 zero one) z ) <| \o iz -> def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| @@ -1050,15 +1050,7 @@ straightFunctionToGlsl name = """ } ] Arg22 -> - [ unknownFunDecl { name = "arg", type_ = "TODO", body = """ - float arg(vec2 v) { - return atan(v.y, v.x); - } - - vec2 carg(vec2 v) { - return vec2(atan(v.y, v.x), 0); - } - """ } ] + [ argDecl, cargDecl ] Pw22 -> [ unknownFunDecl { name = "cpw", type_ = "TODO", body = """ @@ -1162,6 +1154,36 @@ cre = Tuple.second creTuple +argTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression1 Float ) +argTuple = + fun1 floatT "arg" (vec2T "v") <| \v -> return <| atan2_ v.y v.x + + +argDecl : FunDecl +argDecl = + Tuple.first argTuple + + +arg : ExpressionX xa Vec2 -> Expression1 Float +arg = + Tuple.second argTuple + + +cargTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cargTuple = + fun1 vec2T "arg" (vec2T "v") <| \v -> return <| vec2 (atan2_ v.y v.x) zero + + +cargDecl : FunDecl +cargDecl = + Tuple.first cargTuple + + +carg : ExpressionX xa Vec2 -> Expression2 +carg = + Tuple.second cargTuple + + cminTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cminTuple = fun2 vec2T "cmin" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (lt l.x r.x) l r @@ -1199,8 +1221,8 @@ csqrtTuple = if_ (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (sqrt_ z.x) zero) (def2 - ( floatT, "r", pow (dot z z) (float 0.25) ) - ( floatT, "t", byF (float 0.5) (atan2_ z.y z.x) ) + ( floatT "r", pow (dot z z) (float 0.25) ) + ( floatT "t", byF (float 0.5) (atan2_ z.y z.x) ) <| \r t -> return <| byF r <| vec2 (cos_ t) (sin_ t) @@ -1622,8 +1644,8 @@ toSrcImplicit suffix e = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> def2 - ( floatT, "sum", zero ) - ( floatT, "samples", float <| antialiasingSamples * 2 + 1 ) + ( floatT "sum", zero ) + ( floatT "samples", float <| antialiasingSamples * 2 + 1 ) <| \sum samples -> assignBy samples samples <| @@ -1694,17 +1716,17 @@ toSrcPolar suffix e = assignAdd x (div deltaX <| float 2) <| assignAdd y (div deltaY <| float 2) <| def2 - ( floatT, "t", zero ) - ( floatT, "ot", atanPlus y x ) + ( floatT "t", zero ) + ( floatT "ot", atanPlus y x ) <| \t ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) (\_ -> def4 - ( floatT, "h", f x y t ot ) - ( floatT, "l", f (subtract x deltaX) y t ot ) - ( floatT, "u", f x (subtract y deltaY) t ot ) - ( floatT, "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) + ( floatT "h", f x y t ot ) + ( floatT "l", f (subtract x deltaX) y t ot ) + ( floatT "u", f x (subtract y deltaY) t ot ) + ( floatT "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) <| \h l u ul -> if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) @@ -1743,9 +1765,9 @@ toSrcParametric suffix e = fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to -> def3 - ( vec2T, "x", vec2 p.x p.x ) - ( vec2T, "y", vec2 p.y p.y ) - ( vec2T, "t", ternary (lt from to) (vec2 from to) (vec2 to from) ) + ( vec2T "x", vec2 p.x p.x ) + ( vec2T "y", vec2 p.y p.y ) + ( vec2T "t", ternary (lt from to) (vec2 from to) (vec2 to from) ) <| \x y t -> return <| expressionToIntervalGlsl (toPrintExpression e) @@ -1832,8 +1854,8 @@ thetaDeltaCouple = if_ (lt uniforms.u_whiteLines one) (return <| float 100) (def2 - ( floatT, "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) - ( floatT, "thetaNeigh", float 0.05 ) + ( floatT "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) + ( floatT "thetaNeigh", float 0.05 ) <| \thetaSix thetaNeigh -> return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh @@ -1861,27 +1883,28 @@ toSrcVectorField2D suffix xexpr yexpr = fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y -> def2 - ( vec2T, "xv", expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] xexpr ) - ( vec2T, "yv", expressionToGlsl [ ( "x", dotted1 <| unknown "x" ), ( "y", dotted1 <| unknown "y" ) ] yexpr ) + ( vec2T "xv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr ) + ( vec2T "yv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr ) <| \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero - nearDecl = - unknownFunDecl - { name = "near" - , type_ = "TODO" - , body = """ - bool near(vec2 o, vec2 corner, vec2 vector, float deltaX, float mx) { - float angleCorner = arg(o - corner); - float angleVector = arg(vector); - float delta = mod(angleCorner - angleVector, TWOPI); - float l = length(vector) / mx; - float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); - float wantedLength = length(o - corner); - float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); - return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; - }""" - } + ( nearDecl, near ) = + fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| + \o corner vect deltaX mx -> + def2 + ( floatT "angleCorner", arg <| subtract o corner ) + ( floatT "angleVector", arg vect ) + <| + \angleCorner angleVector -> + unknownStatement + (""" + float delta = mod(angleCorner - angleVector, TWOPI); + float l = length(vect) / mx; + float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); + float wantedLength = length(o - corner); + float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); + return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; + """) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| @@ -1949,8 +1972,8 @@ toSrcContour suffix expr = def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> def2 - ( floatT, "theta", div (atan2_ z.y z.x) constants.twopi ) - ( floatT, "logRadius", log2 <| length z ) + ( floatT "theta", div (atan2_ z.y z.x) constants.twopi ) + ( floatT "logRadius", log2 <| length z ) <| \theta logRadius -> def floatT "powerRemainder" (fract logRadius) <| @@ -1979,15 +2002,15 @@ toSrcContour suffix expr = def floatT "dist" (float <| 1 / 3) <| \dist -> def4 - ( vec3T, "a", pixelO deltaX deltaY (add x <| by dist deltaX) (add y <| by dist deltaY) ) - ( vec3T, "b", pixelO deltaX deltaY (subtract x <| by dist deltaX) (subtract y <| by dist deltaY) ) - ( vec3T, "c", pixelO deltaX deltaY (add x <| by dist deltaX) (subtract y <| by dist deltaY) ) - ( vec3T, "d", pixelO deltaX deltaY (subtract x <| by dist deltaX) (add y <| by dist deltaY) ) + ( vec3T "a", pixelO deltaX deltaY (add x <| by dist deltaX) (add y <| by dist deltaY) ) + ( vec3T "b", pixelO deltaX deltaY (subtract x <| by dist deltaX) (subtract y <| by dist deltaY) ) + ( vec3T "c", pixelO deltaX deltaY (add x <| by dist deltaX) (subtract y <| by dist deltaY) ) + ( vec3T "d", pixelO deltaX deltaY (subtract x <| by dist deltaX) (add y <| by dist deltaY) ) <| \a b c d -> def2 - ( vec3T, "mn", min_ a <| min_ b <| min_ c d ) - ( vec3T, "mx", max_ a <| max_ b <| max_ c d ) + ( vec3T "mn", min_ a <| min_ b <| min_ c d ) + ( vec3T "mx", max_ a <| max_ b <| max_ c d ) <| \mn mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| @@ -1997,10 +2020,10 @@ toSrcContour suffix expr = (def floatT "dist2" (by (float 2) dist) <| \dist2 -> def4 - ( vec3T, "e", pixelO deltaX deltaY (add x <| byF dist2 deltaX) y ) - ( vec3T, "f", pixelO deltaX deltaY (subtract x <| byF dist2 deltaX) y ) - ( vec3T, "g", pixelO deltaX deltaY x (subtract y <| byF dist2 deltaY) ) - ( vec3T, "h", pixelO deltaX deltaY x (add y <| byF dist2 deltaY) ) + ( vec3T "e", pixelO deltaX deltaY (add x <| byF dist2 deltaX) y ) + ( vec3T "f", pixelO deltaX deltaY (subtract x <| byF dist2 deltaX) y ) + ( vec3T "g", pixelO deltaX deltaY x (subtract y <| byF dist2 deltaY) ) + ( vec3T "h", pixelO deltaX deltaY x (add y <| byF dist2 deltaY) ) <| \e f g h -> return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) @@ -2667,7 +2690,7 @@ main3D rayDifferentials suffixes = \t -> def floatT "p" (by (float -2.0) uniforms.u_phi) <| \p -> - def vec3T "eye" (eyePosition t p) <| + def vec3T "eye" (eyePosition eyeDist t p) <| \eye -> def vec3T "target" vec3Zero <| \target -> @@ -2704,8 +2727,8 @@ main3D rayDifferentials suffixes = ( raytraceSrc, raytraceF ) = raytrace suffixes - eyePosition t p = - byF (dotted1 <| unknown "eye_dist") <| + eyePosition eyeDist t p = + byF eyeDist <| normalize <| vec3 (by (cos_ t) (sin_ p)) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index ee4380fb..c8961d68 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1039,6 +1039,11 @@ call4Internal name arg0 arg1 arg2 arg3 = Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2, unwrapExpression arg3 ]) +call5Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c n -> ExpressionX d r -> ExpressionX e s -> Expression t +call5Internal name arg0 arg1 arg2 arg3 arg4 = + Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2, unwrapExpression arg3, unwrapExpression arg4 ]) + + dotted1 : Expression t -> Expression1 t dotted1 (Expression e) = dotted1Internal e @@ -1268,6 +1273,30 @@ fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = ) +fun5 : + TypingFunction tr r + -> String + -> ( TypedName ta a, Expression ta -> a ) + -> ( TypedName tb b, Expression tb -> b ) + -> ( TypedName tc c, Expression tc -> c ) + -> ( TypedName td d, Expression td -> d ) + -> ( TypedName te e, Expression te -> e ) + -> (a -> b -> c -> d -> e -> Statement tr) + -> + ( FunDecl + , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> ExpressionX xe te -> r + ) +fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body = + let + ( typed, dotter ) = + typeF name + in + ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3, argToString arg4 ] <| + body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) (toVar arg4) + , \l m c n r -> dotter (call5Internal name l m c n r) + ) + + if_ : Expression1 Bool -> Statement r -> Statement r -> Statement r if_ cond (Statement ifTrue) (Statement ifFalse) = Statement <| If (unwrapExpression cond) ifTrue ifFalse @@ -1330,15 +1359,17 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks -def2 : ( TypingFunction tv v, String, ExpressionX xv tv ) -> ( TypingFunction tw w, String, ExpressionX xw tw ) -> (v -> w -> Statement tr) -> Statement tr -def2 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) k = - let - ( TypedName (Type t0) n0 e0, _ ) = - typeF0 name0 - ( TypedName (Type t1) n1 e1, _ ) = - typeF1 name1 +--def2 : ( TypingFunction tv v, String, ExpressionX xv tv ) -> ( TypingFunction tw w, String, ExpressionX xw tw ) -> (v -> w -> Statement tr) -> Statement tr + +def2 : + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) + -> (a -> b -> Statement r) + -> Statement r +def2 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) k = + let (Statement ks) = k e0 e1 in @@ -1346,22 +1377,13 @@ def2 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) k = def3 : - ( TypingFunction tv v, String, ExpressionX xv tv ) - -> ( TypingFunction tw w, String, ExpressionX xw tw ) - -> ( TypingFunction tx x, String, ExpressionX xx tx ) - -> (v -> w -> x -> Statement tr) - -> Statement tr -def3 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) ( typeF2, name2, v2 ) k = + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) + -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) + -> (a -> b -> c -> Statement r) + -> Statement r +def3 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) k = let - ( TypedName (Type t0) n0 e0, _ ) = - typeF0 name0 - - ( TypedName (Type t1) n1 e1, _ ) = - typeF1 name1 - - ( TypedName (Type t2) n2 e2, _ ) = - typeF2 name2 - (Statement ks) = k e0 e1 e2 in @@ -1373,26 +1395,14 @@ def3 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) ( typeF2, name2, v2 ) k = def4 : - ( TypingFunction tv v, String, ExpressionX xv tv ) - -> ( TypingFunction tw w, String, ExpressionX xw tw ) - -> ( TypingFunction tx x, String, ExpressionX xx tx ) - -> ( TypingFunction ty y, String, ExpressionX xy ty ) - -> (v -> w -> x -> y -> Statement tr) - -> Statement tr -def4 ( typeF0, name0, v0 ) ( typeF1, name1, v1 ) ( typeF2, name2, v2 ) ( typeF3, name3, v3 ) k = + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) + -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) + -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) + -> (a -> b -> c -> d -> Statement r) + -> Statement r +def4 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) k = let - ( TypedName (Type t0) n0 e0, _ ) = - typeF0 name0 - - ( TypedName (Type t1) n1 e1, _ ) = - typeF1 name1 - - ( TypedName (Type t2) n2 e2, _ ) = - typeF2 name2 - - ( TypedName (Type t3) n3 e3, _ ) = - typeF3 name3 - (Statement ks) = k e0 e1 e2 e3 in @@ -1453,6 +1463,11 @@ voidT n = ( TypedName (Type "void") (Name n) never, always never ) +boolT : TypingFunction Bool (Expression1 Bool) +boolT n = + ( TypedName (Type "bool") (Name n) (dotted1Internal (Variable n)), dotted1 ) + + intT : TypingFunction Int (Expression1 Int) intT n = ( TypedName (Type "int") (Name n) (dotted1Internal (Variable n)), dotted1 ) From 3589a961c6c1b8e2ac99b3b3d94ff6f08f716090 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 02:39:55 +0200 Subject: [PATCH 031/139] Fix typo --- src/elm/UI/Glsl/Code.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 1d8b8960..a062bf86 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1171,7 +1171,7 @@ arg = cargTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) cargTuple = - fun1 vec2T "arg" (vec2T "v") <| \v -> return <| vec2 (atan2_ v.y v.x) zero + fun1 vec2T "carg" (vec2T "v") <| \v -> return <| vec2 (atan2_ v.y v.x) zero cargDecl : FunDecl From 1ceb04babb4bae2e1d7a36dc380491851cbbbf18 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 05:18:45 +0200 Subject: [PATCH 032/139] Added parser to codegen faster --- glslParser/.gitignore | 1 + glslParser/elm.json | 36 ++ glslParser/src/GlslConverter.elm | 768 +++++++++++++++++++++++++++++++ src/elm/Expression/Graph.elm | 12 +- src/elm/UI/Glsl/Code.elm | 88 ++-- src/elm/UI/Glsl/Generator.elm | 23 +- 6 files changed, 882 insertions(+), 46 deletions(-) create mode 100644 glslParser/.gitignore create mode 100644 glslParser/elm.json create mode 100644 glslParser/src/GlslConverter.elm diff --git a/glslParser/.gitignore b/glslParser/.gitignore new file mode 100644 index 00000000..dcaf7169 --- /dev/null +++ b/glslParser/.gitignore @@ -0,0 +1 @@ +index.html diff --git a/glslParser/elm.json b/glslParser/elm.json new file mode 100644 index 00000000..2ab30435 --- /dev/null +++ b/glslParser/elm.json @@ -0,0 +1,36 @@ +{ + "type": "application", + "source-directories": [ + "src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0", + "elm/parser": "1.1.0", + "mdgriffith/elm-ui": "1.1.8", + "the-sett/elm-syntax-dsl": "5.2.2" + }, + "indirect": { + "Chadtech/elm-bool-extra": "2.4.2", + "elm/json": "1.1.3", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.2", + "elm-community/basics-extra": "4.1.0", + "elm-community/list-extra": "8.4.0", + "elm-community/maybe-extra": "5.2.0", + "miniBill/elm-unicode": "1.0.2", + "rtfeldman/elm-hex": "1.0.0", + "stil4m/elm-syntax": "7.2.7", + "stil4m/structured-writer": "1.0.3", + "the-sett/elm-pretty-printer": "2.2.3" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm new file mode 100644 index 00000000..68ac415c --- /dev/null +++ b/glslParser/src/GlslConverter.elm @@ -0,0 +1,768 @@ +module GlslConverter exposing (main) + +import Browser +import Element as Element exposing (Element, column, el, fill, height, padding, row, scrollbarY, spacing, text, width) +import Element.Border as Border +import Element.Font as Font +import Element.Input as Input +import Html +import Parser exposing ((|.), (|=), DeadEnd, Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) + + +type alias Model = + { input : String + , output : String + } + + +type Msg + = Input String + + +main : Program () Model Msg +main = + Browser.sandbox + { init = init + , view = Element.layout [ width fill, height fill ] << view + , update = update + } + + +init : Model +init = + let + i = + """vec2 cmbrot(vec2 x, vec2 y) { + vec2 c = x + vec2(-y.y, y.x); + + float p = length(c - vec2(0.25, 0)); + if(c.x <= p - 2.0*p*p + 0.25 || length(c + vec2(1,0)) <= 0.25) + return vec2(0,0); + + vec2 z = c; + for(int i = 0; i < 4000; i++) { + z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; + if(length(z) > 1000000.0) { + float logLength = log(length(z)); + float nu = log(logLength / log(2.0)) / log(2.0); + float fi = float(i) - nu; + return vec2(sin(fi),cos(fi)); + } + } + return vec2(0,0); +}""" + in + { input = i + , output = toOutput i + } + + +view : Model -> Element Msg +view model = + row + [ padding 10 + , spacing 10 + , width fill + , height fill + ] + [ input model.input + , output model.output + ] + + +input : String -> Element Msg +input value = + Input.multiline + [ width fill + , height fill + , spacing 10 + ] + { onChange = Input + , text = value + , placeholder = Nothing + , label = Input.labelAbove [] <| text "Input (GLSL function or expression)" + , spellcheck = False + } + + +output : String -> Element Msg +output value = + let + tc = + Html.pre [] [ Html.text value ] + |> Element.html + |> el + [ width fill + , height fill + , Border.width 1 + , Font.family [ Font.typeface "Fira Code", Font.monospace ] + , padding 10 + , scrollbarY + ] + in + column + [ spacing 10 + , width fill + , height fill + ] + [ text "Output (Elm code)" + , tc + ] + + +update : Msg -> Model -> Model +update msg model = + case msg of + Input i -> + { model | input = i, output = toOutput i } + + +toOutput : String -> String +toOutput i = + case parse i of + Err e -> + Debug.toString e + + Ok o -> + prettyPrint o + + +type alias Function = + { returnType : String + , name : String + , args : List ( String, String ) + , body : Statement + } + + +type Statement + = Expression Expression Statement + | For String Expression RelationOperation Expression Statement Statement + | If Expression Statement Statement + | Return Expression + | Def String String Expression Statement + | Decl String String Statement + | Nop + + +type RelationOperation + = LessThanOrEquals + | LessThan + | Equals + | Assign + | NotEquals + | GreaterThanOrEquals + | GreaterThan + + +type BinaryOperation + = Add + | Subtract + | By + | Div + + +type BooleanOperation + = And + | Or + + +type UnaryOperation + = Negate + + +type Expression + = Float Float + | Int Int + | Dot String String + | Variable String + | Call String (List Expression) + | Ternary Expression Expression Expression + | UnaryOperation UnaryOperation Expression + | BinaryOperation BinaryOperation Expression Expression + | BooleanOperation BooleanOperation Expression Expression + | RelationOperation RelationOperation Expression Expression + + +type Either a b + = Left a + | Right b + + +parse : String -> Result (List DeadEnd) (Either Function Statement) +parse = + Parser.run <| + succeed identity + |. spaces + |= oneOf + [ Parser.map Left functionParser + , Parser.map Right statementParser + ] + |. spaces + |. Parser.end + + +functionParser : Parser Function +functionParser = + succeed Function + |= typeParser + |. spaces + |= identifierParser + |. spaces + |= sequence + { start = "(" + , end = ")" + , spaces = spaces + , separator = "," + , item = argParser + , trailing = Forbidden + } + |. spaces + |= statementParser + + +argParser : Parser ( String, String ) +argParser = + succeed Tuple.pair + |= typeParser + |. spaces + |= identifierParser + + +identifierParser : Parser String +identifierParser = + getChompedString <| + succeed () + |. chompIf (\c -> Char.isAlpha c || c == '_') + |. chompWhile (\c -> Char.isAlphaNum c || c == '_') + + +typeParser : Parser String +typeParser = + [ "void", "bool", "int", "float", "vec2", "vec3", "vec4", "mat3" ] + |> List.map (\s -> succeed s |. symbol s) + |> oneOf + + +statementParser : Parser Statement +statementParser = + Parser.lazy <| + \_ -> + oneOf + [ blockParser + , returnParser + , ifParser + , forParser + , defParser + , expressionStatementParser + ] + + +expressionStatementParser : Parser Statement +expressionStatementParser = + Parser.succeed Expression + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |= maybeStatementParser + + +ifParser : Parser Statement +ifParser = + Parser.succeed If + |. symbol "if" + |. spaces + |. symbol "(" + |. spaces + |= expressionParser + |. spaces + |. symbol ")" + |. spaces + |= statementParser + |. spaces + |= maybeStatementParser + + +maybeStatementParser : Parser Statement +maybeStatementParser = + oneOf [ statementParser, succeed Nop ] + + +forParser : Parser Statement +forParser = + Parser.succeed For + |. symbol "for" + |. spaces + |. symbol "(" + |. spaces + |. symbol "int" + |. spaces + |= identifierParser + |. spaces + |. symbol "=" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |. identifierParser + |. spaces + |= relationOperationParser + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |. identifierParser + |. spaces + |. symbol "++" + |. spaces + |. symbol ")" + |. spaces + |= statementParser + |. spaces + |= maybeStatementParser + + +returnParser : Parser Statement +returnParser = + Parser.succeed Return + |. symbol "return" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + + +blockParser : Parser Statement +blockParser = + Parser.succeed identity + |. symbol "{" + |. spaces + |= maybeStatementParser + |. spaces + |. symbol "}" + + +defParser : Parser Statement +defParser = + succeed Def + |= typeParser + |. spaces + |= identifierParser + |. spaces + |. symbol "=" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |= maybeStatementParser + + +expressionParser : Parser Expression +expressionParser = + booleanParser + + +booleanParser : Parser Expression +booleanParser = + multiSequence + { separators = + [ ( BooleanOperation Or, symbol "||" ) + , ( BooleanOperation And, symbol "&&" ) + ] + , item = relationParser + , allowNegation = False + } + + +relationParser : Parser Expression +relationParser = + let + inner = + succeed (\a f -> f a) + |= addsubtractionParser + |. spaces + |= oneOf + [ succeed (\o r l -> succeed <| RelationOperation o l r) + |= relationOperationParser + |. spaces + |= addsubtractionParser + , succeed succeed + ] + in + Parser.andThen identity inner + + +relationOperationParser : Parser RelationOperation +relationOperationParser = + oneOf + [ succeed LessThanOrEquals |. symbol "<=" + , succeed GreaterThanOrEquals |. symbol ">=" + , succeed LessThan |. symbol "<" + , succeed GreaterThan |. symbol ">" + , succeed Equals |. symbol "==" + , succeed Assign |. symbol "=" + ] + + +addsubtractionParser : Parser Expression +addsubtractionParser = + multiSequence + { separators = + [ ( BinaryOperation Add, symbol "+" ) + , ( BinaryOperation Subtract, symbol "-" ) + ] + , item = multidivisionParser + , allowNegation = False + } + + +type alias SequenceData = + { separators : List ( Expression -> Expression -> Expression, Parser () ) + , item : Parser Expression + , allowNegation : Bool + } + + +multiSequence : SequenceData -> Parser Expression +multiSequence data = + succeed identity + |= data.item + |. spaces + |> Parser.andThen + (\first -> + loop first (\expr -> multiSequenceHelp data expr) + ) + + +multiSequenceHelp : + SequenceData + -> Expression + -> Parser (Step Expression Expression) +multiSequenceHelp { allowNegation, separators, item } acc = + let + separated = + separators + |> List.map + (\( f, parser ) -> + Parser.succeed (\mn e -> Loop <| f acc <| mn e) + |= (if allowNegation then + Parser.oneOf + [ Parser.succeed (UnaryOperation Negate) + |. Parser.symbol "-" + , Parser.succeed identity + ] + + else + Parser.succeed identity + ) + |. parser + |. spaces + |= item + |. spaces + ) + |> Parser.oneOf + in + Parser.oneOf + [ separated + , Parser.succeed (Done acc) + ] + + +multidivisionParser : Parser Expression +multidivisionParser = + multiSequence + { separators = + [ ( BinaryOperation By, symbol "*" ) + , ( BinaryOperation Div, symbol "/" ) + ] + , item = unaryParser + , allowNegation = False + } + + +unaryParser : Parser Expression +unaryParser = + Parser.oneOf + [ succeed (UnaryOperation Negate) + |. symbol "-" + |= atomParser + , atomParser + ] + + +atomParser : Parser Expression +atomParser = + oneOf + [ succeed (\a f -> f a) + |= identifierParser + |= oneOf + [ succeed (\sw v -> Dot v sw) + |. symbol "." + |= identifierParser + , succeed (\args v -> Call v args) + |= sequence + { start = "(" + , separator = "," + , item = Parser.lazy <| \_ -> expressionParser + , end = ")" + , trailing = Forbidden + , spaces = spaces + } + , succeed Variable + ] + , Parser.andThen tryParseNumber <| + getChompedString <| + succeed () + |. chompIf (\c -> c == '.' || Char.isDigit c) + |. chompWhile (\c -> c == '.' || Char.isDigit c) + ] + + +tryParseNumber : String -> Parser Expression +tryParseNumber n = + case String.toInt n of + Just i -> + succeed <| Int i + + Nothing -> + case String.toFloat n of + Just f -> + succeed <| Float f + + Nothing -> + problem "Expected a number" + + +prettyPrint : Either Function Statement -> String +prettyPrint e = + case e of + Left f -> + prettyPrintFunction f + + Right s -> + prettyPrintStatement s + + +prettyPrintFunction : Function -> String +prettyPrintFunction fun = + fun.name + ++ "Couple = " + ++ "fun" + ++ String.fromInt (List.length fun.args) + ++ " " + ++ fun.returnType + ++ "T \"" + ++ fun.name + ++ "\" " + ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ " <| \\" + ++ String.join " " (List.map Tuple.second fun.args) + ++ " ->\n " + ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join "\n ") + ++ "\n\n" + ++ fun.name + ++ "Decl = Tuple.first " + ++ fun.name + ++ "Couple\n" + ++ fun.name + ++ " = Tuple.second " + ++ fun.name + ++ "Couple" + + +prettyPrintStatement : Statement -> String +prettyPrintStatement stat = + case stat of + Expression e next -> + "expr " + ++ prettyPrintExpression e + ++ "(\n" + ++ prettyPrintStatement next + ++ ")" + + For var from LessThan to loop next -> + "for (\"" + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ prettyPrintStatement loop + ++ ") (" + ++ prettyPrintStatement next + ++ ")" + + For var from LessThanOrEquals to loop next -> + "forLeq (" + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ prettyPrintStatement loop + ++ ") (" + ++ prettyPrintStatement next + ++ ")" + + If cond ifTrue next -> + "if_ " + ++ prettyPrintExpression cond + ++ "(\n" + ++ prettyPrintStatement ifTrue + ++ ") (" + ++ prettyPrintStatement next + ++ ")" + + Return e -> + "(return " ++ prettyPrintExpression e ++ ")\n" + + Nop -> + "unsafeNop\n" + + Def t n v next -> + "def " + ++ t + ++ "T \"" + ++ n + ++ "\" (" + ++ prettyPrintExpression v + ++ ") <| \\" + ++ n + ++ " -> \n" + ++ prettyPrintStatement next + + Decl _ _ _ -> + "TODO branch 'Decl _ _ _' not implemented" + + For _ _ _ _ _ _ -> + "TODO branch 'For _ _ _ _ _ _' not implemented" + + +prettyPrintExpression : Expression -> String +prettyPrintExpression e = + let + lisp args = + "(" ++ String.join " " args ++ ")" + in + case e of + BinaryOperation op l r -> + lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] + + Float f -> + lisp [ "float", String.fromFloat f ] + + Int i -> + lisp [ "int", String.fromInt i ] + + Dot v sw -> + v ++ "." ++ sw + + Variable v -> + v + + Call "float" [ arg ] -> + lisp [ "floatCast", prettyPrintExpression arg ] + + Call n args -> + if String.startsWith "vec" n then + if List.all ((==) (Int 0)) args then + n ++ "Zero" + + else + lisp <| + n + :: List.map + (\c -> + case c of + Int 0 -> + "zero" + + Int 1 -> + "one" + + Int i -> + "(float " ++ String.fromInt i ++ ")" + + _ -> + prettyPrintExpression c + ) + args + + else if List.member n [ "sin", "cos" ] then + lisp <| (n ++ "_") :: List.map prettyPrintExpression args + + else + lisp <| n :: List.map prettyPrintExpression args + + Ternary _ _ _ -> + "branch 'Ternary _ _ _' not implemented" + + UnaryOperation Negate ex -> + lisp [ "negate_", prettyPrintExpression ex ] + + BooleanOperation bop l r -> + lisp [ prettyPrintBooleanOperation bop, prettyPrintExpression l, prettyPrintExpression r ] + + RelationOperation rop l r -> + lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] + + +prettyPrintRelationOperation : RelationOperation -> String +prettyPrintRelationOperation op = + case op of + LessThan -> + "lt" + + LessThanOrEquals -> + "leq" + + Equals -> + "eq" + + Assign -> + "assign" + + NotEquals -> + "neq" + + GreaterThanOrEquals -> + "geq" + + GreaterThan -> + "gt" + + +prettyPrintBooleanOperation : BooleanOperation -> String +prettyPrintBooleanOperation op = + case op of + And -> + "and" + + Or -> + "or" + + +prettyPrintBinaryOperation : BinaryOperation -> String +prettyPrintBinaryOperation op = + case op of + Add -> + "add" + + Subtract -> + "subtract" + + By -> + "by" + + Div -> + "div" diff --git a/src/elm/Expression/Graph.elm b/src/elm/Expression/Graph.elm index 0687902a..63581670 100644 --- a/src/elm/Expression/Graph.elm +++ b/src/elm/Expression/Graph.elm @@ -1,6 +1,6 @@ module Expression.Graph exposing (Graph(..), fromExpression, toExpression, toString) -import Expression exposing (AssociativeOperation, BinaryOperation, Expression(..), FunctionName(..), KnownFunction(..), RelationOperation(..), UnaryOperation, getFreeVariables) +import Expression exposing (Expression(..), FunctionName(..), KnownFunction(..), RelationOperation(..), getFreeVariables) import Expression.Simplify import Expression.Utils exposing (minus) import Set @@ -18,16 +18,6 @@ type Graph | GraphList (List Graph) -type GraphExpression - = GFloat Float - | GVariable String - | GAssociative AssociativeOperation GraphExpression GraphExpression (List GraphExpression) - | GBinary BinaryOperation GraphExpression GraphExpression - | GUnary UnaryOperation GraphExpression - | GApply FunctionName (List GraphExpression) - | GList (List GraphExpression) - - fromExpression : Expression -> Graph fromExpression = let diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index a062bf86..b705888b 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1094,27 +1094,7 @@ straightFunctionToGlsl name = """ } ] Mbrot22 -> - [ unknownFunDecl { name = "cmbrot", type_ = "TODO", body = """ - vec2 cmbrot(vec2 x, vec2 y) { - vec2 c = x + vec2(-y.y, y.x); - - float p = length(c - vec2(0.25, 0)); - if(c.x <= p - 2.0*p*p + 0.25 || length(c + vec2(1,0)) <= 0.25) - return vec2(0,0); - - vec2 z = c; - for(int i = 0; i < 4000; i++) { - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - if(length(z) > 1000000.0) { - float logLength = log(length(z)); - float nu = log(logLength / log(2.0)) / log(2.0); - float fi = float(i) - nu; - return vec2(sin(fi),cos(fi)); - } - } - return vec2(0,0); - } - """ } ] + [ cmbrotDecl ] cexpTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) @@ -1214,6 +1194,47 @@ cmax = Tuple.second cmaxTuple +cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cmbrotCouple = + fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| + \x y -> + def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| + \c -> + def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| + \p -> + if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) + (return vec2Zero) + (def vec2T "z" c <| + \z -> + for ( "i", int 0, int 4000 ) + (\i -> + expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) + (if_ (gt (length z) (float 1000000)) + (def floatT "logLength" (log (length z)) <| + \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| + \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| + \fi -> + return (vec2 (sin_ fi) (cos_ fi)) + ) + unsafeNop + ) + ) + (return vec2Zero) + ) + + +cmbrotDecl : FunDecl +cmbrotDecl = + Tuple.first cmbrotCouple + + +cmbrot : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cmbrot = + Tuple.second cmbrotCouple + + csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csqrtTuple = fun1 vec2T "csqrt" (vec2T "z") <| @@ -1674,8 +1695,8 @@ toSrcImplicit suffix e = ) (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> - assign perc - (pow perc <| float 0.2) + expr + (assign perc (pow perc <| float 0.2)) (return <| byF perc (vec3 one one one)) ) ) @@ -2219,8 +2240,9 @@ expressionToGlsl context = -- csolve (go e) -- PApply (KnownFunction Mod) [ e ] -> -- cmod (go e) - -- PApply (KnownFunction Mbrot) [ e ] -> - -- cmbrot (go e) + PApply (KnownFunction Mbrot) [ x, y ] -> + cmbrot (go x) (go y) + -- PApply (KnownFunction For) [ e ] -> -- cfor (go e) PApply (KnownFunction Min) es -> @@ -2466,7 +2488,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor pixel2 unsafeNop + expr (assign gl_FragColor pixel2) + unsafeNop ] ( [], _ ) -> @@ -2479,7 +2502,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor pixel3 unsafeNop + expr (assign gl_FragColor pixel3) + unsafeNop ] _ -> @@ -2496,7 +2520,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - assign gl_FragColor (max4 pixel2 pixel3) unsafeNop + expr (assign gl_FragColor (max4 pixel2 pixel3)) + unsafeNop ] @@ -2589,8 +2614,9 @@ addPixel deltaX deltaY x y px curr i { call, color } next = else call deltaX deltaY x y in - assign curr k <| - assign px (ternary3 (eq curr vec3Zero) px curr) next + expr (assign curr k) <| + expr (assign px (ternary3 (eq curr vec3Zero) px curr)) + next axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index c8961d68..2d3bed61 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -438,6 +438,11 @@ ternary3 = expr33 Ternary +and : ExpressionX a Bool -> ExpressionX b Bool -> Expression1 Bool +and = + expr2 And + + ands : List (Expression1 Bool) -> Expression1 Bool ands es = case es of @@ -448,6 +453,11 @@ ands es = List.foldl (\e a -> expr2 And a e) h t +or : ExpressionX a Bool -> ExpressionX b Bool -> Expression1 Bool +or = + expr2 Or + + ors : List (Expression1 Bool) -> Expression1 Bool ors es = case es of @@ -1414,9 +1424,14 @@ def4 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ) ks -assign : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q -assign name e (Statement next) = - Statement <| ExpressionStatement (Assign (unwrapExpression name) (unwrapExpression e)) next +assign : ExpressionX a t -> ExpressionX b t -> Expression1 t +assign name e = + dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) + + +expr : ExpressionX a t -> Statement q -> Statement q +expr e (Statement next) = + Statement <| ExpressionStatement (unwrapExpression e) next assignAdd : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q From 76eae688b185edf2c6b7523c534ea3994e4c252d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 05:47:45 +0200 Subject: [PATCH 033/139] All functions codegenned --- glslParser/src/GlslConverter.elm | 136 ++++++----- src/elm/UI/Glsl/Code.elm | 373 +++++++++++++++++++++++-------- src/elm/UI/Glsl/Generator.elm | 11 +- 3 files changed, 369 insertions(+), 151 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 68ac415c..75134d83 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -1,7 +1,7 @@ module GlslConverter exposing (main) import Browser -import Element as Element exposing (Element, column, el, fill, height, padding, row, scrollbarY, spacing, text, width) +import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbarY, scrollbars, spacing, text, width) import Element.Border as Border import Element.Font as Font import Element.Input as Input @@ -32,25 +32,14 @@ init : Model init = let i = - """vec2 cmbrot(vec2 x, vec2 y) { - vec2 c = x + vec2(-y.y, y.x); - - float p = length(c - vec2(0.25, 0)); - if(c.x <= p - 2.0*p*p + 0.25 || length(c + vec2(1,0)) <= 0.25) - return vec2(0,0); - - vec2 z = c; - for(int i = 0; i < 4000; i++) { - z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; - if(length(z) > 1000000.0) { - float logLength = log(length(z)); - float nu = log(logLength / log(2.0)) / log(2.0); - float fi = float(i) - nu; - return vec2(sin(fi),cos(fi)); - } - } - return vec2(0,0); -}""" + """vec2 ccbrt(vec2 z) { + if(z.y == 0.0) { + return vec2(sign(z.x) * pow(z.x, 1.0 / 3.0), 0); + } + float r = pow(dot(z, z), 1.0 / 6.0); + float t = atan(z.y, z.x) / 3.0 + (z.x > 0.0 ? 0.0 : radians(120.0)); + return r * vec2(cos(t), sin(t)); + }""" in { input = i , output = toOutput i @@ -88,26 +77,35 @@ input value = output : String -> Element Msg output value = let - tc = - Html.pre [] [ Html.text value ] - |> Element.html - |> el - [ width fill - , height fill - , Border.width 1 - , Font.family [ Font.typeface "Fira Code", Font.monospace ] - , padding 10 - , scrollbarY - ] + bordering = + el + [ width fill + , height fill + , Border.width 1 + , Font.family [ Font.typeface "Fira Code", Font.monospace ] + , padding 10 + , scrollbars + ] in - column - [ spacing 10 - , width fill - , height fill - ] - [ text "Output (Elm code)" - , tc - ] + if String.contains "problem" value then + paragraph [] [ text value ] + |> bordering + + else + let + tc = + Html.pre [] [ Html.text value ] + |> Element.html + |> bordering + in + column + [ spacing 10 + , width fill + , height fill + ] + [ text "Output (Elm code)" + , tc + ] update : Msg -> Model -> Model @@ -363,7 +361,25 @@ defParser = expressionParser : Parser Expression expressionParser = - booleanParser + ternaryParser + + +ternaryParser : Parser Expression +ternaryParser = + Parser.succeed (\c f -> f c) + |= booleanParser + |. spaces + |= oneOf + [ succeed (\t f c -> Ternary c t f) + |. symbol "?" + |. spaces + |= booleanParser + |. spaces + |. symbol ":" + |. spaces + |= Parser.lazy (\_ -> ternaryParser) + , succeed identity + ] booleanParser : Parser Expression @@ -497,7 +513,13 @@ unaryParser = atomParser : Parser Expression atomParser = oneOf - [ succeed (\a f -> f a) + [ succeed identity + |. symbol "(" + |. spaces + |= Parser.lazy (\_ -> expressionParser) + |. spaces + |. symbol ")" + , succeed (\a f -> f a) |= identifierParser |= oneOf [ succeed (\sw v -> Dot v sw) @@ -624,7 +646,7 @@ prettyPrintStatement stat = ++ ")" Return e -> - "(return " ++ prettyPrintExpression e ++ ")\n" + "(return <| " ++ prettyPrintExpression e ++ ")\n" Nop -> "unsafeNop\n" @@ -659,7 +681,14 @@ prettyPrintExpression e = lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] Float f -> - lisp [ "float", String.fromFloat f ] + if f == 0 then + "zero" + + else if f == 1 then + "one" + + else + lisp [ "float", String.fromFloat f ] Int i -> lisp [ "int", String.fromInt i ] @@ -684,28 +713,29 @@ prettyPrintExpression e = :: List.map (\c -> case c of - Int 0 -> - "zero" - - Int 1 -> - "one" - Int i -> - "(float " ++ String.fromInt i ++ ")" + prettyPrintExpression (Float <| toFloat i) _ -> prettyPrintExpression c ) args - else if List.member n [ "sin", "cos" ] then + else if n == "atan" then + if List.length args == 2 then + lisp <| "atan2_" :: List.map prettyPrintExpression args + + else + lisp <| "atan_" :: List.map prettyPrintExpression args + + else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil" ] then lisp <| (n ++ "_") :: List.map prettyPrintExpression args else lisp <| n :: List.map prettyPrintExpression args - Ternary _ _ _ -> - "branch 'Ternary _ _ _' not implemented" + Ternary c l r -> + lisp [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] UnaryOperation Negate ex -> lisp [ "negate_", prettyPrintExpression ex ] diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index b705888b..2ebf872a 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -907,6 +907,60 @@ ccosh = Tuple.second ccoshTuple +ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ctanhCouple = + fun1 vec2T "ctanh" (vec2T "z") <| + \z -> + def2 + ( vec2T "p", cexp z ) + ( vec2T "m", cexp (negate_ z) ) + <| + \p m -> + return <| cdiv (subtract p m) (add p m) + + +ctanhDecl : FunDecl +ctanhDecl = + Tuple.first ctanhCouple + + +ctanh : ExpressionX xa Vec2 -> Expression2 +ctanh = + Tuple.second ctanhCouple + + +cabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cabsCouple = + fun1 vec2T "cabs" (vec2T "z") <| \z -> return <| vec2 (length z) zero + + +cabsDecl : FunDecl +cabsDecl = + Tuple.first cabsCouple + + +cabs : ExpressionX xa Vec2 -> Expression2 +cabs = + Tuple.second cabsCouple + + +csignCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +csignCouple = + fun1 vec2T "csign" (vec2T "z") <| + \z -> + return <| vec2 (sign z.x) (sign z.y) + + +csignDecl : FunDecl +csignDecl = + Tuple.first csignCouple + + +csign : ExpressionX xa Vec2 -> Expression2 +csign = + Tuple.second csignCouple + + intervalOperationToGlsl : GlslOperation -> List FunDecl intervalOperationToGlsl op = case op of @@ -986,42 +1040,19 @@ straightFunctionToGlsl name = [ ccoshDecl ] Tanh22 -> - [ unknownFunDecl { name = "ctanh", type_ = "TODO", body = """ - vec2 ctanh(vec2 z) { - vec2 p = cexp(z); - vec2 m = cexp(-z); - return cdiv(p - m, p + m); - } - """ } ] + [ ctanhDecl ] Abs22 -> - [ unknownFunDecl { name = "cabs", type_ = "TODO", body = """ - vec2 cabs(vec2 z) { - return vec2(length(z), 0.0); - } - """ } ] + [ cabsDecl ] Sign22 -> - [ unknownFunDecl { name = "csign", type_ = "TODO", body = """ - vec2 csign(vec2 z) { - return vec2(sign(z.x), sign(z.y)); - } - """ } ] + [ csignDecl ] Sqrt22 -> [ csqrtDecl ] Cbrt22 -> - [ unknownFunDecl { name = "ccbrt", type_ = "TODO", body = """ - vec2 ccbrt(vec2 z) { - if(z.y == 0.0) { - return vec2(sign(z.x) * pow(z.x, 1.0 / 3.0), 0); - } - float r = pow(dot(z, z), 1.0 / 6.0); - float t = atan(z.y, z.x) / 3.0 + (z.x > 0.0 ? 0.0 : radians(120.0)); - return r * vec2(cos(t), sin(t)); - } - """ } ] + [ ccbrtDecl ] Square22 -> [ csquareDecl ] @@ -1030,11 +1061,7 @@ straightFunctionToGlsl name = [ clnDecl ] Log1022 -> - [ unknownFunDecl { name = "clog10", type_ = "TODO", body = """ - vec2 clog10(vec2 z) { - return cdiv(cln(z), vec2(log(10.0), 0)); - } - """ } ] + [ clog10Decl ] Exp22 -> [ cexpDecl ] @@ -1043,42 +1070,22 @@ straightFunctionToGlsl name = [ creDecl ] Im22 -> - [ unknownFunDecl { name = "cim", type_ = "TODO", body = """ - vec2 cim(vec2 z) { - return vec2(z.y, 0.0); - } - """ } ] + [ cimDecl ] Arg22 -> [ argDecl, cargDecl ] Pw22 -> - [ unknownFunDecl { name = "cpw", type_ = "TODO", body = """ - vec2 cpw(vec2 c, vec2 t, vec2 f) { - return c.x > 0.0 ? t : f; - } - """ } ] + [ cpwDecl ] Ceiling22 -> - [ unknownFunDecl { name = "cceiling", type_ = "TODO", body = """ - vec2 cceiling(vec2 z) { - return ceil(z); - } - """ } ] + [ cceilingDecl ] Floor22 -> - [ unknownFunDecl { name = "cfloor", type_ = "TODO", body = """ - vec2 cfloor(vec2 z) { - return floor(z); - } - """ } ] + [ cfloorDecl ] Round22 -> - [ unknownFunDecl { name = "cround", type_ = "TODO", body = """ - vec2 cround(vec2 z) { - return floor(z + vec2(0.5, 0.5)); - } - """ } ] + [ croundDecl ] Min222 -> [ cminDecl ] @@ -1087,11 +1094,7 @@ straightFunctionToGlsl name = [ cmaxDecl ] Mod22 -> - [ unknownFunDecl { name = "cmod", type_ = "TODO", body = """ - vec2 cmod(vec2 l, vec2 r) { - return vec2(mod(l.x, r.x), 0); - } - """ } ] + [ cmodDecl ] Mbrot22 -> [ cmbrotDecl ] @@ -1134,6 +1137,21 @@ cre = Tuple.second creTuple +cimCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cimCouple = + fun1 vec2T "cim" (vec2T "z") <| \z -> return <| vec2 z.y zero + + +cimDecl : FunDecl +cimDecl = + Tuple.first cimCouple + + +cim : ExpressionX xa Vec2 -> Expression2 +cim = + Tuple.second cimCouple + + argTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression1 Float ) argTuple = fun1 floatT "arg" (vec2T "v") <| \v -> return <| atan2_ v.y v.x @@ -1164,6 +1182,69 @@ carg = Tuple.second cargTuple +cpwCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) +cpwCouple = + fun3 vec2T "cpw" (vec2T "c") (vec2T "t") (vec2T "f") <| + \c t f -> return <| ternary (gt c.x zero) t f + + +cpwDecl : FunDecl +cpwDecl = + Tuple.first cpwCouple + + +cpw : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 +cpw = + Tuple.second cpwCouple + + +cceilingCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cceilingCouple = + fun1 vec2T "cceiling" (vec2T "z") <| \z -> return <| ceil_ z + + +cceilingDecl : FunDecl +cceilingDecl = + Tuple.first cceilingCouple + + +cceiling : ExpressionX xa Vec2 -> Expression2 +cceiling = + Tuple.second cceilingCouple + + +cfloorCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +cfloorCouple = + fun1 vec2T "cfloor" (vec2T "z") <| \z -> return <| floor_ z + + +cfloorDecl : FunDecl +cfloorDecl = + Tuple.first cfloorCouple + + +cfloor : ExpressionX xa Vec2 -> Expression2 +cfloor = + Tuple.second cfloorCouple + + +croundCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +croundCouple = + fun1 vec2T "cround" (vec2T "z") <| + \z -> + return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) + + +croundDecl : FunDecl +croundDecl = + Tuple.first croundCouple + + +cround : ExpressionX xa Vec2 -> Expression2 +cround = + Tuple.second croundCouple + + cminTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cminTuple = fun2 vec2T "cmin" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (lt l.x r.x) l r @@ -1194,6 +1275,23 @@ cmax = Tuple.second cmaxTuple +cmodCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) +cmodCouple = + fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| + \l r -> + return <| vec2 (mod l.x r.x) zero + + +cmodDecl : FunDecl +cmodDecl = + Tuple.first cmodCouple + + +cmod : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 +cmod = + Tuple.second cmodCouple + + cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmbrotCouple = fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| @@ -1216,7 +1314,7 @@ cmbrotCouple = \nu -> def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return (vec2 (sin_ fi) (cos_ fi)) + return <| vec2 (sin_ fi) (cos_ fi) ) unsafeNop ) @@ -1260,6 +1358,49 @@ csqrt = Tuple.second csqrtTuple +ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +ccbrtCouple = + fun1 vec2T "ccbrt" (vec2T "z") <| + \z -> + if_ (eq z.y zero) + (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) + (def floatT "r" (pow (dot z z) (div one (float 6))) <| + \r -> + def floatT + "t" + (add (div (atan2_ z.y z.x) (float 3)) + (ternary + (gt z.x zero) + zero + (radians_ (float 120)) + ) + ) + <| + \t -> + return <| byF r (vec2 (cos_ t) (sin_ t)) + ) + + +ccbrtDecl : FunDecl +ccbrtDecl = + Tuple.first ccbrtCouple + + +ccbrt : ExpressionX xa Vec2 -> Expression2 +ccbrt = + Tuple.second ccbrtCouple + + +ccbrtDecl : FunDecl +ccbrtDecl = + Tuple.first ccbrtCouple + + +ccbrt : ExpressionX xa Vec2 -> Expression2 +ccbrt = + Tuple.second ccbrtCouple + + csquareTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csquareTuple = fun1 vec2T "csquare" (vec2T "z") <| \z -> return <| cby z z @@ -1300,6 +1441,21 @@ cln = Tuple.second clnTuple +clog10Couple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +clog10Couple = + fun1 vec2T "clog10" (vec2T "z") <| \z -> return <| cdiv (cln z) (vec2 (log (float 10)) zero) + + +clog10Decl : FunDecl +clog10Decl = + Tuple.first clog10Couple + + +clog10 : ExpressionX xa Vec2 -> Expression2 +clog10 = + Tuple.second clog10Couple + + intervalFunctionToGlsl : GlslFunction -> String intervalFunctionToGlsl name = case name of @@ -1770,12 +1926,14 @@ constants : , pihalf : ExpressionX { isConstant : Constant } Float , pi : ExpressionX { isConstant : Constant } Float , twopi : ExpressionX { isConstant : Constant } Float + , vectorSpacing : ExpressionX { isConstant : Constant } Float } constants = { maxIterations = constant intT "MAX_ITERATIONS" , pihalf = constant floatT "PIHALF" , pi = constant floatT "PI" , twopi = constant floatT "TWOPI" + , vectorSpacing = constant floatT "VECTOR_SPACING" } @@ -1917,15 +2075,26 @@ toSrcVectorField2D suffix xexpr yexpr = ( floatT "angleVector", arg vect ) <| \angleCorner angleVector -> - unknownStatement - (""" - float delta = mod(angleCorner - angleVector, TWOPI); - float l = length(vect) / mx; - float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); - float wantedLength = length(o - corner); - float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); - return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; - """) + def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| + \delta -> + def floatT "l" (div (length vect) mx) <| + \l -> + def floatT + "maxLength" + (by (by deltaX constants.vectorSpacing) + (ternary + (lt l (float epsilon)) + zero + (add (div l (float 2)) (float 0.5)) + ) + ) + <| + \maxLength -> + def floatT "wantedLength" (length (subtract o corner)) <| + \wantedLength -> + def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| + \angularDistance -> + return <| and (or (lt delta (radians_ angularDistance)) (gt delta (radians_ (subtract (float 360) angularDistance)))) (lt wantedLength maxLength) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| @@ -2158,6 +2327,9 @@ expressionToGlsl context = Nothing -> dotted2 <| unknown <| "Variable " ++ v ++ " is undefined" + PPower l (PInteger 2) -> + csquare (go l) + PPower l r -> cpow (go l) (go r) @@ -2191,29 +2363,35 @@ expressionToGlsl context = PApply (KnownFunction Cosh) [ e ] -> ccosh (go e) - -- PApply (KnownFunction Tanh) [ e ] -> - -- ctanh (go e) - -- PApply (KnownFunction Abs) [ e ] -> - -- cabs (go e) + PApply (KnownFunction Tanh) [ e ] -> + ctanh (go e) + + PApply (KnownFunction Abs) [ e ] -> + cabs (go e) + -- PApply (KnownFunction (Root r)) [ e ] -> -- croot r (go e) PApply (KnownFunction Ln) [ e ] -> cln (go e) - -- PApply (KnownFunction Log10) [ e ] -> - -- clog10 (go e) + PApply (KnownFunction Log10) [ e ] -> + clog10 (go e) + PApply (KnownFunction Exp) [ e ] -> cexp (go e) - -- PApply (KnownFunction Sign) [ e ] -> - -- csign (go e) + PApply (KnownFunction Sign) [ e ] -> + csign (go e) + PApply (KnownFunction Re) [ e ] -> cre (go e) - -- PApply (KnownFunction Im) [ e ] -> - -- cim (go e) - -- PApply (KnownFunction Arg) [ e ] -> - -- carg (go e) + PApply (KnownFunction Im) [ e ] -> + cim (go e) + + PApply (KnownFunction Arg) [ e ] -> + carg (go e) + -- PApply (KnownFunction Gra) [ e ] -> -- cgra (go e) -- PApply (KnownFunction Det) [ e ] -> @@ -2222,14 +2400,18 @@ expressionToGlsl context = -- cdd (go e) -- PApply (KnownFunction Ii) [ e ] -> -- cii (go e) - -- PApply (KnownFunction Round) [ e ] -> - -- cround (go e) - -- PApply (KnownFunction Floor) [ e ] -> - -- cfloor (go e) - -- PApply (KnownFunction Ceiling) [ e ] -> - -- cceiling (go e) - -- PApply (KnownFunction Pw) [ e ] -> - -- cpw (go e) + PApply (KnownFunction Round) [ e ] -> + cround (go e) + + PApply (KnownFunction Floor) [ e ] -> + cfloor (go e) + + PApply (KnownFunction Ceiling) [ e ] -> + cceiling (go e) + + PApply (KnownFunction Pw) [ c, t, f ] -> + cpw (go c) (go t) (go f) + -- PApply (KnownFunction Plot) [ e ] -> -- cplot (go e) -- PApply (KnownFunction APlot) [ e ] -> @@ -2238,8 +2420,9 @@ expressionToGlsl context = -- cstepSimplify (go e) -- PApply (KnownFunction Solve) [ e ] -> -- csolve (go e) - -- PApply (KnownFunction Mod) [ e ] -> - -- cmod (go e) + PApply (KnownFunction Mod) [ l, r ] -> + cmod (go l) (go r) + PApply (KnownFunction Mbrot) [ x, y ] -> cmbrot (go x) (go y) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 2d3bed61..49b1a78d 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -785,12 +785,17 @@ log2 = dotted1 << call1Internal "log2" -ceil_ : ExpressionX a Float -> Expression1 Float +ceil_ : ExpressionX a t -> Expression1 t ceil_ = dotted1 << call1Internal "ceil" -round_ : ExpressionX a Float -> Expression1 Float +floor_ : ExpressionX a t -> Expression1 t +floor_ = + dotted1 << call1Internal "floor" + + +round_ : ExpressionX a t -> Expression1 t round_ = dotted1 << call1Internal "round" From 8ebbbc690bdfcb27ceb034983afb77962eb577f0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 05:48:55 +0200 Subject: [PATCH 034/139] Fix --- src/elm/UI/Glsl/Code.elm | 10 ---------- src/elm/UI/Glsl/Generator.elm | 12 ++++++------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 2ebf872a..498339c2 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1391,16 +1391,6 @@ ccbrt = Tuple.second ccbrtCouple -ccbrtDecl : FunDecl -ccbrtDecl = - Tuple.first ccbrtCouple - - -ccbrt : ExpressionX xa Vec2 -> Expression2 -ccbrt = - Tuple.second ccbrtCouple - - csquareTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csquareTuple = fun1 vec2T "csquare" (vec2T "z") <| \z -> return <| cby z z diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 49b1a78d..83759f09 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1132,10 +1132,10 @@ dotted33Internal e = uniform : TypingFunction t c -> String -> c uniform typeF name = let - ( TypedName _ _ expr, _ ) = + ( TypedName _ _ e, _ ) = typeF name in - expr + e unknown : String -> Expression t @@ -1183,8 +1183,8 @@ argToString (TypedName (Type t) (Name n) _) = toVar : TypedName t c -> c -toVar (TypedName _ _ expr) = - expr +toVar (TypedName _ _ e) = + e fun0 : @@ -1731,8 +1731,8 @@ innerValue2 ctx l r k = autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result ErrorValue ( Dict String GlslValue, GlslValue ) -autovectorizingFloatOp ctx name inner expr = - innerValue ctx expr +autovectorizingFloatOp ctx name inner e = + innerValue ctx e |> Result.andThen (\( ctx2, v ) -> case v of From b3b6662da2efeeb07fcca8806aeb7bed4296096f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 19:43:09 +0200 Subject: [PATCH 035/139] It's long and nice --- glslParser/src/GlslConverter.elm | 213 +++++++++++++++++++++---------- src/elm/UI/Glsl/Code.elm | 68 ++++++---- src/elm/UI/Glsl/Generator.elm | 98 ++++++++++++-- 3 files changed, 278 insertions(+), 101 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 75134d83..14fac3f1 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -1,7 +1,7 @@ module GlslConverter exposing (main) import Browser -import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbarY, scrollbars, spacing, text, width) +import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbars, spacing, text, width) import Element.Border as Border import Element.Font as Font import Element.Input as Input @@ -32,14 +32,52 @@ init : Model init = let i = - """vec2 ccbrt(vec2 z) { - if(z.y == 0.0) { - return vec2(sign(z.x) * pow(z.x, 1.0 / 3.0), 0); - } - float r = pow(dot(z, z), 1.0 / 6.0); - float t = atan(z.y, z.x) / 3.0 + (z.x > 0.0 ? 0.0 : radians(120.0)); - return r * vec2(cos(t), sin(t)); - }""" + """{for(int it = 0; it < MAX_ITERATIONS; it++) { + float midpoint = mix(from, to, 0.5); + vec2 front = interval\"\"\" ++ suffix ++ \"\"\"(p, from, midpoint); + vec2 back = interval\"\"\" ++ suffix ++ \"\"\"(p, midpoint, to); + if(depth >= MAX_DEPTH + || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) + || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) + ) + return vec3(1,1,1); + if(front.x <= 0.0 && front.y >= 0.0) { + to = midpoint; + depth++; + choices = choices * 2; + } else if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + } else { + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval\"\"\" ++ suffix ++ \"\"\"(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return vec3(0,0,0); + } + } + return vec3(0,0,0); + + +}""" in { input = i , output = toOutput i @@ -130,6 +168,7 @@ type alias Function = , name : String , args : List ( String, String ) , body : Statement + , hasSuffix : Bool } @@ -180,6 +219,7 @@ type Expression | BinaryOperation BinaryOperation Expression Expression | BooleanOperation BooleanOperation Expression Expression | RelationOperation RelationOperation Expression Expression + | PostfixIncrement Expression type Either a b @@ -202,10 +242,10 @@ parse = functionParser : Parser Function functionParser = - succeed Function + succeed (\returnType { name, hasSuffix } args body -> { returnType = returnType, name = name, hasSuffix = hasSuffix, args = args, body = body }) |= typeParser |. spaces - |= identifierParser + |= identifierWithSuffixParser |. spaces |= sequence { start = "(" @@ -227,12 +267,23 @@ argParser = |= identifierParser +identifierWithSuffixParser : Parser { name : String, hasSuffix : Bool } +identifierWithSuffixParser = + succeed (\name hasSuffix -> { name = name, hasSuffix = hasSuffix }) + |= identifierParser + |= oneOf + [ succeed True |. symbol "\"\"\" ++ suffix ++ \"\"\"" + , succeed False + ] + + identifierParser : Parser String identifierParser = - getChompedString <| - succeed () + getChompedString + (succeed () |. chompIf (\c -> Char.isAlpha c || c == '_') |. chompWhile (\c -> Char.isAlphaNum c || c == '_') + ) typeParser : Parser String @@ -512,36 +563,43 @@ unaryParser = atomParser : Parser Expression atomParser = - oneOf - [ succeed identity - |. symbol "(" - |. spaces - |= Parser.lazy (\_ -> expressionParser) - |. spaces - |. symbol ")" - , succeed (\a f -> f a) - |= identifierParser - |= oneOf - [ succeed (\sw v -> Dot v sw) - |. symbol "." - |= identifierParser - , succeed (\args v -> Call v args) - |= sequence - { start = "(" - , separator = "," - , item = Parser.lazy <| \_ -> expressionParser - , end = ")" - , trailing = Forbidden - , spaces = spaces - } - , succeed Variable - ] - , Parser.andThen tryParseNumber <| - getChompedString <| - succeed () - |. chompIf (\c -> c == '.' || Char.isDigit c) - |. chompWhile (\c -> c == '.' || Char.isDigit c) - ] + succeed (\a f -> f a) + |= oneOf + [ succeed identity + |. symbol "(" + |. spaces + |= Parser.lazy (\_ -> expressionParser) + |. spaces + |. symbol ")" + , succeed (\a f -> f a) + |= Parser.map .name identifierWithSuffixParser + |= oneOf + [ succeed (\sw v -> Dot v sw) + |. symbol "." + |= identifierParser + , succeed (\args v -> Call v args) + |= sequence + { start = "(" + , separator = "," + , item = Parser.lazy <| \_ -> expressionParser + , end = ")" + , trailing = Forbidden + , spaces = spaces + } + , succeed Variable + ] + , Parser.andThen tryParseNumber <| + getChompedString <| + succeed () + |. chompIf (\c -> c == '.' || Char.isDigit c) + |. chompWhile (\c -> c == '.' || Char.isDigit c) + ] + |. spaces + |= oneOf + [ succeed PostfixIncrement + |. symbol "++" + , succeed identity + ] tryParseNumber : String -> Parser Expression @@ -571,29 +629,49 @@ prettyPrint e = prettyPrintFunction : Function -> String prettyPrintFunction fun = - fun.name - ++ "Couple = " - ++ "fun" - ++ String.fromInt (List.length fun.args) - ++ " " - ++ fun.returnType - ++ "T \"" - ++ fun.name - ++ "\" " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) - ++ " <| \\" - ++ String.join " " (List.map Tuple.second fun.args) - ++ " ->\n " - ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join "\n ") - ++ "\n\n" - ++ fun.name - ++ "Decl = Tuple.first " - ++ fun.name - ++ "Couple\n" - ++ fun.name - ++ " = Tuple.second " - ++ fun.name - ++ "Couple" + if fun.hasSuffix then + "(" + ++ fun.name + ++ "Decl, " + ++ fun.name + ++ ") = fun" + ++ String.fromInt (List.length fun.args) + ++ " " + ++ fun.returnType + ++ "T " + ++ "(\"" + ++ fun.name + ++ "\" ++ suffix)" + ++ " " + ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ " <| \\" + ++ String.join " " (List.map Tuple.second fun.args) + ++ " -> " + ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join " ") + + else + fun.name + ++ "Couple = fun" + ++ String.fromInt (List.length fun.args) + ++ " " + ++ fun.returnType + ++ "T \"" + ++ fun.name + ++ "\" " + ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ " <| \\" + ++ String.join " " (List.map Tuple.second fun.args) + ++ " ->\n " + ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join "\n ") + ++ "\n\n" + ++ fun.name + ++ "Decl = Tuple.first " + ++ fun.name + ++ "Couple\n" + ++ fun.name + ++ " = Tuple.second " + ++ fun.name + ++ "Couple" prettyPrintStatement : Statement -> String @@ -746,6 +824,9 @@ prettyPrintExpression e = RelationOperation rop l r -> lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] + PostfixIncrement c -> + lisp [ "plusPostfix", prettyPrintExpression c ] + prettyPrintRelationOperation : RelationOperation -> String prettyPrintRelationOperation op = diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 498339c2..89ddc334 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1913,6 +1913,7 @@ toSrcPolar suffix e = constants : { maxIterations : ExpressionX { isConstant : Constant } Int + , maxDepth : ExpressionX { isConstant : Constant } Int , pihalf : ExpressionX { isConstant : Constant } Float , pi : ExpressionX { isConstant : Constant } Float , twopi : ExpressionX { isConstant : Constant } Float @@ -1920,6 +1921,7 @@ constants : } constants = { maxIterations = constant intT "MAX_ITERATIONS" + , maxDepth = constant intT "MAX_DEPTH" , pihalf = constant floatT "PIHALF" , pi = constant floatT "PI" , twopi = constant floatT "TWOPI" @@ -1944,24 +1946,45 @@ toSrcParametric suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - unknownStatement - (""" - float max_distance = pow(2.0, 10.0); - float from = -max_distance / 2.0; - float to = max_distance / 2.0; - vec2 p = vec2(x, y); - int depth = 0; - int choices = 0; - float ithreshold = 10.0 * deltaX * deltaX; - for(int it = 0; it < MAX_ITERATIONS; it++) { - float midpoint = mix(from, to, 0.5); - vec2 front = interval""" ++ suffix ++ """(p, from, midpoint); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(depth >= MAX_DEPTH - || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) - || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) - ) - return vec3(1,1,1); + def floatT "max_distance" (float <| 2 ^ 10) <| + \max_distance -> + def6 + ( floatT "from", div (negate_ max_distance) (float 2) ) + ( floatT "to", div max_distance (float 2) ) + ( vec2T "p", vec2 x y ) + ( intT "depth", int 0 ) + ( intT "choices", int 0 ) + ( floatT "ithreshold", by (by (float 10) deltaX) deltaX ) + <| + \from to p depth choices ithreshold -> + for ( "it", int 0, constants.maxIterations ) + (\_ -> + def floatT "midpoint" (mix from to <| float 0.5) <| + \midpoint -> + def2 + ( vec2T "front", interval p from midpoint ) + ( vec2T "back", interval p midpoint to ) + <| + \front back -> + if_ + (ors + [ geq depth constants.maxDepth + , ands + [ lt (subtract front.y front.x) ithreshold + , leq front.x zero + , geq front.y zero + ] + , ands + [ lt (subtract back.y back.x) ithreshold + , leq back.x zero + , geq back.y zero + ] + ] + ) + (return <| vec3 one one one) + (unknownStatement + (""" + if(front.x <= 0.0 && front.y >= 0.0) { to = midpoint; depth++; @@ -1994,9 +2017,10 @@ toSrcParametric suffix e = if(depth == 0) return vec3(0,0,0); } - } - return vec3(0,0,0); - """) + """) + ) + ) + (return vec3Zero) in ( [ intervalDecl, pixelDecl ], pixel ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 83759f09..aaf4fbf0 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -15,6 +15,7 @@ type FunDecl type Stat = If Expr Stat Stat + | IfElse Expr Stat Stat Stat | For String Expr RelationOperation Expr Stat Stat | Line String | Return Expr @@ -148,12 +149,23 @@ statementToGlsl (Statement r) = let go i c = case c of - If cond t f -> + If cond t n -> [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") , go (i + 1) t , indent i "}" , "" - , go i f + , go i n + ] + |> String.join "\n" + + IfElse cond t f n -> + [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") + , go (i + 1) t + , indent i "} else {" + , go (i + 1) f + , indent i "}" + , "" + , go i n ] |> String.join "\n" @@ -1312,9 +1324,14 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body ) -if_ : Expression1 Bool -> Statement r -> Statement r -> Statement r -if_ cond (Statement ifTrue) (Statement ifFalse) = - Statement <| If (unwrapExpression cond) ifTrue ifFalse +if_ : Expression1 Bool -> Statement q -> Statement r -> Statement r +if_ cond (Statement ifTrue) (Statement next) = + Statement <| If (unwrapExpression cond) ifTrue next + + +ifElse : Expression1 Bool -> Statement q -> Statement r -> Statement s -> Statement s +ifElse cond (Statement ifTrue) (Statement ifFalse) (Statement next) = + Statement <| IfElse (unwrapExpression cond) ifTrue ifFalse next for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r @@ -1374,10 +1391,6 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks - ---def2 : ( TypingFunction tv v, String, ExpressionX xv tv ) -> ( TypingFunction tw w, String, ExpressionX xw tw ) -> (v -> w -> Statement tr) -> Statement tr - - def2 : ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) @@ -1429,6 +1442,52 @@ def4 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ) ks +def5 : + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) + -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) + -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) + -> ( ( TypedName te e, Expression te -> e ), ExpressionX xe te ) + -> (a -> b -> c -> d -> e -> Statement r) + -> Statement r +def5 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) ( ( TypedName (Type t4) n4 e4, _ ), v4 ) k = + let + (Statement ks) = + k e0 e1 e2 e3 e4 + in + Statement <| + Decl t0 n0 (Just <| unwrapExpression v0) <| + Decl t1 n1 (Just <| unwrapExpression v1) <| + Decl t2 n2 (Just <| unwrapExpression v2) <| + Decl t3 n3 (Just <| unwrapExpression v3) <| + Decl t4 n4 (Just <| unwrapExpression v4) <| + ks + + +def6 : + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) + -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) + -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) + -> ( ( TypedName te e, Expression te -> e ), ExpressionX xe te ) + -> ( ( TypedName tf f, Expression tf -> f ), ExpressionX xf tf ) + -> (a -> b -> c -> d -> e -> f -> Statement r) + -> Statement r +def6 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) ( ( TypedName (Type t4) n4 e4, _ ), v4 ) ( ( TypedName (Type t5) n5 e5, _ ), v5 ) k = + let + (Statement ks) = + k e0 e1 e2 e3 e4 e5 + in + Statement <| + Decl t0 n0 (Just <| unwrapExpression v0) <| + Decl t1 n1 (Just <| unwrapExpression v1) <| + Decl t2 n2 (Just <| unwrapExpression v2) <| + Decl t3 n3 (Just <| unwrapExpression v3) <| + Decl t4 n4 (Just <| unwrapExpression v4) <| + Decl t5 n5 (Just <| unwrapExpression v5) <| + ks + + assign : ExpressionX a t -> ExpressionX b t -> Expression1 t assign name e = dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) @@ -1760,22 +1819,35 @@ interpret ctx (Statement s) = |> value ctx |> Result.map (\( ctx2, val ) -> ( ctx2, val )) - If c t f -> + If c t n -> Expression c |> value ctx |> Result.andThen (\( ctx2, cval ) -> case cval of VBool True -> - interpret ctx2 <| Statement t + interpret ctx2 (Statement t) + |> Result.andThen + (\( ctx3, res ) -> + case res of + -- TODO: Fix this + VVoid -> + interpret ctx3 (Statement n) + + _ -> + Ok ( ctx3, res ) + ) VBool False -> - interpret ctx2 <| Statement f + interpret ctx2 <| Statement n _ -> Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval ) + IfElse _ _ _ _ -> + Debug.todo "branch 'IfElse _' not implemented" + Nop -> Ok ( ctx, VVoid ) From b6fd246084ac2562b95b4b927df73fd2c1c459cb Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 30 Aug 2021 20:10:42 +0200 Subject: [PATCH 036/139] This is hard tbh --- src/elm/UI/Glsl/Code.elm | 134 ++++++++++++++++++---------------- src/elm/UI/Glsl/Generator.elm | 16 +++- 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 89ddc334..cd663b46 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1958,69 +1958,77 @@ toSrcParametric suffix e = <| \from to p depth choices ithreshold -> for ( "it", int 0, constants.maxIterations ) - (\_ -> - def floatT "midpoint" (mix from to <| float 0.5) <| - \midpoint -> - def2 - ( vec2T "front", interval p from midpoint ) - ( vec2T "back", interval p midpoint to ) - <| - \front back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands - [ lt (subtract front.y front.x) ithreshold - , leq front.x zero - , geq front.y zero - ] - , ands - [ lt (subtract back.y back.x) ithreshold - , leq back.x zero - , geq back.y zero - ] - ] - ) - (return <| vec3 one one one) - (unknownStatement - (""" - - if(front.x <= 0.0 && front.y >= 0.0) { - to = midpoint; - depth++; - choices *= 2; - } else if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - } else { - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - } - """) - ) - ) + (\_ -> innerLoop from to p depth choices ithreshold) (return vec3Zero) + + innerLoop from to p depth choices ithreshold = + def floatT "midpoint" (mix from to <| float 0.5) <| + \midpoint -> + def2 + ( vec2T "front", interval p from midpoint ) + ( vec2T "back", interval p midpoint to ) + <| + \front back -> + if_ + (ors + [ geq depth constants.maxDepth + , ands + [ lt (subtract front.y front.x) ithreshold + , leq front.x zero + , geq front.y zero + ] + , ands + [ lt (subtract back.y back.x) ithreshold + , leq back.x zero + , geq back.y zero + ] + ] + ) + (return <| vec3 one one one) + (ifElse + (ands [ leq front.x zero, geq front.y zero ]) + (expr (assign to midpoint) <| + expr (postfixPlus depth) <| + assignBy choices (int 2) <| + unsafeNop + ) + (ifElse + (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| + expr (postfixPlus depth) <| + expr (assign choices (add (by choices (int 2)) (int 1))) <| + unsafeNop + ) + (unknownStatement + (""" + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return vec3(0,0,0); + """) + ) + unsafeNop + ) + unsafeNop + ) in ( [ intervalDecl, pixelDecl ], pixel ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index aaf4fbf0..960e06b8 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -45,6 +45,7 @@ type Expr | Div Expr Expr | Call String (List Expr) | Negate Expr + | PostfixPlus Expr | Unknown String | Dot Expr String | Array Expr Expr @@ -368,6 +369,9 @@ expressionToGlsl (Expression tree) = Negate c -> "-" ++ go2 False c + PostfixPlus c -> + go2 False c ++ "++" + _ -> go2 rec e @@ -620,6 +624,11 @@ negate2 e = dotted2Internal (Negate <| unwrapExpression e) +postfixPlus : ExpressionX a t -> Expression1 t +postfixPlus = + expr1 PostfixPlus + + by : ExpressionX a t -> ExpressionX b t -> Expression1 t by = expr2 By @@ -650,7 +659,7 @@ div = expr2 Div -div2 : ExpressionX a Vec2 -> ExpressionX a Vec2 -> Expression2 +div2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 div2 = expr22 Div @@ -1770,6 +1779,9 @@ innerValue ctx e = AssignCombo _ _ _ -> Debug.todo "branch 'AssignCombo _ _' not implemented" + PostfixPlus _ -> + Debug.todo "branch 'PostfixPlus _' not implemented" + innerValue2 : Context From b2a475c500a9397e88c1eb8bd268d0ba1e49db39 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 02:09:04 +0200 Subject: [PATCH 037/139] Improving converter --- glslParser/src/GlslConverter.elm | 76 +++++++++----------------------- 1 file changed, 22 insertions(+), 54 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 14fac3f1..7965c720 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -32,50 +32,9 @@ init : Model init = let i = - """{for(int it = 0; it < MAX_ITERATIONS; it++) { - float midpoint = mix(from, to, 0.5); - vec2 front = interval\"\"\" ++ suffix ++ \"\"\"(p, from, midpoint); - vec2 back = interval\"\"\" ++ suffix ++ \"\"\"(p, midpoint, to); - if(depth >= MAX_DEPTH - || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) - || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) - ) - return vec3(1,1,1); - if(front.x <= 0.0 && front.y >= 0.0) { - to = midpoint; - depth++; - choices = choices * 2; - } else if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - } else { - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval\"\"\" ++ suffix ++ \"\"\"(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - } - } - return vec3(0,0,0); - + """{ + + }""" in @@ -211,7 +170,7 @@ type UnaryOperation type Expression = Float Float | Int Int - | Dot String String + | Dot Expression String | Variable String | Call String (List Expression) | Ternary Expression Expression Expression @@ -563,21 +522,19 @@ unaryParser = atomParser : Parser Expression atomParser = - succeed (\a f -> f a) + succeed (\a f -> f a) |= oneOf - [ succeed identity + [ succeed (\a f -> f a) |. symbol "(" |. spaces |= Parser.lazy (\_ -> expressionParser) |. spaces |. symbol ")" - , succeed (\a f -> f a) + |= maybeDot + , succeed (\a f md ->md<| f a) |= Parser.map .name identifierWithSuffixParser |= oneOf - [ succeed (\sw v -> Dot v sw) - |. symbol "." - |= identifierParser - , succeed (\args v -> Call v args) + [ succeed (\args v -> Call v args) |= sequence { start = "(" , separator = "," @@ -588,6 +545,7 @@ atomParser = } , succeed Variable ] + |= maybeDot , Parser.andThen tryParseNumber <| getChompedString <| succeed () @@ -602,6 +560,16 @@ atomParser = ] +maybeDot : Parser (Expression -> Expression) +maybeDot = + oneOf + [ succeed (\p v -> Dot v p) + |. symbol "." + |= identifierParser + , succeed identity + ] + + tryParseNumber : String -> Parser Expression tryParseNumber n = case String.toInt n of @@ -772,7 +740,7 @@ prettyPrintExpression e = lisp [ "int", String.fromInt i ] Dot v sw -> - v ++ "." ++ sw + prettyPrintExpression v ++ "." ++ sw Variable v -> v @@ -806,7 +774,7 @@ prettyPrintExpression e = else lisp <| "atan_" :: List.map prettyPrintExpression args - else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil" ] then + else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then lisp <| (n ++ "_") :: List.map prettyPrintExpression args else From a9bef131bd18d9f23c2f812ae3a308271efe5430 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 02:09:11 +0200 Subject: [PATCH 038/139] Moar codegen --- src/elm/UI/Glsl/Code.elm | 145 ++++++++++++++++++++++------------ src/elm/UI/Glsl/Generator.elm | 22 +++++- 2 files changed, 115 insertions(+), 52 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index cd663b46..bedb4d14 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -127,16 +127,14 @@ cdivTuple = \a b -> def floatT "k" (div one <| dot b b) <| \k -> - def floatT "r" (by k <| dot a b) <| - \r -> - def floatT - "i" - (by k - (subtract (by a.y b.x) (by a.x b.y)) - ) - <| - \i -> - return <| vec2 r i + def2 + ( floatT "r", by k <| dot a b ) + ( floatT "i" + , by k (subtract (by a.y b.x) (by a.x b.y)) + ) + <| + \r i -> + return <| vec2 r i cdivDecl : FunDecl @@ -219,7 +217,7 @@ inegCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) inegCouple = fun1 vec2T "ineg" (vec2T "v") <| \v -> - return <| vec2 (negate_ v.y) (negate_ v.x) + return <| negate_ v.yx inegDecl : FunDecl @@ -534,7 +532,7 @@ gpow = iltCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) iltCouple = - fun2 vec2T "ilt" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + fun2 vec2T "ilt" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx iltDecl : FunDecl @@ -549,7 +547,7 @@ ilt = ileqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ileqCouple = - fun2 vec2T "ileq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + fun2 vec2T "ileq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx ileqDecl : FunDecl @@ -564,7 +562,7 @@ ileq = ineqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ineqCouple = - fun2 vec2T "ineq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract r.x l.y) (subtract r.y l.x) + fun2 vec2T "ineq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx ineqDecl : FunDecl @@ -579,7 +577,7 @@ ineq = ieqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ieqCouple = - fun2 vec2T "ieq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + fun2 vec2T "ieq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx ieqDecl : FunDecl @@ -594,7 +592,7 @@ ieq = igeqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) igeqCouple = - fun2 vec2T "igeq" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + fun2 vec2T "igeq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx igeqDecl : FunDecl @@ -609,7 +607,7 @@ igeq = igtCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) igtCouple = - fun2 vec2T "igt" (vec2T "l") (vec2T "r") <| \l r -> return <| vec2 (subtract l.x r.y) (subtract l.y r.x) + fun2 vec2T "igt" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx igtDecl : FunDecl @@ -632,7 +630,7 @@ iabsCouple = (vec2 zero <| max_ z.y <| abs_ z.x) (ternary (leq z.x zero) - (vec2 (negate_ z.y) (negate_ z.x)) + (negate_ z.yx) z ) @@ -647,6 +645,62 @@ iabs = Tuple.second iabsCouple +iacosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) +iacosCouple = + fun1 vec2T "iacos" (vec2T "z") <| + \z -> + -- Don't use clamp so if z is fully outside range the result is empty + def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| + \clamped -> + return <| (acos2 clamped).yx + + +iacosDecl : FunDecl +iacosDecl = + Tuple.first iacosCouple + + +iacos : ExpressionX xa Vec2 -> Expression2 +iacos = + Tuple.second iacosCouple + + + +-- """ +-- vec2 iacos(vec2 z) { +-- // Don't use clamp so if z is fully outside range the result is empty +-- vec2 clamped = vec2( +-- max(z.x, -1.0), +-- min(z.y, 1.0) +-- ); +-- return acos(clamped).yx; +-- } +-- vec4 gacos(vec4 v) { +-- return vec4(acos(v.x), -v.yzw / sqrt(1.0 - v.x * v.x)); +-- } +-- """ + + +gacosCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) +gacosCouple = + fun1 vec4T "gacos" (vec4T "v") <| + \v -> + return <| + vec4_1_3 + (acos_ v.x) + (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) + + +gacosDecl : FunDecl +gacosDecl = + Tuple.first gacosCouple + + +gacos : ExpressionX xa Vec4 -> Expression4 +gacos = + Tuple.second gacosCouple + + gabsCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gabsCouple = fun1 vec4T "gabs" (vec4T "v") <| \v -> return <| vec4_1_3 (abs_ v.x) (byF (sign v.x) v.yzw) @@ -664,7 +718,7 @@ gabs = iexpCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iexpCouple = - fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| vec2 (exp z.x) (exp z.y) + fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| exp z iexpDecl : FunDecl @@ -694,7 +748,7 @@ gexp = ilnCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ilnCouple = - fun1 vec2T "iln" (vec2T "z") <| \z -> return <| vec2 (log z.x) (log z.y) + fun1 vec2T "iln" (vec2T "z") <| \z -> return <| log z ilnDecl : FunDecl @@ -778,7 +832,10 @@ ctanCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanCouple = fun1 vec2T "ctan" (vec2T "z") <| \z -> - return <| ternary (eq z.y zero) (vec2 (tan_ z.x) zero) (cdiv (csin z) (ccos z)) + return <| + ternary (eq z.y zero) + (vec2 (tan_ z.x) zero) + (cdiv (csin z) (ccos z)) ctanDecl : FunDecl @@ -814,7 +871,9 @@ casin = cacosTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) cacosTuple = - fun1 vec2T "cacos" (vec2T "z") <| \z -> return <| subtract (vec2 constants.pihalf zero) (casin z) + fun1 vec2T "cacos" (vec2T "z") <| + \z -> + return <| subtract (vec2 constants.pihalf zero) (casin z) cacosDecl : FunDecl @@ -946,9 +1005,7 @@ cabs = csignCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csignCouple = - fun1 vec2T "csign" (vec2T "z") <| - \z -> - return <| vec2 (sign z.x) (sign z.y) + fun1 vec2T "csign" (vec2T "z") <| \z -> return <| sign z csignDecl : FunDecl @@ -1107,9 +1164,12 @@ cexpTuple = cexpFunction : Expression2 -> Statement Vec2 cexpFunction z = - if_ (eq z.y zero) - (return <| vec2 (exp z.x) zero) - (return <| vec2 (by (cos_ z.y) (exp z.x)) (by (sin_ z.y) (exp z.x))) + return <| + byF (exp z.x) <| + ternary + (eq z.y zero) + (vec2 one zero) + (vec2 (cos_ z.y) (sin_ z.y)) cexpDecl : FunDecl @@ -1453,20 +1513,7 @@ intervalFunctionToGlsl name = fileToGlsl [ iabsDecl, gabsDecl ] Acos22 -> - """ - vec2 iacos(vec2 z) { - // Don't use clamp so if z is fully outside range the result is empty - vec2 clamped = vec2( - max(z.x, -1.0), - min(z.y, 1.0) - ); - return acos(clamped).yx; - } - - vec4 gacos(vec4 v) { - return vec4(acos(v.x), -v.yzw / sqrt(1.0 - v.x * v.x)); - } - """ + fileToGlsl [ iacosDecl, gacosDecl ] Arg22 -> """ @@ -1697,7 +1744,7 @@ intervalFunctionToGlsl name = Sqrt22 -> """ vec2 isqrt(vec2 v) { - return vec2(sqrt(max(0.0, v.x)), sqrt(max(0.0, v.y))); + return sqrt(max(vec2(0,0), v)); } vec4 gsqrt(vec4 v) { @@ -1754,7 +1801,7 @@ intervalFunctionToGlsl name = Min222 -> """ vec2 imin(vec2 l, vec2 r) { - return vec2(min(l.x, r.x), min(l.y, r.y)); + return min(l, r); } vec4 gmin(vec4 l, vec4 r) { @@ -1765,7 +1812,7 @@ intervalFunctionToGlsl name = Max222 -> """ vec2 imax(vec2 l, vec2 r) { - return vec2(max(l.x, r.x), max(l.y, r.y)); + return max(l, r); } vec4 gmax(vec4 l, vec4 r) { @@ -1938,7 +1985,7 @@ toSrcParametric suffix e = def3 ( vec2T "x", vec2 p.x p.x ) ( vec2T "y", vec2 p.y p.y ) - ( vec2T "t", ternary (lt from to) (vec2 from to) (vec2 to from) ) + ( vec2T "t", vec2 (min_ from to) (max_ from to) ) <| \x y t -> return <| expressionToIntervalGlsl (toPrintExpression e) @@ -2559,7 +2606,7 @@ expressionToIntervalGlsl expr = if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then case List.map go ex of [] -> - vec2 zero zero + vec2Zero head :: tail -> dotted2 <| List.foldl (\e a -> unsafeCall ("i" ++ Expression.functionNameToString name) [ a, e.base ]) head.base tail @@ -2575,7 +2622,7 @@ expressionToIntervalGlsl expr = -- If this happens, it's too late PLambda _ _ -> - vec2 zero zero + vec2Zero expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 960e06b8..6ce09093 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -77,6 +77,7 @@ type alias Expression2 = { base : Expression Vec2 , x : Expression1 Float , y : Expression1 Float + , yx : Expression1 Vec2 } @@ -95,6 +96,7 @@ type alias Expression4 = , z : Expression1 Float , w : Expression1 Float , xy : Expression2 + , yx : Expression2 , yzw : Expression3 } @@ -751,6 +753,16 @@ tan_ = dotted1 << call1Internal "tan" +acos_ : ExpressionX a t -> Expression1 t +acos_ = + dotted1 << call1Internal "acos" + + +acos2 : ExpressionX a Vec2 -> Expression2 +acos2 = + dotted2 << call1Internal "acos" + + sinh : ExpressionX a t -> Expression1 t sinh = dotted1 << call1Internal "sinh" @@ -896,6 +908,7 @@ vec2 x y = { base = call2Internal "vec2" x y , x = { base = x.base } , y = { base = y.base } + , yx = { base = call2Internal "vec2" y x } } @@ -925,6 +938,7 @@ vec4 x y z w = , z = { base = z.base } , w = { base = w.base } , xy = dotted2 <| call2Internal "vec2" x y + , yx = dotted2 <| call2Internal "vec2" y x , yzw = dotted3 <| call3Internal "vec3" y z w } @@ -1106,6 +1120,7 @@ dotted2Internal e = { base = Expression e , x = dotInternal e "x" , y = dotInternal e "y" + , yx = dotInternal e "yx" } @@ -1135,8 +1150,9 @@ dotted4Internal e = , y = dotInternal e "y" , z = dotInternal e "z" , w = dotInternal e "w" - , xy = dotted2 (Expression (Dot e "xy")) - , yzw = dotted3 (Expression (Dot e "yzw")) + , xy = dotted2 <| Expression <| Dot e "xy" + , yx = dotted2 <| Expression <| Dot e "yx" + , yzw = dotted3 <| Expression <| Dot e "yzw" } From fc7fa5fdd2256ae9152b8d0dd0227277c22b4482 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 21:39:32 +0200 Subject: [PATCH 039/139] Less unknown function declarations --- src/elm/UI/Glsl.elm | 27 +++--- src/elm/UI/Glsl/Code.elm | 163 ++++++++++++++------------------- src/elm/UI/Glsl/Generator.elm | 20 +++- src/elm/UI/Glsl/Plane.elm | 33 ++++--- src/elm/UI/Glsl/Polynomial.elm | 8 +- src/elm/UI/Glsl/Sphere.elm | 20 ++-- 6 files changed, 132 insertions(+), 139 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 24d84b3e..e6729669 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, fileToGlsl, unknownFunDecl) +import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, fileToGlsl, floatT, fun4, mat3T, out, unknown, unknownFunDecl, unknownStatement, vec3T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -180,12 +180,12 @@ get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of Just glsl -> { expr = e - , funDecls = [ glsl ] + , funDecls = [ Tuple.first glsl ] } Nothing -> case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of - Just glsl -> + Just ( glsl, _ ) -> { expr = e , funDecls = [ glsl ] } @@ -201,12 +201,12 @@ get3DSource prefix e = toSrc3D prefix e in { expr = e - , funDecls = glsl ++ [ UI.Glsl.Code.suffixToBisect prefix ] + , funDecls = glsl ++ [ Tuple.first <| UI.Glsl.Code.suffixToBisect prefix ] } tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, funDecls : List FunDecl } -tryGlslFromPolynomial prefix e = +tryGlslFromPolynomial suffix e = let t = Variable "t" @@ -280,26 +280,21 @@ tryGlslFromPolynomial prefix e = |> List.reverse |> String.join "\n " - funDecl = - unknownFunDecl - { name = "bisect" ++ prefix - , type_ = "TODO" - , body = - """ - bool bisect""" ++ prefix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + ( funDecl, _ ) = + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> + unknownStatement (""" float t = max_distance * 2.0; """ ++ checks ++ """ found = o + t * mix(d[0], d[1], 0.5); return t < max_distance && t > 0.0; - } - """ - } + """) in { expr = div one <| sqrt_ <| cbrt <| ipow e 3 , funDecls = [ funDecl ] } in - UI.Glsl.Polynomial.getSolutions poly |> Maybe.map (\( _, sols ) -> fromSols sols) + UI.Glsl.Polynomial.getSolutions { base = unknown "max_distance" } poly |> Maybe.map (\( _, sols ) -> fromSols sols) transitiveClosure : List Requirement -> List Requirement diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index bedb4d14..06a46457 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -665,22 +665,6 @@ iacos = Tuple.second iacosCouple - --- """ --- vec2 iacos(vec2 z) { --- // Don't use clamp so if z is fully outside range the result is empty --- vec2 clamped = vec2( --- max(z.x, -1.0), --- min(z.y, 1.0) --- ); --- return acos(clamped).yx; --- } --- vec4 gacos(vec4 v) { --- return vec4(acos(v.x), -v.yzw / sqrt(1.0 - v.x * v.x)); --- } --- """ - - gacosCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gacosCouple = fun1 vec4T "gacos" (vec4T "v") <| @@ -2255,16 +2239,23 @@ toSrcContour suffix expr = ) ( pixelDecl, pixel ) = + let + dist = + 1 / 3 + in fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - -- Antialiasing - def floatT "dist" (float <| 1 / 3) <| - \dist -> + def2 + ( floatT "deltaXr", by deltaX <| float dist ) + ( floatT "deltaYr", by deltaY <| float dist ) + <| + \deltaXr deltaYr -> + -- Antialiasing def4 - ( vec3T "a", pixelO deltaX deltaY (add x <| by dist deltaX) (add y <| by dist deltaY) ) - ( vec3T "b", pixelO deltaX deltaY (subtract x <| by dist deltaX) (subtract y <| by dist deltaY) ) - ( vec3T "c", pixelO deltaX deltaY (add x <| by dist deltaX) (subtract y <| by dist deltaY) ) - ( vec3T "d", pixelO deltaX deltaY (subtract x <| by dist deltaX) (add y <| by dist deltaY) ) + ( vec3T "a", pixelO deltaX deltaY (add x deltaXr) (add y deltaYr) ) + ( vec3T "b", pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr) ) + ( vec3T "c", pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr) ) + ( vec3T "d", pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr) ) <| \a b c d -> def2 @@ -2274,18 +2265,19 @@ toSrcContour suffix expr = \mn mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> - if_ (ands [ lt diff.x dist, lt diff.y dist, lt diff.z dist ]) + if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - (def floatT "dist2" (by (float 2) dist) <| - \dist2 -> + (assignBy deltaXr (float 2) <| + (assignBy deltaYr (float 2) <| def4 - ( vec3T "e", pixelO deltaX deltaY (add x <| byF dist2 deltaX) y ) - ( vec3T "f", pixelO deltaX deltaY (subtract x <| byF dist2 deltaX) y ) - ( vec3T "g", pixelO deltaX deltaY x (subtract y <| byF dist2 deltaY) ) - ( vec3T "h", pixelO deltaX deltaY x (add y <| byF dist2 deltaY) ) + ( vec3T "e", pixelO deltaX deltaY (add x deltaXr) y ) + ( vec3T "f", pixelO deltaX deltaY (subtract x deltaXr) y ) + ( vec3T "g", pixelO deltaX deltaY x (subtract y deltaYr) ) + ( vec3T "h", pixelO deltaX deltaY x (add y deltaYr) ) <| \e f g h -> return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) + ) ) in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2438,8 +2430,6 @@ expressionToGlsl context = PApply (KnownFunction Abs) [ e ] -> cabs (go e) - -- PApply (KnownFunction (Root r)) [ e ] -> - -- croot r (go e) PApply (KnownFunction Ln) [ e ] -> cln (go e) @@ -2461,14 +2451,6 @@ expressionToGlsl context = PApply (KnownFunction Arg) [ e ] -> carg (go e) - -- PApply (KnownFunction Gra) [ e ] -> - -- cgra (go e) - -- PApply (KnownFunction Det) [ e ] -> - -- cdet (go e) - -- PApply (KnownFunction Dd) [ e ] -> - -- cdd (go e) - -- PApply (KnownFunction Ii) [ e ] -> - -- cii (go e) PApply (KnownFunction Round) [ e ] -> cround (go e) @@ -2481,22 +2463,12 @@ expressionToGlsl context = PApply (KnownFunction Pw) [ c, t, f ] -> cpw (go c) (go t) (go f) - -- PApply (KnownFunction Plot) [ e ] -> - -- cplot (go e) - -- PApply (KnownFunction APlot) [ e ] -> - -- caPlot (go e) - -- PApply (KnownFunction StepSimplify) [ e ] -> - -- cstepSimplify (go e) - -- PApply (KnownFunction Solve) [ e ] -> - -- csolve (go e) PApply (KnownFunction Mod) [ l, r ] -> cmod (go l) (go r) PApply (KnownFunction Mbrot) [ x, y ] -> cmbrot (go x) (go y) - -- PApply (KnownFunction For) [ e ] -> - -- cfor (go e) PApply (KnownFunction Min) es -> variadic cmin es @@ -2506,6 +2478,26 @@ expressionToGlsl context = PApply (UserFunction name) ex -> dotted2 <| unsafeCall ("c" ++ name) (List.map (go >> .base) ex) + -- PApply (KnownFunction Gra) [ e ] -> + -- cgra (go e) + -- PApply (KnownFunction Det) [ e ] -> + -- cdet (go e) + -- PApply (KnownFunction Dd) [ e ] -> + -- cdd (go e) + -- PApply (KnownFunction Ii) [ e ] -> + -- cii (go e) + -- PApply (KnownFunction Plot) [ e ] -> + -- cplot (go e) + -- PApply (KnownFunction APlot) [ e ] -> + -- caPlot (go e) + -- PApply (KnownFunction StepSimplify) [ e ] -> + -- cstepSimplify (go e) + -- PApply (KnownFunction Solve) [ e ] -> + -- csolve (go e) + -- PApply (KnownFunction For) [ e ] -> + -- cfor (go e) + -- PApply (KnownFunction (Root r)) [ e ] -> + -- croot r (go e) PApply name ex -> dotted2 <| unsafeCall ("c" ++ functionNameToString name) (List.map (go >> .base) ex) @@ -2956,7 +2948,7 @@ main3D rayDifferentials suffixes = ( block, pixel3 ) = fun0 vec4T "pixel3" <| - (def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| + def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| \eyeDist -> def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> @@ -2993,7 +2985,6 @@ main3D rayDifferentials suffixes = def floatT "max_distance" (by (float 100) eyeDist) <| \maxDistance -> return <| raytraceF canvasPoint d maxDistance - ) dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 dValue rayDirection k diffs = @@ -3002,7 +2993,7 @@ main3D rayDifferentials suffixes = (add rayDirection <| byF k diffs) vec3Zero - ( raytraceSrc, raytraceF ) = + ( raytraceDecl, raytraceF ) = raytrace suffixes eyePosition eyeDist t p = @@ -3013,10 +3004,10 @@ main3D rayDifferentials suffixes = (by (cos_ t) (negate_ <| cos_ p)) (sin_ t) in - ( deindent 12 <| raytraceSrc ++ fileToGlsl [ block ], pixel3 ) + ( fileToGlsl [ raytraceDecl, block ], pixel3 ) -raytrace : List String -> ( String, ExpressionX a Vec3 -> ExpressionX b Mat3 -> Expression1 Float -> Expression4 ) +raytrace : List String -> ( FunDecl, ExpressionX a Vec3 -> ExpressionX b Mat3 -> Expression1 Float -> Expression4 ) raytrace suffixes = let colorCoeff = @@ -3043,16 +3034,19 @@ raytrace suffixes = light_coeff = 0.2; } """ - - src = - """ - vec4 raytrace(vec3 o, mat3 d, float max_distance) { - vec3 found = vec3(0); - float curr_distance = max_distance; - int found_index = -1; - vec3 f = vec3(0); - vec3 n = vec3(0); - """ ++ innerTrace ++ """ + in + fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| + \o d maxDistance -> + def5 + ( vec3T "found", vec3Zero ) + ( floatT "curr_distance", maxDistance ) + ( intT "found_index", int -1 ) + ( vec3T "f", vec3Zero ) + ( vec3T "n", vec3Zero ) + <| + \found currDistance foundIndex f n -> + unknownStatement + (innerTrace ++ """ if(found_index < 0) return vec4(0,0,0,1); @@ -3073,36 +3067,23 @@ raytrace suffixes = max(0.2, """ ++ colorCoeff ++ """) ); return vec4(px, 1.0); - } - """ - in - ( src - , \o d maxDistance -> - dotted4 <| - unsafeCall "raytrace" - [ Generator.uNsAfEtYpEcAsT o.base - , Generator.uNsAfEtYpEcAsT d.base - , Generator.uNsAfEtYpEcAsT maxDistance.base - ] - ) + """) -threshold : String -threshold = - "0.000001 * max_distance" +threshold : ExpressionX x Float -> Expression1 Float +threshold max_distance = + by (float 0.000001) max_distance -suffixToBisect : String -> FunDecl +suffixToBisect : String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) suffixToBisect suffix = - unknownFunDecl - { name = "bisect" ++ suffix - , type_ = "TODO" - , body = - """ - bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> + unknownStatement + (""" mat3 from = mat3(o, o, vec3(0)); mat3 to = from + max_distance * d; - float ithreshold = """ ++ threshold ++ """; + float ithreshold = """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """; int depth = 0; int choices = 0; for(int it = 0; it < MAX_ITERATIONS; it++) { @@ -3150,9 +3131,7 @@ suffixToBisect suffix = } } return false; - } - """ - } + """) deindent : Int -> String -> String diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 6ce09093..fe8aa39f 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1602,6 +1602,24 @@ mat3T n = ( TypedName (Type "mat3") (Name n) (dotted1Internal (Variable n)), dotted1 ) +out : TypingFunction t r -> TypingFunction t r +out inner n = + let + ( TypedName (Type t) name v, c ) = + inner n + in + ( TypedName (Type <| "out " ++ t) name v, c ) + + +in_ : TypingFunction t r -> TypingFunction t r +in_ inner n = + let + ( TypedName (Type t) name v, c ) = + inner n + in + ( TypedName (Type <| "in " ++ t) name v, c ) + + -------------------- -- TESTING HELPER -- diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 0b6377a7..5b85029f 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -4,7 +4,7 @@ import Dict import Expression exposing (Expression) import Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (FunDecl, floatToGlsl, unknownFunDecl) +import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, def2, div, dot, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -35,12 +35,10 @@ asPlane e = ) -toGlsl : String -> Plane -> FunDecl +toGlsl : String -> Plane -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Plane { x, y, z, known }) = - unknownFunDecl - { name = "bisect" ++ suffix - , type_ = "TODO" - , body = + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> -- a x + b y + c z + k = 0 -- x = ox + t dx -- y = oy + t dy @@ -48,11 +46,18 @@ toGlsl suffix (Plane { x, y, z, known }) = -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) -- t = - (k + dot abc o) / (dot abc d) - """bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { - vec3 coeffs = vec3(""" ++ floatToGlsl x ++ "," ++ floatToGlsl y ++ "," ++ floatToGlsl z ++ """); - float t = -(""" ++ floatToGlsl known ++ """ + dot(coeffs, o)) / dot(coeffs, 0.5 * (d[0] + d[1])); - found = o + t * 0.5 * (d[0] + d[1]); - return t > """ ++ threshold ++ """; - } - """ - } + def2 + ( vec3T "coeffs", vec3 (float x) (float y) (float z) ) + ( vec3T "dsum", byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1) ) + <| + \coeffs dsum -> + def floatT + "t" + (div + (negate_ <| add (float known) (dot coeffs o)) + (dot coeffs dsum) + ) + <| + \t -> + expr (assign found <| add o <| byF t dsum) <| + return (gt t <| threshold maxDistance) diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index c4ecef51..333e079e 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -6,7 +6,7 @@ import Expression.Polynomial exposing (Exponents) import Expression.Utils exposing (minus, zero) import Maybe.Extra as Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (dotted1, unknown) +import UI.Glsl.Generator as Generator exposing (ExpressionX, dotted1, unknown) getDegree : Dict (List ( a, number )) b -> number @@ -64,8 +64,8 @@ toFloat e = Nothing -getSolutions : Dict Int Expression -> Maybe ( Int, List ( String, String ) ) -getSolutions poly = +getSolutions : ExpressionX x Float -> Dict Int Expression -> Maybe ( Int, List ( String, String ) ) +getSolutions maxDistance poly = let deg = poly @@ -88,7 +88,7 @@ getSolutions poly = |> Generator.expressionToGlsl tFrom v = - ( "t", v ++ ".x < 0.0 || abs(" ++ v ++ ".y) > " ++ threshold ++ " ? t : min(" ++ v ++ ".x, t)" ) + ( "t", v ++ ".x < 0.0 || abs(" ++ v ++ ".y) > " ++ Generator.expressionToGlsl (threshold maxDistance).base ++ " ? t : min(" ++ v ++ ".x, t)" ) sols = case deg of diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 520370c9..4a276dbc 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -4,7 +4,7 @@ import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (FunDecl, floatToGlsl, unknownFunDecl) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, boolT, floatT, floatToGlsl, fun4, mat3T, out, unknownStatement, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -73,14 +73,12 @@ reduce poly = ) -toGlsl : String -> Sphere -> FunDecl +toGlsl : String -> Sphere -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Sphere { center, radius }) = - unknownFunDecl - { name = "bisect" ++ suffix - , type_ = "TODO" - , body = - """ - bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> + unknownStatement + (""" vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); vec3 to_center = o - center; @@ -90,10 +88,8 @@ toGlsl suffix (Sphere { center, radius }) = if(delta < 0.) return false; float x = -b - sqrt(delta); - if(x < """ ++ threshold ++ """) + if(x < """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """) return false; found = o + x * mix(d[0], d[1], 0.5); return true; - } - """ - } + """) From 1e6b52daa021d901d91ab9e21c0dbb13e6071d0e Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 21:41:35 +0200 Subject: [PATCH 040/139] Unknown function declarations are no more --- src/elm/UI/Glsl.elm | 25 ++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 11 +---------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index e6729669..d135eee5 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, fileToGlsl, floatT, fun4, mat3T, out, unknown, unknownFunDecl, unknownStatement, vec3T) +import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, fileToGlsl, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -149,7 +149,14 @@ getGlsl rayDifferentials graph = |> List.map (requirementToGlsl interval) |> String.join "\n" in - declarations + "#define PIHALF " + ++ String.fromFloat (pi / 2) + ++ "\n#define PI " + ++ String.fromFloat pi + ++ "\n#define TWOPI " + ++ String.fromFloat (pi * 2) + ++ "\n" + ++ declarations ++ thetaDeltaCode ++ reqs ++ "\n/* Expression */\n" @@ -157,21 +164,9 @@ getGlsl rayDifferentials graph = ++ mainGlsl rayDifferentials pixel2D pixel3D -piDecl : FunDecl -piDecl = - unknownFunDecl - { name = "PI" - , type_ = "float" - , body = - """#define PIHALF """ ++ String.fromFloat (pi / 2) ++ """ - #define PI """ ++ String.fromFloat pi ++ """ - #define TWOPI """ ++ String.fromFloat (pi * 2) - } - - declarations : String declarations = - [ piDecl, atanPlusDecl, gnumDecl, dupDecl ] + [ atanPlusDecl, gnumDecl, dupDecl ] |> Generator.fileToGlsl diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index fe8aa39f..85104cc3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownFunDecl, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1533,15 +1533,6 @@ assignBy name e (Statement next) = Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) next -unknownFunDecl : { name : String, type_ : String, body : String } -> FunDecl -unknownFunDecl = - let - _ = - Debug.todo - in - FunDecl - - -- TYPES From 59b48b0eedc25eeada0c9062bfa14e8f608ce48f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 21:46:00 +0200 Subject: [PATCH 041/139] More unsafety gone --- src/elm/UI/Glsl.elm | 13 ++++++------- src/elm/UI/Glsl/Generator.elm | 11 +---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index d135eee5..7ffd5af8 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, fileToGlsl, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) +import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, def, fileToGlsl, float, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -278,12 +278,11 @@ tryGlslFromPolynomial suffix e = ( funDecl, _ ) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - unknownStatement (""" - float t = max_distance * 2.0; - """ ++ checks ++ """ - found = o + t * mix(d[0], d[1], 0.5); - return t < max_distance && t > 0.0; - """) + def floatT "t" (Generator.by maxDistance <| float 2) <| + \t_ -> + unknownStatement (checks ++ """ + found = o + t * mix(d[0], d[1], 0.5); + return t < max_distance && t > 0.0;""") in { expr = div one <| sqrt_ <| cbrt <| ipow e 3 , funDecls = [ funDecl ] diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 85104cc3..3b48ae61 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uNsAfEtYpEcAsT, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -997,15 +997,6 @@ gl_FragCoord = ---------------- -uNsAfEtYpEcAsT : Expression t -> Expression a -uNsAfEtYpEcAsT (Expression i) = - let - _ = - Debug.todo - in - Expression i - - unsafeCall : String -> List (Expression t) -> Expression r unsafeCall name = Expression << Call name << List.map (\(Expression e) -> e) From 9ca14d7287e762dcbaa31e028b5067f47409a4d8 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 1 Sep 2021 22:46:57 +0200 Subject: [PATCH 042/139] New chain declaration --- src/elm/UI/Glsl.elm | 43 +++++++-- src/elm/UI/Glsl/Code.elm | 175 +++++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 32 ++++++- 3 files changed, 171 insertions(+), 79 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 7ffd5af8..80ea3df3 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, boolT, def, fileToGlsl, float, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, boolT, def, fileToGlsl, float, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -92,7 +92,7 @@ getGlsl rayDifferentials graph = , interval = IntervalAndStraight , usesThetaDelta = True , pixel2D = [] - , pixel3D = [ prefix ] + , pixel3D = [ f.bisect ] } GraphList children -> @@ -170,19 +170,33 @@ declarations = |> Generator.fileToGlsl -get3DSource : String -> Expression -> { expr : Expression, funDecls : List FunDecl } +get3DSource : + String + -> Expression + -> + { expr : Expression + , funDecls : List FunDecl + , bisect : + ExpressionX xa Vec3 + -> ExpressionX xb Mat3 + -> ExpressionX xc Float + -> ExpressionX xd Vec3 + -> Expression1 Bool + } get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of - Just glsl -> + Just ( glsl, bisect ) -> { expr = e - , funDecls = [ Tuple.first glsl ] + , funDecls = [ glsl ] + , bisect = bisect } Nothing -> case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of - Just ( glsl, _ ) -> + Just ( glsl, bisect ) -> { expr = e , funDecls = [ glsl ] + , bisect = bisect } Nothing -> @@ -194,13 +208,20 @@ get3DSource prefix e = let glsl = toSrc3D prefix e + + ( decl, bisect ) = + UI.Glsl.Code.suffixToBisect prefix in { expr = e - , funDecls = glsl ++ [ Tuple.first <| UI.Glsl.Code.suffixToBisect prefix ] + , funDecls = glsl ++ [ decl ] + , bisect = bisect } -tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, funDecls : List FunDecl } + +--tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, funDecls : List FunDecl } + + tryGlslFromPolynomial suffix e = let t = @@ -275,7 +296,7 @@ tryGlslFromPolynomial suffix e = |> List.reverse |> String.join "\n " - ( funDecl, _ ) = + ( funDecl, bisect ) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> def floatT "t" (Generator.by maxDistance <| float 2) <| @@ -286,9 +307,11 @@ tryGlslFromPolynomial suffix e = in { expr = div one <| sqrt_ <| cbrt <| ipow e 3 , funDecls = [ funDecl ] + , bisect = bisect } in - UI.Glsl.Polynomial.getSolutions { base = unknown "max_distance" } poly |> Maybe.map (\( _, sols ) -> fromSols sols) + UI.Glsl.Polynomial.getSolutions { base = unknown "max_distance" } poly + |> Maybe.map (\( _, sols ) -> fromSols sols) transitiveClosure : List Requirement -> List Requirement diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 06a46457..259c7fc0 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def1, def2, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -2712,15 +2712,18 @@ expressionToNormalGlsl { x, y, z } = toPrintExpression >> go -mainGlsl : - Bool - -> - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } - -> List String - -> String + +-- mainGlsl : +-- Bool +-- -> +-- List +-- { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 +-- , color : Bool +-- } +-- -> List String +-- -> String + + mainGlsl rayDifferentials pixel2Def pixel3Def = case ( pixel2Def, pixel3Def ) of ( _, [] ) -> @@ -2936,8 +2939,12 @@ toSrc3D suffix e = ] -main3D : Bool -> List String -> ( String, Expression4 ) -main3D rayDifferentials suffixes = + +--main3D : Bool -> List String -> ( String, Expression4 ) + + +main3D : Bool -> List (Expression3 -> Expression1 Mat3 -> Expression1 Float -> Expression3 -> Expression1 Bool) -> ( String, Expression4 ) +main3D rayDifferentials bisects = let kValue = if rayDifferentials then @@ -2980,11 +2987,12 @@ main3D rayDifferentials suffixes = \diffs -> def floatT "k" (float kValue) <| \k -> - def mat3T "d" (dValue rayDirection k diffs) <| - \d -> - def floatT "max_distance" (by (float 100) eyeDist) <| - \maxDistance -> - return <| raytraceF canvasPoint d maxDistance + def2 + ( mat3T "d", dValue rayDirection k diffs ) + ( floatT "max_distance", by (float 100) eyeDist ) + <| + \d maxDistance -> + return <| raytraceF canvasPoint d maxDistance dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 dValue rayDirection k diffs = @@ -2994,7 +3002,7 @@ main3D rayDifferentials suffixes = vec3Zero ( raytraceDecl, raytraceF ) = - raytrace suffixes + raytrace bisects eyePosition eyeDist t p = byF eyeDist <| @@ -3007,67 +3015,98 @@ main3D rayDifferentials suffixes = ( fileToGlsl [ raytraceDecl, block ], pixel3 ) -raytrace : List String -> ( FunDecl, ExpressionX a Vec3 -> ExpressionX b Mat3 -> Expression1 Float -> Expression4 ) -raytrace suffixes = - let - colorCoeff = - floatToGlsl (1.19 - 0.2 * toFloat (List.length suffixes)) - - innerTrace = - String.join "\n" (List.indexedMap suffixToRay suffixes) - innerLightTrace = - String.join "\n" (List.map suffixToRayLight suffixes) +-- raytrace : +-- List +-- (Expression3 +-- -> Expression1 Mat3 +-- -> Expression1 Float +-- -> ExpressionX a Vec3 +-- -> Expression1 Bool +-- ) +-- -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> Expression4 ) - suffixToRay i suffix = - """ - if(bisect""" ++ suffix ++ """(o, d, max_distance, f) && length(f - o) < curr_distance) { - found_index = """ ++ String.fromInt i ++ """; - found = f; - curr_distance = length(found - o); - } - """ - suffixToRayLight suffix = - """ - else if(bisect""" ++ suffix ++ """(offseted, light_direction, light_distance, f)) { - light_coeff = 0.2; - } - """ +raytrace bisects = + let + colorCoeff = + float (1.19 - 0.2 * toFloat (List.length bisects)) in fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance -> - def5 + def4 ( vec3T "found", vec3Zero ) ( floatT "curr_distance", maxDistance ) ( intT "found_index", int -1 ) ( vec3T "f", vec3Zero ) - ( vec3T "n", vec3Zero ) <| - \found currDistance foundIndex f n -> - unknownStatement - (innerTrace ++ """ - if(found_index < 0) - return vec4(0,0,0,1); - - float hue_based_on_index = (float(found_index))*radians(360.0 / 1.1); - - vec3 ld = normalize(vec3(-0.3, 0.0, 1.0)); - vec3 diffs = d[1] - d[0]; - mat3 light_direction = mat3(ld - 0.5 * diffs, ld + 0.5 * diffs, vec3(0)); - float light_distance = max_distance; - float light_coeff = 0.45; - vec3 offseted = found + 0.0001 * max_distance * normalize(o - found); - if(0 == 1) { } - """ ++ innerLightTrace ++ """ - - vec3 px = mix( - hl2rgb(hue_based_on_index, light_coeff), - hl2rgb(found.z * 0.5, light_coeff), - max(0.2, """ ++ colorCoeff ++ """) - ); - return vec4(px, 1.0); - """) + \found currDistance foundIndex f -> + let + innerTrace next = + List.foldl + (\bisect ( i, s ) -> + ( i + 1 + , bisectToRay i bisect s + ) + ) + ( 0, next ) + bisects + |> Tuple.second + + bisectToRay i bisect = + if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) + (expr (assign foundIndex <| int i) <| + expr (assign found f) <| + expr (assign currDistance <| length <| subtract found o) <| + unsafeNop + ) + in + innerTrace <| + if_ (lt foundIndex <| int 0) + (return <| vec4 zero zero zero one) + <| + def5 + ( vec3T "ld", normalize <| vec3 (float -0.3) zero one ) + ( vec3T "diffs", subtract (arr d (int 1)) (arr d (int 0)) ) + ( floatT "light_distance", maxDistance ) + ( vec3T "offseted" + , add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found + ) + ( floatT "hue_based_on_index" + , by (floatCast foundIndex) <| float <| radians (360 / 1.1) + ) + <| + \ld diffs lightDistance offseted hueBasedOnIndex -> + def3Chain + ( mat3T "light_direction" + , mat3_3_3_3 + (subtract ld <| byF (float 0.5) diffs) + (add ld <| byF (float 0.5) diffs) + vec3Zero + ) + ( floatT "light_coeff" + , \lightDirection -> + ternary + (ors + (List.map + (\bisect -> + bisect offseted lightDirection lightDistance f + ) + bisects + ) + ) + (float 0.2) + (float 0.45) + ) + ( vec3T "px" + , \lightCoeff -> + mix + (hl2rgb hueBasedOnIndex lightCoeff) + (hl2rgb (by (float 0.5) found.z) lightCoeff) + (max_ (float 0.2) colorCoeff) + ) + <| + \px -> return <| vec4_3_1 px one threshold : ExpressionX x Float -> Expression1 Float diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 3b48ae61..e652536d 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def2, def3, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def1, def2, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1407,6 +1407,18 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks +def1 : + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> (a -> Statement r) + -> Statement r +def1 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) k = + let + (Statement ks) = + k e0 + in + Statement <| Decl t0 n0 (Just <| unwrapExpression v0) ks + + def2 : ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) @@ -1438,6 +1450,24 @@ def3 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ) ks +def3Chain : + ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) + -> ( ( TypedName tb b, Expression tb -> b ), a -> ExpressionX xb tb ) + -> ( ( TypedName tc c, Expression tc -> c ), b -> ExpressionX xc tc ) + -> (c -> Statement r) + -> Statement r +def3Chain ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) k = + let + (Statement ks) = + k e2 + in + Statement <| + Decl t0 n0 (Just <| unwrapExpression v0) <| + Decl t1 n1 (Just <| unwrapExpression <| v1 e0) <| + Decl t2 n2 (Just <| unwrapExpression <| v2 e1) <| + ks + + def4 : ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) From c9807598fbaa187d6b01e3463669597ae5adfe9f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 5 Sep 2021 14:51:35 +0200 Subject: [PATCH 043/139] Use elm-formatter-hack --- src/elm/UI/Glsl.elm | 12 +- src/elm/UI/Glsl/Code.elm | 1677 +++++++++++++++------------------ src/elm/UI/Glsl/Generator.elm | 103 +- src/elm/UI/Glsl/Plane.elm | 45 +- src/elm/UI/Glsl/Sphere.elm | 33 +- 5 files changed, 843 insertions(+), 1027 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 80ea3df3..96f68186 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -297,13 +297,11 @@ tryGlslFromPolynomial suffix e = |> String.join "\n " ( funDecl, bisect ) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - def floatT "t" (Generator.by maxDistance <| float 2) <| - \t_ -> - unknownStatement (checks ++ """ - found = o + t * mix(d[0], d[1], 0.5); - return t < max_distance && t > 0.0;""") + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + def floatT "t" (Generator.by maxDistance <| float 2) <| \t_ -> + unknownStatement (checks ++ """ + found = o + t * mix(d[0], d[1], 0.5); + return t < max_distance && t > 0.0;""") in { expr = div one <| sqrt_ <| cbrt <| ipow e 3 , funDecls = [ funDecl ] diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 259c7fc0..5ae724cb 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -38,18 +38,17 @@ constantToGlsl c = cbyTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cbyTuple = - fun2 vec2T "cby" (vec2T "a") (vec2T "b") <| - \a b -> - return <| - vec2 - (subtract - (by a.x b.x) - (by a.y b.y) - ) - (add - (by a.x b.y) - (by a.y b.x) - ) + fun2 vec2T "cby" (vec2T "a") (vec2T "b") <| \a b -> + return <| + vec2 + (subtract + (by a.x b.x) + (by a.y b.y) + ) + (add + (by a.x b.y) + (by a.y b.x) + ) cbyDecl : FunDecl @@ -59,9 +58,8 @@ cbyDecl = atanPlusTuple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float ) atanPlusTuple = - fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| - \x y -> - return <| mod (add constants.twopi (dotted1 <| unsafeCall "atan" [ y.base, x.base ])) constants.twopi + fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| \x y -> + return <| mod (add constants.twopi (dotted1 <| unsafeCall "atan" [ y.base, x.base ])) constants.twopi atanPlusDecl : FunDecl @@ -111,9 +109,8 @@ cby = cby3Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) cby3Tuple = - fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| - \a b c -> - return <| cby (cby a b) c + fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| \a b c -> + return <| cby (cby a b) c cby3Decl : FunDecl @@ -123,18 +120,15 @@ cby3Decl = cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cdivTuple = - fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| - \a b -> - def floatT "k" (div one <| dot b b) <| - \k -> - def2 - ( floatT "r", by k <| dot a b ) - ( floatT "i" - , by k (subtract (by a.y b.x) (by a.x b.y)) - ) - <| - \r i -> - return <| vec2 r i + fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b -> + def floatT "k" (div one <| dot b b) <| \k -> + def2 + ( floatT "r", by k <| dot a b ) + ( floatT "i" + , by k (subtract (by a.y b.x) (by a.x b.y)) + ) + <| \r i -> + return <| vec2 r i cdivDecl : FunDecl @@ -189,18 +183,17 @@ straightOperationToGlsl op = cpowTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cpowTuple = - fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| - \w z -> - return <| - ternary - (ands - [ geq w.x zero - , eq w.y zero - , eq z.y zero - ] - ) - (vec2 (pow w.x z.x) zero) - (cexp <| cby (cln w) z) + fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| \w z -> + return <| + ternary + (ands + [ geq w.x zero + , eq w.y zero + , eq z.y zero + ] + ) + (vec2 (pow w.x z.x) zero) + (cexp <| cby (cln w) z) cpowDecl : FunDecl @@ -215,9 +208,8 @@ cpow = inegCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) inegCouple = - fun1 vec2T "ineg" (vec2T "v") <| - \v -> - return <| negate_ v.yx + fun1 vec2T "ineg" (vec2T "v") <| \v -> + return <| negate_ v.yx inegDecl : FunDecl @@ -247,19 +239,15 @@ gneg = isquareCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) isquareCouple = - fun1 vec2T "isquare" (vec2T "z") <| - \z -> - def vec2T "s" (by z z) <| - \s -> - def floatT "mx" (max_ s.x s.y) <| - \mx -> - if_ - (ands [ leq z.x zero, geq z.y zero ]) - (return <| vec2 zero mx) - (def floatT "mn" (min_ s.x s.y) <| - \mn -> - return <| vec2 mn mx - ) + fun1 vec2T "isquare" (vec2T "z") <| \z -> + def vec2T "s" (by z z) <| \s -> + def floatT "mx" (max_ s.x s.y) <| \mx -> + if_ + (ands [ leq z.x zero, geq z.y zero ]) + (return <| vec2 zero mx) + (def floatT "mn" (min_ s.x s.y) <| \mn -> + return <| vec2 mn mx + ) isquareDecl : FunDecl @@ -304,21 +292,14 @@ gby = ibyCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ibyCouple = - fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| - \l r -> - def floatT "a" (by l.x r.x) <| - \a -> - def floatT "b" (by l.x r.y) <| - \b -> - def floatT "c" (by l.y r.x) <| - \c -> - def floatT "d" (by l.y r.y) <| - \d -> - def floatT "mn" (min_ (min_ a b) (min_ c d)) <| - \mn -> - def floatT "mx" (max_ (max_ a b) (max_ c d)) <| - \mx -> - return <| vec2 mn mx + fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| \l r -> + def floatT "a" (by l.x r.x) <| \a -> + def floatT "b" (by l.x r.y) <| \b -> + def floatT "c" (by l.y r.x) <| \c -> + def floatT "d" (by l.y r.y) <| \d -> + def floatT "mn" (min_ (min_ a b) (min_ c d)) <| \mn -> + def floatT "mx" (max_ (max_ a b) (max_ c d)) <| \mx -> + return <| vec2 mn mx ibyDecl : FunDecl @@ -333,21 +314,20 @@ iby = iinverseCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iinverseCouple = - fun1 vec2T "iinverse" (vec2T "y") <| - \y -> - return <| - ternary - (ands [ leq y.x zero, geq y.y zero ]) - (vec2 (div minusOne zero) (div one zero)) - (ternary - (eq y.y zero) - (vec2 (div minusOne zero) (div one y.x)) - (ternary - (eq y.x zero) - (vec2 (div one y.y) (div one zero)) - (vec2 (div one y.y) (div one y.x)) - ) - ) + fun1 vec2T "iinverse" (vec2T "y") <| \y -> + return <| + ternary + (ands [ leq y.x zero, geq y.y zero ]) + (vec2 (div minusOne zero) (div one zero)) + (ternary + (eq y.y zero) + (vec2 (div minusOne zero) (div one y.x)) + (ternary + (eq y.x zero) + (vec2 (div one y.y) (div one zero)) + (vec2 (div one y.y) (div one y.x)) + ) + ) iinverseDecl : FunDecl @@ -362,9 +342,8 @@ iinverse = idivCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) idivCouple = - fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| - \l r -> - return <| iby l (iinverse r) + fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| \l r -> + return <| iby l (iinverse r) idivDecl : FunDecl @@ -379,14 +358,13 @@ idiv = gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gdivCouple = - fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| - \l r -> - return <| - vec4_1_3 (div l.x r.x) - (divF - (subtract (byF r.x l.yzw) (byF l.x r.yzw)) - (pow r.x <| float 2) - ) + fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| \l r -> + return <| + vec4_1_3 (div l.x r.x) + (divF + (subtract (byF r.x l.yzw) (byF l.x r.yzw)) + (pow r.x <| float 2) + ) gdivDecl : FunDecl @@ -401,15 +379,13 @@ gdiv = ipowFICouple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ) ipowFICouple = - fun2 floatT "ipow" (floatT "b") (intT "e") <| - \b e -> - def floatT "fe" (floatCast e) <| - \fe -> - return <| - ternary - (eq (mod fe (float 2.0)) zero) - (pow (abs_ b) fe) - (by b <| pow (abs_ b) (subtract fe one)) + fun2 floatT "ipow" (floatT "b") (intT "e") <| \b e -> + def floatT "fe" (floatCast e) <| \fe -> + return <| + ternary + (eq (mod fe (float 2.0)) zero) + (pow (abs_ b) fe) + (by b <| pow (abs_ b) (subtract fe one)) ipowFIDecl : FunDecl @@ -424,34 +400,29 @@ ipowFI = ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) ipowICouple = - fun2 vec2T "ipow" (vec2T "b") (intT "e") <| - \b e -> - if_ - (eq e (int 0)) - (return <| vec2 one one) - (if_ - (eq e (int 1)) - (return b) - (def floatT "xe" (ipowFI b.x e) <| - \xe -> - def floatT "ye" (ipowFI b.y e) <| - \ye -> - def floatT "mn" (min_ xe ye) <| - \mn -> - def floatT "mx" (max_ xe ye) <| - \mx -> - return <| - ternary - (ands - [ eq (mod (floatCast e) (float 2)) zero - , leq b.x zero - , geq b.y zero - ] - ) - (vec2 (min_ zero mn) (max_ zero mx)) - (vec2 mn mx) + fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e -> + if_ + (eq e (int 0)) + (return <| vec2 one one) + (if_ + (eq e (int 1)) + (return b) + (def floatT "xe" (ipowFI b.x e) <| \xe -> + def floatT "ye" (ipowFI b.y e) <| \ye -> + def floatT "mn" (min_ xe ye) <| \mn -> + def floatT "mx" (max_ xe ye) <| \mx -> + return <| + ternary + (ands + [ eq (mod (floatCast e) (float 2)) zero + , leq b.x zero + , geq b.y zero + ] ) - ) + (vec2 (min_ zero mn) (max_ zero mx)) + (vec2 mn mx) + ) + ) ipowIDecl : FunDecl @@ -466,17 +437,16 @@ ipowI = ipowCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ipowCouple = - fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| - \b e -> - return <| - ternary - (ands - [ lt (subtract e.y e.x) (float 0.000001) - , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) - ] - ) - (ipowI b <| intCast e.x) - (iexp <| iby (iln b) e) + fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| \b e -> + return <| + ternary + (ands + [ lt (subtract e.y e.x) (float 0.000001) + , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) + ] + ) + (ipowI b <| intCast e.x) + (iexp <| iby (iln b) e) ipowDecl : FunDecl @@ -491,12 +461,11 @@ ipow = gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 ) gpowICouple = - fun2 vec4T "gpow" (vec4T "b") (intT "e") <| - \b e -> - return <| - vec4_1_3 - (pow b.x <| floatCast e) - (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) + fun2 vec4T "gpow" (vec4T "b") (intT "e") <| \b e -> + return <| + vec4_1_3 + (pow b.x <| floatCast e) + (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) gpowIDecl : FunDecl @@ -511,13 +480,11 @@ gpowI = gpowCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gpowCouple = - fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| - \b e -> - def intT "ie" (intCast e.x) <| - \ie -> - if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) - (return <| gpowI b ie) - (return <| gexp <| gby (gln b) e) + fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| \b e -> + def intT "ie" (intCast e.x) <| \ie -> + if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) + (return <| gpowI b ie) + (return <| gexp <| gby (gln b) e) gpowDecl : FunDecl @@ -622,17 +589,16 @@ igt = iabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iabsCouple = - fun1 vec2T "iabs" (vec2T "z") <| - \z -> - return <| - ternary - (ands [ leq z.x zero, geq z.y zero ]) - (vec2 zero <| max_ z.y <| abs_ z.x) - (ternary - (leq z.x zero) - (negate_ z.yx) - z - ) + fun1 vec2T "iabs" (vec2T "z") <| \z -> + return <| + ternary + (ands [ leq z.x zero, geq z.y zero ]) + (vec2 zero <| max_ z.y <| abs_ z.x) + (ternary + (leq z.x zero) + (negate_ z.yx) + z + ) iabsDecl : FunDecl @@ -647,12 +613,10 @@ iabs = iacosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iacosCouple = - fun1 vec2T "iacos" (vec2T "z") <| - \z -> - -- Don't use clamp so if z is fully outside range the result is empty - def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| - \clamped -> - return <| (acos2 clamped).yx + fun1 vec2T "iacos" (vec2T "z") <| \z -> + -- Don't use clamp so if z is fully outside range the result is empty + def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| \clamped -> + return <| (acos2 clamped).yx iacosDecl : FunDecl @@ -667,12 +631,11 @@ iacos = gacosCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gacosCouple = - fun1 vec4T "gacos" (vec4T "v") <| - \v -> - return <| - vec4_1_3 - (acos_ v.x) - (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) + fun1 vec4T "gacos" (vec4T "v") <| \v -> + return <| + vec4_1_3 + (acos_ v.x) + (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) gacosDecl : FunDecl @@ -762,18 +725,16 @@ gln = csinCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csinCouple = - fun1 vec2T "csin" (vec2T "z") <| - \z -> - def floatT "s" (sin_ z.x) <| - \s -> - return <| - ternary - (eq z.y zero) - (vec2 s zero) - (vec2 - (by s (cosh z.y)) - (by (cos_ z.x) (sinh z.y)) - ) + fun1 vec2T "csin" (vec2T "z") <| \z -> + def floatT "s" (sin_ z.x) <| \s -> + return <| + ternary + (eq z.y zero) + (vec2 s zero) + (vec2 + (by s (cosh z.y)) + (by (cos_ z.x) (sinh z.y)) + ) csinDecl : FunDecl @@ -788,18 +749,16 @@ csin = ccosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccosCouple = - fun1 vec2T "ccos" (vec2T "z") <| - \z -> - def floatT "c" (cos_ z.x) <| - \c -> - return <| - ternary - (eq z.y zero) - (vec2 c zero) - (vec2 - (by c (cosh z.y)) - (by (sin_ z.x) (sinh z.y)) - ) + fun1 vec2T "ccos" (vec2T "z") <| \z -> + def floatT "c" (cos_ z.x) <| \c -> + return <| + ternary + (eq z.y zero) + (vec2 c zero) + (vec2 + (by c (cosh z.y)) + (by (sin_ z.x) (sinh z.y)) + ) ccosDecl : FunDecl @@ -814,12 +773,11 @@ ccos = ctanCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanCouple = - fun1 vec2T "ctan" (vec2T "z") <| - \z -> - return <| - ternary (eq z.y zero) - (vec2 (tan_ z.x) zero) - (cdiv (csin z) (ccos z)) + fun1 vec2T "ctan" (vec2T "z") <| \z -> + return <| + ternary (eq z.y zero) + (vec2 (tan_ z.x) zero) + (cdiv (csin z) (ccos z)) ctanDecl : FunDecl @@ -834,13 +792,10 @@ ctan = casinTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) casinTuple = - fun1 vec2T "casin" (vec2T "z") <| - \z -> - def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| - \s -> - def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| - \arg_ -> - return <| cby (vec2 zero one) (cln arg_) + fun1 vec2T "casin" (vec2T "z") <| \z -> + def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| \s -> + def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| \arg_ -> + return <| cby (vec2 zero one) (cln arg_) casinDecl : FunDecl @@ -855,9 +810,8 @@ casin = cacosTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) cacosTuple = - fun1 vec2T "cacos" (vec2T "z") <| - \z -> - return <| subtract (vec2 constants.pihalf zero) (casin z) + fun1 vec2T "cacos" (vec2T "z") <| \z -> + return <| subtract (vec2 constants.pihalf zero) (casin z) cacosDecl : FunDecl @@ -872,19 +826,16 @@ cacos = catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) catanTuple = - fun1 vec2T "catan" (vec2T "z") <| - \z -> - if_ (eq z.y zero) - (return <| vec2 (atan_ z.x) zero) - (def2 - ( vec2T "o", vec2 one zero ) - ( vec2T "iz", cby (vec2 zero one) z ) - <| - \o iz -> - def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| - \l -> - return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) - ) + fun1 vec2T "catan" (vec2T "z") <| \z -> + if_ (eq z.y zero) + (return <| vec2 (atan_ z.x) zero) + (def2 + ( vec2T "o", vec2 one zero ) + ( vec2T "iz", cby (vec2 zero one) z ) + <| \o iz -> + def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> + return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) + ) catanDecl : FunDecl @@ -899,11 +850,9 @@ catan = catan2Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) catan2Tuple = - fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| - \y x -> - def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| - \z -> - return <| vec2 (atan2_ z.y z.x) zero + fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| \y x -> + def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| \z -> + return <| vec2 (atan2_ z.y z.x) zero catan2Decl : FunDecl @@ -918,9 +867,8 @@ catan2 = csinhTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csinhTuple = - fun1 vec2T "csinh" (vec2T "z") <| - \z -> - return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) + fun1 vec2T "csinh" (vec2T "z") <| \z -> + return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) csinhDecl : FunDecl @@ -935,9 +883,8 @@ csinh = ccoshTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccoshTuple = - fun1 vec2T "ccosh" (vec2T "z") <| - \z -> - return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) + fun1 vec2T "ccosh" (vec2T "z") <| \z -> + return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) ccoshDecl : FunDecl @@ -952,14 +899,12 @@ ccosh = ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanhCouple = - fun1 vec2T "ctanh" (vec2T "z") <| - \z -> - def2 - ( vec2T "p", cexp z ) - ( vec2T "m", cexp (negate_ z) ) - <| - \p m -> - return <| cdiv (subtract p m) (add p m) + fun1 vec2T "ctanh" (vec2T "z") <| \z -> + def2 + ( vec2T "p", cexp z ) + ( vec2T "m", cexp (negate_ z) ) + <| \p m -> + return <| cdiv (subtract p m) (add p m) ctanhDecl : FunDecl @@ -1041,16 +986,13 @@ straightFunctionToGlsl name = Tanh11 -> [ Tuple.first <| - fun1 floatT "tanh" (floatT "x") <| - \x -> - if_ (gt (abs_ x) (float 10)) - (return <| sign x) - (def floatT "p" (exp x) <| - \p -> - def floatT "m" (exp <| negate_ x) <| - \m -> - return <| div (subtract p m) (add p m) - ) + fun1 floatT "tanh" (floatT "x") <| \x -> + if_ (gt (abs_ x) (float 10)) + (return <| sign x) + (def floatT "p" (exp x) <| \p -> + def floatT "m" (exp <| negate_ x) <| \m -> + return <| div (subtract p m) (add p m) + ) ] Sin22 -> @@ -1274,9 +1216,8 @@ cfloor = croundCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) croundCouple = - fun1 vec2T "cround" (vec2T "z") <| - \z -> - return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) + fun1 vec2T "cround" (vec2T "z") <| \z -> + return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) croundDecl : FunDecl @@ -1321,9 +1262,8 @@ cmax = cmodCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmodCouple = - fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| - \l r -> - return <| vec2 (mod l.x r.x) zero + fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| \l r -> + return <| vec2 (mod l.x r.x) zero cmodDecl : FunDecl @@ -1338,33 +1278,26 @@ cmod = cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmbrotCouple = - fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| - \x y -> - def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| - \c -> - def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| - \p -> - if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) - (return vec2Zero) - (def vec2T "z" c <| - \z -> - for ( "i", int 0, int 4000 ) - (\i -> - expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) - (if_ (gt (length z) (float 1000000)) - (def floatT "logLength" (log (length z)) <| - \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| - \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| - \fi -> - return <| vec2 (sin_ fi) (cos_ fi) - ) - unsafeNop - ) - ) - (return vec2Zero) - ) + fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| \x y -> + def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| \c -> + def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| \p -> + if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) + (return vec2Zero) + (def vec2T "z" c <| \z -> + for ( "i", int 0, int 4000 ) + (\i -> + expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) + (if_ (gt (length z) (float 1000000)) + (def floatT "logLength" (log (length z)) <| \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| \fi -> + return <| vec2 (sin_ fi) (cos_ fi) + ) + unsafeNop + ) + ) + (return vec2Zero) + ) cmbrotDecl : FunDecl @@ -1379,17 +1312,15 @@ cmbrot = csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csqrtTuple = - fun1 vec2T "csqrt" (vec2T "z") <| - \z -> - if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (sqrt_ z.x) zero) - (def2 - ( floatT "r", pow (dot z z) (float 0.25) ) - ( floatT "t", byF (float 0.5) (atan2_ z.y z.x) ) - <| - \r t -> - return <| byF r <| vec2 (cos_ t) (sin_ t) - ) + fun1 vec2T "csqrt" (vec2T "z") <| \z -> + if_ (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (sqrt_ z.x) zero) + (def2 + ( floatT "r", pow (dot z z) (float 0.25) ) + ( floatT "t", byF (float 0.5) (atan2_ z.y z.x) ) + <| \r t -> + return <| byF r <| vec2 (cos_ t) (sin_ t) + ) csqrtDecl : FunDecl @@ -1404,25 +1335,22 @@ csqrt = ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccbrtCouple = - fun1 vec2T "ccbrt" (vec2T "z") <| - \z -> - if_ (eq z.y zero) - (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) - (def floatT "r" (pow (dot z z) (div one (float 6))) <| - \r -> - def floatT - "t" - (add (div (atan2_ z.y z.x) (float 3)) - (ternary - (gt z.x zero) - zero - (radians_ (float 120)) - ) - ) - <| - \t -> - return <| byF r (vec2 (cos_ t) (sin_ t)) + fun1 vec2T "ccbrt" (vec2T "z") <| \z -> + if_ (eq z.y zero) + (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) + (def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> + def floatT + "t" + (add (div (atan2_ z.y z.x) (float 3)) + (ternary + (gt z.x zero) + zero + (radians_ (float 120)) ) + ) + <| \t -> + return <| byF r (vec2 (cos_ t) (sin_ t)) + ) ccbrtDecl : FunDecl @@ -1452,17 +1380,14 @@ csquare = clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) clnTuple = - fun1 vec2T "cln" (vec2T "z") <| - \z -> - if_ - (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (log z.x) zero) - (def floatT "px" (length z) <| - \px -> - def floatT "py" (atan2_ z.y z.x) <| - \py -> - return <| vec2 (log px) py - ) + fun1 vec2T "cln" (vec2T "z") <| \z -> + if_ + (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (log z.x) zero) + (def floatT "px" (length z) <| \px -> + def floatT "py" (atan2_ z.y z.x) <| \py -> + return <| vec2 (log px) py + ) clnDecl : FunDecl @@ -1829,54 +1754,48 @@ toSrcImplicit suffix e = 7 ( fDecl, f ) = - fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| - \x y -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| - \complex -> - return <| - ternary (gt (abs_ complex.y) (float epsilon)) - zero - (ternary (gt complex.x zero) one minusOne) + fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| \x y -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> + return <| + ternary (gt (abs_ complex.y) (float epsilon)) + zero + (ternary (gt complex.x zero) one minusOne) ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX _ x y -> - def2 - ( floatT "sum", zero ) - ( floatT "samples", float <| antialiasingSamples * 2 + 1 ) - <| - \sum samples -> - assignBy samples samples <| - def floatT - "coeff" - (float 0.0875) - (\coeff -> - forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w -> - forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h -> - def floatT - "piece" - (f - (add x <| by (by deltaX coeff) <| floatCast w) - (add y <| by (by deltaX coeff) <| floatCast h) - ) - <| - \piece -> - if_ - (eq piece zero) - (return vec3Zero) - (assignAdd sum piece unsafeNop) - ) - unsafeNop - ) - (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| - \perc -> - expr - (assign perc (pow perc <| float 0.2)) - (return <| byF perc (vec3 one one one)) + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> + def2 + ( floatT "sum", zero ) + ( floatT "samples", float <| antialiasingSamples * 2 + 1 ) + <| \sum samples -> + assignBy samples samples <| + def floatT + "coeff" + (float 0.0875) + (\coeff -> + forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) + (\w -> + forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) + (\h -> + def floatT + "piece" + (f + (add x <| by (by deltaX coeff) <| floatCast w) + (add y <| by (by deltaX coeff) <| floatCast h) ) + <| \piece -> + if_ + (eq piece zero) + (return vec3Zero) + (assignAdd sum piece unsafeNop) ) + unsafeNop + ) + (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> + expr + (assign perc (pow perc <| float 0.2)) + (return <| byF perc (vec3 one one one)) + ) + ) in ( [ fDecl, pixelDecl ], pixel ) @@ -1888,56 +1807,49 @@ toSrcPolar : toSrcPolar suffix e = let ( fDecl, f ) = - fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| - \x y deltaT ot -> - def floatT "r" (length <| vec2 x y) <| - \r -> - def floatT "t" (add (atanPlus y x) deltaT) <| - \t -> - -- Avoid the branch cut at {x > 0, y = 0} - if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) unsafeNop) - (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| - \complex -> - return <| - ternary (gt (abs_ complex.y) (float epsilon)) - minusOne - (ternary (gt complex.x zero) - one - zero - ) - ) + fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| \x y deltaT ot -> + def floatT "r" (length <| vec2 x y) <| \r -> + def floatT "t" (add (atanPlus y x) deltaT) <| \t -> + -- Avoid the branch cut at {x > 0, y = 0} + if_ (gt (abs_ <| subtract t ot) constants.pi) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) unsafeNop) + (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> + return <| + ternary (gt (abs_ complex.y) (float epsilon)) + minusOne + (ternary (gt complex.x zero) + one + zero + ) + ) ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y -> - assignAdd x (div deltaX <| float 2) <| - assignAdd y (div deltaY <| float 2) <| - def2 - ( floatT "t", zero ) - ( floatT "ot", atanPlus y x ) - <| - \t ot -> - for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ -> - def4 - ( floatT "h", f x y t ot ) - ( floatT "l", f (subtract x deltaX) y t ot ) - ( floatT "u", f x (subtract y deltaY) t ot ) - ( floatT "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) - <| - \h l u ul -> - if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - unsafeBreak - (if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - (assignAdd t constants.twopi <| - assignAdd ot constants.twopi <| - unsafeNop - ) - ) - ) - (return vec3Zero) + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + assignAdd x (div deltaX <| float 2) <| + assignAdd y (div deltaY <| float 2) <| + def2 + ( floatT "t", zero ) + ( floatT "ot", atanPlus y x ) + <| \t ot -> + for ( "i", int 0, divConst constants.maxIterations (int 10) ) + (\_ -> + def4 + ( floatT "h", f x y t ot ) + ( floatT "l", f (subtract x deltaX) y t ot ) + ( floatT "u", f x (subtract y deltaY) t ot ) + ( floatT "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) + <| \h l u ul -> + if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) + unsafeBreak + (if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + (assignAdd t constants.twopi <| + assignAdd ot constants.twopi <| + unsafeNop + ) + ) + ) + (return vec3Zero) in ( [ fDecl, pixelDecl ], pixel ) @@ -1964,102 +1876,95 @@ toSrcParametric : String -> Expression.Expression -> ( List FunDecl, ExpressionX toSrcParametric suffix e = let ( intervalDecl, interval ) = - fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| - \p from to -> - def3 - ( vec2T "x", vec2 p.x p.x ) - ( vec2T "y", vec2 p.y p.y ) - ( vec2T "t", vec2 (min_ from to) (max_ from to) ) - <| - \x y t -> - return <| expressionToIntervalGlsl (toPrintExpression e) + fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to -> + def3 + ( vec2T "x", vec2 p.x p.x ) + ( vec2T "y", vec2 p.y p.y ) + ( vec2T "t", vec2 (min_ from to) (max_ from to) ) + <| \x y t -> + return <| expressionToIntervalGlsl (toPrintExpression e) ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y -> - def floatT "max_distance" (float <| 2 ^ 10) <| - \max_distance -> - def6 - ( floatT "from", div (negate_ max_distance) (float 2) ) - ( floatT "to", div max_distance (float 2) ) - ( vec2T "p", vec2 x y ) - ( intT "depth", int 0 ) - ( intT "choices", int 0 ) - ( floatT "ithreshold", by (by (float 10) deltaX) deltaX ) - <| - \from to p depth choices ithreshold -> - for ( "it", int 0, constants.maxIterations ) - (\_ -> innerLoop from to p depth choices ithreshold) - (return vec3Zero) + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + def floatT "max_distance" (float <| 2 ^ 10) <| \max_distance -> + def6 + ( floatT "from", div (negate_ max_distance) (float 2) ) + ( floatT "to", div max_distance (float 2) ) + ( vec2T "p", vec2 x y ) + ( intT "depth", int 0 ) + ( intT "choices", int 0 ) + ( floatT "ithreshold", by (by (float 10) deltaX) deltaX ) + <| \from to p depth choices ithreshold -> + for ( "it", int 0, constants.maxIterations ) + (\_ -> innerLoop from to p depth choices ithreshold) + (return vec3Zero) innerLoop from to p depth choices ithreshold = - def floatT "midpoint" (mix from to <| float 0.5) <| - \midpoint -> - def2 - ( vec2T "front", interval p from midpoint ) - ( vec2T "back", interval p midpoint to ) - <| - \front back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands - [ lt (subtract front.y front.x) ithreshold - , leq front.x zero - , geq front.y zero - ] - , ands - [ lt (subtract back.y back.x) ithreshold - , leq back.x zero - , geq back.y zero - ] - ] - ) - (return <| vec3 one one one) - (ifElse - (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| - expr (postfixPlus depth) <| - assignBy choices (int 2) <| - unsafeNop - ) - (ifElse - (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| - expr (postfixPlus depth) <| - expr (assign choices (add (by choices (int 2)) (int 1))) <| - unsafeNop - ) - (unknownStatement - (""" - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - """) - ) - unsafeNop - ) + def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> + def2 + ( vec2T "front", interval p from midpoint ) + ( vec2T "back", interval p midpoint to ) + <| \front back -> + if_ + (ors + [ geq depth constants.maxDepth + , ands + [ lt (subtract front.y front.x) ithreshold + , leq front.x zero + , geq front.y zero + ] + , ands + [ lt (subtract back.y back.x) ithreshold + , leq back.x zero + , geq back.y zero + ] + ] + ) + (return <| vec3 one one one) + (ifElse + (ands [ leq front.x zero, geq front.y zero ]) + (expr (assign to midpoint) <| + expr (postfixPlus depth) <| + assignBy choices (int 2) <| + unsafeNop + ) + (ifElse + (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| + expr (postfixPlus depth) <| + expr (assign choices (add (by choices (int 2)) (int 1))) <| unsafeNop - ) + ) + (unknownStatement + (""" + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return vec3(0,0,0); + """) + ) + unsafeNop + ) + unsafeNop + ) in ( [ intervalDecl, pixelDecl ], pixel ) @@ -2081,17 +1986,15 @@ uniforms = thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) thetaDeltaCouple = - fun1 floatT "thetaDelta" (floatT "theta") <| - \theta -> - if_ (lt uniforms.u_whiteLines one) - (return <| float 100) - (def2 - ( floatT "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) - ( floatT "thetaNeigh", float 0.05 ) - <| - \thetaSix thetaNeigh -> - return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh - ) + fun1 floatT "thetaDelta" (floatT "theta") <| \theta -> + if_ (lt uniforms.u_whiteLines one) + (return <| float 100) + (def2 + ( floatT "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) + ( floatT "thetaNeigh", float 0.05 ) + <| \thetaSix thetaNeigh -> + return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh + ) thetaDeltaDecl : FunDecl @@ -2112,94 +2015,85 @@ toSrcVectorField2D : toSrcVectorField2D suffix xexpr yexpr = let ( vectorDecl, vector ) = - fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| - \x y -> - def2 - ( vec2T "xv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr ) - ( vec2T "yv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr ) - <| - \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero + fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y -> + def2 + ( vec2T "xv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr ) + ( vec2T "yv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr ) + <| + \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero ( nearDecl, near ) = - fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| - \o corner vect deltaX mx -> - def2 - ( floatT "angleCorner", arg <| subtract o corner ) - ( floatT "angleVector", arg vect ) - <| - \angleCorner angleVector -> - def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| - \delta -> - def floatT "l" (div (length vect) mx) <| - \l -> - def floatT - "maxLength" - (by (by deltaX constants.vectorSpacing) - (ternary - (lt l (float epsilon)) - zero - (add (div l (float 2)) (float 0.5)) - ) - ) - <| - \maxLength -> - def floatT "wantedLength" (length (subtract o corner)) <| - \wantedLength -> - def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| - \angularDistance -> - return <| and (or (lt delta (radians_ angularDistance)) (gt delta (radians_ (subtract (float 360) angularDistance)))) (lt wantedLength maxLength) + fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx -> + def2 + ( floatT "angleCorner", arg <| subtract o corner ) + ( floatT "angleVector", arg vect ) + <| \angleCorner angleVector -> + def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| \delta -> + def floatT "l" (div (length vect) mx) <| \l -> + def floatT + "maxLength" + (by (by deltaX constants.vectorSpacing) + (ternary + (lt l (float epsilon)) + zero + (add (div l (float 2)) (float 0.5)) + ) + ) + <| \maxLength -> + def floatT "wantedLength" (length (subtract o corner)) <| \wantedLength -> + def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| \angularDistance -> + return <| and (or (lt delta (radians_ angularDistance)) (gt delta (radians_ (subtract (float 360) angularDistance)))) (lt wantedLength maxLength) ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y -> - unknownStatement (""" - vec2 o = vec2(x, y); - - float mx = 0.0; - for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { - for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { - vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); - vec2 v = vector""" ++ suffix ++ """(p.x, p.y); - mx = max(mx, length(v)); - } - } + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + unknownStatement (""" + vec2 o = vec2(x, y); + + float mx = 0.0; + for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { + for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { + vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); + vec2 v = vector""" ++ suffix ++ """(p.x, p.y); + mx = max(mx, length(v)); + } + } - vec3 colorA = vec3(0.0, 1.0, 0.0); - vec3 colorB = vec3(0.0, 0.0, 1.0); + vec3 colorA = vec3(0.0, 1.0, 0.0); + vec3 colorB = vec3(0.0, 0.0, 1.0); - x = o.x - mod(o.x, deltaX * VECTOR_SPACING); - y = o.y - mod(o.y, deltaX * VECTOR_SPACING); + x = o.x - mod(o.x, deltaX * VECTOR_SPACING); + y = o.y - mod(o.y, deltaX * VECTOR_SPACING); - vec2 bl = vector""" ++ suffix ++ """(x, y); - vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); - vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); - vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + vec2 bl = vector""" ++ suffix ++ """(x, y); + vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); + vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); + vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - float angleO; - vec2 corner; - float l; + float angleO; + vec2 corner; + float l; - corner = vec2(x, y); - l = length(bl) / mx; - if(near(o, corner, bl, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x, y); + l = length(bl) / mx; + if(near(o, corner, bl, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x + deltaX * VECTOR_SPACING, y); - l = length(br) / mx; - if(near(o, corner, br, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x + deltaX * VECTOR_SPACING, y); + l = length(br) / mx; + if(near(o, corner, br, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x, y + deltaX * VECTOR_SPACING); - l = length(ul) / mx; - if(near(o, corner, ul, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x, y + deltaX * VECTOR_SPACING); + l = length(ul) / mx; + if(near(o, corner, ul, deltaX, mx)) + return mix(colorA, colorB, l); - corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - l = length(ur) / mx; - if(near(o, corner, ur, deltaX, mx)) - return mix(colorA, colorB, l); + corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + l = length(ur) / mx; + if(near(o, corner, ur, deltaX, mx)) + return mix(colorA, colorB, l); - return vec3(0,0,0); + return vec3(0,0,0); """) in @@ -2210,75 +2104,61 @@ toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa toSrcContour suffix expr = let ( pixelODecl, pixelO ) = - fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \_ _ x y -> - def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| - \z -> - def2 - ( floatT "theta", div (atan2_ z.y z.x) constants.twopi ) - ( floatT "logRadius", log2 <| length z ) - <| - \theta logRadius -> - def floatT "powerRemainder" (fract logRadius) <| - \powerRemainder -> - def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| - \squished -> - if_ (gt uniforms.u_completelyReal zero) - (def floatT "haf" (div powerRemainder <| float 6.0) <| - \haf -> - return <| - ternary (gt z.x zero) - (hl2rgb (add haf <| float 0.3) squished) - (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) - ) - (def floatT "td" (thetaDelta theta) <| - \td -> - def floatT "l" (mix one squished <| smoothstep zero one td) <| - \l -> - return <| hl2rgb theta l - ) + fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> + def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> + def2 + ( floatT "theta", div (atan2_ z.y z.x) constants.twopi ) + ( floatT "logRadius", log2 <| length z ) + <| \theta logRadius -> + def floatT "powerRemainder" (fract logRadius) <| \powerRemainder -> + def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| \squished -> + if_ (gt uniforms.u_completelyReal zero) + (def floatT "haf" (div powerRemainder <| float 6.0) <| \haf -> + return <| + ternary (gt z.x zero) + (hl2rgb (add haf <| float 0.3) squished) + (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + ) + (def floatT "td" (thetaDelta theta) <| \td -> + def floatT "l" (mix one squished <| smoothstep zero one td) <| \l -> + return <| hl2rgb theta l + ) ( pixelDecl, pixel ) = let dist = 1 / 3 in - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y -> - def2 - ( floatT "deltaXr", by deltaX <| float dist ) - ( floatT "deltaYr", by deltaY <| float dist ) - <| - \deltaXr deltaYr -> - -- Antialiasing - def4 - ( vec3T "a", pixelO deltaX deltaY (add x deltaXr) (add y deltaYr) ) - ( vec3T "b", pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr) ) - ( vec3T "c", pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr) ) - ( vec3T "d", pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr) ) - <| - \a b c d -> - def2 - ( vec3T "mn", min_ a <| min_ b <| min_ c d ) - ( vec3T "mx", max_ a <| max_ b <| max_ c d ) - <| - \mn mx -> - def vec3T "diff" (abs_ (subtract mx mn)) <| - \diff -> - if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) - (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - (assignBy deltaXr (float 2) <| - (assignBy deltaYr (float 2) <| - def4 - ( vec3T "e", pixelO deltaX deltaY (add x deltaXr) y ) - ( vec3T "f", pixelO deltaX deltaY (subtract x deltaXr) y ) - ( vec3T "g", pixelO deltaX deltaY x (subtract y deltaYr) ) - ( vec3T "h", pixelO deltaX deltaY x (add y deltaYr) ) - <| - \e f g h -> - return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) - ) - ) + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + def2 + ( floatT "deltaXr", by deltaX <| float dist ) + ( floatT "deltaYr", by deltaY <| float dist ) + <| \deltaXr deltaYr -> + -- Antialiasing + def4 + ( vec3T "a", pixelO deltaX deltaY (add x deltaXr) (add y deltaYr) ) + ( vec3T "b", pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr) ) + ( vec3T "c", pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr) ) + ( vec3T "d", pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr) ) + <| \a b c d -> + def2 + ( vec3T "mn", min_ a <| min_ b <| min_ c d ) + ( vec3T "mx", max_ a <| max_ b <| max_ c d ) + <| \mn mx -> + def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> + if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) + (return <| divF (adds3 [ a, b, c, d ]) (float 4)) + (assignBy deltaXr (float 2) <| + (assignBy deltaYr (float 2) <| + def4 + ( vec3T "e", pixelO deltaX deltaY (add x deltaXr) y ) + ( vec3T "f", pixelO deltaX deltaY (subtract x deltaXr) y ) + ( vec3T "g", pixelO deltaX deltaY x (subtract y deltaYr) ) + ( vec3T "h", pixelO deltaX deltaY x (add y deltaYr) ) + <| \e f g h -> + return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) + ) + ) in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2286,19 +2166,17 @@ toSrcContour suffix expr = toSrcRelation : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcRelation suffix e = Tuple.mapFirst (\d -> [ d ]) <| - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \_ _ x y -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| - \complex -> - return <| - ternary - (ands - [ gt complex.x zero - , lt (abs_ complex.y) (float epsilon) - ] - ) - (vec3 (float 0.8) (float 0.5) (float 0.5)) - vec3Zero + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> + return <| + ternary + (ands + [ gt complex.x zero + , lt (abs_ complex.y) (float epsilon) + ] + ) + (vec3 (float 0.8) (float 0.5) (float 0.5)) + vec3Zero epsilon : Float @@ -2803,36 +2681,22 @@ pixel2Tuple pixels = List.foldl (\( i, p ) -> addPixel deltaX deltaY x y px curr i p) cont (List.indexedMap Tuple.pair pixels) in fun0 vec4T "pixel2" <| - def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| - \canvasSize -> - def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| - \uv_centered -> - def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| - \viewportSize -> - def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| - \uv -> - def vec2T "c" (add uniforms.u_zoomCenter uv) <| - \c -> - def floatT "x" c.x <| - \x -> - def floatT "y" c.y <| - \y -> - def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| - \deltaX -> - def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| - \deltaY -> - def vec3T "px" vec3Zero <| - \px -> - decl vec3T "curr" <| - \curr -> - inner deltaX deltaY x y px curr <| - def floatT "maxDelta" (max_ deltaX deltaY) <| - \maxDelta -> - def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| - \yax -> - def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| - \xax -> - return <| vec4_3_1 (max3 px (max3 xax yax)) one + def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> + def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| \uv_centered -> + def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| \viewportSize -> + def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| \uv -> + def vec2T "c" (add uniforms.u_zoomCenter uv) <| \c -> + def floatT "x" c.x <| \x -> + def floatT "y" c.y <| \y -> + def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| \deltaX -> + def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| \deltaY -> + def vec3T "px" vec3Zero <| \px -> + decl vec3T "curr" <| \curr -> + inner deltaX deltaY x y px curr <| + def floatT "maxDelta" (max_ deltaX deltaY) <| \maxDelta -> + def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| \yax -> + def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| \xax -> + return <| vec4_3_1 (max3 px (max3 xax yax)) one addPixel : @@ -2868,34 +2732,29 @@ addPixel deltaX deltaY x y px curr i { call, color } next = axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) axisTuple = - fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| - \coord otherCoord maxDelta -> - def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| - \across -> - if_ (lt across (float -12)) - (return zero) - (def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| - \smallUnit -> - if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) - (def floatT - "unit" - (ternary - (lt across (float -6)) - (by smallUnit (float 100)) - (ternary - (lt across (float -0.1)) - (by smallUnit (float 10)) - (by smallUnit (float 5)) - ) - ) - <| - \unit -> - def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| - \parallel -> - return <| max_ zero (max_ across parallel) - ) - ) + fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta -> + def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| \across -> + if_ (lt across (float -12)) + (return zero) + (def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> + if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) + (return zero) + (def floatT + "unit" + (ternary + (lt across (float -6)) + (by smallUnit (float 100)) + (ternary + (lt across (float -0.1)) + (by smallUnit (float 10)) + (by smallUnit (float 5)) + ) + ) + <| \unit -> + def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| \parallel -> + return <| max_ zero (max_ across parallel) + ) + ) axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float @@ -2911,31 +2770,20 @@ axisDecl = toSrc3D : String -> Expression.Expression -> File toSrc3D suffix e = [ Tuple.first <| - fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| - \p -> - def floatT "x" p.x <| - \x -> - def floatT "y" p.y <| - \y -> - def floatT "z" p.z <| - \z -> - def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| - \gradient -> - return <| normalize gradient.yzw + fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> + def floatT "x" p.x <| \x -> + def floatT "y" p.y <| \y -> + def floatT "z" p.z <| \z -> + def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> + return <| normalize gradient.yzw , Tuple.first <| - fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| - \f t -> - def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| - \mn -> - def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| - \mx -> - def vec2T "x" (vec2 mn.x mx.x) <| - \_ -> - def vec2T "y" (vec2 mn.y mx.y) <| - \_ -> - def vec2T "z" (vec2 mn.z mx.z) <| - \_ -> - return <| expressionToIntervalGlsl <| toPrintExpression e + fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> + def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> + def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> + def vec2T "x" (vec2 mn.x mx.x) <| \_ -> + def vec2T "y" (vec2 mn.y mx.y) <| \_ -> + def vec2T "z" (vec2 mn.z mx.z) <| \_ -> + return <| expressionToIntervalGlsl <| toPrintExpression e ] @@ -2955,44 +2803,27 @@ main3D rayDifferentials bisects = ( block, pixel3 ) = fun0 vec4T "pixel3" <| - def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| - \eyeDist -> - def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| - \canvasSize -> - def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| - \uvCentered -> - def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| - \uvNormalized -> - def floatT "t" (add uniforms.u_theta <| float 0.58) <| - \t -> - def floatT "p" (by (float -2.0) uniforms.u_phi) <| - \p -> - def vec3T "eye" (eyePosition eyeDist t p) <| - \eye -> - def vec3T "target" vec3Zero <| - \target -> - def vec3T "to_target" (normalize <| subtract target eye) <| - \toTarget -> - def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| - \across -> - def vec3T "up" (normalize <| cross across toTarget) <| - \up -> - def vec3T "canvas_center" (add eye toTarget) <| - \canvasCenter -> - def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| - \canvasPoint -> - def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| - \rayDirection -> - def vec3T "diffs" (abs_ <| fwidth rayDirection) <| - \diffs -> - def floatT "k" (float kValue) <| - \k -> - def2 - ( mat3T "d", dValue rayDirection k diffs ) - ( floatT "max_distance", by (float 100) eyeDist ) - <| - \d maxDistance -> - return <| raytraceF canvasPoint d maxDistance + def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| \eyeDist -> + def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> + def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| \uvCentered -> + def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| \uvNormalized -> + def floatT "t" (add uniforms.u_theta <| float 0.58) <| \t -> + def floatT "p" (by (float -2.0) uniforms.u_phi) <| \p -> + def vec3T "eye" (eyePosition eyeDist t p) <| \eye -> + def vec3T "target" vec3Zero <| \target -> + def vec3T "to_target" (normalize <| subtract target eye) <| \toTarget -> + def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| \across -> + def vec3T "up" (normalize <| cross across toTarget) <| \up -> + def vec3T "canvas_center" (add eye toTarget) <| \canvasCenter -> + def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| \canvasPoint -> + def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> + def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> + def floatT "k" (float kValue) <| \k -> + def2 + ( mat3T "d", dValue rayDirection k diffs ) + ( floatT "max_distance", by (float 100) eyeDist ) + <| \d maxDistance -> + return <| raytraceF canvasPoint d maxDistance dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 dValue rayDirection k diffs = @@ -3032,81 +2863,78 @@ raytrace bisects = colorCoeff = float (1.19 - 0.2 * toFloat (List.length bisects)) in - fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| - \o d maxDistance -> - def4 - ( vec3T "found", vec3Zero ) - ( floatT "curr_distance", maxDistance ) - ( intT "found_index", int -1 ) - ( vec3T "f", vec3Zero ) - <| - \found currDistance foundIndex f -> - let - innerTrace next = - List.foldl - (\bisect ( i, s ) -> - ( i + 1 - , bisectToRay i bisect s - ) + fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance -> + def4 + ( vec3T "found", vec3Zero ) + ( floatT "curr_distance", maxDistance ) + ( intT "found_index", int -1 ) + ( vec3T "f", vec3Zero ) + <| \found currDistance foundIndex f -> + let + innerTrace next = + List.foldl + (\bisect ( i, s ) -> + ( i + 1 + , bisectToRay i bisect s + ) + ) + ( 0, next ) + bisects + |> Tuple.second + + bisectToRay i bisect = + if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) + (expr (assign foundIndex <| int i) <| + expr (assign found f) <| + expr (assign currDistance <| length <| subtract found o) <| + unsafeNop + ) + in + innerTrace <| + if_ (lt foundIndex <| int 0) + (return <| vec4 zero zero zero one) + <| + def5 + ( vec3T "ld", normalize <| vec3 (float -0.3) zero one ) + ( vec3T "diffs", subtract (arr d (int 1)) (arr d (int 0)) ) + ( floatT "light_distance", maxDistance ) + ( vec3T "offseted" + , add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found + ) + ( floatT "hue_based_on_index" + , by (floatCast foundIndex) <| float <| radians (360 / 1.1) + ) + <| \ld diffs lightDistance offseted hueBasedOnIndex -> + def3Chain + ( mat3T "light_direction" + , mat3_3_3_3 + (subtract ld <| byF (float 0.5) diffs) + (add ld <| byF (float 0.5) diffs) + vec3Zero + ) + ( floatT "light_coeff" + , \lightDirection -> + ternary + (ors + (List.map + (\bisect -> + bisect offseted lightDirection lightDistance f ) - ( 0, next ) bisects - |> Tuple.second - - bisectToRay i bisect = - if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (expr (assign foundIndex <| int i) <| - expr (assign found f) <| - expr (assign currDistance <| length <| subtract found o) <| - unsafeNop - ) - in - innerTrace <| - if_ (lt foundIndex <| int 0) - (return <| vec4 zero zero zero one) - <| - def5 - ( vec3T "ld", normalize <| vec3 (float -0.3) zero one ) - ( vec3T "diffs", subtract (arr d (int 1)) (arr d (int 0)) ) - ( floatT "light_distance", maxDistance ) - ( vec3T "offseted" - , add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found - ) - ( floatT "hue_based_on_index" - , by (floatCast foundIndex) <| float <| radians (360 / 1.1) - ) - <| - \ld diffs lightDistance offseted hueBasedOnIndex -> - def3Chain - ( mat3T "light_direction" - , mat3_3_3_3 - (subtract ld <| byF (float 0.5) diffs) - (add ld <| byF (float 0.5) diffs) - vec3Zero - ) - ( floatT "light_coeff" - , \lightDirection -> - ternary - (ors - (List.map - (\bisect -> - bisect offseted lightDirection lightDistance f - ) - bisects - ) - ) - (float 0.2) - (float 0.45) - ) - ( vec3T "px" - , \lightCoeff -> - mix - (hl2rgb hueBasedOnIndex lightCoeff) - (hl2rgb (by (float 0.5) found.z) lightCoeff) - (max_ (float 0.2) colorCoeff) - ) - <| - \px -> return <| vec4_3_1 px one + ) + ) + (float 0.2) + (float 0.45) + ) + ( vec3T "px" + , \lightCoeff -> + mix + (hl2rgb hueBasedOnIndex lightCoeff) + (hl2rgb (by (float 0.5) found.z) lightCoeff) + (max_ (float 0.2) colorCoeff) + ) + <| + \px -> return <| vec4_3_1 px one threshold : ExpressionX x Float -> Expression1 Float @@ -3116,60 +2944,59 @@ threshold max_distance = suffixToBisect : String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) suffixToBisect suffix = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - unknownStatement - (""" - mat3 from = mat3(o, o, vec3(0)); - mat3 to = from + max_distance * d; - float ithreshold = """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """; - int depth = 0; - int choices = 0; - for(int it = 0; it < MAX_ITERATIONS; it++) { - mat3 midpoint = 0.5 * (from + to); - vec2 front = interval""" ++ suffix ++ """(from, midpoint); - vec2 back = interval""" ++ suffix ++ """(midpoint, to); - if(depth >= MAX_DEPTH - || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) - || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) - ) { - found = mix(midpoint[0], midpoint[1], 0.5); - return true; + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + unknownStatement + (""" + mat3 from = mat3(o, o, vec3(0)); + mat3 to = from + max_distance * d; + float ithreshold = """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """; + int depth = 0; + int choices = 0; + for(int it = 0; it < MAX_ITERATIONS; it++) { + mat3 midpoint = 0.5 * (from + to); + vec2 front = interval""" ++ suffix ++ """(from, midpoint); + vec2 back = interval""" ++ suffix ++ """(midpoint, to); + if(depth >= MAX_DEPTH + || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) + || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) + ) { + found = mix(midpoint[0], midpoint[1], 0.5); + return true; + } + if(front.x <= 0.0 && front.y >= 0.0) { + to = midpoint; + depth++; + choices = left_shift(choices); + } else if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = left_shift_increment(choices); + } else { + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices = right_shift(choices); + if(is_even(choices)) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = left_shift_increment(choices); + break; } - if(front.x <= 0.0 && front.y >= 0.0) { - to = midpoint; - depth++; - choices = left_shift(choices); - } else if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = left_shift_increment(choices); } else { - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices = right_shift(choices); - if(is_even(choices)) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = left_shift_increment(choices); - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return false; + from = from - (to - from); } } - return false; + if(depth == 0) + return false; + } + } + return false; """) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index e652536d..38971a90 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1712,52 +1712,49 @@ innerValue ctx e = Err <| MissingVariable v And l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) Or l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) Comparison k l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) Ternary _ _ _ -> Debug.todo "branch 'Ternary _ _ _' not implemented" @@ -1769,31 +1766,29 @@ innerValue ctx e = Debug.todo "branch 'Subtract _ _' not implemented" By l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) Div _ _ -> Debug.todo "branch 'Div _ _' not implemented" Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) Call "exp" [ l ] -> autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 5b85029f..54ed832b 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -37,27 +37,24 @@ asPlane e = toGlsl : String -> Plane -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Plane { x, y, z, known }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - -- a x + b y + c z + k = 0 - -- x = ox + t dx - -- y = oy + t dy - -- z = oz + t dz - -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 - -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) - -- t = - (k + dot abc o) / (dot abc d) - def2 - ( vec3T "coeffs", vec3 (float x) (float y) (float z) ) - ( vec3T "dsum", byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1) ) - <| - \coeffs dsum -> - def floatT - "t" - (div - (negate_ <| add (float known) (dot coeffs o)) - (dot coeffs dsum) - ) - <| - \t -> - expr (assign found <| add o <| byF t dsum) <| - return (gt t <| threshold maxDistance) + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + -- a x + b y + c z + k = 0 + -- x = ox + t dx + -- y = oy + t dy + -- z = oz + t dz + -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 + -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) + -- t = - (k + dot abc o) / (dot abc d) + def2 + ( vec3T "coeffs", vec3 (float x) (float y) (float z) ) + ( vec3T "dsum", byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1) ) + <| \coeffs dsum -> + def floatT + "t" + (div + (negate_ <| add (float known) (dot coeffs o)) + (dot coeffs dsum) + ) + <| \t -> + expr (assign found <| add o <| byF t dsum) <| + return (gt t <| threshold maxDistance) diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 4a276dbc..0739257c 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -75,21 +75,20 @@ reduce poly = toGlsl : String -> Sphere -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Sphere { center, radius }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - unknownStatement - (""" - vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + unknownStatement + (""" + vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); - vec3 to_center = o - center; - float b = dot(to_center, mix(d[0], d[1], 0.5)); - float c = dot(to_center, to_center) - """ ++ floatToGlsl (radius * radius) ++ """; - float delta = b*b - c; - if(delta < 0.) - return false; - float x = -b - sqrt(delta); - if(x < """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """) - return false; - found = o + x * mix(d[0], d[1], 0.5); - return true; - """) + vec3 to_center = o - center; + float b = dot(to_center, mix(d[0], d[1], 0.5)); + float c = dot(to_center, to_center) - """ ++ floatToGlsl (radius * radius) ++ """; + float delta = b*b - c; + if(delta < 0.) + return false; + float x = -b - sqrt(delta); + if(x < """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """) + return false; + found = o + x * mix(d[0], d[1], 0.5); + return true; + """) From a1b19d47eed8b5e11f3576ae60112a51ca7e34d0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 5 Sep 2021 14:58:30 +0200 Subject: [PATCH 044/139] Remove def2 by using elm-format-hack --- src/elm/UI/Glsl/Code.elm | 154 ++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 92 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 5ae724cb..a0593d9d 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def1, def2, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -122,12 +122,8 @@ cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 cdivTuple = fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b -> def floatT "k" (div one <| dot b b) <| \k -> - def2 - ( floatT "r", by k <| dot a b ) - ( floatT "i" - , by k (subtract (by a.y b.x) (by a.x b.y)) - ) - <| \r i -> + def floatT "r" (by k <| dot a b) <| \r -> + def floatT "i" (by k (subtract (by a.y b.x) (by a.x b.y))) <| \i -> return <| vec2 r i @@ -829,12 +825,10 @@ catanTuple = fun1 vec2T "catan" (vec2T "z") <| \z -> if_ (eq z.y zero) (return <| vec2 (atan_ z.x) zero) - (def2 - ( vec2T "o", vec2 one zero ) - ( vec2T "iz", cby (vec2 zero one) z ) - <| \o iz -> - def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> - return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) + (def vec2T "o" (vec2 one zero) <| \o -> + def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> + def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> + return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) ) @@ -900,10 +894,8 @@ ccosh = ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanhCouple = fun1 vec2T "ctanh" (vec2T "z") <| \z -> - def2 - ( vec2T "p", cexp z ) - ( vec2T "m", cexp (negate_ z) ) - <| \p m -> + def vec2T "p" (cexp z) <| \p -> + def vec2T "m" (cexp (negate_ z)) <| \m -> return <| cdiv (subtract p m) (add p m) @@ -1315,11 +1307,9 @@ csqrtTuple = fun1 vec2T "csqrt" (vec2T "z") <| \z -> if_ (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (sqrt_ z.x) zero) - (def2 - ( floatT "r", pow (dot z z) (float 0.25) ) - ( floatT "t", byF (float 0.5) (atan2_ z.y z.x) ) - <| \r t -> - return <| byF r <| vec2 (cos_ t) (sin_ t) + (def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> + def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> + return <| byF r <| vec2 (cos_ t) (sin_ t) ) @@ -1763,10 +1753,8 @@ toSrcImplicit suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> - def2 - ( floatT "sum", zero ) - ( floatT "samples", float <| antialiasingSamples * 2 + 1 ) - <| \sum samples -> + def floatT "sum" zero <| \sum -> + def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| \samples -> assignBy samples samples <| def floatT "coeff" @@ -1827,10 +1815,8 @@ toSrcPolar suffix e = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> assignAdd x (div deltaX <| float 2) <| assignAdd y (div deltaY <| float 2) <| - def2 - ( floatT "t", zero ) - ( floatT "ot", atanPlus y x ) - <| \t ot -> + def floatT "t" zero <| \t -> + def floatT "ot" (atanPlus y x) <| \ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) (\_ -> def4 @@ -1901,10 +1887,8 @@ toSrcParametric suffix e = innerLoop from to p depth choices ithreshold = def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> - def2 - ( vec2T "front", interval p from midpoint ) - ( vec2T "back", interval p midpoint to ) - <| \front back -> + def vec2T "front" (interval p from midpoint) <| \front -> + def vec2T "back" (interval p midpoint to) <| \back -> if_ (ors [ geq depth constants.maxDepth @@ -1937,34 +1921,34 @@ toSrcParametric suffix e = ) (unknownStatement (""" - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - """) - ) - unsafeNop - ) - unsafeNop - ) + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return vec3(0,0,0); + """) + ) + unsafeNop + ) + unsafeNop + ) in ( [ intervalDecl, pixelDecl ], pixel ) @@ -1989,11 +1973,9 @@ thetaDeltaCouple = fun1 floatT "thetaDelta" (floatT "theta") <| \theta -> if_ (lt uniforms.u_whiteLines one) (return <| float 100) - (def2 - ( floatT "thetaSix", add (by theta uniforms.u_whiteLines) (float 0.5) ) - ( floatT "thetaNeigh", float 0.05 ) - <| \thetaSix thetaNeigh -> - return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh + (def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> + def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> + return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh ) @@ -2016,18 +1998,14 @@ toSrcVectorField2D suffix xexpr yexpr = let ( vectorDecl, vector ) = fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y -> - def2 - ( vec2T "xv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr ) - ( vec2T "yv", expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr ) - <| - \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero + def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| \xv -> + def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| \yv -> + \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero ( nearDecl, near ) = fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx -> - def2 - ( floatT "angleCorner", arg <| subtract o corner ) - ( floatT "angleVector", arg vect ) - <| \angleCorner angleVector -> + def floatT "angleCorner" (arg <| subtract o corner) <| \angleCorner -> + def floatT "angleVector" (arg vect) <| \angleVector -> def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| \delta -> def floatT "l" (div (length vect) mx) <| \l -> def floatT @@ -2106,10 +2084,8 @@ toSrcContour suffix expr = ( pixelODecl, pixelO ) = fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> - def2 - ( floatT "theta", div (atan2_ z.y z.x) constants.twopi ) - ( floatT "logRadius", log2 <| length z ) - <| \theta logRadius -> + def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| \theta -> + def floatT "logRadius" (log2 <| length z) <| \logRadius -> def floatT "powerRemainder" (fract logRadius) <| \powerRemainder -> def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| \squished -> if_ (gt uniforms.u_completelyReal zero) @@ -2130,10 +2106,8 @@ toSrcContour suffix expr = 1 / 3 in fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - def2 - ( floatT "deltaXr", by deltaX <| float dist ) - ( floatT "deltaYr", by deltaY <| float dist ) - <| \deltaXr deltaYr -> + def floatT "deltaXr" (by deltaX <| float dist) <| \deltaXr -> + def floatT "deltaYr" (by deltaY <| float dist) <| \deltaYr -> -- Antialiasing def4 ( vec3T "a", pixelO deltaX deltaY (add x deltaXr) (add y deltaYr) ) @@ -2141,10 +2115,8 @@ toSrcContour suffix expr = ( vec3T "c", pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr) ) ( vec3T "d", pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr) ) <| \a b c d -> - def2 - ( vec3T "mn", min_ a <| min_ b <| min_ c d ) - ( vec3T "mx", max_ a <| max_ b <| max_ c d ) - <| \mn mx -> + def vec3T "mn" (min_ a <| min_ b <| min_ c d) <| \mn -> + def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| \mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) (return <| divF (adds3 [ a, b, c, d ]) (float 4)) @@ -2819,10 +2791,8 @@ main3D rayDifferentials bisects = def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> def floatT "k" (float kValue) <| \k -> - def2 - ( mat3T "d", dValue rayDirection k diffs ) - ( floatT "max_distance", by (float 100) eyeDist ) - <| \d maxDistance -> + def mat3T "d" (dValue rayDirection k diffs) <| \d -> + def floatT "max_distance" (by (float 100) eyeDist) <| \max_distance -> return <| raytraceF canvasPoint d maxDistance dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 From f28bcaf3103c993a0332f7c027ef8e04636523f9 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 5 Sep 2021 15:02:21 +0200 Subject: [PATCH 045/139] remote the need for def3, def4 --- src/elm/UI/Glsl/Code.elm | 88 ++++++++++++---------------------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index a0593d9d..ade72513 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1819,12 +1819,10 @@ toSrcPolar suffix e = def floatT "ot" (atanPlus y x) <| \ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) (\_ -> - def4 - ( floatT "h", f x y t ot ) - ( floatT "l", f (subtract x deltaX) y t ot ) - ( floatT "u", f x (subtract y deltaY) t ot ) - ( floatT "ul", f (subtract x deltaX) (subtract y deltaY) t ot ) - <| \h l u ul -> + def floatT "h" (f x y t ot) <| \h -> + def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> + def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> + def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) unsafeBreak (if_ (ors [ neq h l, neq h u, neq h ul ]) @@ -1863,11 +1861,9 @@ toSrcParametric suffix e = let ( intervalDecl, interval ) = fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to -> - def3 - ( vec2T "x", vec2 p.x p.x ) - ( vec2T "y", vec2 p.y p.y ) - ( vec2T "t", vec2 (min_ from to) (max_ from to) ) - <| \x y t -> + def vec2T "x" (vec2 p.x p.x) <| \x -> + def vec2T "y" (vec2 p.y p.y) <| \y -> + def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| \t -> return <| expressionToIntervalGlsl (toPrintExpression e) ( pixelDecl, pixel ) = @@ -2000,7 +1996,7 @@ toSrcVectorField2D suffix xexpr yexpr = fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y -> def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| \xv -> def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| \yv -> - \xv yv -> return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero + return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero ( nearDecl, near ) = fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx -> @@ -2109,12 +2105,10 @@ toSrcContour suffix expr = def floatT "deltaXr" (by deltaX <| float dist) <| \deltaXr -> def floatT "deltaYr" (by deltaY <| float dist) <| \deltaYr -> -- Antialiasing - def4 - ( vec3T "a", pixelO deltaX deltaY (add x deltaXr) (add y deltaYr) ) - ( vec3T "b", pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr) ) - ( vec3T "c", pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr) ) - ( vec3T "d", pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr) ) - <| \a b c d -> + def vec3T "a" (pixelO deltaX deltaY (add x deltaXr) (add y deltaYr)) <| \a -> + def vec3T "b" (pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr)) <| \b -> + def vec3T "c" (pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr)) <| \c -> + def vec3T "d" (pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr)) <| \d -> def vec3T "mn" (min_ a <| min_ b <| min_ c d) <| \mn -> def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| \mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> @@ -2122,12 +2116,10 @@ toSrcContour suffix expr = (return <| divF (adds3 [ a, b, c, d ]) (float 4)) (assignBy deltaXr (float 2) <| (assignBy deltaYr (float 2) <| - def4 - ( vec3T "e", pixelO deltaX deltaY (add x deltaXr) y ) - ( vec3T "f", pixelO deltaX deltaY (subtract x deltaXr) y ) - ( vec3T "g", pixelO deltaX deltaY x (subtract y deltaYr) ) - ( vec3T "h", pixelO deltaX deltaY x (add y deltaYr) ) - <| \e f g h -> + def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> + def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> + def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> + def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) ) ) @@ -2792,7 +2784,7 @@ main3D rayDifferentials bisects = def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> def floatT "k" (float kValue) <| \k -> def mat3T "d" (dValue rayDirection k diffs) <| \d -> - def floatT "max_distance" (by (float 100) eyeDist) <| \max_distance -> + def floatT "max_distance" (by (float 100) eyeDist) <| \maxDistance -> return <| raytraceF canvasPoint d maxDistance dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 @@ -2834,12 +2826,10 @@ raytrace bisects = float (1.19 - 0.2 * toFloat (List.length bisects)) in fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance -> - def4 - ( vec3T "found", vec3Zero ) - ( floatT "curr_distance", maxDistance ) - ( intT "found_index", int -1 ) - ( vec3T "f", vec3Zero ) - <| \found currDistance foundIndex f -> + def vec3T "found" vec3Zero <| \found -> + def floatT "curr_distance" maxDistance <| \currDistance -> + def intT "found_index" (int -1) <| \foundIndex -> + def vec3T "f" vec3Zero <| \f -> let innerTrace next = List.foldl @@ -2875,36 +2865,10 @@ raytrace bisects = , by (floatCast foundIndex) <| float <| radians (360 / 1.1) ) <| \ld diffs lightDistance offseted hueBasedOnIndex -> - def3Chain - ( mat3T "light_direction" - , mat3_3_3_3 - (subtract ld <| byF (float 0.5) diffs) - (add ld <| byF (float 0.5) diffs) - vec3Zero - ) - ( floatT "light_coeff" - , \lightDirection -> - ternary - (ors - (List.map - (\bisect -> - bisect offseted lightDirection lightDistance f - ) - bisects - ) - ) - (float 0.2) - (float 0.45) - ) - ( vec3T "px" - , \lightCoeff -> - mix - (hl2rgb hueBasedOnIndex lightCoeff) - (hl2rgb (by (float 0.5) found.z) lightCoeff) - (max_ (float 0.2) colorCoeff) - ) - <| - \px -> return <| vec4_3_1 px one + def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \light_direction -> + def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \light_coeff -> + def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> + return <| vec4_3_1 px one threshold : ExpressionX x Float -> Expression1 Float From 80cbdc9c4007eae983c22e5b00a8fd0af39caedb Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 5 Sep 2021 15:09:46 +0200 Subject: [PATCH 046/139] Cleaner formatting for `expr` and `assingXXX` --- src/elm/UI/Glsl/Code.elm | 205 ++++++++++++++++------------------ src/elm/UI/Glsl/Generator.elm | 153 ++++--------------------- src/elm/UI/Glsl/Plane.elm | 12 +- 3 files changed, 119 insertions(+), 251 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index ade72513..2cc7e973 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deinde import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1278,15 +1278,14 @@ cmbrotCouple = (def vec2T "z" c <| \z -> for ( "i", int 0, int 4000 ) (\i -> - expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) - (if_ (gt (length z) (float 1000000)) - (def floatT "logLength" (log (length z)) <| \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return <| vec2 (sin_ fi) (cos_ fi) - ) - unsafeNop + expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> + if_ (gt (length z) (float 1000000)) + (def floatT "logLength" (log (length z)) <| \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| \fi -> + return <| vec2 (sin_ fi) (cos_ fi) ) + unsafeNop ) (return vec2Zero) ) @@ -1755,35 +1754,30 @@ toSrcImplicit suffix e = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> def floatT "sum" zero <| \sum -> def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| \samples -> - assignBy samples samples <| - def floatT - "coeff" - (float 0.0875) - (\coeff -> - forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w -> - forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h -> - def floatT - "piece" - (f - (add x <| by (by deltaX coeff) <| floatCast w) - (add y <| by (by deltaX coeff) <| floatCast h) - ) - <| \piece -> - if_ - (eq piece zero) - (return vec3Zero) - (assignAdd sum piece unsafeNop) - ) - unsafeNop - ) - (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> - expr - (assign perc (pow perc <| float 0.2)) - (return <| byF perc (vec3 one one one)) - ) - ) + assignBy samples samples <| \_ -> + def floatT "coeff" (float 0.0875) <| \coeff -> + forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) + (\w -> + forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) + (\h -> + def floatT + "piece" + (f + (add x <| by (by deltaX coeff) <| floatCast w) + (add y <| by (by deltaX coeff) <| floatCast h) + ) + <| \piece -> + if_ + (eq piece zero) + (return vec3Zero) + (assignAdd sum piece <| \_ -> unsafeNop) + ) + unsafeNop + ) + (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> + expr (assign perc (pow perc <| float 0.2)) <| \_ -> + return <| byF perc (vec3 one one one) + ) in ( [ fDecl, pixelDecl ], pixel ) @@ -1800,7 +1794,7 @@ toSrcPolar suffix e = def floatT "t" (add (atanPlus y x) deltaT) <| \t -> -- Avoid the branch cut at {x > 0, y = 0} if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) unsafeNop) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) <| \_ -> unsafeNop) (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> return <| ternary (gt (abs_ complex.y) (float epsilon)) @@ -1813,27 +1807,27 @@ toSrcPolar suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - assignAdd x (div deltaX <| float 2) <| - assignAdd y (div deltaY <| float 2) <| - def floatT "t" zero <| \t -> - def floatT "ot" (atanPlus y x) <| \ot -> - for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ -> - def floatT "h" (f x y t ot) <| \h -> - def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> - def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> - def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> - if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - unsafeBreak - (if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - (assignAdd t constants.twopi <| - assignAdd ot constants.twopi <| - unsafeNop - ) - ) + assignAdd x (div deltaX <| float 2) <| \_ -> + assignAdd y (div deltaY <| float 2) <| \_ -> + def floatT "t" zero <| \t -> + def floatT "ot" (atanPlus y x) <| \ot -> + for ( "i", int 0, divConst constants.maxIterations (int 10) ) + (\_ -> + def floatT "h" (f x y t ot) <| \h -> + def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> + def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> + def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> + if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) + unsafeBreak + (if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + (assignAdd t constants.twopi <| \_ -> + assignAdd ot constants.twopi <| \_ -> + unsafeNop + ) ) - (return vec3Zero) + ) + (return vec3Zero) in ( [ fDecl, pixelDecl ], pixel ) @@ -1869,14 +1863,12 @@ toSrcParametric suffix e = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> def floatT "max_distance" (float <| 2 ^ 10) <| \max_distance -> - def6 - ( floatT "from", div (negate_ max_distance) (float 2) ) - ( floatT "to", div max_distance (float 2) ) - ( vec2T "p", vec2 x y ) - ( intT "depth", int 0 ) - ( intT "choices", int 0 ) - ( floatT "ithreshold", by (by (float 10) deltaX) deltaX ) - <| \from to p depth choices ithreshold -> + def floatT "from" (div (negate_ max_distance) (float 2)) <| \from -> + def floatT "to" (div max_distance (float 2)) <| \to -> + def vec2T "p" (vec2 x y) <| \p -> + def intT "depth" (int 0) <| \depth -> + def intT "choices" (int 0) <| \choices -> + def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| \ithreshold -> for ( "it", int 0, constants.maxIterations ) (\_ -> innerLoop from to p depth choices ithreshold) (return vec3Zero) @@ -1903,17 +1895,17 @@ toSrcParametric suffix e = (return <| vec3 one one one) (ifElse (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| - expr (postfixPlus depth) <| - assignBy choices (int 2) <| - unsafeNop + (expr (assign to midpoint) <| \_ -> + expr (postfixPlus depth) <| \_ -> + assignBy choices (int 2) <| \_ -> + unsafeNop ) (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| - expr (postfixPlus depth) <| - expr (assign choices (add (by choices (int 2)) (int 1))) <| - unsafeNop + (expr (assign from midpoint) <| \_ -> + expr (postfixPlus depth) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> + unsafeNop ) (unknownStatement (""" @@ -2114,14 +2106,13 @@ toSrcContour suffix expr = def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - (assignBy deltaXr (float 2) <| - (assignBy deltaYr (float 2) <| - def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> - def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> - def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> - def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> - return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) - ) + (assignBy deltaXr (float 2) <| \_ -> + assignBy deltaYr (float 2) <| \_ -> + def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> + def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> + def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> + def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> + return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) ) in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2577,8 +2568,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel2) - unsafeNop + expr (assign gl_FragColor pixel2) <| \_ -> + unsafeNop ] ( [], _ ) -> @@ -2591,8 +2582,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel3) - unsafeNop + expr (assign gl_FragColor pixel3) <| \_ -> + unsafeNop ] _ -> @@ -2609,8 +2600,8 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor (max4 pixel2 pixel3)) - unsafeNop + expr (assign gl_FragColor (max4 pixel2 pixel3)) <| \_ -> + unsafeNop ] @@ -2689,9 +2680,9 @@ addPixel deltaX deltaY x y px curr i { call, color } next = else call deltaX deltaY x y in - expr (assign curr k) <| - expr (assign px (ternary3 (eq curr vec3Zero) px curr)) - next + expr (assign curr k) <| \_ -> + expr (assign px (ternary3 (eq curr vec3Zero) px curr)) <| \_ -> + next axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) @@ -2844,31 +2835,25 @@ raytrace bisects = bisectToRay i bisect = if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (expr (assign foundIndex <| int i) <| - expr (assign found f) <| - expr (assign currDistance <| length <| subtract found o) <| - unsafeNop + (expr (assign foundIndex <| int i) <| \_ -> + expr (assign found f) <| \_ -> + expr (assign currDistance <| length <| subtract found o) <| \_ -> + unsafeNop ) in innerTrace <| if_ (lt foundIndex <| int 0) (return <| vec4 zero zero zero one) - <| - def5 - ( vec3T "ld", normalize <| vec3 (float -0.3) zero one ) - ( vec3T "diffs", subtract (arr d (int 1)) (arr d (int 0)) ) - ( floatT "light_distance", maxDistance ) - ( vec3T "offseted" - , add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found - ) - ( floatT "hue_based_on_index" - , by (floatCast foundIndex) <| float <| radians (360 / 1.1) - ) - <| \ld diffs lightDistance offseted hueBasedOnIndex -> - def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \light_direction -> - def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \light_coeff -> + (def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> + def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> + def floatT "light_distance" maxDistance <| \lightDistance -> + def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| \offseted -> + def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| \hueBasedOnIndex -> + def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \lightDirection -> + def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \lightCoeff -> def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> return <| vec4_3_1 px one + ) threshold : ExpressionX x Float -> Expression1 Float diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 38971a90..05d099ff 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, def1, def2, def3, def3Chain, def4, def5, def6, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1407,150 +1407,35 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks -def1 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> (a -> Statement r) - -> Statement r -def1 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) k = - let - (Statement ks) = - k e0 - in - Statement <| Decl t0 n0 (Just <| unwrapExpression v0) ks - - -def2 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) - -> (a -> b -> Statement r) - -> Statement r -def2 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) k = - let - (Statement ks) = - k e0 e1 - in - Statement <| Decl t0 n0 (Just <| unwrapExpression v0) <| Decl t1 n1 (Just <| unwrapExpression v1) ks - - -def3 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) - -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) - -> (a -> b -> c -> Statement r) - -> Statement r -def3 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) k = - let - (Statement ks) = - k e0 e1 e2 - in - Statement <| - Decl t0 n0 (Just <| unwrapExpression v0) <| - Decl t1 n1 (Just <| unwrapExpression v1) <| - Decl t2 n2 (Just <| unwrapExpression v2) <| - ks - - -def3Chain : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), a -> ExpressionX xb tb ) - -> ( ( TypedName tc c, Expression tc -> c ), b -> ExpressionX xc tc ) - -> (c -> Statement r) - -> Statement r -def3Chain ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) k = - let - (Statement ks) = - k e2 - in - Statement <| - Decl t0 n0 (Just <| unwrapExpression v0) <| - Decl t1 n1 (Just <| unwrapExpression <| v1 e0) <| - Decl t2 n2 (Just <| unwrapExpression <| v2 e1) <| - ks - - -def4 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) - -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) - -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) - -> (a -> b -> c -> d -> Statement r) - -> Statement r -def4 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) k = - let - (Statement ks) = - k e0 e1 e2 e3 - in - Statement <| - Decl t0 n0 (Just <| unwrapExpression v0) <| - Decl t1 n1 (Just <| unwrapExpression v1) <| - Decl t2 n2 (Just <| unwrapExpression v2) <| - Decl t3 n3 (Just <| unwrapExpression v3) <| - ks - - -def5 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) - -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) - -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) - -> ( ( TypedName te e, Expression te -> e ), ExpressionX xe te ) - -> (a -> b -> c -> d -> e -> Statement r) - -> Statement r -def5 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) ( ( TypedName (Type t4) n4 e4, _ ), v4 ) k = - let - (Statement ks) = - k e0 e1 e2 e3 e4 - in - Statement <| - Decl t0 n0 (Just <| unwrapExpression v0) <| - Decl t1 n1 (Just <| unwrapExpression v1) <| - Decl t2 n2 (Just <| unwrapExpression v2) <| - Decl t3 n3 (Just <| unwrapExpression v3) <| - Decl t4 n4 (Just <| unwrapExpression v4) <| - ks - - -def6 : - ( ( TypedName ta a, Expression ta -> a ), ExpressionX xa ta ) - -> ( ( TypedName tb b, Expression tb -> b ), ExpressionX xb tb ) - -> ( ( TypedName tc c, Expression tc -> c ), ExpressionX xc tc ) - -> ( ( TypedName td d, Expression td -> d ), ExpressionX xd td ) - -> ( ( TypedName te e, Expression te -> e ), ExpressionX xe te ) - -> ( ( TypedName tf f, Expression tf -> f ), ExpressionX xf tf ) - -> (a -> b -> c -> d -> e -> f -> Statement r) - -> Statement r -def6 ( ( TypedName (Type t0) n0 e0, _ ), v0 ) ( ( TypedName (Type t1) n1 e1, _ ), v1 ) ( ( TypedName (Type t2) n2 e2, _ ), v2 ) ( ( TypedName (Type t3) n3 e3, _ ), v3 ) ( ( TypedName (Type t4) n4 e4, _ ), v4 ) ( ( TypedName (Type t5) n5 e5, _ ), v5 ) k = - let - (Statement ks) = - k e0 e1 e2 e3 e4 e5 - in - Statement <| - Decl t0 n0 (Just <| unwrapExpression v0) <| - Decl t1 n1 (Just <| unwrapExpression v1) <| - Decl t2 n2 (Just <| unwrapExpression v2) <| - Decl t3 n3 (Just <| unwrapExpression v3) <| - Decl t4 n4 (Just <| unwrapExpression v4) <| - Decl t5 n5 (Just <| unwrapExpression v5) <| - ks - - assign : ExpressionX a t -> ExpressionX b t -> Expression1 t assign name e = dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) -expr : ExpressionX a t -> Statement q -> Statement q -expr e (Statement next) = +expr : ExpressionX a t -> (() -> Statement q) -> Statement q +expr e n = + let + (Statement next) = + n () + in Statement <| ExpressionStatement (unwrapExpression e) next -assignAdd : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q -assignAdd name e (Statement next) = +assignAdd : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q +assignAdd name e n = + let + (Statement next) = + n () + in Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) next -assignBy : ExpressionX a t -> ExpressionX b t -> Statement q -> Statement q -assignBy name e (Statement next) = +assignBy : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q +assignBy name e n = + let + (Statement next) = + n () + in Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) next diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 54ed832b..c812ab79 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -4,7 +4,7 @@ import Dict import Expression exposing (Expression) import Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, def2, div, dot, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) +import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, div, dot, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -45,10 +45,8 @@ toGlsl suffix (Plane { x, y, z, known }) = -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) -- t = - (k + dot abc o) / (dot abc d) - def2 - ( vec3T "coeffs", vec3 (float x) (float y) (float z) ) - ( vec3T "dsum", byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1) ) - <| \coeffs dsum -> + def vec3T "coeffs" (vec3 (float x) (float y) (float z)) <| \coeffs -> + def vec3T "dsum" (byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1)) <| \dsum -> def floatT "t" (div @@ -56,5 +54,5 @@ toGlsl suffix (Plane { x, y, z, known }) = (dot coeffs dsum) ) <| \t -> - expr (assign found <| add o <| byF t dsum) <| - return (gt t <| threshold maxDistance) + expr (assign found <| add o <| byF t dsum) <| \_ -> + return (gt t <| threshold maxDistance) From d11a05188fb18fd0ad7ba2fb8d9f6f1e0c195a89 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 5 Sep 2021 16:29:59 +0200 Subject: [PATCH 047/139] Improving GlslConverter --- glslParser/src/GlslConverter.elm | 53 ++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 7965c720..0fc0689e 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -170,15 +170,18 @@ type UnaryOperation type Expression = Float Float | Int Int + | Bool Bool | Dot Expression String | Variable String | Call String (List Expression) + | Arr Expression Expression | Ternary Expression Expression Expression | UnaryOperation UnaryOperation Expression | BinaryOperation BinaryOperation Expression Expression | BooleanOperation BooleanOperation Expression Expression | RelationOperation RelationOperation Expression Expression | PostfixIncrement Expression + | PostfixDecrement Expression type Either a b @@ -254,16 +257,15 @@ typeParser = statementParser : Parser Statement statementParser = - Parser.lazy <| - \_ -> - oneOf - [ blockParser - , returnParser - , ifParser - , forParser - , defParser - , expressionStatementParser - ] + Parser.lazy <| \_ -> + oneOf + [ blockParser + , returnParser + , ifParser + , forParser + , defParser + , expressionStatementParser + ] expressionStatementParser : Parser Statement @@ -522,7 +524,7 @@ unaryParser = atomParser : Parser Expression atomParser = - succeed (\a f -> f a) + succeed (\a f -> f a) |= oneOf [ succeed (\a f -> f a) |. symbol "(" @@ -531,8 +533,11 @@ atomParser = |. spaces |. symbol ")" |= maybeDot - , succeed (\a f md ->md<| f a) + , succeed (Bool True) |. symbol "true" + , succeed (Bool False) |. symbol "false" + , succeed (\a f md -> md <| f a) |= Parser.map .name identifierWithSuffixParser + |. spaces |= oneOf [ succeed (\args v -> Call v args) |= sequence @@ -543,6 +548,12 @@ atomParser = , trailing = Forbidden , spaces = spaces } + , succeed (\arg v -> Arr (Variable v) arg) + |. symbol "[" + |. spaces + |= Parser.lazy (\_ -> expressionParser) + |. spaces + |. symbol "]" , succeed Variable ] |= maybeDot @@ -556,6 +567,8 @@ atomParser = |= oneOf [ succeed PostfixIncrement |. symbol "++" + , succeed PostfixDecrement + |. symbol "--" , succeed identity ] @@ -739,6 +752,16 @@ prettyPrintExpression e = Int i -> lisp [ "int", String.fromInt i ] + Bool b -> + lisp + [ "bool" + , if b then + "True" + + else + "False" + ] + Dot v sw -> prettyPrintExpression v ++ "." ++ sw @@ -780,6 +803,9 @@ prettyPrintExpression e = else lisp <| n :: List.map prettyPrintExpression args + Arr l r -> + lisp [ "arr", prettyPrintExpression l, prettyPrintExpression r ] + Ternary c l r -> lisp [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] @@ -795,6 +821,9 @@ prettyPrintExpression e = PostfixIncrement c -> lisp [ "plusPostfix", prettyPrintExpression c ] + PostfixDecrement c -> + lisp [ "minusPostfix", prettyPrintExpression c ] + prettyPrintRelationOperation : RelationOperation -> String prettyPrintRelationOperation op = From 92373b67fed47eaedf870a94765fe02f47a9ccce Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 01:59:13 +0200 Subject: [PATCH 048/139] Moar codegen, fixed some plots --- glslParser/src/GlslConverter.elm | 172 ++++++++++++++++++++---- src/elm/UI/Glsl.elm | 121 +++++++---------- src/elm/UI/Glsl/Code.elm | 220 ++++++++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 96 +++++++++++--- src/elm/UI/Glsl/Polynomial.elm | 67 +++++++++- src/shaders/declarations.frag | 3 - 6 files changed, 450 insertions(+), 229 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 0fc0689e..6b31af3d 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -34,7 +34,8 @@ init = i = """{ - +for(int j = MAX_DEPTH - 1; j > 0; j--) { +} }""" in @@ -119,7 +120,72 @@ toOutput i = Debug.toString e Ok o -> - prettyPrint o + prettyPrint <| simplifyEither o + + +simplifyEither : Either Function Statement -> Either Function Statement +simplifyEither o = + case o of + Left f -> + Left <| simplifyFunction f + + Right s -> + Right <| simplifyStatement s + + +simplifyFunction : Function -> Function +simplifyFunction f = + { f | body = simplifyStatement f.body } + + +simplifyStatement : Statement -> Statement +simplifyStatement s = + case s of + Nop -> + Nop + + Expression e n -> + Expression (simplify e) (simplifyStatement n) + + For v from rel to step inner next -> + For v (simplify from) rel (simplify to) step (simplifyStatement inner) (simplifyStatement next) + + If cond t f -> + If (simplify cond) (simplifyStatement t) (simplifyStatement f) + + Return e -> + Return (simplify e) + + Def t n v next -> + Def t n (simplify v) (simplifyStatement next) + + Decl t n next -> + Decl t n (simplifyStatement next) + + +simplify : Expression -> Expression +simplify e = + case e of + BooleanOperation op es -> + es + |> List.map simplify + |> List.concatMap + (\c -> + case c of + BooleanOperation cop ces -> + if op == cop then + ces + + else + [ c ] + + _ -> + [ c ] + ) + |> BooleanOperation op + + _ -> + e type alias Function = @@ -133,7 +199,7 @@ type alias Function = type Statement = Expression Expression Statement - | For String Expression RelationOperation Expression Statement Statement + | For String Expression RelationOperation Expression Bool Statement Statement | If Expression Statement Statement | Return Expression | Def String String Expression Statement @@ -173,12 +239,13 @@ type Expression | Bool Bool | Dot Expression String | Variable String + | Constant String | Call String (List Expression) | Arr Expression Expression | Ternary Expression Expression Expression | UnaryOperation UnaryOperation Expression | BinaryOperation BinaryOperation Expression Expression - | BooleanOperation BooleanOperation Expression Expression + | BooleanOperation BooleanOperation (List Expression) | RelationOperation RelationOperation Expression Expression | PostfixIncrement Expression | PostfixDecrement Expression @@ -326,7 +393,7 @@ forParser = |. spaces |. identifierParser |. spaces - |. symbol "++" + |= oneOf [ succeed True |. symbol "++", succeed False |. symbol "--" ] |. spaces |. symbol ")" |. spaces @@ -398,8 +465,8 @@ booleanParser : Parser Expression booleanParser = multiSequence { separators = - [ ( BooleanOperation Or, symbol "||" ) - , ( BooleanOperation And, symbol "&&" ) + [ ( \l r -> BooleanOperation Or [ l, r ], symbol "||" ) + , ( \l r -> BooleanOperation And [ l, r ], symbol "&&" ) ] , item = relationParser , allowNegation = False @@ -548,13 +615,13 @@ atomParser = , trailing = Forbidden , spaces = spaces } - , succeed (\arg v -> Arr (Variable v) arg) + , succeed (\arg v -> Arr (toVariableOrConstant v) arg) |. symbol "[" |. spaces |= Parser.lazy (\_ -> expressionParser) |. spaces |. symbol "]" - , succeed Variable + , succeed toVariableOrConstant ] |= maybeDot , Parser.andThen tryParseNumber <| @@ -573,6 +640,15 @@ atomParser = ] +toVariableOrConstant : String -> Expression +toVariableOrConstant s = + if String.toUpper s == s then + Constant s + + else + Variable s + + maybeDot : Parser (Expression -> Expression) maybeDot = oneOf @@ -661,12 +737,17 @@ prettyPrintStatement stat = Expression e next -> "expr " ++ prettyPrintExpression e - ++ "(\n" + ++ "<| (\\_ -> \n" ++ prettyPrintStatement next ++ ")" - For var from LessThan to loop next -> - "for (\"" + For var from LessThan to step loop next -> + (if step then + "for (\"" + + else + "forDown (\"" + ) ++ var ++ "\", " ++ prettyPrintExpression from @@ -680,8 +761,13 @@ prettyPrintStatement stat = ++ prettyPrintStatement next ++ ")" - For var from LessThanOrEquals to loop next -> - "forLeq (" + For var from LessThanOrEquals to step loop next -> + (if step then + "forLeq (\"" + + else + "forLeqDown (\"" + ) ++ var ++ ", " ++ prettyPrintExpression from @@ -725,8 +811,22 @@ prettyPrintStatement stat = Decl _ _ _ -> "TODO branch 'Decl _ _ _' not implemented" - For _ _ _ _ _ _ -> - "TODO branch 'For _ _ _ _ _ _' not implemented" + For v f GreaterThan t _ loop next -> + "forDown (\"" + ++ v + ++ "\", " + ++ prettyPrintExpression f + ++ ", " + ++ prettyPrintExpression t + ++ ") (\\" + ++ v + ++ " ->" + ++ prettyPrintStatement loop + ++ ")" + ++ prettyPrintStatement next + + For _ _ _ _ _ _ _ -> + "TODO branch For not completely implemented" prettyPrintExpression : Expression -> String @@ -736,9 +836,6 @@ prettyPrintExpression e = "(" ++ String.join " " args ++ ")" in case e of - BinaryOperation op l r -> - lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] - Float f -> if f == 0 then "zero" @@ -768,6 +865,23 @@ prettyPrintExpression e = Variable v -> v + Constant c -> + case String.split "_" c of + [] -> + "constants.???" + + h :: t -> + let + toTitle s = + case String.uncons s of + Nothing -> + "" + + Just ( sh, st ) -> + String.cons (Char.toUpper sh) (String.toLower st) + in + "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) + Call "float" [ arg ] -> lisp [ "floatCast", prettyPrintExpression arg ] @@ -812,17 +926,25 @@ prettyPrintExpression e = UnaryOperation Negate ex -> lisp [ "negate_", prettyPrintExpression ex ] - BooleanOperation bop l r -> - lisp [ prettyPrintBooleanOperation bop, prettyPrintExpression l, prettyPrintExpression r ] + BinaryOperation op l r -> + lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] + + BooleanOperation op es -> + lisp + [ prettyPrintBooleanOperation op + , "[" + , String.join ", " <| List.map prettyPrintExpression es + , "]" + ] RelationOperation rop l r -> lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] PostfixIncrement c -> - lisp [ "plusPostfix", prettyPrintExpression c ] + lisp [ "postfixIncrement", prettyPrintExpression c ] PostfixDecrement c -> - lisp [ "minusPostfix", prettyPrintExpression c ] + lisp [ "postfixDecrement", prettyPrintExpression c ] prettyPrintRelationOperation : RelationOperation -> String @@ -854,10 +976,10 @@ prettyPrintBooleanOperation : BooleanOperation -> String prettyPrintBooleanOperation op = case op of And -> - "and" + "ands" Or -> - "or" + "ors" prettyPrintBinaryOperation : BinaryOperation -> String diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 96f68186..349de3c1 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -7,8 +7,8 @@ import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, square) import Maybe.Extra as Maybe import SortedAnySet as Set -import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, deindent, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, boolT, def, fileToGlsl, float, floatT, fun4, mat3T, out, unknown, unknownStatement, vec3T) +import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, def, expr, fileToGlsl, float, floatT, fun4, int, mat3T, mix, out, unknown, unknownStatement, vec3T) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -149,7 +149,8 @@ getGlsl rayDifferentials graph = |> List.map (requirementToGlsl interval) |> String.join "\n" in - "#define PIHALF " + "#define MAX_DEPTH 30\n" + ++ "#define PIHALF " ++ String.fromFloat (pi / 2) ++ "\n#define PI " ++ String.fromFloat pi @@ -160,7 +161,7 @@ getGlsl rayDifferentials graph = ++ thetaDeltaCode ++ reqs ++ "\n/* Expression */\n" - ++ deindent 4 (Generator.fileToGlsl funDecls) + ++ Generator.fileToGlsl funDecls ++ mainGlsl rayDifferentials pixel2D pixel3D @@ -192,36 +193,45 @@ get3DSource prefix e = } Nothing -> - case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of - Just ( glsl, bisect ) -> - { expr = e - , funDecls = [ glsl ] - , bisect = bisect - } + -- case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of + -- Just ( glsl, bisect ) -> + -- { expr = e + -- , funDecls = [ glsl ] + -- , bisect = bisect + -- } + -- Nothing -> + case tryGlslFromPolynomial prefix e of + Just o -> + o Nothing -> - case tryGlslFromPolynomial prefix e of - Just o -> - o - - Nothing -> - let - glsl = - toSrc3D prefix e - - ( decl, bisect ) = - UI.Glsl.Code.suffixToBisect prefix - in - { expr = e - , funDecls = glsl ++ [ decl ] - , bisect = bisect - } - - + let + ( glsl, interval ) = + toSrc3D prefix e ---tryGlslFromPolynomial : String -> Expression -> Maybe { expr : Expression, funDecls : List FunDecl } + ( decl, bisect ) = + UI.Glsl.Code.suffixToBisect interval prefix + in + { expr = e + , funDecls = glsl ++ [ decl ] + , bisect = bisect + } +tryGlslFromPolynomial : + String + -> Expression + -> + Maybe + { expr : Expression + , funDecls : List FunDecl + , bisect : + ExpressionX xa Vec3 + -> ExpressionX xb Mat3 + -> ExpressionX xc Float + -> ExpressionX xd Vec3 + -> Expression1 Bool + } tryGlslFromPolynomial suffix e = let t = @@ -268,48 +278,15 @@ tryGlslFromPolynomial suffix e = ) |> Maybe.map Dict.fromList |> Maybe.withDefault Dict.empty - - fromSols sols = - let - checks = - sols - |> List.foldl - (\( k, v ) ( known, lines ) -> - let - ( decl, drop ) = - if List.member k known then - ( "", 0 ) - - else if String.startsWith "!" k then - ( "float ", 1 ) - - else - ( "vec2 ", 0 ) - - newLine = - decl ++ String.dropLeft drop k ++ " = " ++ v ++ ";" - in - ( k :: known, newLine :: lines ) - ) - ( [ "t" ], [] ) - |> Tuple.second - |> List.reverse - |> String.join "\n " - - ( funDecl, bisect ) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - def floatT "t" (Generator.by maxDistance <| float 2) <| \t_ -> - unknownStatement (checks ++ """ - found = o + t * mix(d[0], d[1], 0.5); - return t < max_distance && t > 0.0;""") - in - { expr = div one <| sqrt_ <| cbrt <| ipow e 3 - , funDecls = [ funDecl ] - , bisect = bisect - } in - UI.Glsl.Polynomial.getSolutions { base = unknown "max_distance" } poly - |> Maybe.map (\( _, sols ) -> fromSols sols) + UI.Glsl.Polynomial.glslFromPolySolutions suffix { base = unknown "max_distance" } poly + |> Maybe.map + (\{ funDecls, bisect } -> + { funDecls = funDecls + , expr = Expression.Utils.div Expression.Utils.one <| Expression.Utils.sqrt_ <| Expression.Utils.cbrt <| Expression.Utils.ipow e 3 + , bisect = bisect + } + ) transitiveClosure : List Requirement -> List Requirement @@ -726,9 +703,9 @@ functionToGlsl interval name = Generator.fileToGlsl <| straightFunctionToGlsl name IntervalOnly -> - deindent 12 <| intervalFunctionToGlsl name + intervalFunctionToGlsl name IntervalAndStraight -> Generator.fileToGlsl (straightFunctionToGlsl name) ++ "\n" - ++ deindent 12 (intervalFunctionToGlsl name) + ++ intervalFunctionToGlsl name diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 2cc7e973..3b61228e 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ -module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, deindent, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator as Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, fileToGlsl, float, floatCast, floatT, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1896,14 +1896,14 @@ toSrcParametric suffix e = (ifElse (ands [ leq front.x zero, geq front.y zero ]) (expr (assign to midpoint) <| \_ -> - expr (postfixPlus depth) <| \_ -> + expr (postfixIncrement depth) <| \_ -> assignBy choices (int 2) <| \_ -> unsafeNop ) (ifElse (ands [ leq back.x zero, geq back.y zero ]) (expr (assign from midpoint) <| \_ -> - expr (postfixPlus depth) <| \_ -> + expr (postfixIncrement depth) <| \_ -> expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> unsafeNop ) @@ -2012,10 +2012,9 @@ toSrcVectorField2D suffix xexpr yexpr = ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> - unknownStatement (""" - vec2 o = vec2(x, y); - - float mx = 0.0; + def vec2T "o" (vec2 x y) <| \o -> + def floatT "mx" zero <| \mx -> + unknownStatement (""" for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); @@ -2722,24 +2721,32 @@ axisDecl = Tuple.first axisTuple -toSrc3D : String -> Expression.Expression -> File +toSrc3D : + String + -> Expression.Expression + -> ( List FunDecl, ExpressionX xa Mat3 -> ExpressionX xb Mat3 -> Expression2 ) toSrc3D suffix e = - [ Tuple.first <| - fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> - def floatT "x" p.x <| \x -> - def floatT "y" p.y <| \y -> - def floatT "z" p.z <| \z -> - def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> - return <| normalize gradient.yzw - , Tuple.first <| - fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> - def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> - def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> - def vec2T "x" (vec2 mn.x mx.x) <| \_ -> - def vec2T "y" (vec2 mn.y mx.y) <| \_ -> - def vec2T "z" (vec2 mn.z mx.z) <| \_ -> - return <| expressionToIntervalGlsl <| toPrintExpression e - ] + let + ( intervalDecl, interval ) = + fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> + def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> + def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> + def vec2T "x" (vec2 mn.x mx.x) <| \_ -> + def vec2T "y" (vec2 mn.y mx.y) <| \_ -> + def vec2T "z" (vec2 mn.z mx.z) <| \_ -> + return <| expressionToIntervalGlsl <| toPrintExpression e + in + ( [ Tuple.first <| + fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> + def floatT "x" p.x <| \x -> + def floatT "y" p.y <| \y -> + def floatT "z" p.z <| \z -> + def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> + return <| normalize gradient.yzw + , intervalDecl + ] + , interval + ) @@ -2799,18 +2806,15 @@ main3D rayDifferentials bisects = ( fileToGlsl [ raytraceDecl, block ], pixel3 ) - --- raytrace : --- List --- (Expression3 --- -> Expression1 Mat3 --- -> Expression1 Float --- -> ExpressionX a Vec3 --- -> Expression1 Bool --- ) --- -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> Expression4 ) - - +raytrace : + List + (Expression3 + -> Expression1 Mat3 + -> Expression1 Float + -> Expression3 + -> Expression1 Bool + ) + -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> Expression4 ) raytrace bisects = let colorCoeff = @@ -2861,77 +2865,75 @@ threshold max_distance = by (float 0.000001) max_distance -suffixToBisect : String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) -suffixToBisect suffix = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - unknownStatement - (""" - mat3 from = mat3(o, o, vec3(0)); - mat3 to = from + max_distance * d; - float ithreshold = """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """; - int depth = 0; - int choices = 0; - for(int it = 0; it < MAX_ITERATIONS; it++) { - mat3 midpoint = 0.5 * (from + to); - vec2 front = interval""" ++ suffix ++ """(from, midpoint); - vec2 back = interval""" ++ suffix ++ """(midpoint, to); - if(depth >= MAX_DEPTH - || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) - || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) - ) { - found = mix(midpoint[0], midpoint[1], 0.5); - return true; - } - if(front.x <= 0.0 && front.y >= 0.0) { - to = midpoint; - depth++; - choices = left_shift(choices); - } else if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = left_shift_increment(choices); - } else { - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices = right_shift(choices); - if(is_even(choices)) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = left_shift_increment(choices); - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return false; - } - } - return false; - """) - - -deindent : Int -> String -> String -deindent i = +suffixToBisect : (Expression33 -> Expression33 -> Expression2) -> String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) +suffixToBisect interval suffix = let - s = - String.repeat i " " + mainLoop found from to ithreshold depth choices _ = + def mat3T "midpoint" (byF (float 0.5) (add33 from to)) <| \midpoint -> + def vec2T "front" (interval from midpoint) <| \front -> + def vec2T "back" (interval midpoint to) <| \back -> + if_ + (ors + [ geq depth constants.maxDepth, ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ], ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] ] + ) + (expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> + return <| bool True + ) + (ifElse (ands [ leq front.x zero, geq front.y zero ]) + (expr (assign to midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) <| \_ -> + unsafeNop + ) + (ifElse (ands [ leq back.x zero, geq back.y zero ]) + (backtrackLeft from to depth choices midpoint) + (backtrackRight from to depth choices midpoint) + unsafeNop + ) + unsafeNop + ) + + backtrackLeft from _ depth choices midpoint = + expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) <| \_ -> + unsafeNop + + backtrackRight from to depth choices midpoint = + -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) + (\j -> + if_ (gt j depth) + (unknownStatement "continue;") + (expr (postfixDecrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> + ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) + (expr (assign midpoint to) <| \_ -> + expr (assign to <| add to (subtract to from)) <| \_ -> + def vec2T "back" (interval midpoint to) <| \back -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> + unknownStatement "break;" + ) + unsafeNop + ) + (expr (assign from <| subtract from (subtract to from)) <| \_ -> unsafeNop) + unsafeNop + ) + ) + (if_ (eq depth (int 0)) + (return false) + unsafeNop + ) in - String.split "\n" - >> List.map - (\l -> - if String.startsWith s l then - String.dropLeft i l - - else - l - ) - >> String.join "\n" + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| \from -> + def mat3T "to" (add from <| byF maxDistance d) <| \to -> + def floatT "ithreshold" (threshold maxDistance) <| \ithreshold -> + def intT "depth" (int 0) <| \depth -> + def intT "choices" (int 0) <| \choices -> + for ( "it", int 0, constants.maxIterations ) + (mainLoop found from to ithreshold depth choices) + (return <| bool False) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 05d099ff..eeb622f4 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixPlus, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -16,7 +16,7 @@ type FunDecl type Stat = If Expr Stat Stat | IfElse Expr Stat Stat Stat - | For String Expr RelationOperation Expr Stat Stat + | For String Expr RelationOperation Expr Expr Stat Stat | Line String | Return Expr | Break @@ -45,7 +45,8 @@ type Expr | Div Expr Expr | Call String (List Expr) | Negate Expr - | PostfixPlus Expr + | PostfixIncrement Expr + | PostfixDecrement Expr | Unknown String | Dot Expr String | Array Expr Expr @@ -161,6 +162,22 @@ statementToGlsl (Statement r) = ] |> String.join "\n" + IfElse cond t ((If _ _ _) as f) n -> + [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") + , go (i + 1) t + , indent i <| "} else " ++ String.trimLeft (go i f) + , go i n + ] + |> String.join "\n" + + IfElse cond t ((IfElse _ _ _ _) as f) n -> + [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") + , go (i + 1) t + , indent i <| "} else " ++ String.trimLeft (go i f) + , go i n + ] + |> String.join "\n" + IfElse cond t f n -> [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") , go (i + 1) t @@ -172,8 +189,8 @@ statementToGlsl (Statement r) = ] |> String.join "\n" - For var from rel to loop next -> - [ indent i ("for (int " ++ var ++ " = " ++ expressionToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ expressionToGlsl (Expression to) ++ "; " ++ var ++ "++) {") + For var from rel to step loop next -> + [ indent i ("for (int " ++ var ++ " = " ++ expressionToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ expressionToGlsl (Expression to) ++ "; " ++ expressionToGlsl (Expression step) ++ ") {") , go (i + 1) loop , indent i "}" , "" @@ -193,6 +210,15 @@ statementToGlsl (Statement r) = Continue -> indent i "continue;" + ExpressionStatement e Nop -> + indent i (expressionToGlsl (Expression e) ++ ";") + + Decl t (Name n) (Just e) Nop -> + indent i (t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";") + + Decl t (Name n) Nothing Nop -> + indent i (t ++ " " ++ n ++ ";") + ExpressionStatement e next -> indent i (expressionToGlsl (Expression e) ++ ";\n") ++ go i next @@ -371,9 +397,12 @@ expressionToGlsl (Expression tree) = Negate c -> "-" ++ go2 False c - PostfixPlus c -> + PostfixIncrement c -> go2 False c ++ "++" + PostfixDecrement c -> + go2 False c ++ "--" + _ -> go2 rec e @@ -551,6 +580,11 @@ expr24 f l r = dotted4Internal (f (unwrapExpression l) (unwrapExpression r)) +expr233 : (Expr -> Expr -> Expr) -> ExpressionX a Mat3 -> ExpressionX b Mat3 -> Expression33 +expr233 f l r = + dotted33Internal (f (unwrapExpression l) (unwrapExpression r)) + + expr3 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX a l -> ExpressionX b m -> ExpressionX c r -> Expression1 t expr3 f l m r = dotted1Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) @@ -596,11 +630,23 @@ add4 = expr24 Add +add33 : ExpressionX a Mat3 -> ExpressionX b Mat3 -> Expression33 +add33 = + expr233 Add + + subtract : ExpressionX a t -> ExpressionX b t -> Expression1 t subtract = expr2 Subtract +subtractConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { b | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t +subtractConst l r = + { base = (expr2 Subtract l r).base + , isConstant = Constant + } + + subtract2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 subtract2 = expr22 Subtract @@ -626,9 +672,14 @@ negate2 e = dotted2Internal (Negate <| unwrapExpression e) -postfixPlus : ExpressionX a t -> Expression1 t -postfixPlus = - expr1 PostfixPlus +postfixIncrement : ExpressionX a t -> Expression1 t +postfixIncrement = + expr1 PostfixIncrement + + +postfixDecrement : ExpressionX a t -> Expression1 t +postfixDecrement = + expr1 PostfixDecrement by : ExpressionX a t -> ExpressionX b t -> Expression1 t @@ -1035,6 +1086,13 @@ int i = } +bool : Bool -> ExpressionX { isConstant : Constant } Bool +bool b = + { base = Expression <| Bool b + , isConstant = Constant + } + + constant : TypingFunction t r -> String -> ExpressionX { isConstant : Constant } t constant _ name = { base = Expression <| Variable name @@ -1352,12 +1410,17 @@ ifElse cond (Statement ifTrue) (Statement ifFalse) (Statement next) = for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r for ( var, from, to ) loop (Statement next) = - Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r forLeq ( var, from, to ) loop (Statement next) = - Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next + + +forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r +forDown ( var, from, to ) loop (Statement next) = + Statement <| For var (unwrapExpression from) GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next return : ExpressionX a r -> Statement r @@ -1705,8 +1768,11 @@ innerValue ctx e = AssignCombo _ _ _ -> Debug.todo "branch 'AssignCombo _ _' not implemented" - PostfixPlus _ -> - Debug.todo "branch 'PostfixPlus _' not implemented" + PostfixIncrement _ -> + Debug.todo "branch 'PostfixIncrement _' not implemented" + + PostfixDecrement _ -> + Debug.todo "branch 'PostfixDecrement _' not implemented" innerValue2 : @@ -1798,8 +1864,8 @@ interpret ctx (Statement s) = Decl _ _ _ _ -> Debug.todo "branch 'Decl _ _ _' not implemented" - For _ _ _ _ _ _ -> - Debug.todo "branch 'For _ _ _ _ _ _' not implemented" + For _ _ _ _ _ _ _ -> + Debug.todo "branch 'For _ _ _ _ _ _ _' not implemented" Break -> Debug.todo "branch 'Break' not implemented" diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 333e079e..fbafdb1e 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -1,12 +1,12 @@ -module UI.Glsl.Polynomial exposing (asPolynomial, getDegree, getSolutions) +module UI.Glsl.Polynomial exposing (asPolynomial, getDegree, getSolutions, glslFromPolySolutions, glslFromSolutions) import Dict exposing (Dict) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), RelationOperation(..), UnaryOperation(..)) import Expression.Polynomial exposing (Exponents) -import Expression.Utils exposing (minus, zero) +import Expression.Utils import Maybe.Extra as Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (ExpressionX, dotted1, unknown) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, ands, arr, assign, boolT, by, byF, def, dotted1, expr, float, floatT, fun4, gt, int, lt, mat3T, mix, out, return, unknown, unknownStatement, vec3T, zero) getDegree : Dict (List ( a, number )) b -> number @@ -22,7 +22,7 @@ asPolynomial : List String -> Expression -> Maybe (Dict Exponents Float) asPolynomial vars e = case e of RelationOperation Equals l r -> - asPolynomial vars (minus l r) + asPolynomial vars (Expression.Utils.minus l r) _ -> e @@ -75,7 +75,7 @@ getSolutions maxDistance poly = get d = Dict.get d poly - |> Maybe.withDefault zero + |> Maybe.withDefault Expression.Utils.zero |> UI.Glsl.Code.expressionToGlsl [ ( "dx", dotted1 <| unknown "dx" ) , ( "dy", dotted1 <| unknown "dy" ) @@ -156,3 +156,60 @@ getSolutions maxDistance poly = else Just ( deg, sols ) + + +glslFromSolutions : + String + -> List ( String, String ) + -> + { funDecls : List FunDecl + , bisect : ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool + } +glslFromSolutions suffix sols = + let + checks = + sols + |> List.foldl + (\( k, v ) ( known, f ) -> + let + ( decl, drop ) = + if List.member k known then + ( "", 0 ) + + else if String.startsWith "!" k then + ( "float ", 1 ) + + else + ( "vec2 ", 0 ) + + newLine = + \n -> f <| expr (dotted1 <| unknown (decl ++ String.dropLeft drop k ++ " = " ++ v ++ ";")) <| \_ -> n + in + ( k :: known, newLine ) + ) + ( [ "t" ], identity ) + |> Tuple.second + + ( funDecl, bisect ) = + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + def floatT "t" (by maxDistance <| float 2) <| \t -> + checks <| + expr (assign found (add o (byF t (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> + return <| ands [ lt t maxDistance, gt t zero ] + in + { funDecls = [ funDecl ] + , bisect = bisect + } + + +glslFromPolySolutions : + String + -> ExpressionX xm Float + -> Dict Int Expression + -> + Maybe + { funDecls : List FunDecl + , bisect : ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool + } +glslFromPolySolutions suffix maxDistance poly = + getSolutions maxDistance poly |> Maybe.map (\( _, sols ) -> glslFromSolutions suffix sols) diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag index a3a3f08b..4d576ef9 100644 --- a/src/shaders/declarations.frag +++ b/src/shaders/declarations.frag @@ -1,6 +1,3 @@ -#define MAX_DEPTH 30 -//#define MAX_DEPTH 60 - precision highp float; uniform float u_whiteLines; From deaec0811483b2fb965d68e77bd0eac7fb3cb7e1 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 02:17:31 +0200 Subject: [PATCH 049/139] Cleanup converter --- glslParser/src/GlslConverter.elm | 72 ++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 6b31af3d..52e45115 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -34,8 +34,7 @@ init = i = """{ -for(int j = MAX_DEPTH - 1; j > 0; j--) { -} + }""" in @@ -737,9 +736,8 @@ prettyPrintStatement stat = Expression e next -> "expr " ++ prettyPrintExpression e - ++ "<| (\\_ -> \n" + ++ " <| \\_ ->\n" ++ prettyPrintStatement next - ++ ")" For var from LessThan to step loop next -> (if step then @@ -757,9 +755,8 @@ prettyPrintStatement stat = ++ var ++ " ->\n" ++ prettyPrintStatement loop - ++ ") (" + ++ ") <| \\_ ->\n" ++ prettyPrintStatement next - ++ ")" For var from LessThanOrEquals to step loop next -> (if step then @@ -777,18 +774,55 @@ prettyPrintStatement stat = ++ var ++ " ->\n" ++ prettyPrintStatement loop - ++ ") (" + ++ ") <| \\_ ->\n" + ++ prettyPrintStatement next + + + For var from GreaterThan to step loop next -> + (if step then + "for (\"" + + else + "forDown (\"" + ) + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ prettyPrintStatement loop + ++ ") <| \\_ ->\n" + ++ prettyPrintStatement next + + For var from GreaterThanOrEquals to step loop next -> + (if step then + "forLeq (\"" + + else + "forLeqDown (\"" + ) + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ prettyPrintStatement loop + ++ ") <| \\_ ->\n" ++ prettyPrintStatement next - ++ ")" If cond ifTrue next -> "if_ " ++ prettyPrintExpression cond ++ "(\n" ++ prettyPrintStatement ifTrue - ++ ") (" + ++ ") <| \\_ ->\n" ++ prettyPrintStatement next - ++ ")" Return e -> "(return <| " ++ prettyPrintExpression e ++ ")\n" @@ -810,23 +844,9 @@ prettyPrintStatement stat = Decl _ _ _ -> "TODO branch 'Decl _ _ _' not implemented" - - For v f GreaterThan t _ loop next -> - "forDown (\"" - ++ v - ++ "\", " - ++ prettyPrintExpression f - ++ ", " - ++ prettyPrintExpression t - ++ ") (\\" - ++ v - ++ " ->" - ++ prettyPrintStatement loop - ++ ")" - ++ prettyPrintStatement next - + For _ _ _ _ _ _ _ -> - "TODO branch For not completely implemented" + "TODO branch 'For _ _ _ _ _ _ _' not implemented" prettyPrintExpression : Expression -> String From a56845c201194da9064b2185d6da518305a975f9 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 02:24:01 +0200 Subject: [PATCH 050/139] Slightly less firebally API --- src/elm/UI/Glsl/Code.elm | 526 ++++++++++++++++++---------------- src/elm/UI/Glsl/Generator.elm | 69 ++--- 2 files changed, 312 insertions(+), 283 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 3b61228e..cf4d1d05 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDec import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -238,12 +238,11 @@ isquareCouple = fun1 vec2T "isquare" (vec2T "z") <| \z -> def vec2T "s" (by z z) <| \s -> def floatT "mx" (max_ s.x s.y) <| \mx -> - if_ - (ands [ leq z.x zero, geq z.y zero ]) + if_ (ands [ leq z.x zero, geq z.y zero ]) (return <| vec2 zero mx) - (def floatT "mn" (min_ s.x s.y) <| \mn -> - return <| vec2 mn mx - ) + <| \_ -> + def floatT "mn" (min_ s.x s.y) <| \mn -> + return <| vec2 mn mx isquareDecl : FunDecl @@ -397,28 +396,26 @@ ipowFI = ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) ipowICouple = fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e -> - if_ - (eq e (int 0)) + if_ (eq e (int 0)) (return <| vec2 one one) - (if_ - (eq e (int 1)) - (return b) - (def floatT "xe" (ipowFI b.x e) <| \xe -> - def floatT "ye" (ipowFI b.y e) <| \ye -> - def floatT "mn" (min_ xe ye) <| \mn -> - def floatT "mx" (max_ xe ye) <| \mx -> - return <| - ternary - (ands - [ eq (mod (floatCast e) (float 2)) zero - , leq b.x zero - , geq b.y zero - ] - ) - (vec2 (min_ zero mn) (max_ zero mx)) - (vec2 mn mx) + <| \_ -> + if_ (eq e (int 1)) + (return b) + <| \_ -> + def floatT "xe" (ipowFI b.x e) <| \xe -> + def floatT "ye" (ipowFI b.y e) <| \ye -> + def floatT "mn" (min_ xe ye) <| \mn -> + def floatT "mx" (max_ xe ye) <| \mx -> + return <| + ternary + (ands + [ eq (mod (floatCast e) (float 2)) zero + , leq b.x zero + , geq b.y zero + ] ) - ) + (vec2 (min_ zero mn) (max_ zero mx)) + (vec2 mn mx) ipowIDecl : FunDecl @@ -480,7 +477,8 @@ gpowCouple = def intT "ie" (intCast e.x) <| \ie -> if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) (return <| gpowI b ie) - (return <| gexp <| gby (gln b) e) + <| \_ -> + return <| gexp <| gby (gln b) e gpowDecl : FunDecl @@ -825,11 +823,11 @@ catanTuple = fun1 vec2T "catan" (vec2T "z") <| \z -> if_ (eq z.y zero) (return <| vec2 (atan_ z.x) zero) - (def vec2T "o" (vec2 one zero) <| \o -> - def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> - def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> - return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) - ) + <| \_ -> + def vec2T "o" (vec2 one zero) <| \o -> + def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> + def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> + return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) catanDecl : FunDecl @@ -981,10 +979,10 @@ straightFunctionToGlsl name = fun1 floatT "tanh" (floatT "x") <| \x -> if_ (gt (abs_ x) (float 10)) (return <| sign x) - (def floatT "p" (exp x) <| \p -> - def floatT "m" (exp <| negate_ x) <| \m -> - return <| div (subtract p m) (add p m) - ) + <| \_ -> + def floatT "p" (exp x) <| \p -> + def floatT "m" (exp <| negate_ x) <| \m -> + return <| div (subtract p m) (add p m) ] Sin22 -> @@ -1275,20 +1273,22 @@ cmbrotCouple = def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| \p -> if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) (return vec2Zero) - (def vec2T "z" c <| \z -> - for ( "i", int 0, int 4000 ) - (\i -> - expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> - if_ (gt (length z) (float 1000000)) - (def floatT "logLength" (log (length z)) <| \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return <| vec2 (sin_ fi) (cos_ fi) - ) - unsafeNop - ) - (return vec2Zero) + <| \_ -> + def vec2T "z" c <| \z -> + for ( "i", int 0, int 4000 ) + (\i -> + expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> + if_ (gt (length z) (float 1000000)) + (def floatT "logLength" (log (length z)) <| \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| \fi -> + return <| vec2 (sin_ fi) (cos_ fi) + ) + <| \_ -> + unsafeNop ) + <| \_ -> + return vec2Zero cmbrotDecl : FunDecl @@ -1306,10 +1306,10 @@ csqrtTuple = fun1 vec2T "csqrt" (vec2T "z") <| \z -> if_ (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (sqrt_ z.x) zero) - (def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> - def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> - return <| byF r <| vec2 (cos_ t) (sin_ t) - ) + <| \_ -> + def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> + def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> + return <| byF r <| vec2 (cos_ t) (sin_ t) csqrtDecl : FunDecl @@ -1327,19 +1327,19 @@ ccbrtCouple = fun1 vec2T "ccbrt" (vec2T "z") <| \z -> if_ (eq z.y zero) (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) - (def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> - def floatT - "t" - (add (div (atan2_ z.y z.x) (float 3)) - (ternary - (gt z.x zero) - zero - (radians_ (float 120)) - ) + <| \_ -> + def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> + def floatT + "t" + (add (div (atan2_ z.y z.x) (float 3)) + (ternary + (gt z.x zero) + zero + (radians_ (float 120)) ) - <| \t -> - return <| byF r (vec2 (cos_ t) (sin_ t)) ) + <| \t -> + return <| byF r (vec2 (cos_ t) (sin_ t)) ccbrtDecl : FunDecl @@ -1373,10 +1373,10 @@ clnTuple = if_ (ands [ eq z.y zero, geq z.x zero ]) (return <| vec2 (log z.x) zero) - (def floatT "px" (length z) <| \px -> - def floatT "py" (atan2_ z.y z.x) <| \py -> - return <| vec2 (log px) py - ) + <| \_ -> + def floatT "px" (length z) <| \px -> + def floatT "py" (atan2_ z.y z.x) <| \py -> + return <| vec2 (log px) py clnDecl : FunDecl @@ -1770,14 +1770,16 @@ toSrcImplicit suffix e = if_ (eq piece zero) (return vec3Zero) - (assignAdd sum piece <| \_ -> unsafeNop) + <| \_ -> + assignAdd sum piece <| \_ -> unsafeNop ) - unsafeNop - ) - (def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> - expr (assign perc (pow perc <| float 0.2)) <| \_ -> - return <| byF perc (vec3 one one one) + <| \_ -> + unsafeNop ) + <| \_ -> + def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> + expr (assign perc (pow perc <| float 0.2)) <| \_ -> + return <| byF perc (vec3 one one one) in ( [ fDecl, pixelDecl ], pixel ) @@ -1794,16 +1796,18 @@ toSrcPolar suffix e = def floatT "t" (add (atanPlus y x) deltaT) <| \t -> -- Avoid the branch cut at {x > 0, y = 0} if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) <| \_ -> unsafeNop) - (def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> - return <| - ternary (gt (abs_ complex.y) (float epsilon)) - minusOne - (ternary (gt complex.x zero) - one - zero - ) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) <| \_ -> + unsafeNop ) + <| \_ -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> + return <| + ternary (gt (abs_ complex.y) (float epsilon)) + minusOne + (ternary (gt complex.x zero) + one + zero + ) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> @@ -1819,15 +1823,16 @@ toSrcPolar suffix e = def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) unsafeBreak - (if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - (assignAdd t constants.twopi <| \_ -> - assignAdd ot constants.twopi <| \_ -> - unsafeNop - ) - ) + <| \_ -> + if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + <| \_ -> + assignAdd t constants.twopi <| \_ -> + assignAdd ot constants.twopi <| \_ -> + unsafeNop ) - (return vec3Zero) + <| \_ -> + return vec3Zero in ( [ fDecl, pixelDecl ], pixel ) @@ -1839,6 +1844,8 @@ constants : , pi : ExpressionX { isConstant : Constant } Float , twopi : ExpressionX { isConstant : Constant } Float , vectorSpacing : ExpressionX { isConstant : Constant } Float + , xPoints : ExpressionX { isConstant : Constant } Int + , yPoints : ExpressionX { isConstant : Constant } Int } constants = { maxIterations = constant intT "MAX_ITERATIONS" @@ -1847,6 +1854,8 @@ constants = , pi = constant floatT "PI" , twopi = constant floatT "TWOPI" , vectorSpacing = constant floatT "VECTOR_SPACING" + , xPoints = constant intT "X_POINTS" + , yPoints = constant intT "Y_POINTS" } @@ -1871,7 +1880,8 @@ toSrcParametric suffix e = def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| \ithreshold -> for ( "it", int 0, constants.maxIterations ) (\_ -> innerLoop from to p depth choices ithreshold) - (return vec3Zero) + <| \_ -> + return vec3Zero innerLoop from to p depth choices ithreshold = def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> @@ -1893,50 +1903,52 @@ toSrcParametric suffix e = ] ) (return <| vec3 one one one) + <| \_ -> + ifElse + (ands [ leq front.x zero, geq front.y zero ]) + (expr (assign to midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + assignBy choices (int 2) <| \_ -> + unsafeNop + ) (ifElse - (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| \_ -> + (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> expr (postfixIncrement depth) <| \_ -> - assignBy choices (int 2) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> unsafeNop ) - (ifElse - (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - unsafeNop - ) - (unknownStatement - (""" - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); + (unknownStatement + (""" + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices /= 2; + if(choices / 2 * 2 == choices) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = choices * 2 + 1; + break; } + } else { + from = from - (to - from); } - if(depth == 0) - return vec3(0,0,0); - """) + } + if(depth == 0) + return vec3(0,0,0); + """) + ) + <| \_ -> + unsafeNop ) - unsafeNop - ) + <| \_ -> unsafeNop - ) in ( [ intervalDecl, pixelDecl ], pixel ) @@ -1961,10 +1973,10 @@ thetaDeltaCouple = fun1 floatT "thetaDelta" (floatT "theta") <| \theta -> if_ (lt uniforms.u_whiteLines one) (return <| float 100) - (def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> - def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> - return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh - ) + <| \_ -> + def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> + def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> + return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh thetaDeltaDecl : FunDecl @@ -2014,53 +2026,57 @@ toSrcVectorField2D suffix xexpr yexpr = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> def vec2T "o" (vec2 x y) <| \o -> def floatT "mx" zero <| \mx -> - unknownStatement (""" - for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { - for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { - vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); - vec2 v = vector""" ++ suffix ++ """(p.x, p.y); - mx = max(mx, length(v)); - } - } - - vec3 colorA = vec3(0.0, 1.0, 0.0); - vec3 colorB = vec3(0.0, 0.0, 1.0); - - x = o.x - mod(o.x, deltaX * VECTOR_SPACING); - y = o.y - mod(o.y, deltaX * VECTOR_SPACING); - - vec2 bl = vector""" ++ suffix ++ """(x, y); - vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); - vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); - vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - - float angleO; - vec2 corner; - float l; - - corner = vec2(x, y); - l = length(bl) / mx; - if(near(o, corner, bl, deltaX, mx)) - return mix(colorA, colorB, l); - - corner = vec2(x + deltaX * VECTOR_SPACING, y); - l = length(br) / mx; - if(near(o, corner, br, deltaX, mx)) - return mix(colorA, colorB, l); - - corner = vec2(x, y + deltaX * VECTOR_SPACING); - l = length(ul) / mx; - if(near(o, corner, ul, deltaX, mx)) - return mix(colorA, colorB, l); - - corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); - l = length(ur) / mx; - if(near(o, corner, ur, deltaX, mx)) - return mix(colorA, colorB, l); - - return vec3(0,0,0); - - """) + def floatT "k" (by deltaX constants.vectorSpacing) <| \k -> + forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) + (\xi -> + forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) + (\yi -> + def vec2T + "p" + (add uniforms.u_zoomCenter + (vec2 + (by k (floatCast xi)) + (by k (floatCast yi)) + ) + ) + <| \p -> + def vec2T "v" (vector p.x p.y) <| \v -> + expr (assign mx (max_ mx (length v))) <| \_ -> + unsafeNop + ) + <| \_ -> + unsafeNop + ) + <| \_ -> + def vec3T "colorA" (vec3 zero one zero) <| \colorA -> + def vec3T "colorB" (vec3 zero zero one) <| \colorB -> + expr (assign x (subtract o.x (mod o.x k))) <| \_ -> + expr (assign y (subtract o.y (mod o.y k))) <| \_ -> + def vec2T "bl" (vector x y) <| \bl -> + def vec2T "br" (vector (add x k) y) <| \br -> + def vec2T "ul" (vector x (add y k)) <| \ul -> + def vec2T "ur" (vector (add x k) (add y k)) <| \ur -> + def vec2T "corner" (vec2 x y) <| \corner -> + def floatT "l" (div (length bl) mx) <| \l -> + if_ (near o corner bl deltaX mx) + (return <| mix colorA colorB l) + <| \_ -> + expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| \_ -> + expr (assign l (div (length br) mx)) <| \_ -> + if_ (near o corner br deltaX mx) + (return <| mix colorA colorB l) + <| \_ -> + expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| \_ -> + expr (assign l (div (length ul) mx)) <| \_ -> + if_ (near o corner ul deltaX mx) + (return <| mix colorA colorB l) + <| \_ -> + expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| \_ -> + expr (assign l (div (length ur) mx)) <| \_ -> + if_ (near o corner ur deltaX mx) + (return <| mix colorA colorB l) + <| \_ -> + return vec3Zero in ( [ vectorDecl, nearDecl, pixelDecl ], pixel ) @@ -2082,10 +2098,10 @@ toSrcContour suffix expr = (hl2rgb (add haf <| float 0.3) squished) (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) ) - (def floatT "td" (thetaDelta theta) <| \td -> - def floatT "l" (mix one squished <| smoothstep zero one td) <| \l -> - return <| hl2rgb theta l - ) + <| \_ -> + def floatT "td" (thetaDelta theta) <| \td -> + def floatT "l" (mix one squished <| smoothstep zero one td) <| \l -> + return <| hl2rgb theta l ( pixelDecl, pixel ) = let @@ -2105,14 +2121,14 @@ toSrcContour suffix expr = def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - (assignBy deltaXr (float 2) <| \_ -> - assignBy deltaYr (float 2) <| \_ -> - def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> - def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> - def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> - def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> - return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) - ) + <| \_ -> + assignBy deltaXr (float 2) <| \_ -> + assignBy deltaYr (float 2) <| \_ -> + def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> + def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> + def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> + def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> + return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2690,25 +2706,25 @@ axisTuple = def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| \across -> if_ (lt across (float -12)) (return zero) - (def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> - if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) - (def floatT - "unit" - (ternary - (lt across (float -6)) - (by smallUnit (float 100)) - (ternary - (lt across (float -0.1)) - (by smallUnit (float 10)) - (by smallUnit (float 5)) - ) - ) - <| \unit -> - def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| \parallel -> - return <| max_ zero (max_ across parallel) + <| \_ -> + def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> + if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) + (return zero) + <| \_ -> + def floatT + "unit" + (ternary + (lt across (float -6)) + (by smallUnit (float 100)) + (ternary + (lt across (float -0.1)) + (by smallUnit (float 10)) + (by smallUnit (float 5)) ) ) + <| \unit -> + def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| \parallel -> + return <| max_ zero (max_ across parallel) axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float @@ -2837,27 +2853,29 @@ raytrace bisects = bisects |> Tuple.second - bisectToRay i bisect = + bisectToRay i bisect next = if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) (expr (assign foundIndex <| int i) <| \_ -> expr (assign found f) <| \_ -> expr (assign currDistance <| length <| subtract found o) <| \_ -> unsafeNop ) + <| \_ -> + next in innerTrace <| if_ (lt foundIndex <| int 0) (return <| vec4 zero zero zero one) - (def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> - def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> - def floatT "light_distance" maxDistance <| \lightDistance -> - def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| \offseted -> - def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| \hueBasedOnIndex -> - def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \lightDirection -> - def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \lightCoeff -> - def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> - return <| vec4_3_1 px one - ) + <| \_ -> + def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> + def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> + def floatT "light_distance" maxDistance <| \lightDistance -> + def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| \offseted -> + def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| \hueBasedOnIndex -> + def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \lightDirection -> + def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \lightCoeff -> + def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> + return <| vec4_3_1 px one threshold : ExpressionX x Float -> Expression1 Float @@ -2879,19 +2897,21 @@ suffixToBisect interval suffix = (expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> return <| bool True ) - (ifElse (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) <| \_ -> - unsafeNop - ) - (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (backtrackLeft from to depth choices midpoint) - (backtrackRight from to depth choices midpoint) - unsafeNop - ) - unsafeNop + <| \_ -> + ifElse (ands [ leq front.x zero, geq front.y zero ]) + (expr (assign to midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) <| \_ -> + unsafeNop + ) + (ifElse (ands [ leq back.x zero, geq back.y zero ]) + (backtrackLeft from to depth choices midpoint) + (backtrackRight from to depth choices midpoint) + <| \_ -> + unsafeNop ) + <| \_ -> + unsafeNop backtrackLeft from _ depth choices midpoint = expr (assign from midpoint) <| \_ -> @@ -2904,29 +2924,32 @@ suffixToBisect interval suffix = forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) (\j -> if_ (gt j depth) - (unknownStatement "continue;") - (expr (postfixDecrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> - ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) - (expr (assign midpoint to) <| \_ -> - expr (assign to <| add to (subtract to from)) <| \_ -> - def vec2T "back" (interval midpoint to) <| \back -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> - unknownStatement "break;" - ) - unsafeNop + unsafeContinue + <| \_ -> + expr (postfixDecrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> + ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) + (expr (assign midpoint to) <| \_ -> + expr (assign to <| add to (subtract to from)) <| \_ -> + def vec2T "back" (interval midpoint to) <| \back -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> + unsafeBreak ) - (expr (assign from <| subtract from (subtract to from)) <| \_ -> unsafeNop) - unsafeNop + <| \_ -> + unsafeNop ) - ) - (if_ (eq depth (int 0)) - (return false) + (expr (assign from <| subtract from (subtract to from)) <| \_ -> unsafeNop) + <| \_ -> unsafeNop ) + <| \_ -> + if_ (eq depth (int 0)) + (return false) + <| \_ -> + unsafeNop in fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| \from -> @@ -2936,4 +2959,5 @@ suffixToBisect interval suffix = def intT "choices" (int 0) <| \choices -> for ( "it", int 0, constants.maxIterations ) (mainLoop found from to ithreshold depth choices) - (return <| bool False) + <| \_ -> + return <| bool False diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index eeb622f4..fa1a9ce3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,7 +1,8 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) +import Expression.NumericRange exposing (isCompletelyReal) import Set @@ -667,6 +668,13 @@ negate_ = expr1 Negate +negateConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t +negateConst l = + { base = (expr1 Negate l).base + , isConstant = Constant + } + + negate2 : ExpressionX a Vec2 -> Expression2 negate2 e = dotted2Internal (Negate <| unwrapExpression e) @@ -1398,29 +1406,29 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body ) -if_ : Expression1 Bool -> Statement q -> Statement r -> Statement r -if_ cond (Statement ifTrue) (Statement next) = - Statement <| If (unwrapExpression cond) ifTrue next +if_ : Expression1 Bool -> Statement q -> (() -> Statement r) -> Statement r +if_ cond (Statement ifTrue) next = + Statement <| If (unwrapExpression cond) ifTrue (unwrapLazyStatement next) -ifElse : Expression1 Bool -> Statement q -> Statement r -> Statement s -> Statement s -ifElse cond (Statement ifTrue) (Statement ifFalse) (Statement next) = - Statement <| IfElse (unwrapExpression cond) ifTrue ifFalse next +ifElse : Expression1 Bool -> Statement q -> Statement r -> (() -> Statement s) -> Statement s +ifElse cond (Statement ifTrue) (Statement ifFalse) next = + Statement <| IfElse (unwrapExpression cond) ifTrue ifFalse (unwrapLazyStatement next) -for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r -for ( var, from, to ) loop (Statement next) = - Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next +for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r +for ( var, from, to ) loop next = + Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) -forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r -forLeq ( var, from, to ) loop (Statement next) = - Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next +forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r +forLeq ( var, from, to ) loop next = + Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) -forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> Statement r -> Statement r -forDown ( var, from, to ) loop (Statement next) = - Statement <| For var (unwrapExpression from) GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) next +forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r +forDown ( var, from, to ) loop next = + Statement <| For var (unwrapExpression from) GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) return : ExpressionX a r -> Statement r @@ -1475,31 +1483,28 @@ assign name e = dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) -expr : ExpressionX a t -> (() -> Statement q) -> Statement q -expr e n = +unwrapLazyStatement : (() -> Statement r) -> Stat +unwrapLazyStatement f = let (Statement next) = - n () + f () in - Statement <| ExpressionStatement (unwrapExpression e) next + next + + +expr : ExpressionX a t -> (() -> Statement q) -> Statement q +expr e next = + Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) assignAdd : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q -assignAdd name e n = - let - (Statement next) = - n () - in - Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) next +assignAdd name e next = + Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) assignBy : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q -assignBy name e n = - let - (Statement next) = - n () - in - Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) next +assignBy name e next = + Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) From e4bcd456a4c05a563c57d67b968895f4bf28ae0d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 19:12:12 +0200 Subject: [PATCH 051/139] No more unknown statements --- src/elm/UI/Glsl.elm | 45 +++++++------- src/elm/UI/Glsl/Code.elm | 104 ++++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 8 +-- src/elm/UI/Glsl/Polynomial.elm | 2 +- src/elm/UI/Glsl/Sphere.elm | 32 +++++----- 5 files changed, 102 insertions(+), 89 deletions(-) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 349de3c1..ffd91d22 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -4,11 +4,11 @@ import Dict import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), FunctionName(..), KnownFunction(..), RelationOperation(..)) import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) -import Expression.Utils exposing (by, cbrt, div, ipow, minus, one, plus, sqrt_, square) +import Expression.Utils exposing (by, minus, plus, square) import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, def, expr, fileToGlsl, float, floatT, fun4, int, mat3T, mix, out, unknown, unknownStatement, vec3T) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, expr, fileToGlsl, unknown) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial @@ -193,30 +193,31 @@ get3DSource prefix e = } Nothing -> - -- case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of - -- Just ( glsl, bisect ) -> - -- { expr = e - -- , funDecls = [ glsl ] - -- , bisect = bisect - -- } - -- Nothing -> - case tryGlslFromPolynomial prefix e of - Just o -> - o - - Nothing -> - let - ( glsl, interval ) = - toSrc3D prefix e - - ( decl, bisect ) = - UI.Glsl.Code.suffixToBisect interval prefix - in + case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of + Just ( glsl, bisect ) -> { expr = e - , funDecls = glsl ++ [ decl ] + , funDecls = [ glsl ] , bisect = bisect } + Nothing -> + case tryGlslFromPolynomial prefix e of + Just o -> + o + + Nothing -> + let + ( glsl, interval ) = + toSrc3D prefix e + + ( decl, bisect ) = + UI.Glsl.Code.suffixToBisect interval prefix + in + { expr = e + , funDecls = glsl ++ [ decl ] + , bisect = bisect + } + tryGlslFromPolynomial : String diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index cf4d1d05..fa01c0d6 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import Dict +import Dict exposing (Dict) import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1867,7 +1867,15 @@ toSrcParametric suffix e = def vec2T "x" (vec2 p.x p.x) <| \x -> def vec2T "y" (vec2 p.y p.y) <| \y -> def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| \t -> - return <| expressionToIntervalGlsl (toPrintExpression e) + return <| + expressionToIntervalGlsl + (Dict.fromList + [ ( "x", x ) + , ( "y", y ) + , ( "t", t ) + ] + ) + (toPrintExpression e) ( pixelDecl, pixel ) = fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> @@ -1918,37 +1926,44 @@ toSrcParametric suffix e = expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> unsafeNop ) - (unknownStatement - (""" - // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - for(int j = MAX_DEPTH - 1; j > 0; j--) { - if(j > depth) - continue; - depth--; - choices /= 2; - if(choices / 2 * 2 == choices) { - midpoint = to; - to = to + (to - from); - vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); - if(back.x <= 0.0 && back.y >= 0.0) { - from = midpoint; - depth++; - choices = choices * 2 + 1; - break; - } - } else { - from = from - (to - from); - } - } - if(depth == 0) - return vec3(0,0,0); - """) - ) - <| \_ -> - unsafeNop - ) - <| \_ -> - unsafeNop + -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + (forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) + (\j -> + if_ (gt j depth) + unsafeContinue + <| \_ -> + expr (postfixDecrement depth) <| \_ -> + expr (assign choices (div choices (int 2))) <| \_ -> + ifElse (eq (by (div choices (int 2)) (int 2)) choices) + (expr (assign midpoint to) <| \_ -> + expr (assign to (add to (subtract to from))) <| \_ -> + expr (assign back (interval p midpoint to)) <| \_ -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> + unsafeBreak + ) + <| \_ -> + unsafeNop + ) + (expr (assign from (subtract from (subtract to from))) <| \_ -> + unsafeNop + ) + <| + \_ -> unsafeNop + ) + <| \_ -> + if_ (eq depth (int 0)) + (return vec3Zero) + <| + \_ -> unsafeNop + ) + <| \_ -> + unsafeNop + ) + <| \_ -> + unsafeNop in ( [ intervalDecl, pixelDecl ], pixel ) @@ -2362,8 +2377,8 @@ expressionToGlsl context = toPrintExpression >> go -expressionToIntervalGlsl : PrintExpression -> Expression2 -expressionToIntervalGlsl expr = +expressionToIntervalGlsl : Dict String Expression2 -> PrintExpression -> Expression2 +expressionToIntervalGlsl vars expr = let unsafeApply name ex = let @@ -2373,7 +2388,7 @@ expressionToIntervalGlsl expr = dotted2 <| unsafeCall name (List.map (go >> .base) ex) go = - expressionToIntervalGlsl + expressionToIntervalGlsl vars in case expr of PVariable "pi" -> @@ -2383,7 +2398,12 @@ expressionToIntervalGlsl expr = dup <| exp one PVariable v -> - dotted2 <| unknown v + case Dict.get v vars of + Just w -> + w + + Nothing -> + dotted2 <| unknown v PInteger v -> dup <| float <| toFloat v @@ -2747,10 +2767,10 @@ toSrc3D suffix e = fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> - def vec2T "x" (vec2 mn.x mx.x) <| \_ -> - def vec2T "y" (vec2 mn.y mx.y) <| \_ -> - def vec2T "z" (vec2 mn.z mx.z) <| \_ -> - return <| expressionToIntervalGlsl <| toPrintExpression e + def vec2T "x" (vec2 mn.x mx.x) <| \x -> + def vec2T "y" (vec2 mn.y mx.y) <| \y -> + def vec2T "z" (vec2 mn.z mx.z) <| \z -> + return <| expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e in ( [ Tuple.first <| fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index fa1a9ce3..318385aa 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,8 +1,7 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unknownStatement, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) -import Expression.NumericRange exposing (isCompletelyReal) import Set @@ -1241,11 +1240,6 @@ unknown = Expression << Unknown -unknownStatement : String -> Statement t -unknownStatement line = - Statement <| Line line - - -- STATEMENTS diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index fbafdb1e..1b5e0ff9 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -6,7 +6,7 @@ import Expression.Polynomial exposing (Exponents) import Expression.Utils import Maybe.Extra as Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, ands, arr, assign, boolT, by, byF, def, dotted1, expr, float, floatT, fun4, gt, int, lt, mat3T, mix, out, return, unknown, unknownStatement, vec3T, zero) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, ands, arr, assign, boolT, by, byF, def, dotted1, expr, float, floatT, fun4, gt, int, lt, mat3T, mix, out, return, unknown, vec3T, zero) getDegree : Dict (List ( a, number )) b -> number diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 0739257c..c840bf7b 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -4,7 +4,7 @@ import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, boolT, floatT, floatToGlsl, fun4, mat3T, out, unknownStatement, vec3T) +import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, bool, boolT, by, byF, def, dot, expr, false, float, floatT, fun4, if_, int, lt, mat3T, mix, negate_, out, return, sqrt_, subtract, true, vec3, vec3T, zero) import UI.Glsl.Polynomial as Polynomial @@ -76,19 +76,17 @@ reduce poly = toGlsl : String -> Sphere -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Sphere { center, radius }) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - unknownStatement - (""" - vec3 center = vec3(""" ++ floatToGlsl center.x ++ """,""" ++ floatToGlsl center.y ++ """,""" ++ floatToGlsl center.z ++ """); - - vec3 to_center = o - center; - float b = dot(to_center, mix(d[0], d[1], 0.5)); - float c = dot(to_center, to_center) - """ ++ floatToGlsl (radius * radius) ++ """; - float delta = b*b - c; - if(delta < 0.) - return false; - float x = -b - sqrt(delta); - if(x < """ ++ Generator.expressionToGlsl (threshold maxDistance).base ++ """) - return false; - found = o + x * mix(d[0], d[1], 0.5); - return true; - """) + def vec3T "center" (vec3 (float center.x) (float center.y) (float center.z)) <| \centerVar -> + def vec3T "to_center" (subtract o centerVar) <| \to_center -> + def floatT "b" (dot to_center (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))) <| \b -> + def floatT "c" (subtract (dot to_center to_center) (float <| radius * radius)) <| \c -> + def floatT "delta" (subtract (by b b) c) <| \delta -> + if_ (lt delta zero) + (return <| bool False) + <| \_ -> + def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| \x -> + if_ (lt x <| threshold maxDistance) + (return false) + <| \_ -> + expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> + return true From cc94d37d01b3b0ca064397bca8aa23dc321bf7d5 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 19:49:47 +0200 Subject: [PATCH 052/139] Removing unsafeNops using continuations --- src/elm/UI/Glsl/Code.elm | 213 ++++++++++++++-------------------- src/elm/UI/Glsl/Generator.elm | 106 +++++++++++++---- 2 files changed, 171 insertions(+), 148 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index fa01c0d6..2bb2692f 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -58,8 +58,8 @@ cbyDecl = atanPlusTuple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float ) atanPlusTuple = - fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| \x y -> - return <| mod (add constants.twopi (dotted1 <| unsafeCall "atan" [ y.base, x.base ])) constants.twopi + fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| \y x -> + return <| mod (add constants.twopi (atan2_ y x)) constants.twopi atanPlusDecl : FunDecl @@ -1276,7 +1276,7 @@ cmbrotCouple = <| \_ -> def vec2T "z" c <| \z -> for ( "i", int 0, int 4000 ) - (\i -> + (\i cont -> expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> if_ (gt (length z) (float 1000000)) (def floatT "logLength" (log (length z)) <| \logLength -> @@ -1284,8 +1284,8 @@ cmbrotCouple = def floatT "fi" (subtract (floatCast i) nu) <| \fi -> return <| vec2 (sin_ fi) (cos_ fi) ) - <| \_ -> - unsafeNop + <| + cont ) <| \_ -> return vec2Zero @@ -1757,9 +1757,9 @@ toSrcImplicit suffix e = assignBy samples samples <| \_ -> def floatT "coeff" (float 0.0875) <| \coeff -> forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w -> + (\w cont -> forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h -> + (\h _ -> def floatT "piece" (f @@ -1771,10 +1771,10 @@ toSrcImplicit suffix e = (eq piece zero) (return vec3Zero) <| \_ -> - assignAdd sum piece <| \_ -> unsafeNop + assignAdd sum piece cont ) - <| \_ -> - unsafeNop + <| + cont ) <| \_ -> def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> @@ -1816,7 +1816,7 @@ toSrcPolar suffix e = def floatT "t" zero <| \t -> def floatT "ot" (atanPlus y x) <| \ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ -> + (\_ cont -> def floatT "h" (f x y t ot) <| \h -> def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> @@ -1828,8 +1828,7 @@ toSrcPolar suffix e = (return <| vec3 one one one) <| \_ -> assignAdd t constants.twopi <| \_ -> - assignAdd ot constants.twopi <| \_ -> - unsafeNop + assignAdd ot constants.twopi cont ) <| \_ -> return vec3Zero @@ -1891,7 +1890,7 @@ toSrcParametric suffix e = <| \_ -> return vec3Zero - innerLoop from to p depth choices ithreshold = + innerLoop from to p depth choices ithreshold cont = def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> def vec2T "front" (interval p from midpoint) <| \front -> def vec2T "back" (interval p midpoint to) <| \back -> @@ -1914,56 +1913,49 @@ toSrcParametric suffix e = <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - assignBy choices (int 2) <| \_ -> - unsafeNop - ) - (ifElse - (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> + (\_ -> + expr (assign to midpoint) <| \_ -> expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - unsafeNop + assignBy choices (int 2) cont + ) + (ifElse (ands [ leq back.x zero, geq back.y zero ]) + (\_ -> + expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) cont ) -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - (forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) - (\j -> - if_ (gt j depth) - unsafeContinue - <| \_ -> - expr (postfixDecrement depth) <| \_ -> - expr (assign choices (div choices (int 2))) <| \_ -> - ifElse (eq (by (div choices (int 2)) (int 2)) choices) - (expr (assign midpoint to) <| \_ -> - expr (assign to (add to (subtract to from))) <| \_ -> - expr (assign back (interval p midpoint to)) <| \_ -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - unsafeBreak - ) + (\_ -> + forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) + (\j _ -> + if_ (gt j depth) + unsafeContinue <| \_ -> - unsafeNop - ) - (expr (assign from (subtract from (subtract to from))) <| \_ -> - unsafeNop - ) - <| - \_ -> unsafeNop - ) - <| \_ -> - if_ (eq depth (int 0)) - (return vec3Zero) - <| - \_ -> unsafeNop + expr (postfixDecrement depth) <| \_ -> + expr (assign choices (div choices (int 2))) <| \_ -> + ifElse (eq (by (div choices (int 2)) (int 2)) choices) + (\_ -> + expr (assign midpoint to) <| \_ -> + expr (assign to (add to (subtract to from))) <| \_ -> + expr (assign back (interval p midpoint to)) <| \_ -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> + unsafeBreak + ) + cont + ) + (expr (assign from (subtract from (subtract to from)))) + cont + ) + <| \_ -> + if_ (eq depth (int 0)) + (return vec3Zero) + cont ) - <| \_ -> - unsafeNop ) - <| \_ -> - unsafeNop + cont in ( [ intervalDecl, pixelDecl ], pixel ) @@ -2043,9 +2035,9 @@ toSrcVectorField2D suffix xexpr yexpr = def floatT "mx" zero <| \mx -> def floatT "k" (by deltaX constants.vectorSpacing) <| \k -> forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) - (\xi -> + (\xi cont -> forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) - (\yi -> + (\yi _ -> def vec2T "p" (add uniforms.u_zoomCenter @@ -2056,11 +2048,9 @@ toSrcVectorField2D suffix xexpr yexpr = ) <| \p -> def vec2T "v" (vector p.x p.y) <| \v -> - expr (assign mx (max_ mx (length v))) <| \_ -> - unsafeNop + expr (assign mx (max_ mx (length v))) cont ) - <| \_ -> - unsafeNop + cont ) <| \_ -> def vec3T "colorA" (vec3 zero one zero) <| \colorA -> @@ -2200,7 +2190,7 @@ expressionToGlsl context = vec2 w zero Nothing -> - dotted2 <| unknown <| "Variable " ++ v ++ " is undefined" + vec2Zero PInteger v -> vec2 (float <| toFloat v) zero @@ -2249,7 +2239,7 @@ expressionToGlsl context = vec2 (by w w) zero Nothing -> - dotted2 <| unknown <| "Variable " ++ v ++ " is undefined" + vec2Zero PPower l (PInteger 2) -> csquare (go l) @@ -2338,39 +2328,16 @@ expressionToGlsl context = PApply (KnownFunction Max) es -> variadic cmax es - PApply (UserFunction name) ex -> - dotted2 <| unsafeCall ("c" ++ name) (List.map (go >> .base) ex) - - -- PApply (KnownFunction Gra) [ e ] -> - -- cgra (go e) - -- PApply (KnownFunction Det) [ e ] -> - -- cdet (go e) - -- PApply (KnownFunction Dd) [ e ] -> - -- cdd (go e) - -- PApply (KnownFunction Ii) [ e ] -> - -- cii (go e) - -- PApply (KnownFunction Plot) [ e ] -> - -- cplot (go e) - -- PApply (KnownFunction APlot) [ e ] -> - -- caPlot (go e) - -- PApply (KnownFunction StepSimplify) [ e ] -> - -- cstepSimplify (go e) - -- PApply (KnownFunction Solve) [ e ] -> - -- csolve (go e) - -- PApply (KnownFunction For) [ e ] -> - -- cfor (go e) - -- PApply (KnownFunction (Root r)) [ e ] -> - -- croot r (go e) - PApply name ex -> - dotted2 <| unsafeCall ("c" ++ functionNameToString name) (List.map (go >> .base) ex) - - PList es -> - dotted2 <| unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map (go >> .base) es) - PReplace var e -> go (Expression.pfullSubstitute var e) -- If this happens, it's too late + PApply _ _ -> + vec2Zero + + PList _ -> + vec2Zero + PLambda _ _ -> vec2Zero in @@ -2403,7 +2370,7 @@ expressionToIntervalGlsl vars expr = w Nothing -> - dotted2 <| unknown v + vec2Zero PInteger v -> dup <| float <| toFloat v @@ -2906,7 +2873,7 @@ threshold max_distance = suffixToBisect : (Expression33 -> Expression33 -> Expression2) -> String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) suffixToBisect interval suffix = let - mainLoop found from to ithreshold depth choices _ = + mainLoop found from to ithreshold depth choices _ cont = def mat3T "midpoint" (byF (float 0.5) (add33 from to)) <| \midpoint -> def vec2T "front" (interval from midpoint) <| \front -> def vec2T "back" (interval midpoint to) <| \back -> @@ -2919,57 +2886,51 @@ suffixToBisect interval suffix = ) <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) - (expr (assign to midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) <| \_ -> - unsafeNop + (\_ -> + expr (assign to midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) cont ) (ifElse (ands [ leq back.x zero, geq back.y zero ]) (backtrackLeft from to depth choices midpoint) (backtrackRight from to depth choices midpoint) - <| \_ -> - unsafeNop ) - <| \_ -> - unsafeNop + cont - backtrackLeft from _ depth choices midpoint = + backtrackLeft from _ depth choices midpoint cont = expr (assign from midpoint) <| \_ -> expr (postfixIncrement depth) <| \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) <| \_ -> - unsafeNop + expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) cont - backtrackRight from to depth choices midpoint = + backtrackRight from to depth choices midpoint cont = -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) - (\j -> + (\j _ -> if_ (gt j depth) unsafeContinue <| \_ -> expr (postfixDecrement depth) <| \_ -> expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) - (expr (assign midpoint to) <| \_ -> - expr (assign to <| add to (subtract to from)) <| \_ -> - def vec2T "back" (interval midpoint to) <| \back -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> - unsafeBreak - ) - <| \_ -> - unsafeNop + (\_ -> + expr (assign midpoint to) <| \_ -> + expr (assign to <| add to (subtract to from)) <| \_ -> + def vec2T "back" (interval midpoint to) <| \back -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> + unsafeBreak + ) + cont ) - (expr (assign from <| subtract from (subtract to from)) <| \_ -> unsafeNop) - <| \_ -> - unsafeNop + (expr (assign from <| subtract from (subtract to from))) + cont ) <| \_ -> if_ (eq depth (int 0)) (return false) - <| \_ -> - unsafeNop + cont in fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| \from -> diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 318385aa..d9a63911 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1041,12 +1041,12 @@ vec4Zero = gl_FragColor : Expression4 gl_FragColor = - dotted4 (Expression (Variable "gl_FragColor")) + dottedVariable4 "gl_FragColor" gl_FragCoord : Expression4 gl_FragCoord = - dotted4 (Expression (Variable "gl_FragCoord")) + dottedVariable4 "gl_FragCoord" @@ -1400,29 +1400,86 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body ) +dottedVariable1 : String -> Expression1 t +dottedVariable1 v = + dotted1 (Expression (Variable v)) + + +dottedVariable2 : String -> Expression2 +dottedVariable2 v = + dotted2 (Expression (Variable v)) + + +dottedVariable3 : String -> Expression3 +dottedVariable3 v = + dotted3 (Expression (Variable v)) + + +dottedVariable4 : String -> Expression4 +dottedVariable4 v = + dotted4 (Expression (Variable v)) + + if_ : Expression1 Bool -> Statement q -> (() -> Statement r) -> Statement r if_ cond (Statement ifTrue) next = Statement <| If (unwrapExpression cond) ifTrue (unwrapLazyStatement next) -ifElse : Expression1 Bool -> Statement q -> Statement r -> (() -> Statement s) -> Statement s -ifElse cond (Statement ifTrue) (Statement ifFalse) next = - Statement <| IfElse (unwrapExpression cond) ifTrue ifFalse (unwrapLazyStatement next) +ifElse : Expression1 Bool -> ((() -> Statement s) -> Statement s) -> ((() -> Statement s) -> Statement s) -> (() -> Statement s) -> Statement s +ifElse cond ifTrue ifFalse next = + let + cont _ = + unsafeNop + in + Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue cont) (unwrapStatement <| ifFalse cont) (unwrapLazyStatement next) -for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r +for : + ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + -> (Expression1 Int -> (() -> Statement r) -> Statement r) + -> (() -> Statement r) + -> Statement r for ( var, from, to ) loop next = - Statement <| For var (unwrapExpression from) LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) - - -forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r + Statement <| + For var + (unwrapExpression from) + LessThan + (unwrapExpression to) + (PostfixIncrement (Variable var)) + (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapLazyStatement next) + + +forLeq : + ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + -> (Expression1 Int -> (() -> Statement r) -> Statement r) + -> (() -> Statement r) + -> Statement r forLeq ( var, from, to ) loop next = - Statement <| For var (unwrapExpression from) LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) - - -forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) -> (Expression1 Int -> Statement w) -> (() -> Statement r) -> Statement r + Statement <| + For var + (unwrapExpression from) + LessThanOrEquals + (unwrapExpression to) + (PostfixIncrement (Variable var)) + (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapLazyStatement next) + + +forDown : + ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + -> (Expression1 Int -> (() -> Statement r) -> Statement r) + -> (() -> Statement r) + -> Statement r forDown ( var, from, to ) loop next = - Statement <| For var (unwrapExpression from) GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) ((\(Statement s) -> s) (loop <| dotted1 <| Expression <| Variable var)) (unwrapLazyStatement next) + Statement <| + For var + (unwrapExpression from) + GreaterThan + (unwrapExpression to) + (PostfixDecrement (Variable var)) + (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapLazyStatement next) return : ExpressionX a r -> Statement r @@ -1486,6 +1543,11 @@ unwrapLazyStatement f = next +unwrapStatement : Statement r -> Stat +unwrapStatement (Statement next) = + next + + expr : ExpressionX a t -> (() -> Statement q) -> Statement q expr e next = Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) @@ -1528,37 +1590,37 @@ voidT n = boolT : TypingFunction Bool (Expression1 Bool) boolT n = - ( TypedName (Type "bool") (Name n) (dotted1Internal (Variable n)), dotted1 ) + ( TypedName (Type "bool") (Name n) (dottedVariable1 n), dotted1 ) intT : TypingFunction Int (Expression1 Int) intT n = - ( TypedName (Type "int") (Name n) (dotted1Internal (Variable n)), dotted1 ) + ( TypedName (Type "int") (Name n) (dottedVariable1 n), dotted1 ) floatT : TypingFunction Float (Expression1 Float) floatT n = - ( TypedName (Type "float") (Name n) (dotted1Internal (Variable n)), dotted1 ) + ( TypedName (Type "float") (Name n) (dottedVariable1 n), dotted1 ) vec2T : TypingFunction Vec2 Expression2 vec2T n = - ( TypedName (Type "vec2") (Name n) (dotted2Internal (Variable n)), dotted2 ) + ( TypedName (Type "vec2") (Name n) (dottedVariable2 n), dotted2 ) vec3T : TypingFunction Vec3 Expression3 vec3T n = - ( TypedName (Type "vec3") (Name n) (dotted3Internal (Variable n)), dotted3 ) + ( TypedName (Type "vec3") (Name n) (dottedVariable3 n), dotted3 ) vec4T : TypingFunction Vec4 Expression4 vec4T n = - ( TypedName (Type "vec4") (Name n) (dotted4Internal (Variable n)), dotted4 ) + ( TypedName (Type "vec4") (Name n) (dottedVariable4 n), dotted4 ) mat3T : TypingFunction Mat3 (Expression1 Mat3) mat3T n = - ( TypedName (Type "mat3") (Name n) (dotted1Internal (Variable n)), dotted1 ) + ( TypedName (Type "mat3") (Name n) (dottedVariable1 n), dotted1 ) out : TypingFunction t r -> TypingFunction t r From 340edf9dc9a9062787067de7939699bff54b2cae Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 19:59:09 +0200 Subject: [PATCH 053/139] Removing more unsafe --- src/elm/UI/Glsl/Code.elm | 135 ++++++++++++++++++---------------- src/elm/UI/Glsl/Generator.elm | 35 +++++---- src/elm/UI/Glsl/Sphere.elm | 4 +- 3 files changed, 93 insertions(+), 81 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 2bb2692f..cf59a3ea 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDec import Dict exposing (Dict) import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -239,7 +239,7 @@ isquareCouple = def vec2T "s" (by z z) <| \s -> def floatT "mx" (max_ s.x s.y) <| \mx -> if_ (ands [ leq z.x zero, geq z.y zero ]) - (return <| vec2 zero mx) + (\_ -> return <| vec2 zero mx) <| \_ -> def floatT "mn" (min_ s.x s.y) <| \mn -> return <| vec2 mn mx @@ -397,10 +397,10 @@ ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression ipowICouple = fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e -> if_ (eq e (int 0)) - (return <| vec2 one one) + (\_ -> return <| vec2 one one) <| \_ -> if_ (eq e (int 1)) - (return b) + (\_ -> return b) <| \_ -> def floatT "xe" (ipowFI b.x e) <| \xe -> def floatT "ye" (ipowFI b.y e) <| \ye -> @@ -476,7 +476,7 @@ gpowCouple = fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| \b e -> def intT "ie" (intCast e.x) <| \ie -> if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) - (return <| gpowI b ie) + (\_ -> return <| gpowI b ie) <| \_ -> return <| gexp <| gby (gln b) e @@ -822,7 +822,7 @@ catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) catanTuple = fun1 vec2T "catan" (vec2T "z") <| \z -> if_ (eq z.y zero) - (return <| vec2 (atan_ z.x) zero) + (\_ -> return <| vec2 (atan_ z.x) zero) <| \_ -> def vec2T "o" (vec2 one zero) <| \o -> def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> @@ -978,7 +978,7 @@ straightFunctionToGlsl name = [ Tuple.first <| fun1 floatT "tanh" (floatT "x") <| \x -> if_ (gt (abs_ x) (float 10)) - (return <| sign x) + (\_ -> return <| sign x) <| \_ -> def floatT "p" (exp x) <| \p -> def floatT "m" (exp <| negate_ x) <| \m -> @@ -1272,17 +1272,18 @@ cmbrotCouple = def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| \c -> def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| \p -> if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) - (return vec2Zero) + (\_ -> return vec2Zero) <| \_ -> def vec2T "z" c <| \z -> for ( "i", int 0, int 4000 ) (\i cont -> expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> if_ (gt (length z) (float 1000000)) - (def floatT "logLength" (log (length z)) <| \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return <| vec2 (sin_ fi) (cos_ fi) + (\_ -> + def floatT "logLength" (log (length z)) <| \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| \fi -> + return <| vec2 (sin_ fi) (cos_ fi) ) <| cont @@ -1305,7 +1306,7 @@ csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csqrtTuple = fun1 vec2T "csqrt" (vec2T "z") <| \z -> if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (sqrt_ z.x) zero) + (\_ -> return <| vec2 (sqrt_ z.x) zero) <| \_ -> def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> @@ -1326,7 +1327,7 @@ ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccbrtCouple = fun1 vec2T "ccbrt" (vec2T "z") <| \z -> if_ (eq z.y zero) - (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) + (\_ -> return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) <| \_ -> def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> def floatT @@ -1370,9 +1371,8 @@ csquare = clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) clnTuple = fun1 vec2T "cln" (vec2T "z") <| \z -> - if_ - (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (log z.x) zero) + if_ (ands [ eq z.y zero, geq z.x zero ]) + (\_ -> return <| vec2 (log z.x) zero) <| \_ -> def floatT "px" (length z) <| \px -> def floatT "py" (atan2_ z.y z.x) <| \py -> @@ -1767,9 +1767,8 @@ toSrcImplicit suffix e = (add y <| by (by deltaX coeff) <| floatCast h) ) <| \piece -> - if_ - (eq piece zero) - (return vec3Zero) + if_ (eq piece zero) + (\_ -> return vec3Zero) <| \_ -> assignAdd sum piece cont ) @@ -1796,9 +1795,7 @@ toSrcPolar suffix e = def floatT "t" (add (atanPlus y x) deltaT) <| \t -> -- Avoid the branch cut at {x > 0, y = 0} if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi)) <| \_ -> - unsafeNop - ) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi))) <| \_ -> def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> return <| @@ -1822,10 +1819,10 @@ toSrcPolar suffix e = def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - unsafeBreak + (\_ -> unsafeBreak) <| \_ -> if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) + (\_ -> return <| vec3 one one one) <| \_ -> assignAdd t constants.twopi <| \_ -> assignAdd ot constants.twopi cont @@ -1890,6 +1887,15 @@ toSrcParametric suffix e = <| \_ -> return vec3Zero + innerLoop : + Expression1 Float + -> Expression1 Float + -> Expression2 + -> Expression1 Int + -> Expression1 Int + -> Expression1 Float + -> Continue Vec3 + -> Statement Vec3 innerLoop from to p depth choices ithreshold cont = def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> def vec2T "front" (interval p from midpoint) <| \front -> @@ -1909,7 +1915,7 @@ toSrcParametric suffix e = ] ] ) - (return <| vec3 one one one) + (\_ -> return <| vec3 one one one) <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) @@ -1929,7 +1935,7 @@ toSrcParametric suffix e = forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) (\j _ -> if_ (gt j depth) - unsafeContinue + (\_ -> unsafeContinue) <| \_ -> expr (postfixDecrement depth) <| \_ -> expr (assign choices (div choices (int 2))) <| \_ -> @@ -1939,10 +1945,11 @@ toSrcParametric suffix e = expr (assign to (add to (subtract to from))) <| \_ -> expr (assign back (interval p midpoint to)) <| \_ -> if_ (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - unsafeBreak + (\_ -> + expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> + unsafeBreak ) cont ) @@ -1951,7 +1958,7 @@ toSrcParametric suffix e = ) <| \_ -> if_ (eq depth (int 0)) - (return vec3Zero) + (\_ -> return vec3Zero) cont ) ) @@ -1979,7 +1986,7 @@ thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) thetaDeltaCouple = fun1 floatT "thetaDelta" (floatT "theta") <| \theta -> if_ (lt uniforms.u_whiteLines one) - (return <| float 100) + (\_ -> return <| float 100) <| \_ -> def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> @@ -2064,22 +2071,22 @@ toSrcVectorField2D suffix xexpr yexpr = def vec2T "corner" (vec2 x y) <| \corner -> def floatT "l" (div (length bl) mx) <| \l -> if_ (near o corner bl deltaX mx) - (return <| mix colorA colorB l) + (\_ -> return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| \_ -> expr (assign l (div (length br) mx)) <| \_ -> if_ (near o corner br deltaX mx) - (return <| mix colorA colorB l) + (\_ -> return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| \_ -> expr (assign l (div (length ul) mx)) <| \_ -> if_ (near o corner ul deltaX mx) - (return <| mix colorA colorB l) + (\_ -> return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| \_ -> expr (assign l (div (length ur) mx)) <| \_ -> if_ (near o corner ur deltaX mx) - (return <| mix colorA colorB l) + (\_ -> return <| mix colorA colorB l) <| \_ -> return vec3Zero in @@ -2097,11 +2104,12 @@ toSrcContour suffix expr = def floatT "powerRemainder" (fract logRadius) <| \powerRemainder -> def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| \squished -> if_ (gt uniforms.u_completelyReal zero) - (def floatT "haf" (div powerRemainder <| float 6.0) <| \haf -> - return <| - ternary (gt z.x zero) - (hl2rgb (add haf <| float 0.3) squished) - (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + (\_ -> + def floatT "haf" (div powerRemainder <| float 6.0) <| \haf -> + return <| + ternary (gt z.x zero) + (hl2rgb (add haf <| float 0.3) squished) + (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) ) <| \_ -> def floatT "td" (thetaDelta theta) <| \td -> @@ -2125,7 +2133,7 @@ toSrcContour suffix expr = def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| \mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) - (return <| divF (adds3 [ a, b, c, d ]) (float 4)) + (\_ -> return <| divF (adds3 [ a, b, c, d ]) (float 4)) <| \_ -> assignBy deltaXr (float 2) <| \_ -> assignBy deltaYr (float 2) <| \_ -> @@ -2570,8 +2578,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel2) <| \_ -> - unsafeNop + expr (assign gl_FragColor pixel2) nop ] ( [], _ ) -> @@ -2584,8 +2591,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel3) <| \_ -> - unsafeNop + expr (assign gl_FragColor pixel3) nop ] _ -> @@ -2602,8 +2608,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor (max4 pixel2 pixel3)) <| \_ -> - unsafeNop + expr (assign gl_FragColor (max4 pixel2 pixel3)) nop ] @@ -2692,11 +2697,11 @@ axisTuple = fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta -> def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| \across -> if_ (lt across (float -12)) - (return zero) + (\_ -> return zero) <| \_ -> def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) + (\_ -> return zero) <| \_ -> def floatT "unit" @@ -2842,17 +2847,17 @@ raytrace bisects = bisectToRay i bisect next = if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (expr (assign foundIndex <| int i) <| \_ -> - expr (assign found f) <| \_ -> - expr (assign currDistance <| length <| subtract found o) <| \_ -> - unsafeNop + (\cont -> + expr (assign foundIndex <| int i) <| \_ -> + expr (assign found f) <| \_ -> + expr (assign currDistance <| length <| subtract found o) cont ) <| \_ -> next in innerTrace <| if_ (lt foundIndex <| int 0) - (return <| vec4 zero zero zero one) + (\_ -> return <| vec4 zero zero zero one) <| \_ -> def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> @@ -2881,8 +2886,9 @@ suffixToBisect interval suffix = (ors [ geq depth constants.maxDepth, ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ], ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] ] ) - (expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> - return <| bool True + (\_ -> + expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> + return <| bool True ) <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) @@ -2907,7 +2913,7 @@ suffixToBisect interval suffix = forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) (\j _ -> if_ (gt j depth) - unsafeContinue + (\_ -> unsafeContinue) <| \_ -> expr (postfixDecrement depth) <| \_ -> expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> @@ -2917,10 +2923,11 @@ suffixToBisect interval suffix = expr (assign to <| add to (subtract to from)) <| \_ -> def vec2T "back" (interval midpoint to) <| \back -> if_ (ands [ leq back.x zero, geq back.y zero ]) - (expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> - unsafeBreak + (\_ -> + expr (assign from midpoint) <| \_ -> + expr (postfixIncrement depth) <| \_ -> + expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> + unsafeBreak ) cont ) @@ -2929,7 +2936,7 @@ suffixToBisect interval suffix = ) <| \_ -> if_ (eq depth (int 0)) - (return false) + (\_ -> return false) cont in fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index d9a63911..73fee884 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -256,8 +256,13 @@ relationToString rel = ">" -unsafeNop : Statement a -unsafeNop = +nop : Continue () +nop () = + Statement Nop + + +unsafeNop : Continue a +unsafeNop () = Statement Nop @@ -1420,18 +1425,18 @@ dottedVariable4 v = dotted4 (Expression (Variable v)) -if_ : Expression1 Bool -> Statement q -> (() -> Statement r) -> Statement r -if_ cond (Statement ifTrue) next = - Statement <| If (unwrapExpression cond) ifTrue (unwrapLazyStatement next) +type alias Continue s = + () -> Statement s + + +if_ : Expression1 Bool -> (Continue r -> Statement r) -> Continue r -> Statement r +if_ cond ifTrue next = + Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue unsafeNop) (unwrapLazyStatement next) ifElse : Expression1 Bool -> ((() -> Statement s) -> Statement s) -> ((() -> Statement s) -> Statement s) -> (() -> Statement s) -> Statement s ifElse cond ifTrue ifFalse next = - let - cont _ = - unsafeNop - in - Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue cont) (unwrapStatement <| ifFalse cont) (unwrapLazyStatement next) + Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue unsafeNop) (unwrapStatement <| ifFalse unsafeNop) (unwrapLazyStatement next) for : @@ -1446,7 +1451,7 @@ for ( var, from, to ) loop next = LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) (unwrapLazyStatement next) @@ -1462,7 +1467,7 @@ forLeq ( var, from, to ) loop next = LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) (unwrapLazyStatement next) @@ -1478,7 +1483,7 @@ forDown ( var, from, to ) loop next = GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) (\_ -> unsafeNop)) + (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) (unwrapLazyStatement next) @@ -1496,7 +1501,7 @@ unsafeBreak = Statement Break -unsafeContinue : Statement () +unsafeContinue : Statement a unsafeContinue = let _ = diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index c840bf7b..36f0c06a 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -82,11 +82,11 @@ toGlsl suffix (Sphere { center, radius }) = def floatT "c" (subtract (dot to_center to_center) (float <| radius * radius)) <| \c -> def floatT "delta" (subtract (by b b) c) <| \delta -> if_ (lt delta zero) - (return <| bool False) + (\_ -> return <| bool False) <| \_ -> def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| \x -> if_ (lt x <| threshold maxDistance) - (return false) + (\_ -> return false) <| \_ -> expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> return true From 01060f91657d9c3e83100a29bd9e9c498ffd58f7 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 20:02:32 +0200 Subject: [PATCH 054/139] Break and continue now safe --- glslParser/src/GlslConverter.elm | 2 +- src/elm/UI/Glsl/Code.elm | 14 +++++++------- src/elm/UI/Glsl/Generator.elm | 32 ++++++++++++-------------------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm index 52e45115..2e483f3e 100644 --- a/glslParser/src/GlslConverter.elm +++ b/glslParser/src/GlslConverter.elm @@ -828,7 +828,7 @@ prettyPrintStatement stat = "(return <| " ++ prettyPrintExpression e ++ ")\n" Nop -> - "unsafeNop\n" + "nop\n" Def t n v next -> "def " diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index cf59a3ea..378003d3 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,8 +1,8 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import Dict exposing (Dict) -import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), functionNameToString, toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) +import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -1819,7 +1819,7 @@ toSrcPolar suffix e = def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - (\_ -> unsafeBreak) + break <| \_ -> if_ (ors [ neq h l, neq h u, neq h ul ]) (\_ -> return <| vec3 one one one) @@ -1935,7 +1935,7 @@ toSrcParametric suffix e = forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) (\j _ -> if_ (gt j depth) - (\_ -> unsafeContinue) + continue <| \_ -> expr (postfixDecrement depth) <| \_ -> expr (assign choices (div choices (int 2))) <| \_ -> @@ -1949,7 +1949,7 @@ toSrcParametric suffix e = expr (assign from midpoint) <| \_ -> expr (postfixIncrement depth) <| \_ -> expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - unsafeBreak + break cont ) cont ) @@ -2913,7 +2913,7 @@ suffixToBisect interval suffix = forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) (\j _ -> if_ (gt j depth) - (\_ -> unsafeContinue) + continue <| \_ -> expr (postfixDecrement depth) <| \_ -> expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> @@ -2927,7 +2927,7 @@ suffixToBisect interval suffix = expr (assign from midpoint) <| \_ -> expr (postfixIncrement depth) <| \_ -> expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> - unsafeBreak + break cont ) cont ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 73fee884..324338a6 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, by, by2, by3, byF, ceil_, constant, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeBreak, unsafeCall, unsafeContinue, unsafeNop, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -261,8 +261,8 @@ nop () = Statement Nop -unsafeNop : Continue a -unsafeNop () = +internalNop : Continue a +internalNop () = Statement Nop @@ -1431,12 +1431,12 @@ type alias Continue s = if_ : Expression1 Bool -> (Continue r -> Statement r) -> Continue r -> Statement r if_ cond ifTrue next = - Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue unsafeNop) (unwrapLazyStatement next) + Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) ifElse : Expression1 Bool -> ((() -> Statement s) -> Statement s) -> ((() -> Statement s) -> Statement s) -> (() -> Statement s) -> Statement s ifElse cond ifTrue ifFalse next = - Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue unsafeNop) (unwrapStatement <| ifFalse unsafeNop) (unwrapLazyStatement next) + Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) for : @@ -1451,7 +1451,7 @@ for ( var, from, to ) loop next = LessThan (unwrapExpression to) (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) + (unwrapStatement <| loop (dottedVariable1 var) internalNop) (unwrapLazyStatement next) @@ -1467,7 +1467,7 @@ forLeq ( var, from, to ) loop next = LessThanOrEquals (unwrapExpression to) (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) + (unwrapStatement <| loop (dottedVariable1 var) internalNop) (unwrapLazyStatement next) @@ -1483,7 +1483,7 @@ forDown ( var, from, to ) loop next = GreaterThan (unwrapExpression to) (PostfixDecrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) unsafeNop) + (unwrapStatement <| loop (dottedVariable1 var) internalNop) (unwrapLazyStatement next) @@ -1492,21 +1492,13 @@ return e = Statement <| Return <| unwrapExpression e -unsafeBreak : Statement a -unsafeBreak = - let - _ = - Debug.todo - in +break : Continue a -> Statement a +break _ = Statement Break -unsafeContinue : Statement a -unsafeContinue = - let - _ = - Debug.todo - in +continue : Continue a -> Statement a +continue _ = Statement Continue From 5c3148cfe316ea93725f993316d2daa1dfea522d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 13 Sep 2021 23:09:03 +0200 Subject: [PATCH 055/139] Less unsafe ops --- src/elm/UI/Glsl/Code.elm | 376 ++++++++++++++++++--------------- src/elm/UI/Glsl/Generator.elm | 52 ++--- src/elm/UI/Glsl/Plane.elm | 4 +- src/elm/UI/Glsl/Polynomial.elm | 4 +- src/elm/UI/Glsl/Sphere.elm | 8 +- 5 files changed, 244 insertions(+), 200 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 378003d3..1dcbee7e 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDec import Dict exposing (Dict) import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -120,11 +120,11 @@ cby3Decl = cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cdivTuple = - fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b -> + fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b nop -> def floatT "k" (div one <| dot b b) <| \k -> def floatT "r" (by k <| dot a b) <| \r -> def floatT "i" (by k (subtract (by a.y b.x) (by a.x b.y))) <| \i -> - return <| vec2 r i + return (vec2 r i) nop cdivDecl : FunDecl @@ -235,14 +235,14 @@ gneg = isquareCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) isquareCouple = - fun1 vec2T "isquare" (vec2T "z") <| \z -> + fun1 vec2T "isquare" (vec2T "z") <| \z nop -> def vec2T "s" (by z z) <| \s -> def floatT "mx" (max_ s.x s.y) <| \mx -> if_ (ands [ leq z.x zero, geq z.y zero ]) - (\_ -> return <| vec2 zero mx) + (return <| vec2 zero mx) <| \_ -> def floatT "mn" (min_ s.x s.y) <| \mn -> - return <| vec2 mn mx + return (vec2 mn mx) nop isquareDecl : FunDecl @@ -257,7 +257,8 @@ isquare = gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gsquareCouple = - fun1 vec4T "gsquare" (vec4T "z") <| \z -> return <| vec4_1_3 (by z.x z.x) z.yzw + fun1 vec4T "gsquare" (vec4T "z") <| \z -> + return <| vec4_1_3 (by z.x z.x) z.yzw gsquareDecl : FunDecl @@ -272,7 +273,8 @@ gsquare = gbyCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gbyCouple = - fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) + fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> + return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) gbyDecl : FunDecl @@ -287,14 +289,14 @@ gby = ibyCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ibyCouple = - fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| \l r -> + fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| \l r nop -> def floatT "a" (by l.x r.x) <| \a -> def floatT "b" (by l.x r.y) <| \b -> def floatT "c" (by l.y r.x) <| \c -> def floatT "d" (by l.y r.y) <| \d -> def floatT "mn" (min_ (min_ a b) (min_ c d)) <| \mn -> def floatT "mx" (max_ (max_ a b) (max_ c d)) <| \mx -> - return <| vec2 mn mx + return (vec2 mn mx) nop ibyDecl : FunDecl @@ -374,13 +376,15 @@ gdiv = ipowFICouple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ) ipowFICouple = - fun2 floatT "ipow" (floatT "b") (intT "e") <| \b e -> + fun2 floatT "ipow" (floatT "b") (intT "e") <| \b e nop -> def floatT "fe" (floatCast e) <| \fe -> - return <| - ternary + return + (ternary (eq (mod fe (float 2.0)) zero) (pow (abs_ b) fe) (by b <| pow (abs_ b) (subtract fe one)) + ) + nop ipowFIDecl : FunDecl @@ -395,19 +399,19 @@ ipowFI = ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) ipowICouple = - fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e -> + fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e nop -> if_ (eq e (int 0)) - (\_ -> return <| vec2 one one) + (return <| vec2 one one) <| \_ -> if_ (eq e (int 1)) - (\_ -> return b) + (return b) <| \_ -> def floatT "xe" (ipowFI b.x e) <| \xe -> def floatT "ye" (ipowFI b.y e) <| \ye -> def floatT "mn" (min_ xe ye) <| \mn -> def floatT "mx" (max_ xe ye) <| \mx -> - return <| - ternary + return + (ternary (ands [ eq (mod (floatCast e) (float 2)) zero , leq b.x zero @@ -416,6 +420,8 @@ ipowICouple = ) (vec2 (min_ zero mn) (max_ zero mx)) (vec2 mn mx) + ) + nop ipowIDecl : FunDecl @@ -473,12 +479,12 @@ gpowI = gpowCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gpowCouple = - fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| \b e -> + fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| \b e nop -> def intT "ie" (intCast e.x) <| \ie -> if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) - (\_ -> return <| gpowI b ie) + (return <| gpowI b ie) <| \_ -> - return <| gexp <| gby (gln b) e + return (gexp <| gby (gln b) e) nop gpowDecl : FunDecl @@ -607,10 +613,10 @@ iabs = iacosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iacosCouple = - fun1 vec2T "iacos" (vec2T "z") <| \z -> + fun1 vec2T "iacos" (vec2T "z") <| \z nop -> -- Don't use clamp so if z is fully outside range the result is empty def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| \clamped -> - return <| (acos2 clamped).yx + return (acos2 clamped).yx nop iacosDecl : FunDecl @@ -719,16 +725,18 @@ gln = csinCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csinCouple = - fun1 vec2T "csin" (vec2T "z") <| \z -> + fun1 vec2T "csin" (vec2T "z") <| \z nop -> def floatT "s" (sin_ z.x) <| \s -> - return <| - ternary + return + (ternary (eq z.y zero) (vec2 s zero) (vec2 (by s (cosh z.y)) (by (cos_ z.x) (sinh z.y)) ) + ) + nop csinDecl : FunDecl @@ -743,16 +751,18 @@ csin = ccosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccosCouple = - fun1 vec2T "ccos" (vec2T "z") <| \z -> + fun1 vec2T "ccos" (vec2T "z") <| \z nop -> def floatT "c" (cos_ z.x) <| \c -> - return <| - ternary + return + (ternary (eq z.y zero) (vec2 c zero) (vec2 (by c (cosh z.y)) (by (sin_ z.x) (sinh z.y)) ) + ) + nop ccosDecl : FunDecl @@ -786,10 +796,10 @@ ctan = casinTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) casinTuple = - fun1 vec2T "casin" (vec2T "z") <| \z -> + fun1 vec2T "casin" (vec2T "z") <| \z nop -> def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| \s -> def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| \arg_ -> - return <| cby (vec2 zero one) (cln arg_) + return (cby (vec2 zero one) (cln arg_)) nop casinDecl : FunDecl @@ -820,14 +830,14 @@ cacos = catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) catanTuple = - fun1 vec2T "catan" (vec2T "z") <| \z -> + fun1 vec2T "catan" (vec2T "z") <| \z nop -> if_ (eq z.y zero) - (\_ -> return <| vec2 (atan_ z.x) zero) + (return <| vec2 (atan_ z.x) zero) <| \_ -> def vec2T "o" (vec2 one zero) <| \o -> def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> - return <| byF (float -0.5) <| cby (vec2 zero one) (cln l) + return (byF (float -0.5) <| cby (vec2 zero one) (cln l)) nop catanDecl : FunDecl @@ -842,9 +852,9 @@ catan = catan2Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) catan2Tuple = - fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| \y x -> + fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| \y x nop -> def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| \z -> - return <| vec2 (atan2_ z.y z.x) zero + return (vec2 (atan2_ z.y z.x) zero) nop catan2Decl : FunDecl @@ -891,10 +901,10 @@ ccosh = ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanhCouple = - fun1 vec2T "ctanh" (vec2T "z") <| \z -> + fun1 vec2T "ctanh" (vec2T "z") <| \z nop -> def vec2T "p" (cexp z) <| \p -> def vec2T "m" (cexp (negate_ z)) <| \m -> - return <| cdiv (subtract p m) (add p m) + return (cdiv (subtract p m) (add p m)) nop ctanhDecl : FunDecl @@ -976,13 +986,13 @@ straightFunctionToGlsl name = Tanh11 -> [ Tuple.first <| - fun1 floatT "tanh" (floatT "x") <| \x -> + fun1 floatT "tanh" (floatT "x") <| \x nop -> if_ (gt (abs_ x) (float 10)) - (\_ -> return <| sign x) + (return <| sign x) <| \_ -> def floatT "p" (exp x) <| \p -> def floatT "m" (exp <| negate_ x) <| \m -> - return <| div (subtract p m) (add p m) + return (div (subtract p m) (add p m)) nop ] Sin22 -> @@ -1078,7 +1088,7 @@ cexpTuple = fun1 vec2T "cexp" (vec2T "z") cexpFunction -cexpFunction : Expression2 -> Statement Vec2 +cexpFunction : Expression2 -> Continue () -> Statement Vec2 cexpFunction z = return <| byF (exp z.x) <| @@ -1268,11 +1278,11 @@ cmod = cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmbrotCouple = - fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| \x y -> + fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| \x y nop -> def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| \c -> def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| \p -> if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) - (\_ -> return vec2Zero) + (return vec2Zero) <| \_ -> def vec2T "z" c <| \z -> for ( "i", int 0, int 4000 ) @@ -1283,13 +1293,13 @@ cmbrotCouple = def floatT "logLength" (log (length z)) <| \logLength -> def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return <| vec2 (sin_ fi) (cos_ fi) + return (vec2 (sin_ fi) (cos_ fi)) nop ) <| cont ) <| \_ -> - return vec2Zero + return vec2Zero nop cmbrotDecl : FunDecl @@ -1304,13 +1314,13 @@ cmbrot = csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csqrtTuple = - fun1 vec2T "csqrt" (vec2T "z") <| \z -> + fun1 vec2T "csqrt" (vec2T "z") <| \z nop -> if_ (ands [ eq z.y zero, geq z.x zero ]) - (\_ -> return <| vec2 (sqrt_ z.x) zero) + (return <| vec2 (sqrt_ z.x) zero) <| \_ -> def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> - return <| byF r <| vec2 (cos_ t) (sin_ t) + return (byF r <| vec2 (cos_ t) (sin_ t)) nop csqrtDecl : FunDecl @@ -1325,9 +1335,9 @@ csqrt = ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccbrtCouple = - fun1 vec2T "ccbrt" (vec2T "z") <| \z -> + fun1 vec2T "ccbrt" (vec2T "z") <| \z nop -> if_ (eq z.y zero) - (\_ -> return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) + (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) <| \_ -> def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> def floatT @@ -1340,7 +1350,7 @@ ccbrtCouple = ) ) <| \t -> - return <| byF r (vec2 (cos_ t) (sin_ t)) + return (byF r (vec2 (cos_ t) (sin_ t))) nop ccbrtDecl : FunDecl @@ -1370,13 +1380,13 @@ csquare = clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) clnTuple = - fun1 vec2T "cln" (vec2T "z") <| \z -> + fun1 vec2T "cln" (vec2T "z") <| \z nop -> if_ (ands [ eq z.y zero, geq z.x zero ]) - (\_ -> return <| vec2 (log z.x) zero) + (return <| vec2 (log z.x) zero) <| \_ -> def floatT "px" (length z) <| \px -> def floatT "py" (atan2_ z.y z.x) <| \py -> - return <| vec2 (log px) py + return (vec2 (log px) py) nop clnDecl : FunDecl @@ -1743,21 +1753,23 @@ toSrcImplicit suffix e = 7 ( fDecl, f ) = - fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| \x y -> + fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| \x y nop -> def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> - return <| - ternary (gt (abs_ complex.y) (float epsilon)) + return + (ternary (gt (abs_ complex.y) (float epsilon)) zero (ternary (gt complex.x zero) one minusOne) + ) + nop ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y cont -> def floatT "sum" zero <| \sum -> def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| \samples -> assignBy samples samples <| \_ -> def floatT "coeff" (float 0.0875) <| \coeff -> forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w cont -> + (\w cont2 -> forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) (\h _ -> def floatT @@ -1768,17 +1780,16 @@ toSrcImplicit suffix e = ) <| \piece -> if_ (eq piece zero) - (\_ -> return vec3Zero) + (return vec3Zero) <| \_ -> - assignAdd sum piece cont + assignAdd sum piece cont2 ) - <| - cont + cont2 ) <| \_ -> def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> expr (assign perc (pow perc <| float 0.2)) <| \_ -> - return <| byF perc (vec3 one one one) + return (byF perc (vec3 one one one)) cont in ( [ fDecl, pixelDecl ], pixel ) @@ -1790,7 +1801,7 @@ toSrcPolar : toSrcPolar suffix e = let ( fDecl, f ) = - fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| \x y deltaT ot -> + fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| \x y deltaT ot cont -> def floatT "r" (length <| vec2 x y) <| \r -> def floatT "t" (add (atanPlus y x) deltaT) <| \t -> -- Avoid the branch cut at {x > 0, y = 0} @@ -1798,22 +1809,24 @@ toSrcPolar suffix e = (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi))) <| \_ -> def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> - return <| - ternary (gt (abs_ complex.y) (float epsilon)) + return + (ternary (gt (abs_ complex.y) (float epsilon)) minusOne (ternary (gt complex.x zero) one zero ) + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> assignAdd x (div deltaX <| float 2) <| \_ -> assignAdd y (div deltaY <| float 2) <| \_ -> def floatT "t" zero <| \t -> def floatT "ot" (atanPlus y x) <| \ot -> for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ cont -> + (\_ cont2 -> def floatT "h" (f x y t ot) <| \h -> def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> @@ -1822,13 +1835,13 @@ toSrcPolar suffix e = break <| \_ -> if_ (ors [ neq h l, neq h u, neq h ul ]) - (\_ -> return <| vec3 one one one) + (return <| vec3 one one one) <| \_ -> assignAdd t constants.twopi <| \_ -> - assignAdd ot constants.twopi cont + assignAdd ot constants.twopi cont2 ) <| \_ -> - return vec3Zero + return vec3Zero cont in ( [ fDecl, pixelDecl ], pixel ) @@ -1859,12 +1872,12 @@ toSrcParametric : String -> Expression.Expression -> ( List FunDecl, ExpressionX toSrcParametric suffix e = let ( intervalDecl, interval ) = - fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to -> + fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to cont -> def vec2T "x" (vec2 p.x p.x) <| \x -> def vec2T "y" (vec2 p.y p.y) <| \y -> def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| \t -> - return <| - expressionToIntervalGlsl + return + (expressionToIntervalGlsl (Dict.fromList [ ( "x", x ) , ( "y", y ) @@ -1872,9 +1885,11 @@ toSrcParametric suffix e = ] ) (toPrintExpression e) + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> def floatT "max_distance" (float <| 2 ^ 10) <| \max_distance -> def floatT "from" (div (negate_ max_distance) (float 2)) <| \from -> def floatT "to" (div max_distance (float 2)) <| \to -> @@ -1883,9 +1898,9 @@ toSrcParametric suffix e = def intT "choices" (int 0) <| \choices -> def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| \ithreshold -> for ( "it", int 0, constants.maxIterations ) - (\_ -> innerLoop from to p depth choices ithreshold) + (innerLoop from to p depth choices ithreshold) <| \_ -> - return vec3Zero + return vec3Zero cont innerLoop : Expression1 Float @@ -1894,9 +1909,10 @@ toSrcParametric suffix e = -> Expression1 Int -> Expression1 Int -> Expression1 Float + -> Expression1 Int -> Continue Vec3 -> Statement Vec3 - innerLoop from to p depth choices ithreshold cont = + innerLoop from to p depth choices ithreshold _ cont = def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> def vec2T "front" (interval p from midpoint) <| \front -> def vec2T "back" (interval p midpoint to) <| \back -> @@ -1915,7 +1931,7 @@ toSrcParametric suffix e = ] ] ) - (\_ -> return <| vec3 one one one) + (return <| vec3 one one one) <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) @@ -1958,7 +1974,7 @@ toSrcParametric suffix e = ) <| \_ -> if_ (eq depth (int 0)) - (\_ -> return vec3Zero) + (return vec3Zero) cont ) ) @@ -1984,13 +2000,13 @@ uniforms = thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) thetaDeltaCouple = - fun1 floatT "thetaDelta" (floatT "theta") <| \theta -> + fun1 floatT "thetaDelta" (floatT "theta") <| \theta cont -> if_ (lt uniforms.u_whiteLines one) - (\_ -> return <| float 100) + (return <| float 100) <| \_ -> def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> - return <| divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh + return (divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh) cont thetaDeltaDecl : FunDecl @@ -2011,13 +2027,13 @@ toSrcVectorField2D : toSrcVectorField2D suffix xexpr yexpr = let ( vectorDecl, vector ) = - fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y -> + fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y cont -> def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| \xv -> def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| \yv -> - return <| ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero + return (ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero) cont ( nearDecl, near ) = - fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx -> + fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx cont -> def floatT "angleCorner" (arg <| subtract o corner) <| \angleCorner -> def floatT "angleVector" (arg vect) <| \angleVector -> def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| \delta -> @@ -2034,15 +2050,24 @@ toSrcVectorField2D suffix xexpr yexpr = <| \maxLength -> def floatT "wantedLength" (length (subtract o corner)) <| \wantedLength -> def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| \angularDistance -> - return <| and (or (lt delta (radians_ angularDistance)) (gt delta (radians_ (subtract (float 360) angularDistance)))) (lt wantedLength maxLength) + return + (ands + [ ors + [ lt delta (radians_ angularDistance) + , gt delta (radians_ (subtract (float 360) angularDistance)) + ] + , lt wantedLength maxLength + ] + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> def vec2T "o" (vec2 x y) <| \o -> def floatT "mx" zero <| \mx -> def floatT "k" (by deltaX constants.vectorSpacing) <| \k -> forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) - (\xi cont -> + (\xi cont2 -> forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) (\yi _ -> def vec2T @@ -2055,9 +2080,9 @@ toSrcVectorField2D suffix xexpr yexpr = ) <| \p -> def vec2T "v" (vector p.x p.y) <| \v -> - expr (assign mx (max_ mx (length v))) cont + expr (assign mx (max_ mx (length v))) cont2 ) - cont + cont2 ) <| \_ -> def vec3T "colorA" (vec3 zero one zero) <| \colorA -> @@ -2071,24 +2096,24 @@ toSrcVectorField2D suffix xexpr yexpr = def vec2T "corner" (vec2 x y) <| \corner -> def floatT "l" (div (length bl) mx) <| \l -> if_ (near o corner bl deltaX mx) - (\_ -> return <| mix colorA colorB l) + (return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| \_ -> expr (assign l (div (length br) mx)) <| \_ -> if_ (near o corner br deltaX mx) - (\_ -> return <| mix colorA colorB l) + (return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| \_ -> expr (assign l (div (length ul) mx)) <| \_ -> if_ (near o corner ul deltaX mx) - (\_ -> return <| mix colorA colorB l) + (return <| mix colorA colorB l) <| \_ -> expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| \_ -> expr (assign l (div (length ur) mx)) <| \_ -> if_ (near o corner ur deltaX mx) - (\_ -> return <| mix colorA colorB l) + (return <| mix colorA colorB l) <| \_ -> - return vec3Zero + return vec3Zero cont in ( [ vectorDecl, nearDecl, pixelDecl ], pixel ) @@ -2097,7 +2122,7 @@ toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa toSrcContour suffix expr = let ( pixelODecl, pixelO ) = - fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> + fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y cont -> def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| \theta -> def floatT "logRadius" (log2 <| length z) <| \logRadius -> @@ -2106,22 +2131,24 @@ toSrcContour suffix expr = if_ (gt uniforms.u_completelyReal zero) (\_ -> def floatT "haf" (div powerRemainder <| float 6.0) <| \haf -> - return <| - ternary (gt z.x zero) + return + (ternary (gt z.x zero) (hl2rgb (add haf <| float 0.3) squished) (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + ) + cont ) <| \_ -> def floatT "td" (thetaDelta theta) <| \td -> def floatT "l" (mix one squished <| smoothstep zero one td) <| \l -> - return <| hl2rgb theta l + return (hl2rgb theta l) cont ( pixelDecl, pixel ) = let dist = 1 / 3 in - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> def floatT "deltaXr" (by deltaX <| float dist) <| \deltaXr -> def floatT "deltaYr" (by deltaY <| float dist) <| \deltaYr -> -- Antialiasing @@ -2133,7 +2160,7 @@ toSrcContour suffix expr = def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| \mx -> def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) - (\_ -> return <| divF (adds3 [ a, b, c, d ]) (float 4)) + (return <| divF (adds3 [ a, b, c, d ]) (float 4)) <| \_ -> assignBy deltaXr (float 2) <| \_ -> assignBy deltaYr (float 2) <| \_ -> @@ -2141,7 +2168,7 @@ toSrcContour suffix expr = def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> - return <| divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8) + return (divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8)) cont in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2149,10 +2176,10 @@ toSrcContour suffix expr = toSrcRelation : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcRelation suffix e = Tuple.mapFirst (\d -> [ d ]) <| - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y -> + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y cont -> def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> - return <| - ternary + return + (ternary (ands [ gt complex.x zero , lt (abs_ complex.y) (float epsilon) @@ -2160,6 +2187,8 @@ toSrcRelation suffix e = ) (vec3 (float 0.8) (float 0.5) (float 0.5)) vec3Zero + ) + cont epsilon : Float @@ -2578,7 +2607,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = pixel2Decl ++ [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel2) nop + expr (assign gl_FragColor pixel2) ] ( [], _ ) -> @@ -2591,7 +2620,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor pixel3) nop + expr (assign gl_FragColor pixel3) ] _ -> @@ -2608,7 +2637,7 @@ mainGlsl rayDifferentials pixel2Def pixel3Def = ++ fileToGlsl [ Tuple.first <| fun0 voidT "main" <| - expr (assign gl_FragColor (max4 pixel2 pixel3)) nop + expr (assign gl_FragColor (max4 pixel2 pixel3)) ] @@ -2642,23 +2671,23 @@ pixel2Tuple pixels = inner deltaX deltaY x y px curr cont = List.foldl (\( i, p ) -> addPixel deltaX deltaY x y px curr i p) cont (List.indexedMap Tuple.pair pixels) in - fun0 vec4T "pixel2" <| - def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> - def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| \uv_centered -> - def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| \viewportSize -> - def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| \uv -> - def vec2T "c" (add uniforms.u_zoomCenter uv) <| \c -> - def floatT "x" c.x <| \x -> - def floatT "y" c.y <| \y -> - def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| \deltaX -> - def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| \deltaY -> - def vec3T "px" vec3Zero <| \px -> - decl vec3T "curr" <| \curr -> - inner deltaX deltaY x y px curr <| - def floatT "maxDelta" (max_ deltaX deltaY) <| \maxDelta -> - def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| \yax -> - def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| \xax -> - return <| vec4_3_1 (max3 px (max3 xax yax)) one + fun0 vec4T "pixel2" <| \cont -> + def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> + def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| \uv_centered -> + def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| \viewportSize -> + def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| \uv -> + def vec2T "c" (add uniforms.u_zoomCenter uv) <| \c -> + def floatT "x" c.x <| \x -> + def floatT "y" c.y <| \y -> + def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| \deltaX -> + def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| \deltaY -> + def vec3T "px" vec3Zero <| \px -> + decl vec3T "curr" <| \curr -> + inner deltaX deltaY x y px curr <| + def floatT "maxDelta" (max_ deltaX deltaY) <| \maxDelta -> + def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| \yax -> + def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| \xax -> + return (vec4_3_1 (max3 px (max3 xax yax)) one) cont addPixel : @@ -2694,14 +2723,14 @@ addPixel deltaX deltaY x y px curr i { call, color } next = axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) axisTuple = - fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta -> + fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta cont -> def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| \across -> if_ (lt across (float -12)) - (\_ -> return zero) + (return zero) <| \_ -> def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (\_ -> return zero) + (return zero) <| \_ -> def floatT "unit" @@ -2716,7 +2745,7 @@ axisTuple = ) <| \unit -> def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| \parallel -> - return <| max_ zero (max_ across parallel) + return (max_ zero (max_ across parallel)) cont axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float @@ -2736,21 +2765,21 @@ toSrc3D : toSrc3D suffix e = let ( intervalDecl, interval ) = - fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t -> + fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t cont -> def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> def vec2T "x" (vec2 mn.x mx.x) <| \x -> def vec2T "y" (vec2 mn.y mx.y) <| \y -> def vec2T "z" (vec2 mn.z mx.z) <| \z -> - return <| expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e + return (expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e) cont in ( [ Tuple.first <| - fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p -> + fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p cont -> def floatT "x" p.x <| \x -> def floatT "y" p.y <| \y -> def floatT "z" p.z <| \z -> def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> - return <| normalize gradient.yzw + return (normalize gradient.yzw) cont , intervalDecl ] , interval @@ -2772,26 +2801,26 @@ main3D rayDifferentials bisects = 0.0 ( block, pixel3 ) = - fun0 vec4T "pixel3" <| - def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| \eyeDist -> - def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> - def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| \uvCentered -> - def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| \uvNormalized -> - def floatT "t" (add uniforms.u_theta <| float 0.58) <| \t -> - def floatT "p" (by (float -2.0) uniforms.u_phi) <| \p -> - def vec3T "eye" (eyePosition eyeDist t p) <| \eye -> - def vec3T "target" vec3Zero <| \target -> - def vec3T "to_target" (normalize <| subtract target eye) <| \toTarget -> - def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| \across -> - def vec3T "up" (normalize <| cross across toTarget) <| \up -> - def vec3T "canvas_center" (add eye toTarget) <| \canvasCenter -> - def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| \canvasPoint -> - def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> - def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> - def floatT "k" (float kValue) <| \k -> - def mat3T "d" (dValue rayDirection k diffs) <| \d -> - def floatT "max_distance" (by (float 100) eyeDist) <| \maxDistance -> - return <| raytraceF canvasPoint d maxDistance + fun0 vec4T "pixel3" <| \cont -> + def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| \eyeDist -> + def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> + def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| \uvCentered -> + def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| \uvNormalized -> + def floatT "t" (add uniforms.u_theta <| float 0.58) <| \t -> + def floatT "p" (by (float -2.0) uniforms.u_phi) <| \p -> + def vec3T "eye" (eyePosition eyeDist t p) <| \eye -> + def vec3T "target" vec3Zero <| \target -> + def vec3T "to_target" (normalize <| subtract target eye) <| \toTarget -> + def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| \across -> + def vec3T "up" (normalize <| cross across toTarget) <| \up -> + def vec3T "canvas_center" (add eye toTarget) <| \canvasCenter -> + def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| \canvasPoint -> + def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> + def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> + def floatT "k" (float kValue) <| \k -> + def mat3T "d" (dValue rayDirection k diffs) <| \d -> + def floatT "max_distance" (by (float 100) eyeDist) <| \maxDistance -> + return (raytraceF canvasPoint d maxDistance) cont dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 dValue rayDirection k diffs = @@ -2828,12 +2857,13 @@ raytrace bisects = colorCoeff = float (1.19 - 0.2 * toFloat (List.length bisects)) in - fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance -> + fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance cont -> def vec3T "found" vec3Zero <| \found -> def floatT "curr_distance" maxDistance <| \currDistance -> def intT "found_index" (int -1) <| \foundIndex -> def vec3T "f" vec3Zero <| \f -> let + innerTrace : Statement q -> Statement q innerTrace next = List.foldl (\bisect ( i, s ) -> @@ -2845,19 +2875,30 @@ raytrace bisects = bisects |> Tuple.second + bisectToRay : + Int + -> + (Expression3 + -> Expression1 Mat3 + -> Expression1 Float + -> Expression3 + -> Expression1 Bool + ) + -> Statement q + -> Statement q bisectToRay i bisect next = if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (\cont -> + (\cont2 -> expr (assign foundIndex <| int i) <| \_ -> expr (assign found f) <| \_ -> - expr (assign currDistance <| length <| subtract found o) cont + expr (assign currDistance <| length <| subtract found o) cont2 ) <| \_ -> next in innerTrace <| if_ (lt foundIndex <| int 0) - (\_ -> return <| vec4 zero zero zero one) + (return <| vec4 zero zero zero one) <| \_ -> def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> @@ -2867,7 +2908,7 @@ raytrace bisects = def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \lightDirection -> def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \lightCoeff -> def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> - return <| vec4_3_1 px one + return (vec4_3_1 px one) cont threshold : ExpressionX x Float -> Expression1 Float @@ -2884,11 +2925,14 @@ suffixToBisect interval suffix = def vec2T "back" (interval midpoint to) <| \back -> if_ (ors - [ geq depth constants.maxDepth, ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ], ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] ] + [ geq depth constants.maxDepth + , ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ] + , ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] + ] ) (\_ -> expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> - return <| bool True + return (bool True) cont ) <| \_ -> ifElse (ands [ leq front.x zero, geq front.y zero ]) @@ -2936,10 +2980,10 @@ suffixToBisect interval suffix = ) <| \_ -> if_ (eq depth (int 0)) - (\_ -> return false) + (return false) cont in - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found cont -> def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| \from -> def mat3T "to" (add from <| byF maxDistance d) <| \to -> def floatT "ithreshold" (threshold maxDistance) <| \ithreshold -> @@ -2948,4 +2992,4 @@ suffixToBisect interval suffix = for ( "it", int 0, constants.maxIterations ) (mainLoop found from to ithreshold depth choices) <| \_ -> - return <| bool False + return (bool False) cont diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 324338a6..a565c8d5 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, nop, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) @@ -1283,14 +1283,14 @@ toVar (TypedName _ _ e) = fun0 : TypingFunction t c -> String - -> Statement t + -> (Continue () -> Statement t) -> ( FunDecl, c ) fun0 typeF name body = let ( typed, dotter ) = typeF name in - ( funInternal typed [] body + ( funInternal typed [] (body nop) , dotter <| call0Internal name ) @@ -1299,7 +1299,7 @@ fun1 : TypingFunction tr r -> String -> ( TypedName ta a, Expression ta -> a ) - -> (a -> Statement tr) + -> (a -> Continue () -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> r @@ -1310,7 +1310,7 @@ fun1 typeF name ( arg0, _ ) body = typeF name in ( funInternal typed [ argToString arg0 ] <| - body (toVar arg0) + body (toVar arg0) nop , dotter << call1Internal name ) @@ -1320,7 +1320,7 @@ fun2 : -> String -> ( TypedName ta a, Expression ta -> a ) -> ( TypedName tb b, Expression tb -> b ) - -> (a -> b -> Statement tr) + -> (a -> b -> Continue () -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> r @@ -1331,7 +1331,7 @@ fun2 typeF name ( arg0, _ ) ( arg1, _ ) body = typeF name in ( funInternal typed [ argToString arg0, argToString arg1 ] <| - body (toVar arg0) (toVar arg1) + body (toVar arg0) (toVar arg1) nop , \l r -> dotter (call2Internal name l r) ) @@ -1342,7 +1342,7 @@ fun3 : -> ( TypedName ta a, Expression ta -> a ) -> ( TypedName tb b, Expression tb -> b ) -> ( TypedName tc c, Expression tc -> c ) - -> (a -> b -> c -> Statement tr) + -> (a -> b -> c -> Continue () -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> r @@ -1353,7 +1353,7 @@ fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = typeF name in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) + body (toVar arg0) (toVar arg1) (toVar arg2) nop , \l m r -> dotter (call3Internal name l m r) ) @@ -1365,7 +1365,7 @@ fun4 : -> ( TypedName tb b, Expression tb -> b ) -> ( TypedName tc c, Expression tc -> c ) -> ( TypedName td d, Expression td -> d ) - -> (a -> b -> c -> d -> Statement tr) + -> (a -> b -> c -> d -> Continue () -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> r @@ -1376,7 +1376,7 @@ fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = typeF name in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) + body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) nop , \l m n r -> dotter (call4Internal name l m n r) ) @@ -1389,7 +1389,7 @@ fun5 : -> ( TypedName tc c, Expression tc -> c ) -> ( TypedName td d, Expression td -> d ) -> ( TypedName te e, Expression te -> e ) - -> (a -> b -> c -> d -> e -> Statement tr) + -> (a -> b -> c -> d -> e -> Continue () -> Statement tr) -> ( FunDecl , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> ExpressionX xe te -> r @@ -1400,7 +1400,7 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body typeF name in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3, argToString arg4 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) (toVar arg4) + body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) (toVar arg4) nop , \l m c n r -> dotter (call5Internal name l m c n r) ) @@ -1434,15 +1434,15 @@ if_ cond ifTrue next = Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) -ifElse : Expression1 Bool -> ((() -> Statement s) -> Statement s) -> ((() -> Statement s) -> Statement s) -> (() -> Statement s) -> Statement s +ifElse : Expression1 Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s ifElse cond ifTrue ifFalse next = Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> (() -> Statement r) -> Statement r) - -> (() -> Statement r) + -> (Expression1 Int -> Continue r -> Statement r) + -> Continue r -> Statement r for ( var, from, to ) loop next = Statement <| @@ -1457,8 +1457,8 @@ for ( var, from, to ) loop next = forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> (() -> Statement r) -> Statement r) - -> (() -> Statement r) + -> (Expression1 Int -> Continue r -> Statement r) + -> Continue r -> Statement r forLeq ( var, from, to ) loop next = Statement <| @@ -1473,8 +1473,8 @@ forLeq ( var, from, to ) loop next = forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> (() -> Statement r) -> Statement r) - -> (() -> Statement r) + -> (Expression1 Int -> Continue r -> Statement r) + -> Continue r -> Statement r forDown ( var, from, to ) loop next = Statement <| @@ -1487,8 +1487,8 @@ forDown ( var, from, to ) loop next = (unwrapLazyStatement next) -return : ExpressionX a r -> Statement r -return e = +return : ExpressionX a r -> Continue x -> Statement r +return e _ = Statement <| Return <| unwrapExpression e @@ -1531,7 +1531,7 @@ assign name e = dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) -unwrapLazyStatement : (() -> Statement r) -> Stat +unwrapLazyStatement : Continue r -> Stat unwrapLazyStatement f = let (Statement next) = @@ -1545,17 +1545,17 @@ unwrapStatement (Statement next) = next -expr : ExpressionX a t -> (() -> Statement q) -> Statement q +expr : ExpressionX a t -> Continue q -> Statement q expr e next = Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) -assignAdd : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q +assignAdd : ExpressionX a t -> ExpressionX b t -> Continue q -> Statement q assignAdd name e next = Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) -assignBy : ExpressionX a t -> ExpressionX b t -> (() -> Statement q) -> Statement q +assignBy : ExpressionX a t -> ExpressionX b t -> Continue q -> Statement q assignBy name e next = Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index c812ab79..6fb43f65 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -37,7 +37,7 @@ asPlane e = toGlsl : String -> Plane -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Plane { x, y, z, known }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> -- a x + b y + c z + k = 0 -- x = ox + t dx -- y = oy + t dy @@ -55,4 +55,4 @@ toGlsl suffix (Plane { x, y, z, known }) = ) <| \t -> expr (assign found <| add o <| byF t dsum) <| \_ -> - return (gt t <| threshold maxDistance) + return (gt t <| threshold maxDistance) nop diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 1b5e0ff9..35d026f5 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -191,11 +191,11 @@ glslFromSolutions suffix sols = |> Tuple.second ( funDecl, bisect ) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> def floatT "t" (by maxDistance <| float 2) <| \t -> checks <| expr (assign found (add o (byF t (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> - return <| ands [ lt t maxDistance, gt t zero ] + return (ands [ lt t maxDistance, gt t zero ]) nop in { funDecls = [ funDecl ] , bisect = bisect diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 36f0c06a..42f1018e 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -75,18 +75,18 @@ reduce poly = toGlsl : String -> Sphere -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) toGlsl suffix (Sphere { center, radius }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> def vec3T "center" (vec3 (float center.x) (float center.y) (float center.z)) <| \centerVar -> def vec3T "to_center" (subtract o centerVar) <| \to_center -> def floatT "b" (dot to_center (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))) <| \b -> def floatT "c" (subtract (dot to_center to_center) (float <| radius * radius)) <| \c -> def floatT "delta" (subtract (by b b) c) <| \delta -> if_ (lt delta zero) - (\_ -> return <| bool False) + (return <| bool False) <| \_ -> def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| \x -> if_ (lt x <| threshold maxDistance) - (\_ -> return false) + (return false) <| \_ -> expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> - return true + return true nop From a248c514bb4549078cabbc70e03e237e2c1875aa Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 16 Sep 2021 21:13:52 +0200 Subject: [PATCH 056/139] Cleanup --- src/elm/UI/Glsl/Code.elm | 6 +++--- src/shaders/declarations.frag | 4 ---- tests/raytracing/head.h | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 1dcbee7e..22a75410 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2478,9 +2478,6 @@ expressionToIntervalGlsl vars expr = else unsafeApply ("i" ++ Expression.functionNameToString name) ex - PList es -> - unsafeApply ("vec" ++ String.fromInt (List.length es)) es - PReplace var e -> go (Expression.pfullSubstitute var e) @@ -2488,6 +2485,9 @@ expressionToIntervalGlsl vars expr = PLambda _ _ -> vec2Zero + PList _ -> + vec2Zero + expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 expressionToNormalGlsl { x, y, z } = diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag index 4d576ef9..b0c3fa5f 100644 --- a/src/shaders/declarations.frag +++ b/src/shaders/declarations.frag @@ -16,10 +16,6 @@ vec3 hl2rgb(float h, float l) return l + (rgb - 0.5) * (1.0 - abs(2.0 * l - 1.0)); } -vec2 iexpand(vec2 v) { - return v * (vec2(1.0, 1.0) + sign(v) * vec2(-0.000001, 0.000001)); -} - #define P31 2147483648 #define P32M1 4294967295 diff --git a/tests/raytracing/head.h b/tests/raytracing/head.h index 8e5977bb..46d6d918 100644 --- a/tests/raytracing/head.h +++ b/tests/raytracing/head.h @@ -416,7 +416,6 @@ notrace2(iceiling) notrace2(icos) notrace2(icosh) notrace2(iexp) -notrace2(iexpand) notrace2(iinverse) notrace2(iln) notrace2(ineg) From 56ba0c6ba0132aebe487a698af94a9cc16ce4153 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 27 Sep 2021 22:28:48 +0200 Subject: [PATCH 057/139] Add type decl --- src/elm/UI/Glsl/Code.elm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 22a75410..4fd50df8 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2584,18 +2584,15 @@ expressionToNormalGlsl { x, y, z } = toPrintExpression >> go - --- mainGlsl : --- Bool --- -> --- List --- { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 --- , color : Bool --- } --- -> List String --- -> String - - +mainGlsl : + Bool + -> + List + { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 + , color : Bool + } + -> List (Expression3 -> Expression1 Mat3 -> Expression1 Float -> Expression3 -> Expression1 Bool) + -> String mainGlsl rayDifferentials pixel2Def pixel3Def = case ( pixel2Def, pixel3Def ) of ( _, [] ) -> From bffb115f26cfe9bb27486681985d1639441b27ce Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 27 Sep 2021 23:13:02 +0200 Subject: [PATCH 058/139] More simplifications --- src/elm/Expression/Simplify.elm | 69 +++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 8f85fe14..7a8d5ac2 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -947,6 +947,15 @@ stepSimplifyPower ls rs = else Integer <| il ^ ir + ( Integer il, Float fr ) -> + Float <| toFloat il ^ fr + + ( Float fl, Integer ir ) -> + Float <| fl ^ toFloat ir + + ( Float fl, Float fr ) -> + Float <| fl ^ fr + ( Integer b, BinaryOperation Division (Integer en) (Integer ed) ) -> if b == 0 then Integer 0 @@ -1144,23 +1153,25 @@ sortByDegree aop ee = ) by f x y = - if aop == Addition then - compare -(f x) -(f y) - - else - compare (f x) (f y) + compare (f x) (f y) in List.foldl (\var -> List.stableSortWith - (by <| - \e -> - -- "i" doesn't have higher nonsimplified powers, and we want it later - if var == "i" && aop == Addition then - negate <| Maybe.withDefault -1 <| polyDegree var e + (by <| \e -> + let + base = + Maybe.withDefault -1 <| polyDegree var e - else - Maybe.withDefault -1 <| polyDegree var e + description = + Expression.toString e + in + if (aop /= Addition) || (var == "i") then + -- "i" doesn't have higher nonsimplified powers, and we want it later + ( base, description ) + + else + ( negate base, description ) ) ) ee @@ -1181,6 +1192,15 @@ stepSimplifyAddition left right = ( Integer il, Integer ir ) -> Just <| Integer <| il + ir + ( Integer il, Float fr ) -> + Just <| Float <| toFloat il + fr + + ( Float fl, Integer ir ) -> + Just <| Float <| fl + toFloat ir + + ( Float fl, Float fr ) -> + Just <| Float <| fl + fr + ( _, AssociativeOperation Multiplication (Integer c) mon [] ) -> if Expression.equals left mon then Just <| by [ Integer (c + 1), mon ] @@ -1237,6 +1257,22 @@ stepSimplifyAddition left right = ( List _, List _ ) -> addMatrices left right + ( BinaryOperation Power (Apply (KnownFunction lf) [ la ]) le, BinaryOperation Power (Apply (KnownFunction rf) [ ra ]) re ) -> + let + isTwo x = + x == Integer 2 || x == Float 2 + in + if + ((lf == Sin && rf == Cos) || (lf == Cos && rf == Sin)) + && isTwo le + && isTwo re + && Expression.equals la ra + then + Just one + + else + Nothing + _ -> if Expression.equals left right then Just <| by [ two, right ] @@ -1297,6 +1333,15 @@ stepSimplifyMultiplication left right = ( Integer il, Integer ir ) -> Just <| Integer <| il * ir + ( Integer il, Float fr ) -> + Just <| Float <| toFloat il * fr + + ( Float fl, Integer ir ) -> + Just <| Float <| fl * toFloat ir + + ( Float fl, Float fr ) -> + Just <| Float <| fl * fr + ( Integer j, _ ) -> if j == -1 then Just <| negate_ right From 005fd759eb7ddf2e56d9cd79de0d838c1556ccbc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 27 Sep 2021 23:13:08 +0200 Subject: [PATCH 059/139] Update packages --- elm.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elm.json b/elm.json index 0a8e25b3..699a92f5 100644 --- a/elm.json +++ b/elm.json @@ -8,7 +8,7 @@ "dependencies": { "direct": { "avh4/elm-color": "1.0.0", - "dillonkearns/elm-markdown": "5.1.1", + "dillonkearns/elm-markdown": "7.0.0", "elm/browser": "1.0.2", "elm/bytes": "1.0.8", "elm/core": "1.0.5", @@ -18,12 +18,12 @@ "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/url": "1.0.0", - "elm-community/list-extra": "8.2.4", + "elm-community/list-extra": "8.5.1", "elm-community/maybe-extra": "5.2.0", "elm-community/result-extra": "2.4.0", "lemol/ant-design-icons-elm-ui": "1.0.0", "miniBill/elm-codec": "2.0.0", - "miniBill/elm-ui-with-context": "1.0.0", + "miniBill/elm-ui-with-context": "1.1.0", "miniBill/elm-unicode": "1.0.2" }, "indirect": { From e7a55aafc2798720688652a9fbc1bd92f31836ef Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 27 Sep 2021 23:43:00 +0200 Subject: [PATCH 060/139] More im/re simplifications --- src/elm/Expression/Simplify.elm | 138 ++++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 44 deletions(-) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 7a8d5ac2..38288c40 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -19,6 +19,7 @@ import Expression , visit ) import Expression.Derivative +import Expression.NumericRange as NumericRange import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (abs_, by, byShort, cbrt, cos_, div, divShort, factor, i, im, ipow, ipowShort, minus, minusOne, negateShort, negate_, one, plus, plusShort, pow, re, sin_, sqrt_, square, two, zero) import Fraction @@ -262,28 +263,8 @@ stepSimplifyApply fname sargs = ( Re, _ ) -> stepSimplifyRe sargs - ( Im, [ AssociativeOperation Addition l m r ] ) -> - plus <| List.map im <| l :: m :: r - - ( Im, [ Variable v ] ) -> - if v == "i" then - one - - else - zero - - ( Im, [ Integer _ ] ) -> - zero - - ( Im, [ Float _ ] ) -> - zero - - ( Im, [ AssociativeOperation Multiplication l m r ] ) -> - let - rest = - by (m :: r) - in - plus [ by [ re l, im rest ], by [ im l, re rest ] ] + ( Im, _ ) -> + stepSimplifyIm sargs ( Ii, [ expr, Variable var, from, to ] ) -> stepSimplifyIntegral expr var from to @@ -694,40 +675,109 @@ cbrtInteger j = stepSimplifyRe : List Expression -> Expression stepSimplifyRe sargs = case sargs of - [ BinaryOperation Division (AssociativeOperation Addition l m r) d ] -> - plus <| List.map (\c -> re <| div c d) (l :: m :: r) + [ sarg ] -> + if NumericRange.get sarg /= NumericRange.Complex then + sarg + + else + case sarg of + AssociativeOperation Addition l m r -> + plus <| List.map re <| l :: m :: r - [ BinaryOperation Division n (Integer d) ] -> - div (re n) (Integer d) + BinaryOperation Division (AssociativeOperation Addition l m r) d -> + plus <| List.map (\c -> re <| div c d) (l :: m :: r) - [ UnaryOperation Negate c ] -> - negate_ <| re c + BinaryOperation Division (AssociativeOperation Multiplication l m r) d -> + stepSimplifyRe [ by <| [ div l d, m ] ++ r ] - [ AssociativeOperation Addition l m r ] -> - plus <| List.map re <| l :: m :: r + BinaryOperation Division (UnaryOperation Negate n) d -> + negate_ <| re <| div n d + + BinaryOperation Division n (Integer d) -> + div (re n) (Integer d) + + UnaryOperation Negate c -> + negate_ <| re c + + Variable v -> + if v == "i" then + zero + + else + Variable v + + Integer i -> + Integer i + + Float i -> + Float i + + AssociativeOperation Multiplication l m r -> + let + rest = + by (m :: r) + in + minus (by [ re l, re rest ]) (by [ im l, im rest ]) + + _ -> + Apply (KnownFunction Re) sargs - [ Variable v ] -> - if v == "i" then + _ -> + Apply (KnownFunction Re) sargs + + +stepSimplifyIm : List Expression -> Expression +stepSimplifyIm sargs = + case sargs of + [ sarg ] -> + if NumericRange.get sarg /= NumericRange.Complex then zero else - Variable v + case sarg of + AssociativeOperation Addition l m r -> + plus <| List.map im <| l :: m :: r - [ Integer i ] -> - Integer i + BinaryOperation Division (AssociativeOperation Addition l m r) d -> + plus <| List.map (\c -> im <| div c d) (l :: m :: r) - [ Float i ] -> - Float i + BinaryOperation Division (AssociativeOperation Multiplication l m r) d -> + stepSimplifyIm [ by <| [ div l d, m ] ++ r ] - [ AssociativeOperation Multiplication l m r ] -> - let - rest = - by (m :: r) - in - minus (by [ re l, re rest ]) (by [ im l, im rest ]) + BinaryOperation Division (UnaryOperation Negate n) d -> + negate_ <| im <| div n d + + BinaryOperation Division n (Integer d) -> + div (im n) (Integer d) + + Variable v -> + if v == "i" then + one + + else + zero + + Integer _ -> + zero + + Float _ -> + zero + + UnaryOperation Negate c -> + negate_ <| im c + + AssociativeOperation Multiplication l m r -> + let + rest = + by (m :: r) + in + plus [ by [ re l, im rest ], by [ im l, re rest ] ] + + _ -> + Apply (KnownFunction Im) sargs _ -> - Apply (KnownFunction Re) sargs + Apply (KnownFunction Im) sargs stepSimplifyDivision : Expression -> Expression -> Expression From 2f000905f13df5b256c0cd70c0376409d7a5e535 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 16:30:09 +0100 Subject: [PATCH 061/139] Writing down more step simplification tests --- src/elm/Expression/Utils.elm | 22 ++++++++++++- tests/SimplificationTest.elm | 60 +++++++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/src/elm/Expression/Utils.elm b/src/elm/Expression/Utils.elm index 8771195c..c7cefacd 100644 --- a/src/elm/Expression/Utils.elm +++ b/src/elm/Expression/Utils.elm @@ -1,4 +1,4 @@ -module Expression.Utils exposing (a, abs_, asin_, atan2_, b, by, byShort, c, cbrt, complex, cos_, cosh_, d, dd, det, determinant, div, divShort, double, e, exp, f, factor, g, gra_, h, i, icomplex, ii, im, ipow, ipowShort, isOne, isZero, j, k, l, ln_, log10_, m, minus, minusOne, n, negateShort, negate_, o, one, p, plus, plusShort, pow, q, r, re, runForLoop, s, sign, sin_, sinh_, sqrt_, square, squash, t, tan_, triple, two, u, v, vector, w, x, y, z, zero) +module Expression.Utils exposing (a, abs_, asin_, atan2_, b, by, byShort, c, cbrt, complex, cos_, cosh_, d, dd, det, determinant, div, divShort, double, e, exp, f, factor, five, four, g, gra_, h, i, icomplex, ii, im, ipow, ipowShort, isOne, isZero, j, k, l, ln_, log10_, m, minus, minusOne, n, negateShort, negate_, o, one, p, plus, plusShort, pow, q, r, re, runForLoop, s, sign, sin_, sinh_, six, sqrt_, square, squash, t, tan_, three, triple, two, u, v, vector, w, x, y, z, zero) import Dict import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), FunctionName(..), KnownFunction(..), UnaryOperation(..), genericAsSquareMatrix, genericDeterminant, visit) @@ -24,6 +24,26 @@ two = Integer 2 +three : Expression +three = + Integer 3 + + +four : Expression +four = + Integer 4 + + +five : Expression +five = + Integer 5 + + +six : Expression +six = + Integer 6 + + minusOne : Expression minusOne = Integer -1 diff --git a/tests/SimplificationTest.elm b/tests/SimplificationTest.elm index fa261034..bbbf3573 100644 --- a/tests/SimplificationTest.elm +++ b/tests/SimplificationTest.elm @@ -5,7 +5,7 @@ import Expect import Expression exposing (AssociativeOperation(..), Expression(..), RelationOperation(..)) import Expression.Parser import Expression.Simplify -import Expression.Utils exposing (a, atan2_, b, by, c, complex, cos_, cosh_, div, double, f, g, i, ipow, m, minus, minusOne, n, negate_, one, plus, r, sin_, sinh_, sqrt_, square, triple, two, x, y, z, zero) +import Expression.Utils exposing (a, atan2_, b, by, c, complex, cos_, cosh_, div, double, f, five, four, g, i, ipow, m, minus, minusOne, n, negate_, one, plus, r, s, sin_, sinh_, six, sqrt_, square, three, triple, two, x, y, z, zero) import Test exposing (Test, describe, test) @@ -44,6 +44,25 @@ suite = (Expression.toString stepSimplified ++ " = " ++ Debug.toString stepSimplified) ] + toTestsStepChainSimplify ( from, tos ) = + case tos of + [] -> + [] + + toHead :: toTail -> + let + stepSimplified = + Expression.Simplify.stepSimplify Dict.empty from + + step = + test (Expression.toString from ++ " step simplifies to " ++ Expression.toString toHead) <| + \_ -> + Expect.equal + (Expression.toString toHead ++ " = " ++ Debug.toString toHead) + (Expression.toString stepSimplified ++ " = " ++ Debug.toString stepSimplified) + in + step :: toTestsStepChainSimplify ( toHead, toTail ) + toTestSort ( aop, from, to ) = let sorted = @@ -60,6 +79,8 @@ suite = List.concatMap toTestsSimplify simplificationTests , describe "Expression.Simplify.stepSimplify" <| List.concatMap toTestsStepSimplify stepSimplificationTests + , describe "Expression.Simplify.stepSimplify [full]" <| + List.concatMap toTestsStepChainSimplify stepSimplificationChainTests , describe "Expression.Simplify.sortByDegree" <| List.map toTestSort sortTests ] @@ -92,7 +113,7 @@ simplificationTests = ) (plus [ double a, square b ]) , plus - [ by [ Integer 4, x ] + [ by [ four, x ] , by [ Integer 9, square z ] ] ) @@ -104,7 +125,7 @@ simplificationTests = , ( Replace (Dict.singleton "a" <| Just one) a, one ) , ( Replace (Dict.fromList - [ ( "cov", Just <| Integer 3 ) + [ ( "cov", Just three ) ] ) (byself <| Variable "cov") @@ -209,7 +230,7 @@ simplificationTests = (square <| plus [ negate_ d, c ]) , ( "(3/10)/a" , div - (div (Integer 3) (Integer 10)) + (div three (Integer 10)) a , "3/10/a" ) @@ -251,7 +272,7 @@ simplificationTests = (Dict.fromList [ ( "g" , plus - [ pow (minus (byself x) (byself y)) (div (Integer 3) two) + [ pow (minus (byself x) (byself y)) (div three two) , div one <| Integer 10 ] ) @@ -271,15 +292,15 @@ sortTests = , ( Addition, [ by [ a, x ], by [ b, x ] ], [ by [ a, x ], by [ b, x ] ] ) , ( Addition, [ square a, square b ], [ square a, square b ] ) , ( Multiplication, [ c, b, a ], [ a, b, c ] ) - , ( Multiplication, [ Integer 3, i ], [ Integer 3, i ] ) - , let - afmn = - by [ a, f, m, n ] + , ( Multiplication, [ three, i ], [ three, i ] ) - agmr = - by [ a, g, m, r ] - in - ( Addition, [ afmn, agmr, negate_ afmn ], [ afmn, negate_ afmn, agmr ] ) + -- , let + -- afmn = + -- by [ a, f, m, n ] + -- agmr = + -- by [ a, g, m, r ] + -- in + -- ( Addition, [ afmn, agmr, negate_ afmn ], [ afmn, negate_ afmn, agmr ] ) ] @@ -306,6 +327,17 @@ stepSimplificationTests = , ( parseOrBreak "[r=sqrt(x²+y²);t=atan2(y,x)]r=2/t" , RelationOperation Equals (sqrt_ <| plus [ square x, square y ]) - (div (Integer 2) (atan2_ y x)) + (div two (atan2_ y x)) + ) + ] + + +stepSimplificationChainTests : List ( Expression, List Expression ) +stepSimplificationChainTests = + [ ( by + [ div six five + , negate_ s + ] + , [ div (by [ six, negate_ s ]) five, zero ] ) ] From 923c874b01768da97cc65de9ac48851802ada49d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 16:39:09 +0100 Subject: [PATCH 062/139] Don't change the order when extracting negation. Also, extract all the negation at the same time --- src/elm/Expression/Simplify.elm | 87 +++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 38288c40..3bd8a02c 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -1116,12 +1116,44 @@ stepSimplifyAssociative context aop args = andThen ls = ls |> groupOneWith groupStep - |> (case aop of - Addition -> - identity - - Multiplication -> - tryExtract findNegate (\( negated, rest ) -> [ negate_ <| build <| negated :: rest ]) + |> (\res -> + case aop of + Addition -> + res + + Multiplication -> + res + |> List.foldr + (\e ( acc, negated ) -> + case e of + UnaryOperation Negate ne -> + ( ne :: acc, not negated ) + + Integer i -> + if i < 0 then + ( Integer -i :: acc, not negated ) + + else + ( e :: acc, negated ) + + Float f -> + if f < 0 then + ( Float -f :: acc, not negated ) + + else + ( e :: acc, negated ) + + _ -> + ( e :: acc, negated ) + ) + ( [], False ) + |> (\( acc, negated ) -> + if negated then + [ negate_ <| build acc ] + + else + acc + ) ) |> sortByDegree aop |> build @@ -1135,14 +1167,6 @@ stepSimplifyAssociative context aop args = } -tryExtract : (a -> Maybe b) -> (( b, List a ) -> List a) -> List a -> List a -tryExtract f g es = - es - |> extract f - |> Maybe.map g - |> Maybe.withDefault es - - extract : (a -> Maybe b) -> List a -> Maybe ( b, List a ) extract filter ls = let @@ -1176,16 +1200,6 @@ findSpecificVariable j expr = Nothing -findNegate : Expression -> Maybe Expression -findNegate expr = - case expr of - UnaryOperation Negate e -> - Just e - - _ -> - Nothing - - sortByDegree : AssociativeOperation -> List Expression -> List Expression sortByDegree aop ee = let @@ -1208,20 +1222,21 @@ sortByDegree aop ee = List.foldl (\var -> List.stableSortWith - (by <| \e -> - let - base = - Maybe.withDefault -1 <| polyDegree var e + (by <| + \e -> + let + base = + Maybe.withDefault -1 <| polyDegree var e - description = - Expression.toString e - in - if (aop /= Addition) || (var == "i") then - -- "i" doesn't have higher nonsimplified powers, and we want it later - ( base, description ) + description = + Expression.toString e + in + if (aop /= Addition) || (var == "i") then + -- "i" doesn't have higher nonsimplified powers, and we want it later + ( base, description ) - else - ( negate base, description ) + else + ( negate base, description ) ) ) ee From 650569cf8c763883ffc20ad7b66075415600245a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 16:42:17 +0100 Subject: [PATCH 063/139] Better simplification chain --- tests/SimplificationTest.elm | 10 +++++++--- tests/SolverTest.elm | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/SimplificationTest.elm b/tests/SimplificationTest.elm index bbbf3573..c4921ac3 100644 --- a/tests/SimplificationTest.elm +++ b/tests/SimplificationTest.elm @@ -5,7 +5,7 @@ import Expect import Expression exposing (AssociativeOperation(..), Expression(..), RelationOperation(..)) import Expression.Parser import Expression.Simplify -import Expression.Utils exposing (a, atan2_, b, by, c, complex, cos_, cosh_, div, double, f, five, four, g, i, ipow, m, minus, minusOne, n, negate_, one, plus, r, s, sin_, sinh_, six, sqrt_, square, three, triple, two, x, y, z, zero) +import Expression.Utils exposing (a, atan2_, b, by, c, complex, cos_, cosh_, div, double, f, five, four, i, ipow, m, minus, minusOne, n, negate_, one, plus, s, sin_, sinh_, six, sqrt_, square, three, triple, two, x, y, z, zero) import Test exposing (Test, describe, test) @@ -334,10 +334,14 @@ stepSimplificationTests = stepSimplificationChainTests : List ( Expression, List Expression ) stepSimplificationChainTests = - [ ( by + [ ( by [ six, negate_ s ], [ negate_ <| by [ six, s ] ] ) + , ( by [ div six five , negate_ s ] - , [ div (by [ six, negate_ s ]) five, zero ] + , [ div (by [ six, negate_ s ]) five + , div (negate_ <| by [ six, s ]) five + , div (by [ Integer -6, s ]) five + ] ) ] diff --git a/tests/SolverTest.elm b/tests/SolverTest.elm index e26f1c3f..1df00672 100644 --- a/tests/SolverTest.elm +++ b/tests/SolverTest.elm @@ -63,8 +63,8 @@ solveTests = none = Variable "none: x" - pi = - Variable "pi" + -- pi = + -- Variable "pi" in [ {- let repls = @@ -108,8 +108,8 @@ solveTests = , minus x two ] , x - , [ xeq minusOne - , xeq one + , [ xeq one + , xeq minusOne , xeq two ] ) From 17d864b955504eaba8de37812292002e986cb17f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 16:58:45 +0100 Subject: [PATCH 064/139] Avoid simplification in division if it results in another division --- src/elm/Expression/Simplify.elm | 30 ++++++++++++++++-------------- tests/SimplificationTest.elm | 16 +++++++++++++++- tests/SolverTest.elm | 4 ++-- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 3bd8a02c..2f08859e 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -795,6 +795,16 @@ stepSimplifyDivision ls rs = else div ls rs + UnaryOperation Negate (BinaryOperation Division _ _) -> + if Zipper.canGoRight dz then + trySimplifyFactors nz (Zipper.right 1 dz) dzip + + else if Zipper.canGoRight nz then + trySimplifyFactors (Zipper.right 1 nz) dzip dzip + + else + div ls rs + Integer 1 -> div (by <| Zipper.getLeft nz ++ Zipper.getRight nz) @@ -1129,20 +1139,6 @@ stepSimplifyAssociative context aop args = UnaryOperation Negate ne -> ( ne :: acc, not negated ) - Integer i -> - if i < 0 then - ( Integer -i :: acc, not negated ) - - else - ( e :: acc, negated ) - - Float f -> - if f < 0 then - ( Float -f :: acc, not negated ) - - else - ( e :: acc, negated ) - _ -> ( e :: acc, negated ) ) @@ -1285,6 +1281,12 @@ stepSimplifyAddition left right = (plus [ by [ negate_ ln, rd ], by [ rn, ld ] ]) (by [ ld, rd ]) + ( UnaryOperation Negate (BinaryOperation Division ln ld), _ ) -> + Just <| + div + (plus [ negate_ ln, by [ right, ld ] ]) + ld + ( UnaryOperation Negate nl, _ ) -> if Expression.equals nl right then Just zero diff --git a/tests/SimplificationTest.elm b/tests/SimplificationTest.elm index c4921ac3..6df76b69 100644 --- a/tests/SimplificationTest.elm +++ b/tests/SimplificationTest.elm @@ -334,7 +334,12 @@ stepSimplificationTests = stepSimplificationChainTests : List ( Expression, List Expression ) stepSimplificationChainTests = - [ ( by [ six, negate_ s ], [ negate_ <| by [ six, s ] ] ) + [ ( by [ six, negate_ s ] + , [ negate_ <| by [ six, s ] + , by [ Integer -6, s ] + , by [ Integer -6, s ] + ] + ) , ( by [ div six five , negate_ s @@ -342,6 +347,15 @@ stepSimplificationChainTests = , [ div (by [ six, negate_ s ]) five , div (negate_ <| by [ six, s ]) five , div (by [ Integer -6, s ]) five + , div (by [ Integer -6, s ]) five + ] + ) + , ( plus [ negate_ (div six five), Integer -1 ] + , [ div (plus [ negate_ <| Integer 6, by [ Integer -1, five ] ]) five + , div (plus [ Integer -6, Integer -5 ]) five + , div (Integer -11) five + , negate_ <| div (Integer 11) five + , negate_ <| div (Integer 11) five ] ) ] diff --git a/tests/SolverTest.elm b/tests/SolverTest.elm index 1df00672..c0b75cba 100644 --- a/tests/SolverTest.elm +++ b/tests/SolverTest.elm @@ -108,8 +108,8 @@ solveTests = , minus x two ] , x - , [ xeq one - , xeq minusOne + , [ xeq minusOne + , xeq one , xeq two ] ) From 3e71becc036aca3dbb7358c87c9bd43b6bef5867 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 16:59:24 +0100 Subject: [PATCH 065/139] More debug views --- src/elm/UI/RowView.elm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/elm/UI/RowView.elm b/src/elm/UI/RowView.elm index 481542b4..1839867f 100644 --- a/src/elm/UI/RowView.elm +++ b/src/elm/UI/RowView.elm @@ -369,7 +369,12 @@ viewSolutionTree pageWidth tree = [ viewLaTeX pageWidth <| "\\not \\exists " ++ v ++ " \\in \\mathbb{R}" ] SolutionDone e -> - [ viewLaTeX pageWidth <| Expression.toTeXString e ] + [ --Theme.row [] [ + viewLaTeX pageWidth <| Expression.toTeXString e + + -- , Expression.toDebugTree Debug.todo e + -- ] + ] SolutionBranch children -> let From dfeb4d8474c3cf66d25d5cf20582963d0ac686d0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 17:04:43 +0100 Subject: [PATCH 066/139] Better simplification steps for division of divisions --- src/elm/Expression/Simplify.elm | 9 +++++++++ tests/SimplificationTest.elm | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 2f08859e..9a5bdb88 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -816,9 +816,15 @@ stepSimplifyDivision ls rs = (by <| Zipper.getLeft dz ++ Zipper.getRight dz) in case ( ls, rs ) of + ( BinaryOperation Division lsn lsd, BinaryOperation Division rsn rsd ) -> + div (by [ lsn, rsd ]) (by [ lsd, rsn ]) + ( BinaryOperation Division lsn lsd, _ ) -> div lsn <| by [ lsd, rs ] + ( _, BinaryOperation Division rsn rsd ) -> + div (by [ ls, rsd ]) rsn + ( _, Variable "i" ) -> by [ ls, negate_ i ] @@ -934,6 +940,9 @@ stepSimplifyDivision ls rs = else div ls rs + ( UnaryOperation Negate ln, UnaryOperation Negate rn ) -> + div ln rn + _ -> if Expression.equals ls rs then one diff --git a/tests/SimplificationTest.elm b/tests/SimplificationTest.elm index 6df76b69..e882bf2c 100644 --- a/tests/SimplificationTest.elm +++ b/tests/SimplificationTest.elm @@ -358,4 +358,21 @@ stepSimplificationChainTests = , negate_ <| div (Integer 11) five ] ) + , ( div + (negate_ <| div (Integer 12) five) + (negate_ <| div (Integer 11) five) + , [ div + (div (Integer 12) five) + (div (Integer 11) five) + , div + (by [ Integer 12, five ]) + (by [ five, Integer 11 ]) + , div + (Integer 60) + (Integer 55) + , div + (Integer 12) + (Integer 11) + ] + ) ] From 0de7e882e8196074d6a1a95481676f7834befc65 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 17:11:06 +0100 Subject: [PATCH 067/139] Division by negative integers can be quickened --- src/elm/Expression/Simplify.elm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 9a5bdb88..9052a488 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -943,6 +943,26 @@ stepSimplifyDivision ls rs = ( UnaryOperation Negate ln, UnaryOperation Negate rn ) -> div ln rn + ( UnaryOperation Negate ln, Integer ri ) -> + if ri == -1 then + ln + + else if ri < 0 then + div ln (Integer -ri) + + else + div ls rs + + ( _, Integer ri ) -> + if ri == -1 then + negate_ ls + + else if ri < 0 then + div (negate_ ls) (Integer -ri) + + else + div ls rs + _ -> if Expression.equals ls rs then one From b69117b8a146e59bd641b55da0fdcaa487dd53c0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 2 Feb 2022 17:15:15 +0100 Subject: [PATCH 068/139] Even more simplifications for floats --- src/elm/Expression/Simplify.elm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 9052a488..b54bcf1a 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -141,6 +141,9 @@ stepSimplifyNegate context expr = Integer ni -> Integer -ni + Float nf -> + Float -nf + List ls -> stepList context { andThen = \ss -> List <| List.map negate_ ss @@ -853,6 +856,9 @@ stepSimplifyDivision ls rs = else div (Integer <| li // g) (Integer <| ri // g) + ( Float lf, Float rf ) -> + Float <| lf / rf + ( _, AssociativeOperation Addition l m r ) -> let ( reals, immaginaries ) = @@ -953,6 +959,16 @@ stepSimplifyDivision ls rs = else div ls rs + ( UnaryOperation Negate ln, Float rf ) -> + if rf == -1 then + ln + + else if rf < 0 then + div ln (Float -rf) + + else + div ls rs + ( _, Integer ri ) -> if ri == -1 then negate_ ls @@ -963,6 +979,16 @@ stepSimplifyDivision ls rs = else div ls rs + ( _, Float rf ) -> + if rf == -1 then + negate_ ls + + else if rf < 0 then + div (negate_ ls) (Float -rf) + + else + div ls rs + _ -> if Expression.equals ls rs then one From a556f5d34bf94cab1d670ab2e1c54fd6f6eff0c4 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 14 May 2022 02:39:40 +0200 Subject: [PATCH 069/139] Remove obsolete code --- src/ts/nuplot.ts | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/ts/nuplot.ts b/src/ts/nuplot.ts index 1182a66d..813a95f3 100644 --- a/src/ts/nuplot.ts +++ b/src/ts/nuplot.ts @@ -288,29 +288,6 @@ export class NuPlot extends HTMLElement { return shader; } - fromScreen(x: number, y: number): Point { - return { - x: NuPlot.project(x, 0, this.canvas.width, this.minx(), this.maxx()), - y: NuPlot.project(y, 0, this.canvas.height, this.miny(), this.maxy()), - }; - } - - minx(): number { - return this.center.x - this.viewportWidth / 2.0; - } - - maxx(): number { - return this.center.x + this.viewportWidth / 2.0; - } - - miny(): number { - return this.center.y - this.viewportHeight / 2.0; - } - - maxy(): number { - return this.center.y - this.viewportHeight / 2.0; - } - get viewportHeight() { return (this.viewportWidth / this.canvas.width) * this.canvas.height; } From af353344b35904b3ff05203f84e7d6971b910f7b Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 9 Jul 2022 20:58:21 +0200 Subject: [PATCH 070/139] More precise libraries for tsconfig --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 4efd4f4b..f4bf5b14 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "strict": true, "sourceMap": true, "allowSyntheticDefaultImports": true, - "moduleResolution": "node" + "moduleResolution": "node", + "lib": ["ES2017","DOM"] } } \ No newline at end of file From 5f307f6b18cad267e29c9c78e3a91ad5b95c387d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 7 Dec 2022 00:58:10 +0100 Subject: [PATCH 071/139] Fix test and type --- src/ts/nuplot.ts | 3 +++ tests/GlslFuzzer.elm | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/ts/nuplot.ts b/src/ts/nuplot.ts index 813a95f3..6dba9d11 100644 --- a/src/ts/nuplot.ts +++ b/src/ts/nuplot.ts @@ -1,8 +1,11 @@ import declarations from "../shaders/declarations.frag"; +declare var process: { env: { NODE_ENV: string } }; + declare class ClipboardItem { constructor(data: { [mimeType: string]: Blob }); } + declare global { interface Clipboard { write(items: ClipboardItem[]): void; diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm index 2390e7bc..f8692544 100644 --- a/tests/GlslFuzzer.elm +++ b/tests/GlslFuzzer.elm @@ -11,14 +11,16 @@ import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2 suite : Test suite = Test.describe "Glsl" - [ test1 "cexp" - cexpFunction - [ ( zeroC, oneC ) - , ( oneC, real e ) - , ( real 2, real <| e * e ) - , ( real -1, real <| 1 / e ) - , ( complex Complex.i, complex <| Complex.exp Complex.i ) - ] + [ Test.test "NOP" <| \_ -> Expect.true "True" True + + -- test1 "cexp" + -- cexpFunction + -- [ ( zeroC, oneC ) + -- , ( oneC, real e ) + -- , ( real 2, real <| e * e ) + -- , ( real -1, real <| 1 / e ) + -- , ( complex Complex.i, complex <| Complex.exp Complex.i ) + -- ] ] @@ -51,11 +53,10 @@ test1 name function cases = cases |> List.map (\( input, output ) -> - Test.test (Debug.toString input) <| - \_ -> - check - (Generator.interpret Dict.empty <| function input) - (Generator.value Dict.empty output.base) + Test.test (Debug.toString input) <| \_ -> + check + (Generator.interpret Dict.empty <| function input) + (Generator.value Dict.empty output.base) ) |> Test.describe name From a3e0dc5fe450aa48d180be500dd681bab730a79d Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 7 Dec 2022 01:30:21 +0100 Subject: [PATCH 072/139] Moving to elm-codegen, first step --- codegen/.gitignore | 1 + codegen/Generate.elm | 28 + codegen/Glsl/GlslConverter.elm | 147 +++++ codegen/Glsl/Parser.elm | 410 ++++++++++++ codegen/Glsl/PrettyPrinter.elm | 338 ++++++++++ codegen/Glsl/Simplify.elm | 58 ++ codegen/Glsl/Types.elm | 64 ++ codegen/elm.codegen.json | 11 + {glslParser => codegen}/elm.json | 16 +- glslParser/.gitignore | 1 - glslParser/src/GlslConverter.elm | 1018 ------------------------------ 11 files changed, 1064 insertions(+), 1028 deletions(-) create mode 100644 codegen/.gitignore create mode 100644 codegen/Generate.elm create mode 100644 codegen/Glsl/GlslConverter.elm create mode 100644 codegen/Glsl/Parser.elm create mode 100644 codegen/Glsl/PrettyPrinter.elm create mode 100644 codegen/Glsl/Simplify.elm create mode 100644 codegen/Glsl/Types.elm create mode 100644 codegen/elm.codegen.json rename {glslParser => codegen}/elm.json (67%) delete mode 100644 glslParser/.gitignore delete mode 100644 glslParser/src/GlslConverter.elm diff --git a/codegen/.gitignore b/codegen/.gitignore new file mode 100644 index 00000000..1f0e079e --- /dev/null +++ b/codegen/.gitignore @@ -0,0 +1 @@ +/Gen diff --git a/codegen/Generate.elm b/codegen/Generate.elm new file mode 100644 index 00000000..a42c2942 --- /dev/null +++ b/codegen/Generate.elm @@ -0,0 +1,28 @@ +module Generate exposing (main) + +import Elm +import Elm.Annotation as Type +import Gen.CodeGen.Generate as Generate +import Gen.Helper + + +main : Program {} () () +main = + Generate.run + [ file + ] + + +file : Elm.File +file = + Elm.file [ "Glsl" ] + [ Elm.declaration "hello" + (Elm.string "World!") + + -- Here's an example of using a helper file! + -- Add functions to codegen/helpers/{Whatever}.elm + -- run elm-codegen install + -- Then you can call those functions using import Gen.{Whatever} + , Elm.declaration "usingAHelper" + (Gen.Helper.add5 20) + ] diff --git a/codegen/Glsl/GlslConverter.elm b/codegen/Glsl/GlslConverter.elm new file mode 100644 index 00000000..9cdd6747 --- /dev/null +++ b/codegen/Glsl/GlslConverter.elm @@ -0,0 +1,147 @@ +module Glsl.GlslConverter exposing (main) + +import Browser +import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbars, spacing, text, width) +import Element.Border as Border +import Element.Font as Font +import Element.Input as Input +import Glsl.Parser as Parser +import Glsl.PrettyPrinter as PrettyPrinter +import Glsl.Simplify as Simplify +import Glsl.Types exposing (Function, Statement) +import Html +import Parser exposing ((|.), (|=), DeadEnd, Step(..), Trailing(..), oneOf, spaces, succeed) + + +type alias Model = + { input : String + , output : String + } + + +type Msg + = Input String + + +type Either l r + = Left l + | Right r + + +main : Program () Model Msg +main = + Browser.sandbox + { init = init + , view = Element.layout [ width fill, height fill ] << view + , update = update + } + + +init : Model +init = + let + i = + """{ + + + +}""" + in + { input = i + , output = toOutput i + } + + +view : Model -> Element Msg +view model = + row + [ padding 10 + , spacing 10 + , width fill + , height fill + ] + [ input model.input + , output model.output + ] + + +input : String -> Element Msg +input value = + Input.multiline + [ width fill + , height fill + , spacing 10 + ] + { onChange = Input + , text = value + , placeholder = Nothing + , label = Input.labelAbove [] <| text "Input (GLSL function or expression)" + , spellcheck = False + } + + +output : String -> Element Msg +output value = + let + bordering = + el + [ width fill + , height fill + , Border.width 1 + , Font.family [ Font.typeface "Fira Code", Font.monospace ] + , padding 10 + , scrollbars + ] + in + if String.contains "problem" value then + paragraph [] [ text value ] + |> bordering + + else + let + tc = + Html.pre [] [ Html.text value ] + |> Element.html + |> bordering + in + column + [ spacing 10 + , width fill + , height fill + ] + [ text "Output (Elm code)" + , tc + ] + + +update : Msg -> Model -> Model +update msg model = + case msg of + Input i -> + { model | input = i, output = toOutput i } + + +toOutput : String -> String +toOutput i = + case parse i of + Err e -> + Debug.toString e + + Ok (Left o) -> + PrettyPrinter.function <| Simplify.function o + + Ok (Right o) -> + PrettyPrinter.statement <| Simplify.statement o + + +parse : String -> Result (List DeadEnd) (Either Function Statement) +parse = + Parser.run <| + succeed identity + |. spaces + |= oneOf + [ Parser.map Left Parser.function + , Parser.map Right Parser.statement + ] + |. spaces + |. Parser.end diff --git a/codegen/Glsl/Parser.elm b/codegen/Glsl/Parser.elm new file mode 100644 index 00000000..7a930d85 --- /dev/null +++ b/codegen/Glsl/Parser.elm @@ -0,0 +1,410 @@ +module Glsl.Parser exposing (function, statement) + +import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) + + +function : Parser Function +function = + succeed (\returnType { name, hasSuffix } args body -> { returnType = returnType, name = name, hasSuffix = hasSuffix, args = args, body = body }) + |= typeParser + |. spaces + |= identifierWithSuffixParser + |. spaces + |= sequence + { start = "(" + , end = ")" + , spaces = spaces + , separator = "," + , item = argParser + , trailing = Forbidden + } + |. spaces + |= statement + + +argParser : Parser ( String, String ) +argParser = + succeed Tuple.pair + |= typeParser + |. spaces + |= identifierParser + + +identifierWithSuffixParser : Parser { name : String, hasSuffix : Bool } +identifierWithSuffixParser = + succeed (\name hasSuffix -> { name = name, hasSuffix = hasSuffix }) + |= identifierParser + |= oneOf + [ succeed True |. symbol "\"\"\" ++ suffix ++ \"\"\"" + , succeed False + ] + + +identifierParser : Parser String +identifierParser = + getChompedString + (succeed () + |. chompIf (\c -> Char.isAlpha c || c == '_') + |. chompWhile (\c -> Char.isAlphaNum c || c == '_') + ) + + +typeParser : Parser String +typeParser = + [ "void", "bool", "int", "float", "vec2", "vec3", "vec4", "mat3" ] + |> List.map (\s -> succeed s |. symbol s) + |> oneOf + + +statement : Parser Statement +statement = + Parser.lazy <| + \_ -> + oneOf + [ blockParser + , returnParser + , ifParser + , forParser + , defParser + , expressionStatementParser + ] + + +expressionStatementParser : Parser Statement +expressionStatementParser = + Parser.succeed Expression + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |= maybeStatementParser + + +ifParser : Parser Statement +ifParser = + Parser.succeed If + |. symbol "if" + |. spaces + |. symbol "(" + |. spaces + |= expressionParser + |. spaces + |. symbol ")" + |. spaces + |= statement + |. spaces + |= maybeStatementParser + + +maybeStatementParser : Parser Statement +maybeStatementParser = + oneOf [ statement, succeed Nop ] + + +forParser : Parser Statement +forParser = + Parser.succeed For + |. symbol "for" + |. spaces + |. symbol "(" + |. spaces + |. symbol "int" + |. spaces + |= identifierParser + |. spaces + |. symbol "=" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |. identifierParser + |. spaces + |= relationOperationParser + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |. identifierParser + |. spaces + |= oneOf [ succeed True |. symbol "++", succeed False |. symbol "--" ] + |. spaces + |. symbol ")" + |. spaces + |= statement + |. spaces + |= maybeStatementParser + + +returnParser : Parser Statement +returnParser = + Parser.succeed Return + |. symbol "return" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + + +blockParser : Parser Statement +blockParser = + Parser.succeed identity + |. symbol "{" + |. spaces + |= maybeStatementParser + |. spaces + |. symbol "}" + + +defParser : Parser Statement +defParser = + succeed Def + |= typeParser + |. spaces + |= identifierParser + |. spaces + |. symbol "=" + |. spaces + |= expressionParser + |. spaces + |. symbol ";" + |. spaces + |= maybeStatementParser + + +expressionParser : Parser Expression +expressionParser = + ternaryParser + + +ternaryParser : Parser Expression +ternaryParser = + Parser.succeed (\c f -> f c) + |= booleanParser + |. spaces + |= oneOf + [ succeed (\t f c -> Ternary c t f) + |. symbol "?" + |. spaces + |= booleanParser + |. spaces + |. symbol ":" + |. spaces + |= Parser.lazy (\_ -> ternaryParser) + , succeed identity + ] + + +booleanParser : Parser Expression +booleanParser = + multiSequence + { separators = + [ ( \l r -> BooleanOperation Or [ l, r ], symbol "||" ) + , ( \l r -> BooleanOperation And [ l, r ], symbol "&&" ) + ] + , item = relationParser + , allowNegation = False + } + + +relationParser : Parser Expression +relationParser = + let + inner = + succeed (\a f -> f a) + |= addsubtractionParser + |. spaces + |= oneOf + [ succeed (\o r l -> succeed <| RelationOperation o l r) + |= relationOperationParser + |. spaces + |= addsubtractionParser + , succeed succeed + ] + in + Parser.andThen identity inner + + +relationOperationParser : Parser RelationOperation +relationOperationParser = + oneOf + [ succeed LessThanOrEquals |. symbol "<=" + , succeed GreaterThanOrEquals |. symbol ">=" + , succeed LessThan |. symbol "<" + , succeed GreaterThan |. symbol ">" + , succeed Equals |. symbol "==" + , succeed Assign |. symbol "=" + ] + + +addsubtractionParser : Parser Expression +addsubtractionParser = + multiSequence + { separators = + [ ( BinaryOperation Add, symbol "+" ) + , ( BinaryOperation Subtract, symbol "-" ) + ] + , item = multidivisionParser + , allowNegation = False + } + + +type alias SequenceData = + { separators : List ( Expression -> Expression -> Expression, Parser () ) + , item : Parser Expression + , allowNegation : Bool + } + + +multiSequence : SequenceData -> Parser Expression +multiSequence data = + succeed identity + |= data.item + |. spaces + |> Parser.andThen + (\first -> + loop first (\expr -> multiSequenceHelp data expr) + ) + + +multiSequenceHelp : + SequenceData + -> Expression + -> Parser (Step Expression Expression) +multiSequenceHelp { allowNegation, separators, item } acc = + let + separated = + separators + |> List.map + (\( f, parser ) -> + Parser.succeed (\mn e -> Loop <| f acc <| mn e) + |= (if allowNegation then + Parser.oneOf + [ Parser.succeed (UnaryOperation Negate) + |. Parser.symbol "-" + , Parser.succeed identity + ] + + else + Parser.succeed identity + ) + |. parser + |. spaces + |= item + |. spaces + ) + |> Parser.oneOf + in + Parser.oneOf + [ separated + , Parser.succeed (Done acc) + ] + + +multidivisionParser : Parser Expression +multidivisionParser = + multiSequence + { separators = + [ ( BinaryOperation By, symbol "*" ) + , ( BinaryOperation Div, symbol "/" ) + ] + , item = unaryParser + , allowNegation = False + } + + +unaryParser : Parser Expression +unaryParser = + Parser.oneOf + [ succeed (UnaryOperation Negate) + |. symbol "-" + |= atomParser + , atomParser + ] + + +atomParser : Parser Expression +atomParser = + succeed (\a f -> f a) + |= oneOf + [ succeed (\a f -> f a) + |. symbol "(" + |. spaces + |= Parser.lazy (\_ -> expressionParser) + |. spaces + |. symbol ")" + |= maybeDot + , succeed (Bool True) |. symbol "true" + , succeed (Bool False) |. symbol "false" + , succeed (\a f md -> md <| f a) + |= Parser.map .name identifierWithSuffixParser + |. spaces + |= oneOf + [ succeed (\args v -> Call v args) + |= sequence + { start = "(" + , separator = "," + , item = Parser.lazy <| \_ -> expressionParser + , end = ")" + , trailing = Forbidden + , spaces = spaces + } + , succeed (\arg v -> Arr (toVariableOrConstant v) arg) + |. symbol "[" + |. spaces + |= Parser.lazy (\_ -> expressionParser) + |. spaces + |. symbol "]" + , succeed toVariableOrConstant + ] + |= maybeDot + , Parser.andThen tryParseNumber <| + getChompedString <| + succeed () + |. chompIf (\c -> c == '.' || Char.isDigit c) + |. chompWhile (\c -> c == '.' || Char.isDigit c) + ] + |. spaces + |= oneOf + [ succeed PostfixIncrement + |. symbol "++" + , succeed PostfixDecrement + |. symbol "--" + , succeed identity + ] + + +toVariableOrConstant : String -> Expression +toVariableOrConstant s = + if String.toUpper s == s then + Constant s + + else + Variable s + + +maybeDot : Parser (Expression -> Expression) +maybeDot = + oneOf + [ succeed (\p v -> Dot v p) + |. symbol "." + |= identifierParser + , succeed identity + ] + + +tryParseNumber : String -> Parser Expression +tryParseNumber n = + case String.toInt n of + Just i -> + succeed <| Int i + + Nothing -> + case String.toFloat n of + Just f -> + succeed <| Float f + + Nothing -> + problem "Expected a number" diff --git a/codegen/Glsl/PrettyPrinter.elm b/codegen/Glsl/PrettyPrinter.elm new file mode 100644 index 00000000..78ac860a --- /dev/null +++ b/codegen/Glsl/PrettyPrinter.elm @@ -0,0 +1,338 @@ +module Glsl.PrettyPrinter exposing (function, statement) + +import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Step(..), Trailing(..), loop) + + +function : Function -> String +function fun = + if fun.hasSuffix then + "(" + ++ fun.name + ++ "Decl, " + ++ fun.name + ++ ") = fun" + ++ String.fromInt (List.length fun.args) + ++ " " + ++ fun.returnType + ++ "T " + ++ "(\"" + ++ fun.name + ++ "\" ++ suffix)" + ++ " " + ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ " <| \\" + ++ String.join " " (List.map Tuple.second fun.args) + ++ " -> " + ++ (statement fun.body |> String.split "\n" |> String.join " ") + + else + fun.name + ++ "Couple = fun" + ++ String.fromInt (List.length fun.args) + ++ " " + ++ fun.returnType + ++ "T \"" + ++ fun.name + ++ "\" " + ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ " <| \\" + ++ String.join " " (List.map Tuple.second fun.args) + ++ " ->\n " + ++ (statement fun.body |> String.split "\n" |> String.join "\n ") + ++ "\n\n" + ++ fun.name + ++ "Decl = Tuple.first " + ++ fun.name + ++ "Couple\n" + ++ fun.name + ++ " = Tuple.second " + ++ fun.name + ++ "Couple" + + +statement : Statement -> String +statement stat = + case stat of + Expression e next -> + "expr " + ++ prettyPrintExpression e + ++ " <| \\_ ->\n" + ++ statement next + + For var from LessThan to step loop next -> + (if step then + "for (\"" + + else + "forDown (\"" + ) + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement loop + ++ ") <| \\_ ->\n" + ++ statement next + + For var from LessThanOrEquals to step loop next -> + (if step then + "forLeq (\"" + + else + "forLeqDown (\"" + ) + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement loop + ++ ") <| \\_ ->\n" + ++ statement next + + For var from GreaterThan to step loop next -> + (if step then + "for (\"" + + else + "forDown (\"" + ) + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement loop + ++ ") <| \\_ ->\n" + ++ statement next + + For var from GreaterThanOrEquals to step loop next -> + (if step then + "forLeq (\"" + + else + "forLeqDown (\"" + ) + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement loop + ++ ") <| \\_ ->\n" + ++ statement next + + If cond ifTrue next -> + "if_ " + ++ prettyPrintExpression cond + ++ "(\n" + ++ statement ifTrue + ++ ") <| \\_ ->\n" + ++ statement next + + Return e -> + "(return <| " ++ prettyPrintExpression e ++ ")\n" + + Nop -> + "nop\n" + + Def t n v next -> + "def " + ++ t + ++ "T \"" + ++ n + ++ "\" (" + ++ prettyPrintExpression v + ++ ") <| \\" + ++ n + ++ " -> \n" + ++ statement next + + Decl _ _ _ -> + "TODO branch 'Decl _ _ _' not implemented" + + For _ _ _ _ _ _ _ -> + "TODO branch 'For _ _ _ _ _ _ _' not implemented" + + +prettyPrintExpression : Expression -> String +prettyPrintExpression e = + let + lisp args = + "(" ++ String.join " " args ++ ")" + in + case e of + Float f -> + if f == 0 then + "zero" + + else if f == 1 then + "one" + + else + lisp [ "float", String.fromFloat f ] + + Int i -> + lisp [ "int", String.fromInt i ] + + Bool b -> + lisp + [ "bool" + , if b then + "True" + + else + "False" + ] + + Dot v sw -> + prettyPrintExpression v ++ "." ++ sw + + Variable v -> + v + + Constant c -> + case String.split "_" c of + [] -> + "constants.???" + + h :: t -> + let + toTitle s = + case String.uncons s of + Nothing -> + "" + + Just ( sh, st ) -> + String.cons (Char.toUpper sh) (String.toLower st) + in + "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) + + Call "float" [ arg ] -> + lisp [ "floatCast", prettyPrintExpression arg ] + + Call n args -> + if String.startsWith "vec" n then + if List.all ((==) (Int 0)) args then + n ++ "Zero" + + else + lisp <| + n + :: List.map + (\c -> + case c of + Int i -> + prettyPrintExpression (Float <| toFloat i) + + _ -> + prettyPrintExpression c + ) + args + + else if n == "atan" then + if List.length args == 2 then + lisp <| "atan2_" :: List.map prettyPrintExpression args + + else + lisp <| "atan_" :: List.map prettyPrintExpression args + + else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then + lisp <| (n ++ "_") :: List.map prettyPrintExpression args + + else + lisp <| n :: List.map prettyPrintExpression args + + Arr l r -> + lisp [ "arr", prettyPrintExpression l, prettyPrintExpression r ] + + Ternary c l r -> + lisp [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] + + UnaryOperation Negate ex -> + lisp [ "negate_", prettyPrintExpression ex ] + + BinaryOperation op l r -> + lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] + + BooleanOperation op es -> + lisp + [ prettyPrintBooleanOperation op + , "[" + , String.join ", " <| List.map prettyPrintExpression es + , "]" + ] + + RelationOperation rop l r -> + lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] + + PostfixIncrement c -> + lisp [ "postfixIncrement", prettyPrintExpression c ] + + PostfixDecrement c -> + lisp [ "postfixDecrement", prettyPrintExpression c ] + + +prettyPrintRelationOperation : RelationOperation -> String +prettyPrintRelationOperation op = + case op of + LessThan -> + "lt" + + LessThanOrEquals -> + "leq" + + Equals -> + "eq" + + Assign -> + "assign" + + NotEquals -> + "neq" + + GreaterThanOrEquals -> + "geq" + + GreaterThan -> + "gt" + + +prettyPrintBooleanOperation : BooleanOperation -> String +prettyPrintBooleanOperation op = + case op of + And -> + "ands" + + Or -> + "ors" + + +prettyPrintBinaryOperation : BinaryOperation -> String +prettyPrintBinaryOperation op = + case op of + Add -> + "add" + + Subtract -> + "subtract" + + By -> + "by" + + Div -> + "div" diff --git a/codegen/Glsl/Simplify.elm b/codegen/Glsl/Simplify.elm new file mode 100644 index 00000000..41fbad91 --- /dev/null +++ b/codegen/Glsl/Simplify.elm @@ -0,0 +1,58 @@ +module Glsl.Simplify exposing (expression, function, statement) + +import Glsl.Types exposing (BooleanOperation, Expression(..), Function, Statement(..)) + + +function : Function -> Function +function f = + { f | body = statement f.body } + + +statement : Statement -> Statement +statement s = + case s of + Nop -> + Nop + + Expression e n -> + Expression (expression e) (statement n) + + For v from rel to step inner next -> + For v (expression from) rel (expression to) step (statement inner) (statement next) + + If cond t f -> + If (expression cond) (statement t) (statement f) + + Return e -> + Return (expression e) + + Def t n v next -> + Def t n (expression v) (statement next) + + Decl t n next -> + Decl t n (statement next) + + +expression : Expression -> Expression +expression e = + case e of + BooleanOperation op es -> + es + |> List.map expression + |> List.concatMap + (\c -> + case c of + BooleanOperation cop ces -> + if op == cop then + ces + + else + [ c ] + + _ -> + [ c ] + ) + |> BooleanOperation op + + _ -> + e diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm new file mode 100644 index 00000000..77d236c6 --- /dev/null +++ b/codegen/Glsl/Types.elm @@ -0,0 +1,64 @@ +module Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) + + +type alias Function = + { returnType : String + , name : String + , args : List ( String, String ) + , body : Statement + , hasSuffix : Bool + } + + +type Statement + = Expression Expression Statement + | For String Expression RelationOperation Expression Bool Statement Statement + | If Expression Statement Statement + | Return Expression + | Def String String Expression Statement + | Decl String String Statement + | Nop + + +type RelationOperation + = LessThanOrEquals + | LessThan + | Equals + | Assign + | NotEquals + | GreaterThanOrEquals + | GreaterThan + + +type BinaryOperation + = Add + | Subtract + | By + | Div + + +type BooleanOperation + = And + | Or + + +type UnaryOperation + = Negate + + +type Expression + = Float Float + | Int Int + | Bool Bool + | Dot Expression String + | Variable String + | Constant String + | Call String (List Expression) + | Arr Expression Expression + | Ternary Expression Expression Expression + | UnaryOperation UnaryOperation Expression + | BinaryOperation BinaryOperation Expression Expression + | BooleanOperation BooleanOperation (List Expression) + | RelationOperation RelationOperation Expression Expression + | PostfixIncrement Expression + | PostfixDecrement Expression diff --git a/codegen/elm.codegen.json b/codegen/elm.codegen.json new file mode 100644 index 00000000..40850565 --- /dev/null +++ b/codegen/elm.codegen.json @@ -0,0 +1,11 @@ +{ + "elm-codegen-version": "0.2.0", + "codegen-helpers": { + "packages": { + "elm/core": "1.0.5" + }, + "local": [ + "codegen/helpers/" + ] + } +} \ No newline at end of file diff --git a/glslParser/elm.json b/codegen/elm.json similarity index 67% rename from glslParser/elm.json rename to codegen/elm.json index 2ab30435..72cb13d8 100644 --- a/glslParser/elm.json +++ b/codegen/elm.json @@ -1,7 +1,7 @@ { "type": "application", "source-directories": [ - "src" + "." ], "elm-version": "0.19.1", "dependencies": { @@ -9,24 +9,22 @@ "elm/browser": "1.0.2", "elm/core": "1.0.5", "elm/html": "1.0.0", + "elm/json": "1.1.3", "elm/parser": "1.1.0", - "mdgriffith/elm-ui": "1.1.8", - "the-sett/elm-syntax-dsl": "5.2.2" + "mdgriffith/elm-codegen": "2.0.0", + "mdgriffith/elm-ui": "1.1.8" }, "indirect": { - "Chadtech/elm-bool-extra": "2.4.2", - "elm/json": "1.1.3", "elm/time": "1.0.0", "elm/url": "1.0.0", "elm/virtual-dom": "1.0.2", "elm-community/basics-extra": "4.1.0", - "elm-community/list-extra": "8.4.0", - "elm-community/maybe-extra": "5.2.0", + "elm-community/list-extra": "8.6.0", "miniBill/elm-unicode": "1.0.2", "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.7", + "stil4m/elm-syntax": "7.2.9", "stil4m/structured-writer": "1.0.3", - "the-sett/elm-pretty-printer": "2.2.3" + "the-sett/elm-pretty-printer": "3.0.0" } }, "test-dependencies": { diff --git a/glslParser/.gitignore b/glslParser/.gitignore deleted file mode 100644 index dcaf7169..00000000 --- a/glslParser/.gitignore +++ /dev/null @@ -1 +0,0 @@ -index.html diff --git a/glslParser/src/GlslConverter.elm b/glslParser/src/GlslConverter.elm deleted file mode 100644 index 2e483f3e..00000000 --- a/glslParser/src/GlslConverter.elm +++ /dev/null @@ -1,1018 +0,0 @@ -module GlslConverter exposing (main) - -import Browser -import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbars, spacing, text, width) -import Element.Border as Border -import Element.Font as Font -import Element.Input as Input -import Html -import Parser exposing ((|.), (|=), DeadEnd, Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) - - -type alias Model = - { input : String - , output : String - } - - -type Msg - = Input String - - -main : Program () Model Msg -main = - Browser.sandbox - { init = init - , view = Element.layout [ width fill, height fill ] << view - , update = update - } - - -init : Model -init = - let - i = - """{ - - - -}""" - in - { input = i - , output = toOutput i - } - - -view : Model -> Element Msg -view model = - row - [ padding 10 - , spacing 10 - , width fill - , height fill - ] - [ input model.input - , output model.output - ] - - -input : String -> Element Msg -input value = - Input.multiline - [ width fill - , height fill - , spacing 10 - ] - { onChange = Input - , text = value - , placeholder = Nothing - , label = Input.labelAbove [] <| text "Input (GLSL function or expression)" - , spellcheck = False - } - - -output : String -> Element Msg -output value = - let - bordering = - el - [ width fill - , height fill - , Border.width 1 - , Font.family [ Font.typeface "Fira Code", Font.monospace ] - , padding 10 - , scrollbars - ] - in - if String.contains "problem" value then - paragraph [] [ text value ] - |> bordering - - else - let - tc = - Html.pre [] [ Html.text value ] - |> Element.html - |> bordering - in - column - [ spacing 10 - , width fill - , height fill - ] - [ text "Output (Elm code)" - , tc - ] - - -update : Msg -> Model -> Model -update msg model = - case msg of - Input i -> - { model | input = i, output = toOutput i } - - -toOutput : String -> String -toOutput i = - case parse i of - Err e -> - Debug.toString e - - Ok o -> - prettyPrint <| simplifyEither o - - -simplifyEither : Either Function Statement -> Either Function Statement -simplifyEither o = - case o of - Left f -> - Left <| simplifyFunction f - - Right s -> - Right <| simplifyStatement s - - -simplifyFunction : Function -> Function -simplifyFunction f = - { f | body = simplifyStatement f.body } - - -simplifyStatement : Statement -> Statement -simplifyStatement s = - case s of - Nop -> - Nop - - Expression e n -> - Expression (simplify e) (simplifyStatement n) - - For v from rel to step inner next -> - For v (simplify from) rel (simplify to) step (simplifyStatement inner) (simplifyStatement next) - - If cond t f -> - If (simplify cond) (simplifyStatement t) (simplifyStatement f) - - Return e -> - Return (simplify e) - - Def t n v next -> - Def t n (simplify v) (simplifyStatement next) - - Decl t n next -> - Decl t n (simplifyStatement next) - - -simplify : Expression -> Expression -simplify e = - case e of - BooleanOperation op es -> - es - |> List.map simplify - |> List.concatMap - (\c -> - case c of - BooleanOperation cop ces -> - if op == cop then - ces - - else - [ c ] - - _ -> - [ c ] - ) - |> BooleanOperation op - - _ -> - e - - -type alias Function = - { returnType : String - , name : String - , args : List ( String, String ) - , body : Statement - , hasSuffix : Bool - } - - -type Statement - = Expression Expression Statement - | For String Expression RelationOperation Expression Bool Statement Statement - | If Expression Statement Statement - | Return Expression - | Def String String Expression Statement - | Decl String String Statement - | Nop - - -type RelationOperation - = LessThanOrEquals - | LessThan - | Equals - | Assign - | NotEquals - | GreaterThanOrEquals - | GreaterThan - - -type BinaryOperation - = Add - | Subtract - | By - | Div - - -type BooleanOperation - = And - | Or - - -type UnaryOperation - = Negate - - -type Expression - = Float Float - | Int Int - | Bool Bool - | Dot Expression String - | Variable String - | Constant String - | Call String (List Expression) - | Arr Expression Expression - | Ternary Expression Expression Expression - | UnaryOperation UnaryOperation Expression - | BinaryOperation BinaryOperation Expression Expression - | BooleanOperation BooleanOperation (List Expression) - | RelationOperation RelationOperation Expression Expression - | PostfixIncrement Expression - | PostfixDecrement Expression - - -type Either a b - = Left a - | Right b - - -parse : String -> Result (List DeadEnd) (Either Function Statement) -parse = - Parser.run <| - succeed identity - |. spaces - |= oneOf - [ Parser.map Left functionParser - , Parser.map Right statementParser - ] - |. spaces - |. Parser.end - - -functionParser : Parser Function -functionParser = - succeed (\returnType { name, hasSuffix } args body -> { returnType = returnType, name = name, hasSuffix = hasSuffix, args = args, body = body }) - |= typeParser - |. spaces - |= identifierWithSuffixParser - |. spaces - |= sequence - { start = "(" - , end = ")" - , spaces = spaces - , separator = "," - , item = argParser - , trailing = Forbidden - } - |. spaces - |= statementParser - - -argParser : Parser ( String, String ) -argParser = - succeed Tuple.pair - |= typeParser - |. spaces - |= identifierParser - - -identifierWithSuffixParser : Parser { name : String, hasSuffix : Bool } -identifierWithSuffixParser = - succeed (\name hasSuffix -> { name = name, hasSuffix = hasSuffix }) - |= identifierParser - |= oneOf - [ succeed True |. symbol "\"\"\" ++ suffix ++ \"\"\"" - , succeed False - ] - - -identifierParser : Parser String -identifierParser = - getChompedString - (succeed () - |. chompIf (\c -> Char.isAlpha c || c == '_') - |. chompWhile (\c -> Char.isAlphaNum c || c == '_') - ) - - -typeParser : Parser String -typeParser = - [ "void", "bool", "int", "float", "vec2", "vec3", "vec4", "mat3" ] - |> List.map (\s -> succeed s |. symbol s) - |> oneOf - - -statementParser : Parser Statement -statementParser = - Parser.lazy <| \_ -> - oneOf - [ blockParser - , returnParser - , ifParser - , forParser - , defParser - , expressionStatementParser - ] - - -expressionStatementParser : Parser Statement -expressionStatementParser = - Parser.succeed Expression - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |= maybeStatementParser - - -ifParser : Parser Statement -ifParser = - Parser.succeed If - |. symbol "if" - |. spaces - |. symbol "(" - |. spaces - |= expressionParser - |. spaces - |. symbol ")" - |. spaces - |= statementParser - |. spaces - |= maybeStatementParser - - -maybeStatementParser : Parser Statement -maybeStatementParser = - oneOf [ statementParser, succeed Nop ] - - -forParser : Parser Statement -forParser = - Parser.succeed For - |. symbol "for" - |. spaces - |. symbol "(" - |. spaces - |. symbol "int" - |. spaces - |= identifierParser - |. spaces - |. symbol "=" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |. identifierParser - |. spaces - |= relationOperationParser - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |. identifierParser - |. spaces - |= oneOf [ succeed True |. symbol "++", succeed False |. symbol "--" ] - |. spaces - |. symbol ")" - |. spaces - |= statementParser - |. spaces - |= maybeStatementParser - - -returnParser : Parser Statement -returnParser = - Parser.succeed Return - |. symbol "return" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - - -blockParser : Parser Statement -blockParser = - Parser.succeed identity - |. symbol "{" - |. spaces - |= maybeStatementParser - |. spaces - |. symbol "}" - - -defParser : Parser Statement -defParser = - succeed Def - |= typeParser - |. spaces - |= identifierParser - |. spaces - |. symbol "=" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |= maybeStatementParser - - -expressionParser : Parser Expression -expressionParser = - ternaryParser - - -ternaryParser : Parser Expression -ternaryParser = - Parser.succeed (\c f -> f c) - |= booleanParser - |. spaces - |= oneOf - [ succeed (\t f c -> Ternary c t f) - |. symbol "?" - |. spaces - |= booleanParser - |. spaces - |. symbol ":" - |. spaces - |= Parser.lazy (\_ -> ternaryParser) - , succeed identity - ] - - -booleanParser : Parser Expression -booleanParser = - multiSequence - { separators = - [ ( \l r -> BooleanOperation Or [ l, r ], symbol "||" ) - , ( \l r -> BooleanOperation And [ l, r ], symbol "&&" ) - ] - , item = relationParser - , allowNegation = False - } - - -relationParser : Parser Expression -relationParser = - let - inner = - succeed (\a f -> f a) - |= addsubtractionParser - |. spaces - |= oneOf - [ succeed (\o r l -> succeed <| RelationOperation o l r) - |= relationOperationParser - |. spaces - |= addsubtractionParser - , succeed succeed - ] - in - Parser.andThen identity inner - - -relationOperationParser : Parser RelationOperation -relationOperationParser = - oneOf - [ succeed LessThanOrEquals |. symbol "<=" - , succeed GreaterThanOrEquals |. symbol ">=" - , succeed LessThan |. symbol "<" - , succeed GreaterThan |. symbol ">" - , succeed Equals |. symbol "==" - , succeed Assign |. symbol "=" - ] - - -addsubtractionParser : Parser Expression -addsubtractionParser = - multiSequence - { separators = - [ ( BinaryOperation Add, symbol "+" ) - , ( BinaryOperation Subtract, symbol "-" ) - ] - , item = multidivisionParser - , allowNegation = False - } - - -type alias SequenceData = - { separators : List ( Expression -> Expression -> Expression, Parser () ) - , item : Parser Expression - , allowNegation : Bool - } - - -multiSequence : SequenceData -> Parser Expression -multiSequence data = - succeed identity - |= data.item - |. spaces - |> Parser.andThen - (\first -> - loop first (\expr -> multiSequenceHelp data expr) - ) - - -multiSequenceHelp : - SequenceData - -> Expression - -> Parser (Step Expression Expression) -multiSequenceHelp { allowNegation, separators, item } acc = - let - separated = - separators - |> List.map - (\( f, parser ) -> - Parser.succeed (\mn e -> Loop <| f acc <| mn e) - |= (if allowNegation then - Parser.oneOf - [ Parser.succeed (UnaryOperation Negate) - |. Parser.symbol "-" - , Parser.succeed identity - ] - - else - Parser.succeed identity - ) - |. parser - |. spaces - |= item - |. spaces - ) - |> Parser.oneOf - in - Parser.oneOf - [ separated - , Parser.succeed (Done acc) - ] - - -multidivisionParser : Parser Expression -multidivisionParser = - multiSequence - { separators = - [ ( BinaryOperation By, symbol "*" ) - , ( BinaryOperation Div, symbol "/" ) - ] - , item = unaryParser - , allowNegation = False - } - - -unaryParser : Parser Expression -unaryParser = - Parser.oneOf - [ succeed (UnaryOperation Negate) - |. symbol "-" - |= atomParser - , atomParser - ] - - -atomParser : Parser Expression -atomParser = - succeed (\a f -> f a) - |= oneOf - [ succeed (\a f -> f a) - |. symbol "(" - |. spaces - |= Parser.lazy (\_ -> expressionParser) - |. spaces - |. symbol ")" - |= maybeDot - , succeed (Bool True) |. symbol "true" - , succeed (Bool False) |. symbol "false" - , succeed (\a f md -> md <| f a) - |= Parser.map .name identifierWithSuffixParser - |. spaces - |= oneOf - [ succeed (\args v -> Call v args) - |= sequence - { start = "(" - , separator = "," - , item = Parser.lazy <| \_ -> expressionParser - , end = ")" - , trailing = Forbidden - , spaces = spaces - } - , succeed (\arg v -> Arr (toVariableOrConstant v) arg) - |. symbol "[" - |. spaces - |= Parser.lazy (\_ -> expressionParser) - |. spaces - |. symbol "]" - , succeed toVariableOrConstant - ] - |= maybeDot - , Parser.andThen tryParseNumber <| - getChompedString <| - succeed () - |. chompIf (\c -> c == '.' || Char.isDigit c) - |. chompWhile (\c -> c == '.' || Char.isDigit c) - ] - |. spaces - |= oneOf - [ succeed PostfixIncrement - |. symbol "++" - , succeed PostfixDecrement - |. symbol "--" - , succeed identity - ] - - -toVariableOrConstant : String -> Expression -toVariableOrConstant s = - if String.toUpper s == s then - Constant s - - else - Variable s - - -maybeDot : Parser (Expression -> Expression) -maybeDot = - oneOf - [ succeed (\p v -> Dot v p) - |. symbol "." - |= identifierParser - , succeed identity - ] - - -tryParseNumber : String -> Parser Expression -tryParseNumber n = - case String.toInt n of - Just i -> - succeed <| Int i - - Nothing -> - case String.toFloat n of - Just f -> - succeed <| Float f - - Nothing -> - problem "Expected a number" - - -prettyPrint : Either Function Statement -> String -prettyPrint e = - case e of - Left f -> - prettyPrintFunction f - - Right s -> - prettyPrintStatement s - - -prettyPrintFunction : Function -> String -prettyPrintFunction fun = - if fun.hasSuffix then - "(" - ++ fun.name - ++ "Decl, " - ++ fun.name - ++ ") = fun" - ++ String.fromInt (List.length fun.args) - ++ " " - ++ fun.returnType - ++ "T " - ++ "(\"" - ++ fun.name - ++ "\" ++ suffix)" - ++ " " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) - ++ " <| \\" - ++ String.join " " (List.map Tuple.second fun.args) - ++ " -> " - ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join " ") - - else - fun.name - ++ "Couple = fun" - ++ String.fromInt (List.length fun.args) - ++ " " - ++ fun.returnType - ++ "T \"" - ++ fun.name - ++ "\" " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) - ++ " <| \\" - ++ String.join " " (List.map Tuple.second fun.args) - ++ " ->\n " - ++ (prettyPrintStatement fun.body |> String.split "\n" |> String.join "\n ") - ++ "\n\n" - ++ fun.name - ++ "Decl = Tuple.first " - ++ fun.name - ++ "Couple\n" - ++ fun.name - ++ " = Tuple.second " - ++ fun.name - ++ "Couple" - - -prettyPrintStatement : Statement -> String -prettyPrintStatement stat = - case stat of - Expression e next -> - "expr " - ++ prettyPrintExpression e - ++ " <| \\_ ->\n" - ++ prettyPrintStatement next - - For var from LessThan to step loop next -> - (if step then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ prettyPrintStatement loop - ++ ") <| \\_ ->\n" - ++ prettyPrintStatement next - - For var from LessThanOrEquals to step loop next -> - (if step then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ prettyPrintStatement loop - ++ ") <| \\_ ->\n" - ++ prettyPrintStatement next - - - For var from GreaterThan to step loop next -> - (if step then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ prettyPrintStatement loop - ++ ") <| \\_ ->\n" - ++ prettyPrintStatement next - - For var from GreaterThanOrEquals to step loop next -> - (if step then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ prettyPrintStatement loop - ++ ") <| \\_ ->\n" - ++ prettyPrintStatement next - - If cond ifTrue next -> - "if_ " - ++ prettyPrintExpression cond - ++ "(\n" - ++ prettyPrintStatement ifTrue - ++ ") <| \\_ ->\n" - ++ prettyPrintStatement next - - Return e -> - "(return <| " ++ prettyPrintExpression e ++ ")\n" - - Nop -> - "nop\n" - - Def t n v next -> - "def " - ++ t - ++ "T \"" - ++ n - ++ "\" (" - ++ prettyPrintExpression v - ++ ") <| \\" - ++ n - ++ " -> \n" - ++ prettyPrintStatement next - - Decl _ _ _ -> - "TODO branch 'Decl _ _ _' not implemented" - - For _ _ _ _ _ _ _ -> - "TODO branch 'For _ _ _ _ _ _ _' not implemented" - - -prettyPrintExpression : Expression -> String -prettyPrintExpression e = - let - lisp args = - "(" ++ String.join " " args ++ ")" - in - case e of - Float f -> - if f == 0 then - "zero" - - else if f == 1 then - "one" - - else - lisp [ "float", String.fromFloat f ] - - Int i -> - lisp [ "int", String.fromInt i ] - - Bool b -> - lisp - [ "bool" - , if b then - "True" - - else - "False" - ] - - Dot v sw -> - prettyPrintExpression v ++ "." ++ sw - - Variable v -> - v - - Constant c -> - case String.split "_" c of - [] -> - "constants.???" - - h :: t -> - let - toTitle s = - case String.uncons s of - Nothing -> - "" - - Just ( sh, st ) -> - String.cons (Char.toUpper sh) (String.toLower st) - in - "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) - - Call "float" [ arg ] -> - lisp [ "floatCast", prettyPrintExpression arg ] - - Call n args -> - if String.startsWith "vec" n then - if List.all ((==) (Int 0)) args then - n ++ "Zero" - - else - lisp <| - n - :: List.map - (\c -> - case c of - Int i -> - prettyPrintExpression (Float <| toFloat i) - - _ -> - prettyPrintExpression c - ) - args - - else if n == "atan" then - if List.length args == 2 then - lisp <| "atan2_" :: List.map prettyPrintExpression args - - else - lisp <| "atan_" :: List.map prettyPrintExpression args - - else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then - lisp <| (n ++ "_") :: List.map prettyPrintExpression args - - else - lisp <| n :: List.map prettyPrintExpression args - - Arr l r -> - lisp [ "arr", prettyPrintExpression l, prettyPrintExpression r ] - - Ternary c l r -> - lisp [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] - - UnaryOperation Negate ex -> - lisp [ "negate_", prettyPrintExpression ex ] - - BinaryOperation op l r -> - lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] - - BooleanOperation op es -> - lisp - [ prettyPrintBooleanOperation op - , "[" - , String.join ", " <| List.map prettyPrintExpression es - , "]" - ] - - RelationOperation rop l r -> - lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] - - PostfixIncrement c -> - lisp [ "postfixIncrement", prettyPrintExpression c ] - - PostfixDecrement c -> - lisp [ "postfixDecrement", prettyPrintExpression c ] - - -prettyPrintRelationOperation : RelationOperation -> String -prettyPrintRelationOperation op = - case op of - LessThan -> - "lt" - - LessThanOrEquals -> - "leq" - - Equals -> - "eq" - - Assign -> - "assign" - - NotEquals -> - "neq" - - GreaterThanOrEquals -> - "geq" - - GreaterThan -> - "gt" - - -prettyPrintBooleanOperation : BooleanOperation -> String -prettyPrintBooleanOperation op = - case op of - And -> - "ands" - - Or -> - "ors" - - -prettyPrintBinaryOperation : BinaryOperation -> String -prettyPrintBinaryOperation op = - case op of - Add -> - "add" - - Subtract -> - "subtract" - - By -> - "by" - - Div -> - "div" From 6c88839af628a07b98c08b4c7cf6909987f64055 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Fri, 9 Dec 2022 01:57:27 +0100 Subject: [PATCH 073/139] Adding codegen --- .gitignore | 2 + Makefile | 5 + codegen/Generate.elm | 834 +++++++++++++++++++++++++++++++- codegen/Glsl/Parser.elm | 59 ++- codegen/Glsl/Types.elm | 33 +- codegen/elm.json | 7 +- codegen/functions.glsl | 478 ++++++++++++++++++ codegen/helpers/Glsl/Helper.elm | 22 + elm.json | 3 +- 9 files changed, 1404 insertions(+), 39 deletions(-) create mode 100644 Makefile create mode 100644 codegen/functions.glsl create mode 100644 codegen/helpers/Glsl/Helper.elm diff --git a/.gitignore b/.gitignore index 54f3f1a5..0cabce1d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ elm-stuff .cache node_modules /dist +/src/optimized.js +generated # Ignore Yarn caches .yarn/* diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..0fd00b1e --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +.PHONY: all +all: generated/Glsl.elm + +generated/Glsl.elm: codegen/functions.glsl codegen/Generate.elm codegen/helpers/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile + elm-codegen run --flags-from $< diff --git a/codegen/Generate.elm b/codegen/Generate.elm index a42c2942..c4266bf3 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -1,28 +1,822 @@ module Generate exposing (main) +import Dict exposing (Dict) import Elm import Elm.Annotation as Type import Gen.CodeGen.Generate as Generate -import Gen.Helper +import Gen.Debug +import Gen.Dict +import Gen.Glsl.Helper +import Glsl.Parser +import Glsl.Types exposing (BinaryOperation(..), Expression(..), Function, Statement(..), Type(..)) +import List.Extra +import Parser exposing ((|.), (|=), Parser) +import Parser.Workaround +import Result.Extra +import Set exposing (Set) -main : Program {} () () +main : Program String () () main = - Generate.run - [ file - ] - - -file : Elm.File -file = - Elm.file [ "Glsl" ] - [ Elm.declaration "hello" - (Elm.string "World!") - - -- Here's an example of using a helper file! - -- Add functions to codegen/helpers/{Whatever}.elm - -- run elm-codegen install - -- Then you can call those functions using import Gen.{Whatever} - , Elm.declaration "usingAHelper" - (Gen.Helper.add5 20) - ] + Generate.fromText + (\glsl -> + [ Elm.file [ "Glsl" ] (generate glsl) + ] + ) + + +generate : String -> List Elm.Declaration +generate glsl = + case parseFile glsl of + Err e -> + Gen.Debug.todo "Error parsing file" + |> Elm.declaration "err" + |> Elm.withDocumentation (errorToString e) + |> List.singleton + + Ok functions -> + let + env : Env + env = + List.foldl + (\( { name, returnType, args }, _ ) -> + functionHasType + name + (List.map Tuple.first args) + returnType + ) + { functionsEnv = builtinFunctions + , variablesEnv = builtinUniforms + } + functions + + maybeDecls : Result String (List (List Elm.Declaration)) + maybeDecls = + Result.Extra.combineMap + (functionToDeclarations env) + functions + in + case maybeDecls of + Ok decls -> + declarationsDictionary functions :: List.concat decls + + Err e -> + "Error generating file" + |> Gen.Debug.todo + |> Elm.declaration "err" + |> Elm.withDocumentation e + |> List.singleton + + +functionHasType : String -> List Type -> Type -> Env -> Env +functionHasType baseName argTypes returnType env = + { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } + + +declarationsDictionary : List ( Function, String ) -> Elm.Declaration +declarationsDictionary functions = + functions + |> List.map + (\( { name }, _ ) -> + Elm.tuple + (Elm.string name) + (Elm.withType Type.string <| + Elm.val (name ++ "Body") + ) + ) + |> Gen.Dict.fromList + |> Elm.declaration "declarationsDictionary" + |> Elm.expose + + +errorToString : List Parser.DeadEnd -> String +errorToString deadEnds = + deadEnds + |> List.map deadEndToString + |> String.join "\n" + + +deadEndToString : Parser.DeadEnd -> String +deadEndToString { row, col, problem } = + "R " ++ String.fromInt row ++ " C " ++ String.fromInt col ++ " " ++ problemToString problem + + +problemToString : Parser.Problem -> String +problemToString problem = + case problem of + Parser.Expecting e -> + "Expecting " ++ e + + Parser.ExpectingInt -> + "Expecting Int" + + Parser.ExpectingHex -> + "Expecting Hex" + + Parser.ExpectingOctal -> + "Expecting Octal" + + Parser.ExpectingBinary -> + "Expecting Binary" + + Parser.ExpectingFloat -> + "Expecting Float" + + Parser.ExpectingNumber -> + "Expecting Number" + + Parser.ExpectingVariable -> + "Expecting Variable" + + Parser.ExpectingSymbol _ -> + "Expecting Symbol" + + Parser.ExpectingKeyword _ -> + "Expecting Keyword" + + Parser.ExpectingEnd -> + "Expecting End" + + Parser.UnexpectedChar -> + "Unexpected char" + + Parser.Problem p -> + p + + Parser.BadRepeat -> + "Bad repeat" + + +type alias Env = + { functionsEnv : Dict String Type + , variablesEnv : Dict String Type + } + + +functionToDeclarations : Env -> ( Function, String ) -> Result String (List Elm.Declaration) +functionToDeclarations env ( function, body ) = + let + argDecls : List ( String, Maybe Type.Annotation ) + argDecls = + List.map + (\( _, name ) -> + ( name + , Just Gen.Glsl.Helper.annotation_.expression + ) + ) + function.args + + envWithArgs : Env + envWithArgs = + List.foldl (\( type_, name ) -> variableHasType name type_) env function.args + + maybeDeps : Result String (Set String) + maybeDeps = + findDepsStatement envWithArgs function.body + |> Result.mapError (\e -> e ++ " while generating " ++ function.name) + in + Result.map + (\deps -> + let + expr : List Elm.Expression -> Elm.Expression + expr args = + Gen.Glsl.Helper.call_.call + (Elm.string function.name) + (Elm.list args) + (deps + |> Set.toList + |> List.map Elm.string + |> Elm.list + ) + |> Elm.withType Gen.Glsl.Helper.annotation_.expression + in + [ Elm.string body + |> Elm.declaration (function.name ++ "Body") + , Elm.function argDecls expr + |> Elm.declaration function.name + |> Elm.expose + ] + ) + maybeDeps + + +variableHasType : String -> Type -> Env -> Env +variableHasType var type_ env = + { env | variablesEnv = Dict.insert var type_ env.variablesEnv } + + +union : List (Result String (Set comparable)) -> Result String (Set comparable) +union = + List.foldl (Result.map2 Set.union) (Ok Set.empty) + + +findDepsStatement : Env -> Statement -> Result String (Set String) +findDepsStatement env statement = + case statement of + If cond true false -> + union + [ findDepsExpression env cond + , findDepsStatement env true + , findDepsStatement env false + ] + + Expression e cont -> + union + [ findDepsExpression env e + , findDepsStatement env cont + ] + + For { var, from, to, step } cont -> + let + newEnv : Env + newEnv = + variableHasType var TInt env + in + union + [ findDepsExpression env from + , findDepsExpression env to + , findDepsStatement newEnv step + , findDepsStatement env cont + ] + + Return e -> + findDepsExpression env e + + Def { type_, var, val } cont -> + let + newEnv : Env + newEnv = + variableHasType var type_ env + in + union + [ findDepsExpression env val + , findDepsStatement newEnv cont + ] + + Decl { type_, var } cont -> + let + newEnv : Env + newEnv = + variableHasType var type_ env + in + findDepsStatement newEnv cont + + Nop -> + Ok Set.empty + + +findDepsExpression : Env -> Expression -> Result String (Set String) +findDepsExpression env = + let + go : Expression -> Result String ( Type, Set String ) + go expr = + case expr of + Float _ -> + Ok ( TFloat, Set.empty ) + + Int _ -> + Ok ( TInt, Set.empty ) + + Bool _ -> + Ok ( TBool, Set.empty ) + + Dot e field -> + Result.andThen + (\( et, deps ) -> + Result.map + (\t -> + ( t + , deps + ) + ) + (case ( et, String.length field ) of + ( TIVec2, 1 ) -> + Ok TInt + + ( _, 1 ) -> + Ok TFloat + + ( _, 2 ) -> + Ok TVec2 + + ( _, 3 ) -> + Ok TVec3 + + _ -> + Err <| "Unknown size when accessing field " ++ field + ) + ) + (go e) + + Variable v -> + case Dict.get v env.variablesEnv of + Nothing -> + Err <| "Couldn't find variable " ++ v + + Just t -> + Ok ( t, Set.empty ) + + Constant "P32M1" -> + Ok ( TInt, Set.empty ) + + Constant "P31" -> + Ok ( TInt, Set.empty ) + + Constant c -> + Err <| "TODO: findDepsExpression _ (Constant \"" ++ c ++ "\")" + + Call f args -> + args + |> Result.Extra.combineMap go + |> Result.map List.unzip + |> Result.andThen + (\( argTypes, argDeps ) -> + let + deps = + if Dict.member fname builtinFunctions then + List.foldl Set.union Set.empty argDeps + + else + List.foldl Set.union (Set.singleton fname) argDeps + + fname = + fullName f argTypes + in + case Dict.get fname env.functionsEnv of + Nothing -> + Err <| "Function " ++ fname ++ " not found" + + Just to -> + Ok ( to, deps ) + ) + + Arr l r -> + --union [ go l, go r ] + Err "TODO: findDepsExpression _ (Arr _ _)" + + Ternary c t f -> + Result.map3 + (\( _, cd ) ( tt, td ) ( _, fd ) -> + ( tt, Set.union cd td |> Set.union fd ) + ) + (go c) + (go t) + (go f) + + UnaryOperation _ e -> + go e + + BinaryOperation bop l r -> + Result.andThen + (\( ( lt, ld ), ( rt, rd ) ) -> + Result.map + (\t -> ( t, Set.union ld rd )) + (if lt == rt then + Ok lt + + else + case ( lt, rt ) of + ( TFloat, _ ) -> + Ok rt + + ( _, TFloat ) -> + Ok lt + + ( TInt, _ ) -> + Ok rt + + ( _, TInt ) -> + Ok lt + + _ -> + Err <| "Don't know what the result of " ++ typeToString lt ++ " " ++ binaryOperationToString bop ++ " " ++ typeToString rt + ) + ) + (Result.map2 Tuple.pair + (go l) + (go r) + ) + + BooleanOperation _ es -> + es + |> Result.Extra.combineMap go + |> Result.map + (\res -> + let + ( _, deps ) = + List.unzip res + in + ( TBool, List.foldl Set.union Set.empty deps ) + ) + + RelationOperation _ l r -> + Result.map2 + (\( _, ld ) ( _, rd ) -> + ( TBool, Set.union ld rd ) + ) + (go l) + (go r) + + PostfixIncrement e -> + go e + + PostfixDecrement e -> + go e + in + go >> Result.map Tuple.second + + +typeToString : Type -> String +typeToString t = + case t of + TFloat -> + "float" + + TInt -> + "int" + + TVec2 -> + "vec2" + + TIVec2 -> + "ivec2" + + TVec3 -> + "vec3" + + TIVec3 -> + "ivec3" + + TVec4 -> + "vec4" + + TIVec4 -> + "ivec4" + + TMat3 -> + "mat3" + + TVoid -> + "void" + + TBool -> + "bool" + + +binaryOperationToString : BinaryOperation -> String +binaryOperationToString bop = + case bop of + Add -> + "+" + + Subtract -> + "-" + + By -> + "*" + + Div -> + "/" + + +fullName : String -> List Type -> String +fullName baseName argTypes = + let + typeToShort : Type -> String + typeToShort t = + case t of + TFloat -> + "1" + + TInt -> + "i1" + + TVec2 -> + "2" + + TIVec2 -> + "i2" + + TVec3 -> + "3" + + TIVec3 -> + "i3" + + TVec4 -> + "4" + + TIVec4 -> + "i4" + + TMat3 -> + "m3" + + TVoid -> + "v" + + TBool -> + "b1" + in + String.concat (baseName :: List.map typeToShort argTypes) + + +builtinUniforms : Dict String Type +builtinUniforms = + [ ( "u_whiteLines", TFloat ) + , ( "u_completelyReal", TFloat ) + , ( "u_drawAxes", TFloat ) + , ( "u_zoomCenter", TVec2 ) + , ( "u_viewportWidth", TFloat ) + , ( "u_canvasWidth", TFloat ) + , ( "u_canvasHeight", TFloat ) + , ( "u_phi", TFloat ) + , ( "u_theta", TFloat ) + ] + |> Dict.fromList + + +builtinFunctions : Dict String Type +builtinFunctions = + let + overload : List String -> List ( String, Type ) -> List ( String, Type ) + overload names kinds = + List.Extra.lift2 + (\name ( suffix, result ) -> ( name ++ suffix, result )) + names + kinds + + regular : List ( String, Type ) + regular = + [ builtin_v_v + , builtin_v_s + , builtin_vv_v + , builtin_vv_s + , builtin_vs_v + , builtin_sv_v + , builtin_vvv_v + , builtin_vss_v + , builtin_ssv_v + , builtin_vvs_v + ] + |> List.concatMap (\( names, kinds ) -> overload names kinds) + + vecs : List ( String, Type ) + vecs = + [ ( 2, TVec2 ) + , ( 3, TVec3 ) + , ( 4, TVec4 ) + ] + |> List.concatMap + (\( size, type_ ) -> + List.map + (\opt -> + ( "vec" ++ String.fromInt size ++ opt, type_ ) + ) + ([ "1", "i1" ] + |> List.repeat size + |> List.Extra.cartesianProduct + |> List.map String.concat + |> (++) [ "i1", "1", "13" ] + ) + ) + + ivecs : List ( String, Type ) + ivecs = + [ ( 2, TVec2 ) + , ( 3, TVec3 ) + , ( 4, TVec4 ) + ] + |> List.concatMap + (\( size, type_ ) -> + List.map + (\opt -> + ( "ivec" ++ String.fromInt size ++ opt, type_ ) + ) + ([ "i1" ] + |> List.repeat size + |> List.Extra.cartesianProduct + |> List.map String.concat + |> (++) [ "i1" ] + ) + ) + + others : List ( String, Type ) + others = + [ ( "cross33", TVec3 ) + , ( "floati1", TFloat ) + , ( "int1", TInt ) + ] + in + Dict.fromList <| regular ++ vecs ++ ivecs ++ others + + +builtin_vv_s : ( List String, List ( String, Type ) ) +builtin_vv_s = + ( [ -- Geometric + "distance" + , "dot" + ] + , [ ( "11", TFloat ) + , ( "22", TFloat ) + , ( "33", TFloat ) + , ( "44", TFloat ) + ] + ) + + +builtin_vvs_v : ( List String, List ( String, Type ) ) +builtin_vvs_v = + ( [ --Geometric + "refract" + + -- Other + , "mix" + ] + , [ ( "111", TFloat ) + , ( "221", TVec2 ) + , ( "331", TVec3 ) + , ( "441", TVec4 ) + ] + ) + + +builtin_ssv_v : ( List String, List ( String, Type ) ) +builtin_ssv_v = + ( [ -- Other + "smoothstep" + ] + , [ ( "111", TFloat ) + , ( "112", TVec2 ) + , ( "113", TVec3 ) + , ( "114", TVec4 ) + ] + ) + + +builtin_vss_v : ( List String, List ( String, Type ) ) +builtin_vss_v = + ( [ -- Other + "clamp" + ] + , [ ( "111", TFloat ) + , ( "211", TVec2 ) + , ( "311", TVec3 ) + , ( "411", TVec4 ) + ] + ) + + +builtin_vvv_v : ( List String, List ( String, Type ) ) +builtin_vvv_v = + ( [ -- Other + "clamp" + , "mix" + , "smoothstep" + + -- Geometry + , "faceforward" + ] + , [ ( "111", TFloat ) + , ( "222", TVec2 ) + , ( "333", TVec3 ) + , ( "444", TVec4 ) + ] + ) + + +builtin_sv_v : ( List String, List ( String, Type ) ) +builtin_sv_v = + ( [ -- Other + "step" + ] + , [ ( "11", TFloat ) + , ( "12", TVec2 ) + , ( "13", TVec3 ) + , ( "14", TVec4 ) + ] + ) + + +builtin_vs_v : ( List String, List ( String, Type ) ) +builtin_vs_v = + ( [ -- Comparison + "min" + , "max" + + -- Other + , "mod" + ] + , [ ( "11", TFloat ) + , ( "21", TVec2 ) + , ( "31", TVec3 ) + , ( "41", TVec4 ) + ] + ) + + +builtin_vv_v : ( List String, List ( String, Type ) ) +builtin_vv_v = + ( [ -- Comparison + "min" + , "max" + + -- Complex and power + , "pow" + + -- Trig + , "atan" + + -- Geometry + , "reflect" + + -- Other + , "mod" + , "step" + ] + , [ ( "11", TFloat ) + , ( "22", TVec2 ) + , ( "33", TVec3 ) + , ( "44", TVec4 ) + ] + ) + + +builtin_v_s : ( List String, List ( String, Type ) ) +builtin_v_s = + ( [ -- Geometric + "length" + ] + , [ ( "1", TFloat ) + , ( "2", TFloat ) + , ( "3", TFloat ) + , ( "4", TFloat ) + ] + ) + + +builtin_v_v : ( List String, List ( String, Type ) ) +builtin_v_v = + ( [ -- Rounding + "ceil" + , "floor" + , "round" + , "fract" + + -- Complex and power + , "sign" + , "exp" + , "log" + , "abs" + , "exp2" + , "log2" + , "sqrt" + , "inversesqrt" + + -- Trig + , "radians" + , "degrees" + , "sin" + , "cos" + , "tan" + , "asin" + , "acos" + , "atan" + , "normalize" + ] + , [ ( "1", TFloat ) + , ( "2", TVec2 ) + , ( "3", TVec3 ) + , ( "4", TVec4 ) + ] + ) + + +parseFile : String -> Result (List Parser.DeadEnd) (List ( Function, String )) +parseFile glsl = + Parser.run + (fileParser glsl) + glsl + + +fileParser : String -> Parser (List ( Function, String )) +fileParser glsl = + Parser.succeed (List.filterMap identity) + |= Parser.sequence + { start = "" + , separator = "" + , item = + Parser.oneOf + [ Parser.succeed Nothing + |. Parser.Workaround.lineCommentAfter "//" + , Parser.succeed + (\begin parsed end -> Just ( parsed, String.slice begin end glsl )) + |= Parser.getOffset + |= Glsl.Parser.function + |= Parser.getOffset + ] + , end = "" + , trailing = Parser.Optional + , spaces = Parser.spaces + } + |. Parser.end diff --git a/codegen/Glsl/Parser.elm b/codegen/Glsl/Parser.elm index 7a930d85..a0ce7b50 100644 --- a/codegen/Glsl/Parser.elm +++ b/codegen/Glsl/Parser.elm @@ -1,7 +1,9 @@ module Glsl.Parser exposing (function, statement) -import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) +import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) +import Html.Attributes exposing (id) import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) +import Parser.Workaround function : Parser Function @@ -23,7 +25,7 @@ function = |= statement -argParser : Parser ( String, String ) +argParser : Parser ( Type, String ) argParser = succeed Tuple.pair |= typeParser @@ -50,10 +52,19 @@ identifierParser = ) -typeParser : Parser String +typeParser : Parser Type typeParser = - [ "void", "bool", "int", "float", "vec2", "vec3", "vec4", "mat3" ] - |> List.map (\s -> succeed s |. symbol s) + [ ( "void", TVoid ) + , ( "bool", TBool ) + , ( "float", TFloat ) + , ( "int", TInt ) + , ( "vec2", TVec2 ) + , ( "ivec2", TIVec2 ) + , ( "vec3", TVec3 ) + , ( "vec4", TVec4 ) + , ( "mat3", TMat3 ) + ] + |> List.map (\( s, t ) -> succeed t |. symbol s) |> oneOf @@ -62,7 +73,8 @@ statement = Parser.lazy <| \_ -> oneOf - [ blockParser + [ commentParser + , blockParser , returnParser , ifParser , forParser @@ -104,7 +116,17 @@ maybeStatementParser = forParser : Parser Statement forParser = - Parser.succeed For + Parser.succeed + (\var from op to direction step -> + For + { var = var + , from = from + , op = op + , to = to + , direction = direction + , step = step + } + ) |. symbol "for" |. spaces |. symbol "(" @@ -129,7 +151,10 @@ forParser = |. spaces |. identifierParser |. spaces - |= oneOf [ succeed True |. symbol "++", succeed False |. symbol "--" ] + |= oneOf + [ succeed PlusPlus |. symbol "++" + , succeed MinusMinus |. symbol "--" + ] |. spaces |. symbol ")" |. spaces @@ -148,6 +173,14 @@ returnParser = |. symbol ";" +commentParser : Parser Statement +commentParser = + Parser.succeed identity + |. Parser.Workaround.lineCommentAfter "//" + |. spaces + |= maybeStatementParser + + blockParser : Parser Statement blockParser = Parser.succeed identity @@ -160,7 +193,14 @@ blockParser = defParser : Parser Statement defParser = - succeed Def + succeed + (\type_ var val -> + Def + { type_ = type_ + , var = var + , val = val + } + ) |= typeParser |. spaces |= identifierParser @@ -235,6 +275,7 @@ relationOperationParser = , succeed LessThan |. symbol "<" , succeed GreaterThan |. symbol ">" , succeed Equals |. symbol "==" + , succeed NotEquals |. symbol "!=" , succeed Assign |. symbol "=" ] diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm index 77d236c6..eced8817 100644 --- a/codegen/Glsl/Types.elm +++ b/codegen/Glsl/Types.elm @@ -1,31 +1,50 @@ -module Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) +module Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) type alias Function = - { returnType : String + { returnType : Type , name : String - , args : List ( String, String ) + , args : List ( Type, String ) , body : Statement , hasSuffix : Bool } +type Type + = TFloat + | TInt + | TVec2 + | TIVec2 + | TIVec3 + | TIVec4 + | TVec3 + | TVec4 + | TMat3 + | TVoid + | TBool + + type Statement = Expression Expression Statement - | For String Expression RelationOperation Expression Bool Statement Statement + | For { var : String, from : Expression, op : RelationOperation, to : Expression, direction : ForDirection, step : Statement } Statement | If Expression Statement Statement | Return Expression - | Def String String Expression Statement - | Decl String String Statement + | Def { type_ : Type, var : String, val : Expression } Statement + | Decl { type_ : Type, var : String } Statement | Nop +type ForDirection + = PlusPlus + | MinusMinus + + type RelationOperation = LessThanOrEquals | LessThan | Equals - | Assign | NotEquals + | Assign | GreaterThanOrEquals | GreaterThan diff --git a/codegen/elm.json b/codegen/elm.json index 72cb13d8..545c6944 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -11,16 +11,19 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/parser": "1.1.0", + "elm-community/list-extra": "8.6.0", + "elm-community/result-extra": "2.4.0", "mdgriffith/elm-codegen": "2.0.0", - "mdgriffith/elm-ui": "1.1.8" + "mdgriffith/elm-ui": "1.1.8", + "pithub/elm-parser-bug-workaround": "1.0.0" }, "indirect": { "elm/time": "1.0.0", "elm/url": "1.0.0", "elm/virtual-dom": "1.0.2", "elm-community/basics-extra": "4.1.0", - "elm-community/list-extra": "8.6.0", "miniBill/elm-unicode": "1.0.2", + "pithub/elm-parser-extra": "1.0.0", "rtfeldman/elm-hex": "1.0.0", "stil4m/elm-syntax": "7.2.9", "stil4m/structured-writer": "1.0.3", diff --git a/codegen/functions.glsl b/codegen/functions.glsl new file mode 100644 index 00000000..bcb31d17 --- /dev/null +++ b/codegen/functions.glsl @@ -0,0 +1,478 @@ +/////////// +// Utils // +/////////// + +float sinh(float x) { return 0.5 * (exp(x) - exp(-x)); } +float cosh(float x) { return 0.5 * (exp(x) + exp(-x)); } +float tanh(float x) { + if (abs(x) > 10.) + return sign(x); + float p = exp(x); + float m = exp(-x); + return (p - m) / (p + m); +} + +float cbrt(float v) { return sign(v) * pow(abs(v), 1. / 3.); } + +bool between(float x, float low, float high) { return low <= x && x <= high; } + +vec2 dup(float x) { return vec2(x, x); } + +vec3 hl2rgb(float h, float l) { + vec3 rgb = clamp(abs(mod(h * 6. + vec3(0., 4., 2.), 6.) - 3.) - 1., 0., 1.); + return l + (rgb - .5) * (1. - abs(2. * l - 1.)); +} + +vec2 dup(float x) { return vec2(x, x); } + +vec4 gnum(float f) { return vec4(f, 0, 0, 0); } + +float atanPlus(float y, float x) { + return mod(radians(360.) + atan(y, x), radians(360.)); +} + +vec2 iexpand(vec2 v) { + return v * (vec2(1., 1.) + sign(v) * vec2(-0.000001, 0.000001)); +} + +float thetaDelta(float theta) { + if (u_whiteLines < 1.) + return 100.; + float thetaSix = theta * u_whiteLines + .5; + float thetaNeigh = .05; + return abs(fract(thetaSix) - .5) / thetaNeigh; +} + +// Shifts for the recursive algorithm +int left_shift(int i) { return i * 2; } +int left_shift_increment(int i) { return i * 2 + 1; } + +ivec2 increment(ivec2 i) { + return i.x == P32M1 ? ivec2(0, i.y + 1) : ivec2(i.x + 1, i.y); +} + +ivec2 left_shift(ivec2 i) { + return i.x >= P31 ? ivec2(2 * (i.x - P31), i.y * 2 + 1) : 2 * i; +} + +ivec2 left_shift_increment(ivec2 i) { return increment(left_shift(i)); } + +bool is_even(int i) { return i / 2 * 2 == i; } +bool is_odd(int i) { return i / 2 * 2 != i; } +bool is_even(ivec2 i) { return is_even(i.x); } + +ivec2 right_shift(ivec2 i) { + return is_odd(i.y) ? ivec2(i.x / 2 + P31, i.y / 2) : i / 2; +} + +int right_shift(int i) { return i / 2; } + +///////////// +// Complex // +///////////// + +// Constants +vec2 ci() { return vec2(0, 1); } + +vec2 cpi() { return vec2(radians(180.), 0); } + +vec2 ce() { return vec2(exp(1.), 0); } + +// Operations +vec2 cby(vec2 a, vec2 b) { + return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); +} + +vec2 cdiv(vec2 a, vec2 b) { + float k = 1. / dot(b, b); + float r = k * dot(a, b); + float i = k * (a.y * b.x - a.x * b.y); + return vec2(r, i); +} + +vec2 cpow(vec2 w, vec2 z) { + if (w.x >= 0. && w.y == 0. && z.y == 0.) { + return vec2(pow(w.x, z.x), 0); + } + return cexp(cby(cln(w), z)); +} + +// Trig +vec2 csin(vec2 z) { + if (z.y == 0.0) { + return vec2(sin(z.x), 0); + } + return vec2(sin(z.x) * cosh(z.y), cos(z.x) * sinh(z.y)); +} + +vec2 ccos(vec2 z) { + if (z.y == 0.0) { + return vec2(cos(z.x), 0); + } + return vec2(cos(z.x) * cosh(z.y), sin(z.x) * sinh(z.y)); +} + +vec2 ctan(vec2 z) { + if (z.y == 0.0) { + return vec2(tan(z.x), 0); + } + return cdiv(csin(z), ccos(z)); +} + +vec2 casin(vec2 z) { + vec2 s = csqrt(vec2(1, 0) - cby(z, z)); + vec2 arg = s - cby(vec2(0, 1), z); + return cby(vec2(0, 1), cln(arg)); +} + +vec2 cacos(vec2 z) { return cpi() * .5 - casin(z); } + +vec2 catan(vec2 z) { + if (z.y == 0.) { + return vec2(atan(z.x), 0); + } + vec2 o = vec2(1, 0); + vec2 iz = cby(vec2(0, 1), z); + vec2 l = cdiv(o + iz, o - iz); + return -0.5 * cby(vec2(0, 1), cln(l)); +} + +vec2 catan2(vec2 y, vec2 x) { + vec2 z = vec2(x.x - y.y, x.y + y.x); + return vec2(atan(z.y, z.x), 0.); +} + +vec2 csinh(vec2 z) { return .5 * (cexp(z) - cexp(-z)); } +vec2 ccosh(vec2 z) { return .5 * (cexp(z) + cexp(-z)); } + +vec2 ctanh(vec2 z) { + vec2 p = cexp(z); + vec2 m = cexp(-z); + return cdiv(p - m, p + m); +} + +// Power and sign +vec2 cabs(vec2 z) { return vec2(length(z), 0.); } + +vec2 csign(vec2 z) { return vec2(sign(z.x), sign(z.y)); } + +vec2 csqrt(vec2 z) { + if (z.y == 0. && z.x >= 0.) { + return vec2(sqrt(z.x), 0); + } + float r = pow(dot(z, z), .25); + float t = atan(z.y, z.x) * .5; + return r * vec2(cos(t), sin(t)); +} + +vec2 ccbrt(vec2 z) { + if (z.y == 0.) { + return vec2(sign(z.x) * pow(z.x, 1. / 3.), 0); + } + float r = pow(dot(z, z), 1. / 6.); + float t = atan(z.y, z.x) / 3. + (z.x > 0. ? 0. : radians(120.)); + return r * vec2(cos(t), sin(t)); +} + +vec2 csquare(vec2 z) { return cby(z, z); } + +vec2 cln(vec2 z) { + if (z.y == 0. && z.x >= 0.) { + return vec2(log(z.x), 0); + } + float px = length(z); + float py = atan(z.y, z.x); + return vec2(log(px), py); +} + +vec2 clog10(vec2 z) { return cdiv(cln(z), vec2(log(10.), 0)); } + +vec2 cexp(vec2 z) { + if (z.y == 0.) { + return vec2(exp(z.x), 0); + } + return vec2(cos(z.y) * exp(z.x), sin(z.y) * exp(z.x)); +} + +vec2 cre(vec2 z) { return vec2(z.x, 0); } +vec2 cim(vec2 z) { return vec2(z.y, 0); } + +float arg(vec2 v) { return atan(v.y, v.x); } +vec2 carg(vec2 v) { return vec2(atan(v.y, v.x), 0); } + +vec2 cpw(vec2 c, vec2 t, vec2 f) { return c.x > 0. ? t : f; } + +// Rounding +vec2 cceiling(vec2 z) { return ceil(z); } +vec2 cfloor(vec2 z) { return floor(z); } +vec2 cround(vec2 z) { return floor(z + vec2(0.5, 0.5)); } + +// Comparison +vec2 cmin(vec2 l, vec2 r) { return l.x < r.x ? l : r; } +vec2 cmax(vec2 l, vec2 r) { return l.x > r.x ? l : r; } + +// Other +vec2 cmod(vec2 l, vec2 r) { return vec2(mod(l.x, r.x), 0); } + +vec2 cmbrot(vec2 x, vec2 y) { + vec2 c = x + vec2(-y.y, y.x); + float p = length(c - vec2(.25, 0)); + if (c.x <= p - 2.0 * p * p + .25 || length(c + vec2(1, 0)) <= .25) + return vec2(0, 0); + vec2 z = c; + for (int i = 0; i < 4000; i++) { + z = vec2(z.x * z.x - z.y * z.y, 2. * z.x * z.y) + c; + if (length(z) > 1000000.) { + float logLength = log(length(z)); + float nu = log(logLength / log(2.)) / log(2.); + float fi = float(i) - nu; + return vec2(sin(fi), cos(fi)); + } + } + return vec2(0, 0); +} + +////////////// +// Interval // +////////////// + +// Operations +vec2 ineg(vec2 v) { return vec2(-v.y, -v.x); } + +vec2 iby(vec2 l, vec2 r) { + float a = l.x * r.x; + float b = l.x * r.y; + float c = l.y * r.x; + float d = l.y * r.y; + float mn = min(min(a, b), min(c, d)); + float mx = max(max(a, b), max(c, d)); + return vec2(mn, mx); +} + +vec2 iinverse(vec2 y) { + if (y.x <= 0.0 && y.y >= 0.0) + return vec2(-1.0 / 0.0, 1.0 / 0.0); + if (y.y == 0.0) + return vec2(-1.0 / 0.0, 1.0 / y.x); + if (y.x == 0.0) + return vec2(1.0 / y.y, 1.0 / 0.0); + return vec2(1.0 / y.y, 1.0 / y.x); +} + +vec2 idiv(vec2 l, vec2 r) { return iby(l, iinverse(r)); } + +float ipow(float b, int e) { + float fe = float(e); + if (mod(fe, 2.0) == 0.0) + return pow(abs(b), fe); + return b * pow(abs(b), fe - 1.0); +} + +vec2 ipow(vec2 b, int e) { + if (e == 0) + return vec2(1, 1); + if (e == 1) + return b; + float xe = ipow(b.x, e); + float ye = ipow(b.y, e); + float mn = min(xe, ye); + float mx = max(xe, ye); + if (mod(float(e), 2.) == 0. && b.x <= 0. && b.y >= 0.) { + return vec2(min(0., mn), max(0., mx)); + } + return vec2(mn, mx); +} + +vec2 ipow(vec2 b, vec2 e) { + if (e.y - e.x < .000001 && abs(e.x - round(e.x)) < .000001) + return ipow(b, int(e.x)); + return iexp(iby(iln(b), e)); +} + +// Relations +vec2 ilt(vec2 l, vec2 r) { return vec2(r.x - l.y, r.y - l.x); } +vec2 ileq(vec2 l, vec2 r) { return vec2(r.x - l.y, r.y - l.x); } +vec2 ieq(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } +vec2 igeq(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } +vec2 igt(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } + +vec2 iabs(vec2 z) { + if (z.x <= 0. && z.y >= 0.) + return vec2(0, max(z.y, abs(z.x))); + if (z.x <= 0.) + return vec2(-z.y, -z.x); + return z; +} + +vec2 isin(vec2 v) { + if (v.y - v.x > radians(360.)) { + return vec2(-1., 1.); + } + float from = mod(v.x, radians(360.)); // [0, 360°] + float to = from + v.y - v.x; // [0, 720°] + vec2 s = sin(vec2(from, to)); + vec2 res = vec2(min(s.x, s.y), max(s.x, s.y)); + if (between(radians(90.), from, to) || between(radians(90. + 360.), from, to)) + res.y = 1.; + if (between(radians(270.), from, to) || + between(radians(270. + 360.), from, to)) + res.x = -1.; + return res; +} + +vec2 icos(vec2 v) { + vec2 shift = radians(90.) * vec2(1, 1); + return isin(v + shift); +} + +vec2 itan(vec2 z) { return idiv(isin(z), icos(z)); } + +vec2 isinh(vec2 v) { return vec2(sinh(v.x), sinh(v.y)); } + +vec2 icosh(vec2 z) { + if (z.x <= 0. && z.y >= 0.) + return vec2(cosh(0.), max(z.y, abs(z.x))); + if (z.x <= 0.) + return vec2(cosh(-z.y), cosh(-z.x)); + return vec2(cosh(z.x), cosh(z.y)); +} + +vec2 itanh(vec2 z) { return vec2(tanh(z.x), tanh(z.y)); } + +vec2 iasin(vec2 z) { + // Don't use clamp so if z is fully outside range the result is empty + vec2 clamped = vec2(max(z.x, -1.), min(z.y, 1.)); + return asin(clamped); +} + +vec2 iacos(vec2 z) { + // Don't use clamp so if z is fully outside range the result is empty + vec2 clamped = vec2(max(z.x, -1.), min(z.y, 1.)); + return acos(clamped).yx; +} + +vec2 iatan(vec2 z) { return atan(z); } + +vec2 iatan2(vec2 y, vec2 x) { + // TODO: improve this + vec2 r = vec2(atan(y.x, x.x), atan(y.y, x.x)); + vec2 q = vec2(atan(y.x, x.y), atan(y.y, x.y)); + vec2 rs = vec2(min(r.x, r.y), max(r.x, r.y)); + vec2 qs = vec2(min(q.x, q.y), max(q.x, q.y)); + return vec2(min(rs.x, qs.x), max(rs.y, qs.y)); +} + +vec2 ire(vec2 v) { return v; } +vec2 iim(vec2 v) { return vec2(0); } + +vec2 iarg(vec2 z) { + if (z.y < 0.) + return dup(radians(180.)); + if (z.x >= 0.) + return vec2(0); + return vec2(0., radians(180.)); +} + +vec2 isign(vec2 z) { return sign(z); } + +vec2 iexp(vec2 z) { return vec2(exp(z.x), exp(z.y)); } +vec2 iln(vec2 z) { return vec2(log(z.x), log(z.y)); } +vec2 ilog10(vec2 z) { return log(z) / log(10.); } + +vec2 ipw(vec2 c, vec2 t, vec2 f) { + if (c.y <= 0.) + return f; + if (c.x > 0.) + return t; + return vec2(min(t.x, f.x), max(t.y, f.y)); +} + +vec2 isquare(vec2 z) { + vec2 s = z * z; + float mx = max(s.x, s.y); + if (z.x <= 0. && z.y >= 0.) + return vec2(0., mx); + float mn = min(s.x, s.y); + return vec2(mn, mx); +} + +vec2 isqrt(vec2 v) { return vec2(sqrt(max(0., v.x)), sqrt(max(0., v.y))); } +vec2 icbrt(vec2 v) { return vec2(cbrt(v.x), cbrt(v.y)); } + +vec2 imin(vec2 l, vec2 r) { return vec2(min(l.x, r.x), min(l.y, r.y)); } +vec2 imax(vec2 l, vec2 r) { return vec2(max(l.x, r.x), max(l.y, r.y)); } +vec2 imod(vec2 x, vec2 y) { return x + ineg(iby(y, ifloor(idiv(x, y)))); } + +vec2 iceiling(vec2 z) { return ceil(z); } +vec2 ifloor(vec2 z) { return floor(z); } +vec2 iround(vec2 z) { return round(z); } + +////////////////////////////////////////////////// +// With derivatives - used to calculate normals // +////////////////////////////////////////////////// + +// Operations +vec4 gneg(vec4 v) { return -v; } + +vec4 gby(vec4 l, vec4 r) { return vec4(l.x * r.x, l.x * r.yzw + r.x * l.yzw); } + +vec4 gdiv(vec4 l, vec4 r) { + return vec4(l.x / r.x, (r.x * l.yzw - l.x * r.yzw) / pow(r.x, 2.)); +} + +vec4 gpow(vec4 b, int e) { + return vec4(pow(b.x, float(e)), float(e) * pow(b.x, float(e - 1)) * b.yzw); +} +vec4 gpow(vec4 b, vec4 e) { + int ie = int(e.x); + if (float(ie) == e.x && e.y == 0. && e.z == 0. && e.w == 0.) { + return gpow(b, ie); + } + return gexp(gby(gln(b), e)); +} + +vec4 gabs(vec4 v) { return vec4(abs(v.x), sign(v.x) * v.yzw); } + +vec4 gsin(vec4 v) { return vec4(sin(v.x), cos(v.x) * v.yzw); } +vec4 gcos(vec4 v) { return vec4(cos(v.x), -sin(v.x) * v.yzw); } +vec4 gtan(vec4 z) { + float c = cos(z.x); + return vec4(tan(z.x), 1. / (c * c) * z.yzw); +} + +vec4 gsinh(vec4 v) { return vec4(sinh(v.x), cosh(v.x) * v.yzw); } +vec4 gcosh(vec4 v) { return vec4(cosh(v.x), sinh(v.x) * v.yzw); } +vec4 gtanh(vec4 z) { + float c = 1. / cosh(z.x); + return vec4(tanh(z.x), c * c * z.yzw); +} + +vec4 gasin(vec4 v) { return vec4(asin(v.x), v.yzw / sqrt(1. - v.x * v.x)); } +vec4 gacos(vec4 v) { return vec4(acos(v.x), -v.yzw / sqrt(1. - v.x * v.x)); } +vec4 gatan(vec4 v) { return vec4(atan(v.x), v.yzw / (1. + v.x * v.x)); } + +vec4 gatan2(vec4 y, vec4 x) { + return vec4(atan(y.x, x.x), y.yzw / x.yzw / (1. + y.x * y.x / x.x / x.x)); +} + +vec4 gre(vec4 v) { return v; } +vec4 gim(vec4 v) { return vec4(0, 0, 0, 1); } +vec4 garg(vec4 z) { return gnum(z.x >= 0. ? 0. : radians(180.)); } + +vec4 gexp(vec4 z) { return vec4(exp(z.x), exp(z.x) * z.yzw); } +vec4 gln(vec4 z) { return vec4(log(z.x), z.yzw / z.x); } +vec4 glog10(vec4 z) { return vec4(log(z.x), z.yzw / z.x) / log(10.); } +vec4 gpw(vec4 c, vec4 t, vec4 f) { return c.x > 0. ? t : f; } +vec4 gsquare(vec4 z) { return vec4(z.x * z.x, 2. * z.x * z.yzw); } +vec4 gsqrt(vec4 v) { return vec4(sqrt(v.x), .5 * pow(v.x, -.5) * v.yzw); } +vec4 gcbrt(vec4 v) { return vec4(cbrt(v.x), pow(v.x, -2. / 3.) / 3. * v.yzw); } + +vec4 gmin(vec4 l, vec4 r) { return l.x < r.x ? l : r; } +vec4 gmax(vec4 l, vec4 r) { return l.x > r.x ? l : r; } +vec4 gmod(vec4 l, vec4 r) { return vec4(mod(l.x, r.x), l.yzw); } + +vec4 gsign(vec4 v) { return gnum(sign(v.x)); } + +vec4 gceiling(vec4 z) { return gnum(ceil(z.x)); } +vec4 gfloor(vec4 z) { return gnum(floor(z.x)); } +vec4 ground(vec4 z) { return gnum(round(z.x)); } diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl/Helper.elm new file mode 100644 index 00000000..f46b2f90 --- /dev/null +++ b/codegen/helpers/Glsl/Helper.elm @@ -0,0 +1,22 @@ +module Glsl.Helper exposing (..) + +import Set exposing (Set) + + +type alias Expression = + { expr : String + , deps : Set String + } + + +call : String -> List Expression -> List String -> Expression +call name args deps = + { expr = + name + ++ "(" + ++ String.join ", " (List.map .expr args) + ++ ")" + , deps = + List.map .deps args + |> List.foldr Set.union (Set.fromList deps) + } diff --git a/elm.json b/elm.json index 699a92f5..abbee705 100644 --- a/elm.json +++ b/elm.json @@ -2,7 +2,8 @@ "type": "application", "source-directories": [ "src/elm", - "src/elm-extra" + "src/elm-extra", + "generated" ], "elm-version": "0.19.1", "dependencies": { From affc5af1f19553b2350bb209b723fc73ba6f6051 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Fri, 9 Dec 2022 20:09:39 +0100 Subject: [PATCH 074/139] Reorder codegen file so it's valid according to glslangValidator --- Makefile | 2 +- codegen/{functions.glsl => functions.frag} | 121 ++++++++++++--------- 2 files changed, 73 insertions(+), 50 deletions(-) rename codegen/{functions.glsl => functions.frag} (91%) diff --git a/Makefile b/Makefile index 0fd00b1e..56516183 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: all all: generated/Glsl.elm -generated/Glsl.elm: codegen/functions.glsl codegen/Generate.elm codegen/helpers/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile +generated/Glsl.elm: codegen/functions.frag codegen/Generate.elm codegen/helpers/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile elm-codegen run --flags-from $< diff --git a/codegen/functions.glsl b/codegen/functions.frag similarity index 91% rename from codegen/functions.glsl rename to codegen/functions.frag index bcb31d17..b0405284 100644 --- a/codegen/functions.glsl +++ b/codegen/functions.frag @@ -1,3 +1,21 @@ +#define MAX_DEPTH 30 +//#define MAX_DEPTH 60 + +#define P31 2147483648 +#define P32M1 4294967295 + +precision highp float; + +uniform float u_whiteLines; +uniform float u_completelyReal; +uniform float u_drawAxes; +uniform vec2 u_zoomCenter; +uniform float u_viewportWidth; +uniform float u_canvasWidth; +uniform float u_canvasHeight; +uniform float u_phi; +uniform float u_theta; + /////////// // Utils // /////////// @@ -12,6 +30,11 @@ float tanh(float x) { return (p - m) / (p + m); } +float round(float v) { return floor(v + 0.5); } +vec2 round(vec2 v) { return floor(v + 0.5); } +vec3 round(vec3 v) { return floor(v + 0.5); } +vec4 round(vec4 v) { return floor(v + 0.5); } + float cbrt(float v) { return sign(v) * pow(abs(v), 1. / 3.); } bool between(float x, float low, float high) { return low <= x && x <= high; } @@ -23,8 +46,6 @@ vec3 hl2rgb(float h, float l) { return l + (rgb - .5) * (1. - abs(2. * l - 1.)); } -vec2 dup(float x) { return vec2(x, x); } - vec4 gnum(float f) { return vec4(f, 0, 0, 0); } float atanPlus(float y, float x) { @@ -90,6 +111,22 @@ vec2 cdiv(vec2 a, vec2 b) { return vec2(r, i); } +vec2 cln(vec2 z) { + if (z.y == 0. && z.x >= 0.) { + return vec2(log(z.x), 0); + } + float px = length(z); + float py = atan(z.y, z.x); + return vec2(log(px), py); +} + +vec2 cexp(vec2 z) { + if (z.y == 0.) { + return vec2(exp(z.x), 0); + } + return vec2(cos(z.y), sin(z.y)) * exp(z.x); +} + vec2 cpow(vec2 w, vec2 z) { if (w.x >= 0. && w.y == 0. && z.y == 0.) { return vec2(pow(w.x, z.x), 0); @@ -119,6 +156,15 @@ vec2 ctan(vec2 z) { return cdiv(csin(z), ccos(z)); } +vec2 csqrt(vec2 z) { + if (z.y == 0. && z.x >= 0.) { + return vec2(sqrt(z.x), 0); + } + float r = pow(dot(z, z), .25); + float t = atan(z.y, z.x) * .5; + return r * vec2(cos(t), sin(t)); +} + vec2 casin(vec2 z) { vec2 s = csqrt(vec2(1, 0) - cby(z, z)); vec2 arg = s - cby(vec2(0, 1), z); @@ -156,15 +202,6 @@ vec2 cabs(vec2 z) { return vec2(length(z), 0.); } vec2 csign(vec2 z) { return vec2(sign(z.x), sign(z.y)); } -vec2 csqrt(vec2 z) { - if (z.y == 0. && z.x >= 0.) { - return vec2(sqrt(z.x), 0); - } - float r = pow(dot(z, z), .25); - float t = atan(z.y, z.x) * .5; - return r * vec2(cos(t), sin(t)); -} - vec2 ccbrt(vec2 z) { if (z.y == 0.) { return vec2(sign(z.x) * pow(z.x, 1. / 3.), 0); @@ -176,24 +213,8 @@ vec2 ccbrt(vec2 z) { vec2 csquare(vec2 z) { return cby(z, z); } -vec2 cln(vec2 z) { - if (z.y == 0. && z.x >= 0.) { - return vec2(log(z.x), 0); - } - float px = length(z); - float py = atan(z.y, z.x); - return vec2(log(px), py); -} - vec2 clog10(vec2 z) { return cdiv(cln(z), vec2(log(10.), 0)); } -vec2 cexp(vec2 z) { - if (z.y == 0.) { - return vec2(exp(z.x), 0); - } - return vec2(cos(z.y) * exp(z.x), sin(z.y) * exp(z.x)); -} - vec2 cre(vec2 z) { return vec2(z.x, 0); } vec2 cim(vec2 z) { return vec2(z.y, 0); } @@ -250,22 +271,22 @@ vec2 iby(vec2 l, vec2 r) { } vec2 iinverse(vec2 y) { - if (y.x <= 0.0 && y.y >= 0.0) - return vec2(-1.0 / 0.0, 1.0 / 0.0); - if (y.y == 0.0) - return vec2(-1.0 / 0.0, 1.0 / y.x); - if (y.x == 0.0) - return vec2(1.0 / y.y, 1.0 / 0.0); - return vec2(1.0 / y.y, 1.0 / y.x); + if (y.x <= 0. && y.y >= 0.) + return vec2(-1. / 0., 1. / 0.); + if (y.y == 0.) + return vec2(-1. / 0., 1. / y.x); + if (y.x == 0.) + return vec2(1. / y.y, 1. / 0.); + return vec2(1. / y.y, 1. / y.x); } vec2 idiv(vec2 l, vec2 r) { return iby(l, iinverse(r)); } float ipow(float b, int e) { float fe = float(e); - if (mod(fe, 2.0) == 0.0) + if (mod(fe, 2.) == 0.) return pow(abs(b), fe); - return b * pow(abs(b), fe - 1.0); + return b * pow(abs(b), fe - 1.); } vec2 ipow(vec2 b, int e) { @@ -283,6 +304,9 @@ vec2 ipow(vec2 b, int e) { return vec2(mn, mx); } +vec2 iln(vec2 z) { return log(z); } +vec2 iexp(vec2 z) { return exp(z); } + vec2 ipow(vec2 b, vec2 e) { if (e.y - e.x < .000001 && abs(e.x - round(e.x)) < .000001) return ipow(b, int(e.x)); @@ -375,8 +399,6 @@ vec2 iarg(vec2 z) { vec2 isign(vec2 z) { return sign(z); } -vec2 iexp(vec2 z) { return vec2(exp(z.x), exp(z.y)); } -vec2 iln(vec2 z) { return vec2(log(z.x), log(z.y)); } vec2 ilog10(vec2 z) { return log(z) / log(10.); } vec2 ipw(vec2 c, vec2 t, vec2 f) { @@ -399,14 +421,14 @@ vec2 isquare(vec2 z) { vec2 isqrt(vec2 v) { return vec2(sqrt(max(0., v.x)), sqrt(max(0., v.y))); } vec2 icbrt(vec2 v) { return vec2(cbrt(v.x), cbrt(v.y)); } -vec2 imin(vec2 l, vec2 r) { return vec2(min(l.x, r.x), min(l.y, r.y)); } -vec2 imax(vec2 l, vec2 r) { return vec2(max(l.x, r.x), max(l.y, r.y)); } -vec2 imod(vec2 x, vec2 y) { return x + ineg(iby(y, ifloor(idiv(x, y)))); } - vec2 iceiling(vec2 z) { return ceil(z); } vec2 ifloor(vec2 z) { return floor(z); } vec2 iround(vec2 z) { return round(z); } +vec2 imin(vec2 l, vec2 r) { return vec2(min(l.x, r.x), min(l.y, r.y)); } +vec2 imax(vec2 l, vec2 r) { return vec2(max(l.x, r.x), max(l.y, r.y)); } +vec2 imod(vec2 x, vec2 y) { return x + ineg(iby(y, ifloor(idiv(x, y)))); } + ////////////////////////////////////////////////// // With derivatives - used to calculate normals // ////////////////////////////////////////////////// @@ -420,13 +442,16 @@ vec4 gdiv(vec4 l, vec4 r) { return vec4(l.x / r.x, (r.x * l.yzw - l.x * r.yzw) / pow(r.x, 2.)); } -vec4 gpow(vec4 b, int e) { - return vec4(pow(b.x, float(e)), float(e) * pow(b.x, float(e - 1)) * b.yzw); +vec4 gpow(vec4 b, float e) { + return vec4(pow(b.x, e), e * pow(b.x, e - 1.) * b.yzw); } + +vec4 gexp(vec4 z) { return vec4(exp(z.x), exp(z.x) * z.yzw); } +vec4 gln(vec4 z) { return vec4(log(z.x), z.yzw / z.x); } + vec4 gpow(vec4 b, vec4 e) { - int ie = int(e.x); - if (float(ie) == e.x && e.y == 0. && e.z == 0. && e.w == 0.) { - return gpow(b, ie); + if (floor(e.x) == e.x && e.y == 0. && e.z == 0. && e.w == 0.) { + return gpow(b, e.x); } return gexp(gby(gln(b), e)); } @@ -459,8 +484,6 @@ vec4 gre(vec4 v) { return v; } vec4 gim(vec4 v) { return vec4(0, 0, 0, 1); } vec4 garg(vec4 z) { return gnum(z.x >= 0. ? 0. : radians(180.)); } -vec4 gexp(vec4 z) { return vec4(exp(z.x), exp(z.x) * z.yzw); } -vec4 gln(vec4 z) { return vec4(log(z.x), z.yzw / z.x); } vec4 glog10(vec4 z) { return vec4(log(z.x), z.yzw / z.x) / log(10.); } vec4 gpw(vec4 c, vec4 t, vec4 f) { return c.x > 0. ? t : f; } vec4 gsquare(vec4 z) { return vec4(z.x * z.x, 2. * z.x * z.yzw); } From 11ad7a96f2c73c1e9324fad593474ebe3e53698a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Fri, 9 Dec 2022 20:17:26 +0100 Subject: [PATCH 075/139] Moving code around --- codegen/helpers/Glsl/Helper.elm | 171 ++- src/elm/UI/Glsl/Code.elm | 1859 ++++++++++++++++++------------- src/elm/UI/Glsl/Generator.elm | 215 +--- 3 files changed, 1292 insertions(+), 953 deletions(-) diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl/Helper.elm index f46b2f90..ccc0f4ed 100644 --- a/codegen/helpers/Glsl/Helper.elm +++ b/codegen/helpers/Glsl/Helper.elm @@ -1,22 +1,167 @@ -module Glsl.Helper exposing (..) +module Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Mat3(..), RelationOperation(..), Stat(..), Statement(..), TypingFunction, Vec2(..), Vec3(..), Vec4(..), innerCall) import Set exposing (Set) -type alias Expression = - { expr : String +innerCall : String -> List ExprWithDeps -> List String -> ExprWithDeps +innerCall name args deps = + { expr = Call name (List.map .expr args) + , deps = + List.map .deps args + |> List.foldr Set.union (Set.fromList deps) + } + + + +-- Typed expressions + + +type Expression t + = Expression ExprWithDeps + + +type alias ExprWithDeps = + { expr : Expr , deps : Set String } -call : String -> List Expression -> List String -> Expression -call name args deps = - { expr = - name - ++ "(" - ++ String.join ", " (List.map .expr args) - ++ ")" - , deps = - List.map .deps args - |> List.foldr Set.union (Set.fromList deps) +type Expr + = Bool Bool + | Int Int + | Float Float + | Variable String + | And Expr Expr + | Or Expr Expr + | Comparison RelationOperation Expr Expr + | Ternary Expr Expr Expr + | Add Expr Expr + | Subtract Expr Expr + | By Expr Expr + | Div Expr Expr + | Call String (List Expr) + | Negate Expr + | PostfixIncrement Expr + | PostfixDecrement Expr + | Unknown String + | Dot Expr String + | Array Expr Expr + | Assign Expr Expr + | AssignCombo ComboOperation Expr Expr + + +type RelationOperation + = LessThan + | LessThanOrEquals + | Equals + | NotEquals + | GreaterThanOrEquals + | GreaterThan + + +type ComboOperation + = ComboAdd + | ComboSubtract + | ComboBy + | ComboDiv + + +type alias ExpressionX a t = + { a | base : Expression t } + + +type alias Expression1 t = + { base : Expression t } + + +type alias Expression2 = + { base : Expression Vec2 + , x : Expression1 Float + , y : Expression1 Float + , yx : Expression1 Vec2 + } + + +type alias Expression3 = + { base : Expression Vec3 + , x : Expression1 Float + , y : Expression1 Float + , z : Expression1 Float + } + + +type alias Expression4 = + { base : Expression Vec4 + , x : Expression1 Float + , y : Expression1 Float + , z : Expression1 Float + , w : Expression1 Float + , xy : Expression2 + , yx : Expression2 + , yzw : Expression3 + } + + +type alias Expression33 = + { base : Expression Mat3 } + + + +-- Typed statements + + +type Statement r + = Statement + { stat : Stat + , deps : Set String + } + + +type Stat + = If Expr Stat Stat + | IfElse Expr Stat Stat Stat + | For String Expr RelationOperation Expr Expr Stat Stat + | Line String + | Return Expr + | Break + | Continue + | ExpressionStatement Expr Stat + | Decl String Name (Maybe Expr) Stat + | Nop + + +type alias TypingFunction t r = + String -> ( TypedName t r, Expression t -> r ) + + +type TypedName t r + = TypedName Type Name r + + +type Type + = Type String + + +type Name + = Name String + + + +-- Typelevel types. Eh. + + +type Vec2 + = Vec2 Vec2 + + +type Vec3 + = Vec3 Vec3 + + +type Vec4 + = Vec4 Vec4 + + +type Mat3 + = Mat3 Mat3 diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 4fd50df8..d44671b3 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,8 @@ module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDec import Dict exposing (Dict) import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import UI.Glsl.Generator exposing (Constant, Continue, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, Mat3, Statement, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Glsl.Helper exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX) +import UI.Glsl.Generator exposing (Constant, Continue, File, FunDecl, Mat3, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) @@ -36,30 +37,11 @@ constantToGlsl c = return (vec2 (exp one) zero) -cbyTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cbyTuple = - fun2 vec2T "cby" (vec2T "a") (vec2T "b") <| \a b -> - return <| - vec2 - (subtract - (by a.x b.x) - (by a.y b.y) - ) - (add - (by a.x b.y) - (by a.y b.x) - ) - - -cbyDecl : FunDecl -cbyDecl = - Tuple.first cbyTuple - - atanPlusTuple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float ) atanPlusTuple = - fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| \y x -> - return <| mod (add constants.twopi (atan2_ y x)) constants.twopi + fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| + \y x -> + return <| mod (add constants.twopi (atan2_ y x)) constants.twopi atanPlusDecl : FunDecl @@ -102,15 +84,11 @@ dup = Tuple.second dupTuple -cby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cby = - Tuple.second cbyTuple - - cby3Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) cby3Tuple = - fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| \a b c -> - return <| cby (cby a b) c + fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| + \a b c -> + return <| cby (cby a b) c cby3Decl : FunDecl @@ -120,11 +98,15 @@ cby3Decl = cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cdivTuple = - fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| \a b nop -> - def floatT "k" (div one <| dot b b) <| \k -> - def floatT "r" (by k <| dot a b) <| \r -> - def floatT "i" (by k (subtract (by a.y b.x) (by a.x b.y))) <| \i -> - return (vec2 r i) nop + fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| + \a b nop -> + def floatT "k" (div one <| dot b b) <| + \k -> + def floatT "r" (by k <| dot a b) <| + \r -> + def floatT "i" (by k (subtract (by a.y b.x) (by a.x b.y))) <| + \i -> + return (vec2 r i) nop cdivDecl : FunDecl @@ -179,17 +161,18 @@ straightOperationToGlsl op = cpowTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cpowTuple = - fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| \w z -> - return <| - ternary - (ands - [ geq w.x zero - , eq w.y zero - , eq z.y zero - ] - ) - (vec2 (pow w.x z.x) zero) - (cexp <| cby (cln w) z) + fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| + \w z -> + return <| + ternary + (ands + [ geq w.x zero + , eq w.y zero + , eq z.y zero + ] + ) + (vec2 (pow w.x z.x) zero) + (cexp <| cby (cln w) z) cpowDecl : FunDecl @@ -204,8 +187,9 @@ cpow = inegCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) inegCouple = - fun1 vec2T "ineg" (vec2T "v") <| \v -> - return <| negate_ v.yx + fun1 vec2T "ineg" (vec2T "v") <| + \v -> + return <| negate_ v.yx inegDecl : FunDecl @@ -235,14 +219,19 @@ gneg = isquareCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) isquareCouple = - fun1 vec2T "isquare" (vec2T "z") <| \z nop -> - def vec2T "s" (by z z) <| \s -> - def floatT "mx" (max_ s.x s.y) <| \mx -> - if_ (ands [ leq z.x zero, geq z.y zero ]) - (return <| vec2 zero mx) - <| \_ -> - def floatT "mn" (min_ s.x s.y) <| \mn -> - return (vec2 mn mx) nop + fun1 vec2T "isquare" (vec2T "z") <| + \z nop -> + def vec2T "s" (by z z) <| + \s -> + def floatT "mx" (max_ s.x s.y) <| + \mx -> + if_ (ands [ leq z.x zero, geq z.y zero ]) + (return <| vec2 zero mx) + <| + \_ -> + def floatT "mn" (min_ s.x s.y) <| + \mn -> + return (vec2 mn mx) nop isquareDecl : FunDecl @@ -257,8 +246,9 @@ isquare = gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gsquareCouple = - fun1 vec4T "gsquare" (vec4T "z") <| \z -> - return <| vec4_1_3 (by z.x z.x) z.yzw + fun1 vec4T "gsquare" (vec4T "z") <| + \z -> + return <| vec4_1_3 (by z.x z.x) z.yzw gsquareDecl : FunDecl @@ -273,8 +263,9 @@ gsquare = gbyCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gbyCouple = - fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| \l r -> - return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) + fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| + \l r -> + return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) gbyDecl : FunDecl @@ -289,14 +280,21 @@ gby = ibyCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ibyCouple = - fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| \l r nop -> - def floatT "a" (by l.x r.x) <| \a -> - def floatT "b" (by l.x r.y) <| \b -> - def floatT "c" (by l.y r.x) <| \c -> - def floatT "d" (by l.y r.y) <| \d -> - def floatT "mn" (min_ (min_ a b) (min_ c d)) <| \mn -> - def floatT "mx" (max_ (max_ a b) (max_ c d)) <| \mx -> - return (vec2 mn mx) nop + fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| + \l r nop -> + def floatT "a" (by l.x r.x) <| + \a -> + def floatT "b" (by l.x r.y) <| + \b -> + def floatT "c" (by l.y r.x) <| + \c -> + def floatT "d" (by l.y r.y) <| + \d -> + def floatT "mn" (min_ (min_ a b) (min_ c d)) <| + \mn -> + def floatT "mx" (max_ (max_ a b) (max_ c d)) <| + \mx -> + return (vec2 mn mx) nop ibyDecl : FunDecl @@ -311,20 +309,21 @@ iby = iinverseCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iinverseCouple = - fun1 vec2T "iinverse" (vec2T "y") <| \y -> - return <| - ternary - (ands [ leq y.x zero, geq y.y zero ]) - (vec2 (div minusOne zero) (div one zero)) - (ternary - (eq y.y zero) - (vec2 (div minusOne zero) (div one y.x)) - (ternary - (eq y.x zero) - (vec2 (div one y.y) (div one zero)) - (vec2 (div one y.y) (div one y.x)) - ) - ) + fun1 vec2T "iinverse" (vec2T "y") <| + \y -> + return <| + ternary + (ands [ leq y.x zero, geq y.y zero ]) + (vec2 (div minusOne zero) (div one zero)) + (ternary + (eq y.y zero) + (vec2 (div minusOne zero) (div one y.x)) + (ternary + (eq y.x zero) + (vec2 (div one y.y) (div one zero)) + (vec2 (div one y.y) (div one y.x)) + ) + ) iinverseDecl : FunDecl @@ -339,8 +338,9 @@ iinverse = idivCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) idivCouple = - fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| \l r -> - return <| iby l (iinverse r) + fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| + \l r -> + return <| iby l (iinverse r) idivDecl : FunDecl @@ -355,13 +355,14 @@ idiv = gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gdivCouple = - fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| \l r -> - return <| - vec4_1_3 (div l.x r.x) - (divF - (subtract (byF r.x l.yzw) (byF l.x r.yzw)) - (pow r.x <| float 2) - ) + fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| + \l r -> + return <| + vec4_1_3 (div l.x r.x) + (divF + (subtract (byF r.x l.yzw) (byF l.x r.yzw)) + (pow r.x <| float 2) + ) gdivDecl : FunDecl @@ -376,15 +377,17 @@ gdiv = ipowFICouple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ) ipowFICouple = - fun2 floatT "ipow" (floatT "b") (intT "e") <| \b e nop -> - def floatT "fe" (floatCast e) <| \fe -> - return - (ternary - (eq (mod fe (float 2.0)) zero) - (pow (abs_ b) fe) - (by b <| pow (abs_ b) (subtract fe one)) - ) - nop + fun2 floatT "ipow" (floatT "b") (intT "e") <| + \b e nop -> + def floatT "fe" (floatCast e) <| + \fe -> + return + (ternary + (eq (mod fe (float 2.0)) zero) + (pow (abs_ b) fe) + (by b <| pow (abs_ b) (subtract fe one)) + ) + nop ipowFIDecl : FunDecl @@ -399,29 +402,36 @@ ipowFI = ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) ipowICouple = - fun2 vec2T "ipow" (vec2T "b") (intT "e") <| \b e nop -> - if_ (eq e (int 0)) - (return <| vec2 one one) - <| \_ -> - if_ (eq e (int 1)) - (return b) - <| \_ -> - def floatT "xe" (ipowFI b.x e) <| \xe -> - def floatT "ye" (ipowFI b.y e) <| \ye -> - def floatT "mn" (min_ xe ye) <| \mn -> - def floatT "mx" (max_ xe ye) <| \mx -> - return - (ternary - (ands - [ eq (mod (floatCast e) (float 2)) zero - , leq b.x zero - , geq b.y zero - ] - ) - (vec2 (min_ zero mn) (max_ zero mx)) - (vec2 mn mx) - ) - nop + fun2 vec2T "ipow" (vec2T "b") (intT "e") <| + \b e nop -> + if_ (eq e (int 0)) + (return <| vec2 one one) + <| + \_ -> + if_ (eq e (int 1)) + (return b) + <| + \_ -> + def floatT "xe" (ipowFI b.x e) <| + \xe -> + def floatT "ye" (ipowFI b.y e) <| + \ye -> + def floatT "mn" (min_ xe ye) <| + \mn -> + def floatT "mx" (max_ xe ye) <| + \mx -> + return + (ternary + (ands + [ eq (mod (floatCast e) (float 2)) zero + , leq b.x zero + , geq b.y zero + ] + ) + (vec2 (min_ zero mn) (max_ zero mx)) + (vec2 mn mx) + ) + nop ipowIDecl : FunDecl @@ -436,16 +446,17 @@ ipowI = ipowCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) ipowCouple = - fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| \b e -> - return <| - ternary - (ands - [ lt (subtract e.y e.x) (float 0.000001) - , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) - ] - ) - (ipowI b <| intCast e.x) - (iexp <| iby (iln b) e) + fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| + \b e -> + return <| + ternary + (ands + [ lt (subtract e.y e.x) (float 0.000001) + , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) + ] + ) + (ipowI b <| intCast e.x) + (iexp <| iby (iln b) e) ipowDecl : FunDecl @@ -460,11 +471,12 @@ ipow = gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 ) gpowICouple = - fun2 vec4T "gpow" (vec4T "b") (intT "e") <| \b e -> - return <| - vec4_1_3 - (pow b.x <| floatCast e) - (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) + fun2 vec4T "gpow" (vec4T "b") (intT "e") <| + \b e -> + return <| + vec4_1_3 + (pow b.x <| floatCast e) + (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) gpowIDecl : FunDecl @@ -479,12 +491,15 @@ gpowI = gpowCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) gpowCouple = - fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| \b e nop -> - def intT "ie" (intCast e.x) <| \ie -> - if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) - (return <| gpowI b ie) - <| \_ -> - return (gexp <| gby (gln b) e) nop + fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| + \b e nop -> + def intT "ie" (intCast e.x) <| + \ie -> + if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) + (return <| gpowI b ie) + <| + \_ -> + return (gexp <| gby (gln b) e) nop gpowDecl : FunDecl @@ -589,16 +604,17 @@ igt = iabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iabsCouple = - fun1 vec2T "iabs" (vec2T "z") <| \z -> - return <| - ternary - (ands [ leq z.x zero, geq z.y zero ]) - (vec2 zero <| max_ z.y <| abs_ z.x) - (ternary - (leq z.x zero) - (negate_ z.yx) - z - ) + fun1 vec2T "iabs" (vec2T "z") <| + \z -> + return <| + ternary + (ands [ leq z.x zero, geq z.y zero ]) + (vec2 zero <| max_ z.y <| abs_ z.x) + (ternary + (leq z.x zero) + (negate_ z.yx) + z + ) iabsDecl : FunDecl @@ -613,10 +629,12 @@ iabs = iacosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) iacosCouple = - fun1 vec2T "iacos" (vec2T "z") <| \z nop -> - -- Don't use clamp so if z is fully outside range the result is empty - def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| \clamped -> - return (acos2 clamped).yx nop + fun1 vec2T "iacos" (vec2T "z") <| + \z nop -> + -- Don't use clamp so if z is fully outside range the result is empty + def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| + \clamped -> + return (acos2 clamped).yx nop iacosDecl : FunDecl @@ -631,11 +649,12 @@ iacos = gacosCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) gacosCouple = - fun1 vec4T "gacos" (vec4T "v") <| \v -> - return <| - vec4_1_3 - (acos_ v.x) - (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) + fun1 vec4T "gacos" (vec4T "v") <| + \v -> + return <| + vec4_1_3 + (acos_ v.x) + (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) gacosDecl : FunDecl @@ -725,18 +744,20 @@ gln = csinCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csinCouple = - fun1 vec2T "csin" (vec2T "z") <| \z nop -> - def floatT "s" (sin_ z.x) <| \s -> - return - (ternary - (eq z.y zero) - (vec2 s zero) - (vec2 - (by s (cosh z.y)) - (by (cos_ z.x) (sinh z.y)) - ) - ) - nop + fun1 vec2T "csin" (vec2T "z") <| + \z nop -> + def floatT "s" (sin_ z.x) <| + \s -> + return + (ternary + (eq z.y zero) + (vec2 s zero) + (vec2 + (by s (cosh z.y)) + (by (cos_ z.x) (sinh z.y)) + ) + ) + nop csinDecl : FunDecl @@ -751,18 +772,20 @@ csin = ccosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccosCouple = - fun1 vec2T "ccos" (vec2T "z") <| \z nop -> - def floatT "c" (cos_ z.x) <| \c -> - return - (ternary - (eq z.y zero) - (vec2 c zero) - (vec2 - (by c (cosh z.y)) - (by (sin_ z.x) (sinh z.y)) - ) - ) - nop + fun1 vec2T "ccos" (vec2T "z") <| + \z nop -> + def floatT "c" (cos_ z.x) <| + \c -> + return + (ternary + (eq z.y zero) + (vec2 c zero) + (vec2 + (by c (cosh z.y)) + (by (sin_ z.x) (sinh z.y)) + ) + ) + nop ccosDecl : FunDecl @@ -777,11 +800,12 @@ ccos = ctanCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanCouple = - fun1 vec2T "ctan" (vec2T "z") <| \z -> - return <| - ternary (eq z.y zero) - (vec2 (tan_ z.x) zero) - (cdiv (csin z) (ccos z)) + fun1 vec2T "ctan" (vec2T "z") <| + \z -> + return <| + ternary (eq z.y zero) + (vec2 (tan_ z.x) zero) + (cdiv (csin z) (ccos z)) ctanDecl : FunDecl @@ -796,10 +820,13 @@ ctan = casinTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) casinTuple = - fun1 vec2T "casin" (vec2T "z") <| \z nop -> - def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| \s -> - def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| \arg_ -> - return (cby (vec2 zero one) (cln arg_)) nop + fun1 vec2T "casin" (vec2T "z") <| + \z nop -> + def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| + \s -> + def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| + \arg_ -> + return (cby (vec2 zero one) (cln arg_)) nop casinDecl : FunDecl @@ -814,8 +841,9 @@ casin = cacosTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) cacosTuple = - fun1 vec2T "cacos" (vec2T "z") <| \z -> - return <| subtract (vec2 constants.pihalf zero) (casin z) + fun1 vec2T "cacos" (vec2T "z") <| + \z -> + return <| subtract (vec2 constants.pihalf zero) (casin z) cacosDecl : FunDecl @@ -830,14 +858,19 @@ cacos = catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) catanTuple = - fun1 vec2T "catan" (vec2T "z") <| \z nop -> - if_ (eq z.y zero) - (return <| vec2 (atan_ z.x) zero) - <| \_ -> - def vec2T "o" (vec2 one zero) <| \o -> - def vec2T "iz" (cby (vec2 zero one) z) <| \iz -> - def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| \l -> - return (byF (float -0.5) <| cby (vec2 zero one) (cln l)) nop + fun1 vec2T "catan" (vec2T "z") <| + \z nop -> + if_ (eq z.y zero) + (return <| vec2 (atan_ z.x) zero) + <| + \_ -> + def vec2T "o" (vec2 one zero) <| + \o -> + def vec2T "iz" (cby (vec2 zero one) z) <| + \iz -> + def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| + \l -> + return (byF (float -0.5) <| cby (vec2 zero one) (cln l)) nop catanDecl : FunDecl @@ -852,9 +885,11 @@ catan = catan2Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) catan2Tuple = - fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| \y x nop -> - def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| \z -> - return (vec2 (atan2_ z.y z.x) zero) nop + fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| + \y x nop -> + def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| + \z -> + return (vec2 (atan2_ z.y z.x) zero) nop catan2Decl : FunDecl @@ -869,8 +904,9 @@ catan2 = csinhTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csinhTuple = - fun1 vec2T "csinh" (vec2T "z") <| \z -> - return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) + fun1 vec2T "csinh" (vec2T "z") <| + \z -> + return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) csinhDecl : FunDecl @@ -885,8 +921,9 @@ csinh = ccoshTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccoshTuple = - fun1 vec2T "ccosh" (vec2T "z") <| \z -> - return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) + fun1 vec2T "ccosh" (vec2T "z") <| + \z -> + return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) ccoshDecl : FunDecl @@ -901,10 +938,13 @@ ccosh = ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ctanhCouple = - fun1 vec2T "ctanh" (vec2T "z") <| \z nop -> - def vec2T "p" (cexp z) <| \p -> - def vec2T "m" (cexp (negate_ z)) <| \m -> - return (cdiv (subtract p m) (add p m)) nop + fun1 vec2T "ctanh" (vec2T "z") <| + \z nop -> + def vec2T "p" (cexp z) <| + \p -> + def vec2T "m" (cexp (negate_ z)) <| + \m -> + return (cdiv (subtract p m) (add p m)) nop ctanhDecl : FunDecl @@ -986,13 +1026,17 @@ straightFunctionToGlsl name = Tanh11 -> [ Tuple.first <| - fun1 floatT "tanh" (floatT "x") <| \x nop -> - if_ (gt (abs_ x) (float 10)) - (return <| sign x) - <| \_ -> - def floatT "p" (exp x) <| \p -> - def floatT "m" (exp <| negate_ x) <| \m -> - return (div (subtract p m) (add p m)) nop + fun1 floatT "tanh" (floatT "x") <| + \x nop -> + if_ (gt (abs_ x) (float 10)) + (return <| sign x) + <| + \_ -> + def floatT "p" (exp x) <| + \p -> + def floatT "m" (exp <| negate_ x) <| + \m -> + return (div (subtract p m) (add p m)) nop ] Sin22 -> @@ -1216,8 +1260,9 @@ cfloor = croundCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) croundCouple = - fun1 vec2T "cround" (vec2T "z") <| \z -> - return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) + fun1 vec2T "cround" (vec2T "z") <| + \z -> + return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) croundDecl : FunDecl @@ -1262,8 +1307,9 @@ cmax = cmodCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmodCouple = - fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| \l r -> - return <| vec2 (mod l.x r.x) zero + fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| + \l r -> + return <| vec2 (mod l.x r.x) zero cmodDecl : FunDecl @@ -1278,28 +1324,38 @@ cmod = cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) cmbrotCouple = - fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| \x y nop -> - def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| \c -> - def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| \p -> - if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) - (return vec2Zero) - <| \_ -> - def vec2T "z" c <| \z -> - for ( "i", int 0, int 4000 ) - (\i cont -> - expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| \_ -> - if_ (gt (length z) (float 1000000)) - (\_ -> - def floatT "logLength" (log (length z)) <| \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| \fi -> - return (vec2 (sin_ fi) (cos_ fi)) nop - ) - <| - cont - ) - <| \_ -> - return vec2Zero nop + fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| + \x y nop -> + def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| + \c -> + def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| + \p -> + if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) + (return vec2Zero) + <| + \_ -> + def vec2T "z" c <| + \z -> + for ( "i", int 0, int 4000 ) + (\i cont -> + expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| + \_ -> + if_ (gt (length z) (float 1000000)) + (\_ -> + def floatT "logLength" (log (length z)) <| + \logLength -> + def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| + \nu -> + def floatT "fi" (subtract (floatCast i) nu) <| + \fi -> + return (vec2 (sin_ fi) (cos_ fi)) nop + ) + <| + cont + ) + <| + \_ -> + return vec2Zero nop cmbrotDecl : FunDecl @@ -1314,13 +1370,17 @@ cmbrot = csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) csqrtTuple = - fun1 vec2T "csqrt" (vec2T "z") <| \z nop -> - if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (sqrt_ z.x) zero) - <| \_ -> - def floatT "r" (pow (dot z z) (float 0.25)) <| \r -> - def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| \t -> - return (byF r <| vec2 (cos_ t) (sin_ t)) nop + fun1 vec2T "csqrt" (vec2T "z") <| + \z nop -> + if_ (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (sqrt_ z.x) zero) + <| + \_ -> + def floatT "r" (pow (dot z z) (float 0.25)) <| + \r -> + def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| + \t -> + return (byF r <| vec2 (cos_ t) (sin_ t)) nop csqrtDecl : FunDecl @@ -1335,22 +1395,26 @@ csqrt = ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) ccbrtCouple = - fun1 vec2T "ccbrt" (vec2T "z") <| \z nop -> - if_ (eq z.y zero) - (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) - <| \_ -> - def floatT "r" (pow (dot z z) (div one (float 6))) <| \r -> - def floatT - "t" - (add (div (atan2_ z.y z.x) (float 3)) - (ternary - (gt z.x zero) - zero - (radians_ (float 120)) - ) - ) - <| \t -> - return (byF r (vec2 (cos_ t) (sin_ t))) nop + fun1 vec2T "ccbrt" (vec2T "z") <| + \z nop -> + if_ (eq z.y zero) + (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) + <| + \_ -> + def floatT "r" (pow (dot z z) (div one (float 6))) <| + \r -> + def floatT + "t" + (add (div (atan2_ z.y z.x) (float 3)) + (ternary + (gt z.x zero) + zero + (radians_ (float 120)) + ) + ) + <| + \t -> + return (byF r (vec2 (cos_ t) (sin_ t))) nop ccbrtDecl : FunDecl @@ -1380,13 +1444,17 @@ csquare = clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) clnTuple = - fun1 vec2T "cln" (vec2T "z") <| \z nop -> - if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (log z.x) zero) - <| \_ -> - def floatT "px" (length z) <| \px -> - def floatT "py" (atan2_ z.y z.x) <| \py -> - return (vec2 (log px) py) nop + fun1 vec2T "cln" (vec2T "z") <| + \z nop -> + if_ (ands [ eq z.y zero, geq z.x zero ]) + (return <| vec2 (log z.x) zero) + <| + \_ -> + def floatT "px" (length z) <| + \px -> + def floatT "py" (atan2_ z.y z.x) <| + \py -> + return (vec2 (log px) py) nop clnDecl : FunDecl @@ -1753,43 +1821,55 @@ toSrcImplicit suffix e = 7 ( fDecl, f ) = - fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| \x y nop -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> - return - (ternary (gt (abs_ complex.y) (float epsilon)) - zero - (ternary (gt complex.x zero) one minusOne) - ) - nop + fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| + \x y nop -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \complex -> + return + (ternary (gt (abs_ complex.y) (float epsilon)) + zero + (ternary (gt complex.x zero) one minusOne) + ) + nop ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX _ x y cont -> - def floatT "sum" zero <| \sum -> - def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| \samples -> - assignBy samples samples <| \_ -> - def floatT "coeff" (float 0.0875) <| \coeff -> - forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w cont2 -> - forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h _ -> - def floatT - "piece" - (f - (add x <| by (by deltaX coeff) <| floatCast w) - (add y <| by (by deltaX coeff) <| floatCast h) - ) - <| \piece -> - if_ (eq piece zero) - (return vec3Zero) - <| \_ -> - assignAdd sum piece cont2 - ) - cont2 - ) - <| \_ -> - def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| \perc -> - expr (assign perc (pow perc <| float 0.2)) <| \_ -> - return (byF perc (vec3 one one one)) cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX _ x y cont -> + def floatT "sum" zero <| + \sum -> + def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| + \samples -> + assignBy samples samples <| + \_ -> + def floatT "coeff" (float 0.0875) <| + \coeff -> + forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) + (\w cont2 -> + forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) + (\h _ -> + def floatT + "piece" + (f + (add x <| by (by deltaX coeff) <| floatCast w) + (add y <| by (by deltaX coeff) <| floatCast h) + ) + <| + \piece -> + if_ (eq piece zero) + (return vec3Zero) + <| + \_ -> + assignAdd sum piece cont2 + ) + cont2 + ) + <| + \_ -> + def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| + \perc -> + expr (assign perc (pow perc <| float 0.2)) <| + \_ -> + return (byF perc (vec3 one one one)) cont in ( [ fDecl, pixelDecl ], pixel ) @@ -1801,47 +1881,65 @@ toSrcPolar : toSrcPolar suffix e = let ( fDecl, f ) = - fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| \x y deltaT ot cont -> - def floatT "r" (length <| vec2 x y) <| \r -> - def floatT "t" (add (atanPlus y x) deltaT) <| \t -> - -- Avoid the branch cut at {x > 0, y = 0} - if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi))) - <| \_ -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| \complex -> - return - (ternary (gt (abs_ complex.y) (float epsilon)) - minusOne - (ternary (gt complex.x zero) - one - zero - ) - ) - cont + fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| + \x y deltaT ot cont -> + def floatT "r" (length <| vec2 x y) <| + \r -> + def floatT "t" (add (atanPlus y x) deltaT) <| + \t -> + -- Avoid the branch cut at {x > 0, y = 0} + if_ (gt (abs_ <| subtract t ot) constants.pi) + (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi))) + <| + \_ -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| + \complex -> + return + (ternary (gt (abs_ complex.y) (float epsilon)) + minusOne + (ternary (gt complex.x zero) + one + zero + ) + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> - assignAdd x (div deltaX <| float 2) <| \_ -> - assignAdd y (div deltaY <| float 2) <| \_ -> - def floatT "t" zero <| \t -> - def floatT "ot" (atanPlus y x) <| \ot -> - for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ cont2 -> - def floatT "h" (f x y t ot) <| \h -> - def floatT "l" (f (subtract x deltaX) y t ot) <| \l -> - def floatT "u" (f x (subtract y deltaY) t ot) <| \u -> - def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| \ul -> - if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - break - <| \_ -> - if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - <| \_ -> - assignAdd t constants.twopi <| \_ -> - assignAdd ot constants.twopi cont2 - ) - <| \_ -> - return vec3Zero cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y cont -> + assignAdd x (div deltaX <| float 2) <| + \_ -> + assignAdd y (div deltaY <| float 2) <| + \_ -> + def floatT "t" zero <| + \t -> + def floatT "ot" (atanPlus y x) <| + \ot -> + for ( "i", int 0, divConst constants.maxIterations (int 10) ) + (\_ cont2 -> + def floatT "h" (f x y t ot) <| + \h -> + def floatT "l" (f (subtract x deltaX) y t ot) <| + \l -> + def floatT "u" (f x (subtract y deltaY) t ot) <| + \u -> + def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| + \ul -> + if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) + break + <| + \_ -> + if_ (ors [ neq h l, neq h u, neq h ul ]) + (return <| vec3 one one one) + <| + \_ -> + assignAdd t constants.twopi <| + \_ -> + assignAdd ot constants.twopi cont2 + ) + <| + \_ -> + return vec3Zero cont in ( [ fDecl, pixelDecl ], pixel ) @@ -1872,35 +1970,48 @@ toSrcParametric : String -> Expression.Expression -> ( List FunDecl, ExpressionX toSrcParametric suffix e = let ( intervalDecl, interval ) = - fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| \p from to cont -> - def vec2T "x" (vec2 p.x p.x) <| \x -> - def vec2T "y" (vec2 p.y p.y) <| \y -> - def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| \t -> - return - (expressionToIntervalGlsl - (Dict.fromList - [ ( "x", x ) - , ( "y", y ) - , ( "t", t ) - ] - ) - (toPrintExpression e) - ) - cont + fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| + \p from to cont -> + def vec2T "x" (vec2 p.x p.x) <| + \x -> + def vec2T "y" (vec2 p.y p.y) <| + \y -> + def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| + \t -> + return + (expressionToIntervalGlsl + (Dict.fromList + [ ( "x", x ) + , ( "y", y ) + , ( "t", t ) + ] + ) + (toPrintExpression e) + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> - def floatT "max_distance" (float <| 2 ^ 10) <| \max_distance -> - def floatT "from" (div (negate_ max_distance) (float 2)) <| \from -> - def floatT "to" (div max_distance (float 2)) <| \to -> - def vec2T "p" (vec2 x y) <| \p -> - def intT "depth" (int 0) <| \depth -> - def intT "choices" (int 0) <| \choices -> - def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| \ithreshold -> - for ( "it", int 0, constants.maxIterations ) - (innerLoop from to p depth choices ithreshold) - <| \_ -> - return vec3Zero cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y cont -> + def floatT "max_distance" (float <| 2 ^ 10) <| + \max_distance -> + def floatT "from" (div (negate_ max_distance) (float 2)) <| + \from -> + def floatT "to" (div max_distance (float 2)) <| + \to -> + def vec2T "p" (vec2 x y) <| + \p -> + def intT "depth" (int 0) <| + \depth -> + def intT "choices" (int 0) <| + \choices -> + def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| + \ithreshold -> + for ( "it", int 0, constants.maxIterations ) + (innerLoop from to p depth choices ithreshold) + <| + \_ -> + return vec3Zero cont innerLoop : Expression1 Float @@ -1913,72 +2024,90 @@ toSrcParametric suffix e = -> Continue Vec3 -> Statement Vec3 innerLoop from to p depth choices ithreshold _ cont = - def floatT "midpoint" (mix from to <| float 0.5) <| \midpoint -> - def vec2T "front" (interval p from midpoint) <| \front -> - def vec2T "back" (interval p midpoint to) <| \back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands - [ lt (subtract front.y front.x) ithreshold - , leq front.x zero - , geq front.y zero - ] - , ands - [ lt (subtract back.y back.x) ithreshold - , leq back.x zero - , geq back.y zero - ] - ] - ) - (return <| vec3 one one one) - <| \_ -> - ifElse - (ands [ leq front.x zero, geq front.y zero ]) - (\_ -> - expr (assign to midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - assignBy choices (int 2) cont - ) - (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) cont - ) - -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - (\_ -> - forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) - (\j _ -> - if_ (gt j depth) - continue - <| \_ -> - expr (postfixDecrement depth) <| \_ -> - expr (assign choices (div choices (int 2))) <| \_ -> - ifElse (eq (by (div choices (int 2)) (int 2)) choices) - (\_ -> - expr (assign midpoint to) <| \_ -> - expr (assign to (add to (subtract to from))) <| \_ -> - expr (assign back (interval p midpoint to)) <| \_ -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| \_ -> - break cont - ) - cont - ) - (expr (assign from (subtract from (subtract to from)))) - cont - ) - <| \_ -> - if_ (eq depth (int 0)) - (return vec3Zero) - cont - ) - ) - cont + def floatT "midpoint" (mix from to <| float 0.5) <| + \midpoint -> + def vec2T "front" (interval p from midpoint) <| + \front -> + def vec2T "back" (interval p midpoint to) <| + \back -> + if_ + (ors + [ geq depth constants.maxDepth + , ands + [ lt (subtract front.y front.x) ithreshold + , leq front.x zero + , geq front.y zero + ] + , ands + [ lt (subtract back.y back.x) ithreshold + , leq back.x zero + , geq back.y zero + ] + ] + ) + (return <| vec3 one one one) + <| + \_ -> + ifElse + (ands [ leq front.x zero, geq front.y zero ]) + (\_ -> + expr (assign to midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + assignBy choices (int 2) cont + ) + (ifElse (ands [ leq back.x zero, geq back.y zero ]) + (\_ -> + expr (assign from midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) cont + ) + -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + (\_ -> + forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) + (\j _ -> + if_ (gt j depth) + continue + <| + \_ -> + expr (postfixDecrement depth) <| + \_ -> + expr (assign choices (div choices (int 2))) <| + \_ -> + ifElse (eq (by (div choices (int 2)) (int 2)) choices) + (\_ -> + expr (assign midpoint to) <| + \_ -> + expr (assign to (add to (subtract to from))) <| + \_ -> + expr (assign back (interval p midpoint to)) <| + \_ -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (\_ -> + expr (assign from midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + expr (assign choices (add (by choices (int 2)) (int 1))) <| + \_ -> + break cont + ) + cont + ) + (expr (assign from (subtract from (subtract to from)))) + cont + ) + <| + \_ -> + if_ (eq depth (int 0)) + (return vec3Zero) + cont + ) + ) + cont in ( [ intervalDecl, pixelDecl ], pixel ) @@ -2000,13 +2129,17 @@ uniforms = thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) thetaDeltaCouple = - fun1 floatT "thetaDelta" (floatT "theta") <| \theta cont -> - if_ (lt uniforms.u_whiteLines one) - (return <| float 100) - <| \_ -> - def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| \thetaSix -> - def floatT "thetaNeigh" (float 0.05) <| \thetaNeigh -> - return (divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh) cont + fun1 floatT "thetaDelta" (floatT "theta") <| + \theta cont -> + if_ (lt uniforms.u_whiteLines one) + (return <| float 100) + <| + \_ -> + def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| + \thetaSix -> + def floatT "thetaNeigh" (float 0.05) <| + \thetaNeigh -> + return (divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh) cont thetaDeltaDecl : FunDecl @@ -2027,93 +2160,131 @@ toSrcVectorField2D : toSrcVectorField2D suffix xexpr yexpr = let ( vectorDecl, vector ) = - fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| \x y cont -> - def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| \xv -> - def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| \yv -> - return (ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero) cont + fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| + \x y cont -> + def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| + \xv -> + def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| + \yv -> + return (ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero) cont ( nearDecl, near ) = - fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| \o corner vect deltaX mx cont -> - def floatT "angleCorner" (arg <| subtract o corner) <| \angleCorner -> - def floatT "angleVector" (arg vect) <| \angleVector -> - def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| \delta -> - def floatT "l" (div (length vect) mx) <| \l -> - def floatT - "maxLength" - (by (by deltaX constants.vectorSpacing) - (ternary - (lt l (float epsilon)) - zero - (add (div l (float 2)) (float 0.5)) - ) - ) - <| \maxLength -> - def floatT "wantedLength" (length (subtract o corner)) <| \wantedLength -> - def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| \angularDistance -> - return - (ands - [ ors - [ lt delta (radians_ angularDistance) - , gt delta (radians_ (subtract (float 360) angularDistance)) - ] - , lt wantedLength maxLength - ] - ) - cont + fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| + \o corner vect deltaX mx cont -> + def floatT "angleCorner" (arg <| subtract o corner) <| + \angleCorner -> + def floatT "angleVector" (arg vect) <| + \angleVector -> + def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| + \delta -> + def floatT "l" (div (length vect) mx) <| + \l -> + def floatT + "maxLength" + (by (by deltaX constants.vectorSpacing) + (ternary + (lt l (float epsilon)) + zero + (add (div l (float 2)) (float 0.5)) + ) + ) + <| + \maxLength -> + def floatT "wantedLength" (length (subtract o corner)) <| + \wantedLength -> + def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| + \angularDistance -> + return + (ands + [ ors + [ lt delta (radians_ angularDistance) + , gt delta (radians_ (subtract (float 360) angularDistance)) + ] + , lt wantedLength maxLength + ] + ) + cont ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> - def vec2T "o" (vec2 x y) <| \o -> - def floatT "mx" zero <| \mx -> - def floatT "k" (by deltaX constants.vectorSpacing) <| \k -> - forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) - (\xi cont2 -> - forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) - (\yi _ -> - def vec2T - "p" - (add uniforms.u_zoomCenter - (vec2 - (by k (floatCast xi)) - (by k (floatCast yi)) - ) - ) - <| \p -> - def vec2T "v" (vector p.x p.y) <| \v -> - expr (assign mx (max_ mx (length v))) cont2 - ) - cont2 - ) - <| \_ -> - def vec3T "colorA" (vec3 zero one zero) <| \colorA -> - def vec3T "colorB" (vec3 zero zero one) <| \colorB -> - expr (assign x (subtract o.x (mod o.x k))) <| \_ -> - expr (assign y (subtract o.y (mod o.y k))) <| \_ -> - def vec2T "bl" (vector x y) <| \bl -> - def vec2T "br" (vector (add x k) y) <| \br -> - def vec2T "ul" (vector x (add y k)) <| \ul -> - def vec2T "ur" (vector (add x k) (add y k)) <| \ur -> - def vec2T "corner" (vec2 x y) <| \corner -> - def floatT "l" (div (length bl) mx) <| \l -> - if_ (near o corner bl deltaX mx) - (return <| mix colorA colorB l) - <| \_ -> - expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| \_ -> - expr (assign l (div (length br) mx)) <| \_ -> - if_ (near o corner br deltaX mx) - (return <| mix colorA colorB l) - <| \_ -> - expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| \_ -> - expr (assign l (div (length ul) mx)) <| \_ -> - if_ (near o corner ul deltaX mx) - (return <| mix colorA colorB l) - <| \_ -> - expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| \_ -> - expr (assign l (div (length ur) mx)) <| \_ -> - if_ (near o corner ur deltaX mx) - (return <| mix colorA colorB l) - <| \_ -> - return vec3Zero cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y cont -> + def vec2T "o" (vec2 x y) <| + \o -> + def floatT "mx" zero <| + \mx -> + def floatT "k" (by deltaX constants.vectorSpacing) <| + \k -> + forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) + (\xi cont2 -> + forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) + (\yi _ -> + def vec2T + "p" + (add uniforms.u_zoomCenter + (vec2 + (by k (floatCast xi)) + (by k (floatCast yi)) + ) + ) + <| + \p -> + def vec2T "v" (vector p.x p.y) <| + \v -> + expr (assign mx (max_ mx (length v))) cont2 + ) + cont2 + ) + <| + \_ -> + def vec3T "colorA" (vec3 zero one zero) <| + \colorA -> + def vec3T "colorB" (vec3 zero zero one) <| + \colorB -> + expr (assign x (subtract o.x (mod o.x k))) <| + \_ -> + expr (assign y (subtract o.y (mod o.y k))) <| + \_ -> + def vec2T "bl" (vector x y) <| + \bl -> + def vec2T "br" (vector (add x k) y) <| + \br -> + def vec2T "ul" (vector x (add y k)) <| + \ul -> + def vec2T "ur" (vector (add x k) (add y k)) <| + \ur -> + def vec2T "corner" (vec2 x y) <| + \corner -> + def floatT "l" (div (length bl) mx) <| + \l -> + if_ (near o corner bl deltaX mx) + (return <| mix colorA colorB l) + <| + \_ -> + expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| + \_ -> + expr (assign l (div (length br) mx)) <| + \_ -> + if_ (near o corner br deltaX mx) + (return <| mix colorA colorB l) + <| + \_ -> + expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| + \_ -> + expr (assign l (div (length ul) mx)) <| + \_ -> + if_ (near o corner ul deltaX mx) + (return <| mix colorA colorB l) + <| + \_ -> + expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| + \_ -> + expr (assign l (div (length ur) mx)) <| + \_ -> + if_ (near o corner ur deltaX mx) + (return <| mix colorA colorB l) + <| + \_ -> + return vec3Zero cont in ( [ vectorDecl, nearDecl, pixelDecl ], pixel ) @@ -2122,53 +2293,80 @@ toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa toSrcContour suffix expr = let ( pixelODecl, pixelO ) = - fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y cont -> - def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| \z -> - def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| \theta -> - def floatT "logRadius" (log2 <| length z) <| \logRadius -> - def floatT "powerRemainder" (fract logRadius) <| \powerRemainder -> - def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| \squished -> - if_ (gt uniforms.u_completelyReal zero) - (\_ -> - def floatT "haf" (div powerRemainder <| float 6.0) <| \haf -> - return - (ternary (gt z.x zero) - (hl2rgb (add haf <| float 0.3) squished) - (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) - ) - cont - ) - <| \_ -> - def floatT "td" (thetaDelta theta) <| \td -> - def floatT "l" (mix one squished <| smoothstep zero one td) <| \l -> - return (hl2rgb theta l) cont + fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \_ _ x y cont -> + def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| + \z -> + def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| + \theta -> + def floatT "logRadius" (log2 <| length z) <| + \logRadius -> + def floatT "powerRemainder" (fract logRadius) <| + \powerRemainder -> + def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| + \squished -> + if_ (gt uniforms.u_completelyReal zero) + (\_ -> + def floatT "haf" (div powerRemainder <| float 6.0) <| + \haf -> + return + (ternary (gt z.x zero) + (hl2rgb (add haf <| float 0.3) squished) + (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) + ) + cont + ) + <| + \_ -> + def floatT "td" (thetaDelta theta) <| + \td -> + def floatT "l" (mix one squished <| smoothstep zero one td) <| + \l -> + return (hl2rgb theta l) cont ( pixelDecl, pixel ) = let dist = 1 / 3 in - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \deltaX deltaY x y cont -> - def floatT "deltaXr" (by deltaX <| float dist) <| \deltaXr -> - def floatT "deltaYr" (by deltaY <| float dist) <| \deltaYr -> - -- Antialiasing - def vec3T "a" (pixelO deltaX deltaY (add x deltaXr) (add y deltaYr)) <| \a -> - def vec3T "b" (pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr)) <| \b -> - def vec3T "c" (pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr)) <| \c -> - def vec3T "d" (pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr)) <| \d -> - def vec3T "mn" (min_ a <| min_ b <| min_ c d) <| \mn -> - def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| \mx -> - def vec3T "diff" (abs_ (subtract mx mn)) <| \diff -> - if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) - (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - <| \_ -> - assignBy deltaXr (float 2) <| \_ -> - assignBy deltaYr (float 2) <| \_ -> - def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| \e -> - def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| \f -> - def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| \g -> - def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| \h -> - return (divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8)) cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \deltaX deltaY x y cont -> + def floatT "deltaXr" (by deltaX <| float dist) <| + \deltaXr -> + def floatT "deltaYr" (by deltaY <| float dist) <| + \deltaYr -> + -- Antialiasing + def vec3T "a" (pixelO deltaX deltaY (add x deltaXr) (add y deltaYr)) <| + \a -> + def vec3T "b" (pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr)) <| + \b -> + def vec3T "c" (pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr)) <| + \c -> + def vec3T "d" (pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr)) <| + \d -> + def vec3T "mn" (min_ a <| min_ b <| min_ c d) <| + \mn -> + def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| + \mx -> + def vec3T "diff" (abs_ (subtract mx mn)) <| + \diff -> + if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) + (return <| divF (adds3 [ a, b, c, d ]) (float 4)) + <| + \_ -> + assignBy deltaXr (float 2) <| + \_ -> + assignBy deltaYr (float 2) <| + \_ -> + def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| + \e -> + def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| + \f -> + def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| + \g -> + def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| + \h -> + return (divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8)) cont in ( [ pixelODecl, pixelDecl ], pixel ) @@ -2176,19 +2374,21 @@ toSrcContour suffix expr = toSrcRelation : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) toSrcRelation suffix e = Tuple.mapFirst (\d -> [ d ]) <| - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| \_ _ x y cont -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| \complex -> - return - (ternary - (ands - [ gt complex.x zero - , lt (abs_ complex.y) (float epsilon) - ] - ) - (vec3 (float 0.8) (float 0.5) (float 0.5)) - vec3Zero - ) - cont + fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| + \_ _ x y cont -> + def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| + \complex -> + return + (ternary + (ands + [ gt complex.x zero + , lt (abs_ complex.y) (float epsilon) + ] + ) + (vec3 (float 0.8) (float 0.5) (float 0.5)) + vec3Zero + ) + cont epsilon : Float @@ -2668,23 +2868,38 @@ pixel2Tuple pixels = inner deltaX deltaY x y px curr cont = List.foldl (\( i, p ) -> addPixel deltaX deltaY x y px curr i p) cont (List.indexedMap Tuple.pair pixels) in - fun0 vec4T "pixel2" <| \cont -> - def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> - def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| \uv_centered -> - def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| \viewportSize -> - def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| \uv -> - def vec2T "c" (add uniforms.u_zoomCenter uv) <| \c -> - def floatT "x" c.x <| \x -> - def floatT "y" c.y <| \y -> - def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| \deltaX -> - def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| \deltaY -> - def vec3T "px" vec3Zero <| \px -> - decl vec3T "curr" <| \curr -> - inner deltaX deltaY x y px curr <| - def floatT "maxDelta" (max_ deltaX deltaY) <| \maxDelta -> - def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| \yax -> - def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| \xax -> - return (vec4_3_1 (max3 px (max3 xax yax)) one) cont + fun0 vec4T "pixel2" <| + \cont -> + def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| + \canvasSize -> + def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| + \uv_centered -> + def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| + \viewportSize -> + def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| + \uv -> + def vec2T "c" (add uniforms.u_zoomCenter uv) <| + \c -> + def floatT "x" c.x <| + \x -> + def floatT "y" c.y <| + \y -> + def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| + \deltaX -> + def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| + \deltaY -> + def vec3T "px" vec3Zero <| + \px -> + decl vec3T "curr" <| + \curr -> + inner deltaX deltaY x y px curr <| + def floatT "maxDelta" (max_ deltaX deltaY) <| + \maxDelta -> + def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| + \yax -> + def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| + \xax -> + return (vec4_3_1 (max3 px (max3 xax yax)) one) cont addPixel : @@ -2713,36 +2928,45 @@ addPixel deltaX deltaY x y px curr i { call, color } next = else call deltaX deltaY x y in - expr (assign curr k) <| \_ -> - expr (assign px (ternary3 (eq curr vec3Zero) px curr)) <| \_ -> - next + expr (assign curr k) <| + \_ -> + expr (assign px (ternary3 (eq curr vec3Zero) px curr)) <| + \_ -> + next axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) axisTuple = - fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| \coord otherCoord maxDelta cont -> - def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| \across -> - if_ (lt across (float -12)) - (return zero) - <| \_ -> - def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| \smallUnit -> - if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) - <| \_ -> - def floatT - "unit" - (ternary - (lt across (float -6)) - (by smallUnit (float 100)) - (ternary - (lt across (float -0.1)) - (by smallUnit (float 10)) - (by smallUnit (float 5)) - ) - ) - <| \unit -> - def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| \parallel -> - return (max_ zero (max_ across parallel)) cont + fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| + \coord otherCoord maxDelta cont -> + def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| + \across -> + if_ (lt across (float -12)) + (return zero) + <| + \_ -> + def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| + \smallUnit -> + if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) + (return zero) + <| + \_ -> + def floatT + "unit" + (ternary + (lt across (float -6)) + (by smallUnit (float 100)) + (ternary + (lt across (float -0.1)) + (by smallUnit (float 10)) + (by smallUnit (float 5)) + ) + ) + <| + \unit -> + def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| + \parallel -> + return (max_ zero (max_ across parallel)) cont axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float @@ -2762,21 +2986,32 @@ toSrc3D : toSrc3D suffix e = let ( intervalDecl, interval ) = - fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| \f t cont -> - def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| \mn -> - def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| \mx -> - def vec2T "x" (vec2 mn.x mx.x) <| \x -> - def vec2T "y" (vec2 mn.y mx.y) <| \y -> - def vec2T "z" (vec2 mn.z mx.z) <| \z -> - return (expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e) cont + fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| + \f t cont -> + def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| + \mn -> + def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| + \mx -> + def vec2T "x" (vec2 mn.x mx.x) <| + \x -> + def vec2T "y" (vec2 mn.y mx.y) <| + \y -> + def vec2T "z" (vec2 mn.z mx.z) <| + \z -> + return (expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e) cont in ( [ Tuple.first <| - fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| \p cont -> - def floatT "x" p.x <| \x -> - def floatT "y" p.y <| \y -> - def floatT "z" p.z <| \z -> - def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| \gradient -> - return (normalize gradient.yzw) cont + fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| + \p cont -> + def floatT "x" p.x <| + \x -> + def floatT "y" p.y <| + \y -> + def floatT "z" p.z <| + \z -> + def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| + \gradient -> + return (normalize gradient.yzw) cont , intervalDecl ] , interval @@ -2798,26 +3033,45 @@ main3D rayDifferentials bisects = 0.0 ( block, pixel3 ) = - fun0 vec4T "pixel3" <| \cont -> - def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| \eyeDist -> - def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| \canvasSize -> - def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| \uvCentered -> - def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| \uvNormalized -> - def floatT "t" (add uniforms.u_theta <| float 0.58) <| \t -> - def floatT "p" (by (float -2.0) uniforms.u_phi) <| \p -> - def vec3T "eye" (eyePosition eyeDist t p) <| \eye -> - def vec3T "target" vec3Zero <| \target -> - def vec3T "to_target" (normalize <| subtract target eye) <| \toTarget -> - def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| \across -> - def vec3T "up" (normalize <| cross across toTarget) <| \up -> - def vec3T "canvas_center" (add eye toTarget) <| \canvasCenter -> - def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| \canvasPoint -> - def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| \rayDirection -> - def vec3T "diffs" (abs_ <| fwidth rayDirection) <| \diffs -> - def floatT "k" (float kValue) <| \k -> - def mat3T "d" (dValue rayDirection k diffs) <| \d -> - def floatT "max_distance" (by (float 100) eyeDist) <| \maxDistance -> - return (raytraceF canvasPoint d maxDistance) cont + fun0 vec4T "pixel3" <| + \cont -> + def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| + \eyeDist -> + def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| + \canvasSize -> + def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| + \uvCentered -> + def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| + \uvNormalized -> + def floatT "t" (add uniforms.u_theta <| float 0.58) <| + \t -> + def floatT "p" (by (float -2.0) uniforms.u_phi) <| + \p -> + def vec3T "eye" (eyePosition eyeDist t p) <| + \eye -> + def vec3T "target" vec3Zero <| + \target -> + def vec3T "to_target" (normalize <| subtract target eye) <| + \toTarget -> + def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| + \across -> + def vec3T "up" (normalize <| cross across toTarget) <| + \up -> + def vec3T "canvas_center" (add eye toTarget) <| + \canvasCenter -> + def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| + \canvasPoint -> + def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| + \rayDirection -> + def vec3T "diffs" (abs_ <| fwidth rayDirection) <| + \diffs -> + def floatT "k" (float kValue) <| + \k -> + def mat3T "d" (dValue rayDirection k diffs) <| + \d -> + def floatT "max_distance" (by (float 100) eyeDist) <| + \maxDistance -> + return (raytraceF canvasPoint d maxDistance) cont dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 dValue rayDirection k diffs = @@ -2854,58 +3108,75 @@ raytrace bisects = colorCoeff = float (1.19 - 0.2 * toFloat (List.length bisects)) in - fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| \o d maxDistance cont -> - def vec3T "found" vec3Zero <| \found -> - def floatT "curr_distance" maxDistance <| \currDistance -> - def intT "found_index" (int -1) <| \foundIndex -> - def vec3T "f" vec3Zero <| \f -> - let - innerTrace : Statement q -> Statement q - innerTrace next = - List.foldl - (\bisect ( i, s ) -> - ( i + 1 - , bisectToRay i bisect s - ) - ) - ( 0, next ) - bisects - |> Tuple.second - - bisectToRay : - Int - -> - (Expression3 - -> Expression1 Mat3 - -> Expression1 Float - -> Expression3 - -> Expression1 Bool - ) - -> Statement q - -> Statement q - bisectToRay i bisect next = - if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (\cont2 -> - expr (assign foundIndex <| int i) <| \_ -> - expr (assign found f) <| \_ -> - expr (assign currDistance <| length <| subtract found o) cont2 - ) - <| \_ -> - next - in - innerTrace <| - if_ (lt foundIndex <| int 0) - (return <| vec4 zero zero zero one) - <| \_ -> - def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| \ld -> - def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| \diffs -> - def floatT "light_distance" maxDistance <| \lightDistance -> - def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| \offseted -> - def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| \hueBasedOnIndex -> - def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| \lightDirection -> - def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| \lightCoeff -> - def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| \px -> - return (vec4_3_1 px one) cont + fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| + \o d maxDistance cont -> + def vec3T "found" vec3Zero <| + \found -> + def floatT "curr_distance" maxDistance <| + \currDistance -> + def intT "found_index" (int -1) <| + \foundIndex -> + def vec3T "f" vec3Zero <| + \f -> + let + innerTrace : Statement q -> Statement q + innerTrace next = + List.foldl + (\bisect ( i, s ) -> + ( i + 1 + , bisectToRay i bisect s + ) + ) + ( 0, next ) + bisects + |> Tuple.second + + bisectToRay : + Int + -> + (Expression3 + -> Expression1 Mat3 + -> Expression1 Float + -> Expression3 + -> Expression1 Bool + ) + -> Statement q + -> Statement q + bisectToRay i bisect next = + if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) + (\cont2 -> + expr (assign foundIndex <| int i) <| + \_ -> + expr (assign found f) <| + \_ -> + expr (assign currDistance <| length <| subtract found o) cont2 + ) + <| + \_ -> + next + in + innerTrace <| + if_ (lt foundIndex <| int 0) + (return <| vec4 zero zero zero one) + <| + \_ -> + def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| + \ld -> + def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| + \diffs -> + def floatT "light_distance" maxDistance <| + \lightDistance -> + def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| + \offseted -> + def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| + \hueBasedOnIndex -> + def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| + \lightDirection -> + def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| + \lightCoeff -> + def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| + \px -> + return (vec4_3_1 px one) cont threshold : ExpressionX x Float -> Expression1 Float @@ -2917,37 +3188,46 @@ suffixToBisect : (Expression33 -> Expression33 -> Expression2) -> String -> ( Fu suffixToBisect interval suffix = let mainLoop found from to ithreshold depth choices _ cont = - def mat3T "midpoint" (byF (float 0.5) (add33 from to)) <| \midpoint -> - def vec2T "front" (interval from midpoint) <| \front -> - def vec2T "back" (interval midpoint to) <| \back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ] - , ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] - ] - ) - (\_ -> - expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| \_ -> - return (bool True) cont - ) - <| \_ -> - ifElse (ands [ leq front.x zero, geq front.y zero ]) - (\_ -> - expr (assign to midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) cont - ) - (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (backtrackLeft from to depth choices midpoint) - (backtrackRight from to depth choices midpoint) - ) - cont + def mat3T "midpoint" (byF (float 0.5) (add33 from to)) <| + \midpoint -> + def vec2T "front" (interval from midpoint) <| + \front -> + def vec2T "back" (interval midpoint to) <| + \back -> + if_ + (ors + [ geq depth constants.maxDepth + , ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ] + , ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] + ] + ) + (\_ -> + expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| + \_ -> + return (bool True) cont + ) + <| + \_ -> + ifElse (ands [ leq front.x zero, geq front.y zero ]) + (\_ -> + expr (assign to midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) cont + ) + (ifElse (ands [ leq back.x zero, geq back.y zero ]) + (backtrackLeft from to depth choices midpoint) + (backtrackRight from to depth choices midpoint) + ) + cont backtrackLeft from _ depth choices midpoint cont = - expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) cont + expr (assign from midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) cont backtrackRight from to depth choices midpoint cont = -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch @@ -2955,38 +3235,55 @@ suffixToBisect interval suffix = (\j _ -> if_ (gt j depth) continue - <| \_ -> - expr (postfixDecrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| \_ -> - ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) - (\_ -> - expr (assign midpoint to) <| \_ -> - expr (assign to <| add to (subtract to from)) <| \_ -> - def vec2T "back" (interval midpoint to) <| \back -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| \_ -> - expr (postfixIncrement depth) <| \_ -> - expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| \_ -> - break cont - ) - cont - ) - (expr (assign from <| subtract from (subtract to from))) - cont + <| + \_ -> + expr (postfixDecrement depth) <| + \_ -> + expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| + \_ -> + ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) + (\_ -> + expr (assign midpoint to) <| + \_ -> + expr (assign to <| add to (subtract to from)) <| + \_ -> + def vec2T "back" (interval midpoint to) <| + \back -> + if_ (ands [ leq back.x zero, geq back.y zero ]) + (\_ -> + expr (assign from midpoint) <| + \_ -> + expr (postfixIncrement depth) <| + \_ -> + expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| + \_ -> + break cont + ) + cont + ) + (expr (assign from <| subtract from (subtract to from))) + cont ) - <| \_ -> - if_ (eq depth (int 0)) - (return false) - cont + <| + \_ -> + if_ (eq depth (int 0)) + (return false) + cont in - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found cont -> - def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| \from -> - def mat3T "to" (add from <| byF maxDistance d) <| \to -> - def floatT "ithreshold" (threshold maxDistance) <| \ithreshold -> - def intT "depth" (int 0) <| \depth -> - def intT "choices" (int 0) <| \choices -> - for ( "it", int 0, constants.maxIterations ) - (mainLoop found from to ithreshold depth choices) - <| \_ -> - return (bool False) cont + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found cont -> + def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| + \from -> + def mat3T "to" (add from <| byF maxDistance d) <| + \to -> + def floatT "ithreshold" (threshold maxDistance) <| + \ithreshold -> + def intT "depth" (int 0) <| + \depth -> + def intT "choices" (int 0) <| + \choices -> + for ( "it", int 0, constants.maxIterations ) + (mainLoop found from to ithreshold depth choices) + <| + \_ -> + return (bool False) cont diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index a565c8d5..4aadb9a5 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,7 +1,8 @@ -module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), Expression, Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) import Expression exposing (RelationOperation(..)) +import Glsl.Helper exposing (Expression(..), Expression1, Expression2, Expression3, Expression4, ExpressionX, Statement) import Set @@ -13,115 +14,6 @@ type FunDecl = FunDecl { name : String, type_ : String, body : String } -type Stat - = If Expr Stat Stat - | IfElse Expr Stat Stat Stat - | For String Expr RelationOperation Expr Expr Stat Stat - | Line String - | Return Expr - | Break - | Continue - | ExpressionStatement Expr Stat - | Decl String Name (Maybe Expr) Stat - | Nop - - -type Statement r - = Statement Stat - - -type Expr - = Bool Bool - | Int Int - | Float Float - | Variable String - | And Expr Expr - | Or Expr Expr - | Comparison RelationOperation Expr Expr - | Ternary Expr Expr Expr - | Add Expr Expr - | Subtract Expr Expr - | By Expr Expr - | Div Expr Expr - | Call String (List Expr) - | Negate Expr - | PostfixIncrement Expr - | PostfixDecrement Expr - | Unknown String - | Dot Expr String - | Array Expr Expr - | Assign Expr Expr - | AssignCombo ComboOperation Expr Expr - - -type ComboOperation - = ComboAdd - | ComboSubtract - | ComboBy - | ComboDiv - - -type Expression t - = Expression Expr - - -type alias ExpressionX a t = - { a | base : Expression t } - - -type alias Expression1 t = - { base : Expression t - } - - -type alias Expression2 = - { base : Expression Vec2 - , x : Expression1 Float - , y : Expression1 Float - , yx : Expression1 Vec2 - } - - -type alias Expression3 = - { base : Expression Vec3 - , x : Expression1 Float - , y : Expression1 Float - , z : Expression1 Float - } - - -type alias Expression4 = - { base : Expression Vec4 - , x : Expression1 Float - , y : Expression1 Float - , z : Expression1 Float - , w : Expression1 Float - , xy : Expression2 - , yx : Expression2 - , yzw : Expression3 - } - - -type alias Expression33 = - { base : Expression Mat3 } - - -type alias TypingFunction t r = - String -> ( TypedName t r, Expression t -> r ) - - -type TypedName t r - = TypedName Type Name r - - -type Type - = Type String - - -type Name - = Name String - - -- UTILS @@ -1718,49 +1610,52 @@ innerValue ctx e = Err <| MissingVariable v And l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) Or l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) Comparison k l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) Ternary _ _ _ -> Debug.todo "branch 'Ternary _ _ _' not implemented" @@ -1772,29 +1667,31 @@ innerValue ctx e = Debug.todo "branch 'Subtract _ _' not implemented" By l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) Div _ _ -> Debug.todo "branch 'Div _ _' not implemented" Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) Call "exp" [ l ] -> autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l From 7eb6b841f021304349c9f1372a0b4e19d339330b Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 10 Dec 2022 00:08:57 +0100 Subject: [PATCH 076/139] Yeet Simplify --- codegen/Glsl/Simplify.elm | 58 --------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 codegen/Glsl/Simplify.elm diff --git a/codegen/Glsl/Simplify.elm b/codegen/Glsl/Simplify.elm deleted file mode 100644 index 41fbad91..00000000 --- a/codegen/Glsl/Simplify.elm +++ /dev/null @@ -1,58 +0,0 @@ -module Glsl.Simplify exposing (expression, function, statement) - -import Glsl.Types exposing (BooleanOperation, Expression(..), Function, Statement(..)) - - -function : Function -> Function -function f = - { f | body = statement f.body } - - -statement : Statement -> Statement -statement s = - case s of - Nop -> - Nop - - Expression e n -> - Expression (expression e) (statement n) - - For v from rel to step inner next -> - For v (expression from) rel (expression to) step (statement inner) (statement next) - - If cond t f -> - If (expression cond) (statement t) (statement f) - - Return e -> - Return (expression e) - - Def t n v next -> - Def t n (expression v) (statement next) - - Decl t n next -> - Decl t n (statement next) - - -expression : Expression -> Expression -expression e = - case e of - BooleanOperation op es -> - es - |> List.map expression - |> List.concatMap - (\c -> - case c of - BooleanOperation cop ces -> - if op == cop then - ces - - else - [ c ] - - _ -> - [ c ] - ) - |> BooleanOperation op - - _ -> - e From c4de692fe805eb500ef12328aa5d17cbbfc9e818 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 10 Dec 2022 00:43:15 +0100 Subject: [PATCH 077/139] Moving towards stringly bodied functions --- codegen/Generate.elm | 46 ++----- codegen/Glsl/Parser.elm | 43 +++++- codegen/Glsl/PrettyPrinter.elm | 227 +++++++++++++++++++------------- codegen/Glsl/Types.elm | 3 +- codegen/helpers/Glsl/Helper.elm | 2 +- src/elm/UI/Glsl/Generator.elm | 173 ++++++++++++------------ 6 files changed, 278 insertions(+), 216 deletions(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index c4266bf3..b03345e9 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -10,8 +10,7 @@ import Gen.Glsl.Helper import Glsl.Parser import Glsl.Types exposing (BinaryOperation(..), Expression(..), Function, Statement(..), Type(..)) import List.Extra -import Parser exposing ((|.), (|=), Parser) -import Parser.Workaround +import Parser import Result.Extra import Set exposing (Set) @@ -39,7 +38,7 @@ generate glsl = env : Env env = List.foldl - (\( { name, returnType, args }, _ ) -> + (\{ name, returnType, args } -> functionHasType name (List.map Tuple.first args) @@ -73,11 +72,11 @@ functionHasType baseName argTypes returnType env = { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } -declarationsDictionary : List ( Function, String ) -> Elm.Declaration +declarationsDictionary : List Function -> Elm.Declaration declarationsDictionary functions = functions |> List.map - (\( { name }, _ ) -> + (\{ name } -> Elm.tuple (Elm.string name) (Elm.withType Type.string <| @@ -153,8 +152,8 @@ type alias Env = } -functionToDeclarations : Env -> ( Function, String ) -> Result String (List Elm.Declaration) -functionToDeclarations env ( function, body ) = +functionToDeclarations : Env -> Function -> Result String (List Elm.Declaration) +functionToDeclarations env function = let argDecls : List ( String, Maybe Type.Annotation ) argDecls = @@ -172,7 +171,7 @@ functionToDeclarations env ( function, body ) = maybeDeps : Result String (Set String) maybeDeps = - findDepsStatement envWithArgs function.body + findDepsStatement envWithArgs function.stat |> Result.mapError (\e -> e ++ " while generating " ++ function.name) in Result.map @@ -190,7 +189,7 @@ functionToDeclarations env ( function, body ) = ) |> Elm.withType Gen.Glsl.Helper.annotation_.expression in - [ Elm.string body + [ Elm.string function.body |> Elm.declaration (function.name ++ "Body") , Elm.function argDecls expr |> Elm.declaration function.name @@ -792,31 +791,6 @@ builtin_v_v = ) -parseFile : String -> Result (List Parser.DeadEnd) (List ( Function, String )) +parseFile : String -> Result (List Parser.DeadEnd) (List Function) parseFile glsl = - Parser.run - (fileParser glsl) - glsl - - -fileParser : String -> Parser (List ( Function, String )) -fileParser glsl = - Parser.succeed (List.filterMap identity) - |= Parser.sequence - { start = "" - , separator = "" - , item = - Parser.oneOf - [ Parser.succeed Nothing - |. Parser.Workaround.lineCommentAfter "//" - , Parser.succeed - (\begin parsed end -> Just ( parsed, String.slice begin end glsl )) - |= Parser.getOffset - |= Glsl.Parser.function - |= Parser.getOffset - ] - , end = "" - , trailing = Parser.Optional - , spaces = Parser.spaces - } - |. Parser.end + Parser.run Glsl.Parser.file glsl diff --git a/codegen/Glsl/Parser.elm b/codegen/Glsl/Parser.elm index a0ce7b50..30943462 100644 --- a/codegen/Glsl/Parser.elm +++ b/codegen/Glsl/Parser.elm @@ -1,14 +1,24 @@ -module Glsl.Parser exposing (function, statement) +module Glsl.Parser exposing (file, function, statement) import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) -import Html.Attributes exposing (id) import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) import Parser.Workaround function : Parser Function function = - succeed (\returnType { name, hasSuffix } args body -> { returnType = returnType, name = name, hasSuffix = hasSuffix, args = args, body = body }) + succeed + (\glsl begin returnType { name, hasSuffix } args stat end -> + { returnType = returnType + , name = name + , hasSuffix = hasSuffix + , args = args + , stat = stat + , body = String.slice begin end glsl + } + ) + |= Parser.getSource + |= Parser.getOffset |= typeParser |. spaces |= identifierWithSuffixParser @@ -23,6 +33,7 @@ function = } |. spaces |= statement + |= Parser.getOffset argParser : Parser ( Type, String ) @@ -449,3 +460,29 @@ tryParseNumber n = Nothing -> problem "Expected a number" + + +file : Parser (List Function) +file = + Parser.succeed (List.filterMap identity) + |= Parser.sequence + { start = "" + , separator = "" + , item = + Parser.oneOf + [ Parser.succeed Nothing + |. Parser.Workaround.lineCommentAfter "//" + , Parser.succeed Nothing + |. Parser.Workaround.lineCommentAfter "#define" + , Parser.succeed Nothing + |. Parser.Workaround.lineCommentAfter "precision highp" + , Parser.succeed Nothing + |. Parser.Workaround.lineCommentAfter "uniform" + , Parser.succeed Just + |= function + ] + , end = "" + , trailing = Parser.Optional + , spaces = Parser.spaces + } + |. Parser.end diff --git a/codegen/Glsl/PrettyPrinter.elm b/codegen/Glsl/PrettyPrinter.elm index 78ac860a..f71a30f2 100644 --- a/codegen/Glsl/PrettyPrinter.elm +++ b/codegen/Glsl/PrettyPrinter.elm @@ -1,7 +1,7 @@ module Glsl.PrettyPrinter exposing (function, statement) -import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), Function, RelationOperation(..), Statement(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Step(..), Trailing(..), loop) +import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Step(..), Trailing(..)) function : Function -> String @@ -14,32 +14,32 @@ function fun = ++ ") = fun" ++ String.fromInt (List.length fun.args) ++ " " - ++ fun.returnType + ++ prettyPrintType fun.returnType ++ "T " ++ "(\"" ++ fun.name ++ "\" ++ suffix)" ++ " " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ String.join " " (List.map (\( t, n ) -> "(" ++ prettyPrintType t ++ "T \"" ++ n ++ "\")") fun.args) ++ " <| \\" ++ String.join " " (List.map Tuple.second fun.args) ++ " -> " - ++ (statement fun.body |> String.split "\n" |> String.join " ") + ++ (statement fun.stat |> String.split "\n" |> String.join " ") else fun.name ++ "Couple = fun" ++ String.fromInt (List.length fun.args) ++ " " - ++ fun.returnType + ++ prettyPrintType fun.returnType ++ "T \"" ++ fun.name ++ "\" " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ t ++ "T \"" ++ n ++ "\")") fun.args) + ++ String.join " " (List.map (\( t, n ) -> "(" ++ prettyPrintType t ++ "T \"" ++ n ++ "\")") fun.args) ++ " <| \\" ++ String.join " " (List.map Tuple.second fun.args) ++ " ->\n " - ++ (statement fun.body |> String.split "\n" |> String.join "\n ") + ++ (statement fun.stat |> String.split "\n" |> String.join "\n ") ++ "\n\n" ++ fun.name ++ "Decl = Tuple.first " @@ -60,81 +60,92 @@ statement stat = ++ " <| \\_ ->\n" ++ statement next - For var from LessThan to step loop next -> - (if step then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement loop - ++ ") <| \\_ ->\n" - ++ statement next - - For var from LessThanOrEquals to step loop next -> - (if step then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement loop - ++ ") <| \\_ ->\n" - ++ statement next - - For var from GreaterThan to step loop next -> - (if step then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement loop - ++ ") <| \\_ ->\n" - ++ statement next - - For var from GreaterThanOrEquals to step loop next -> - (if step then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement loop - ++ ") <| \\_ ->\n" - ++ statement next + For { var, from, op, to, step, direction } next -> + case op of + LessThan -> + (if direction == PlusPlus then + "for (\"" + + else + "forDown (\"" + ) + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement step + ++ ") <| \\_ ->\n" + ++ statement next + + LessThanOrEquals -> + (if direction == PlusPlus then + "forLeq (\"" + + else + "forLeqDown (\"" + ) + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement step + ++ ") <| \\_ ->\n" + ++ statement next + + GreaterThan -> + (if direction == PlusPlus then + "for (\"" + + else + "forDown (\"" + ) + ++ var + ++ "\", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement step + ++ ") <| \\_ ->\n" + ++ statement next + + GreaterThanOrEquals -> + (if direction == PlusPlus then + "forLeq (\"" + + else + "forLeqDown (\"" + ) + ++ var + ++ ", " + ++ prettyPrintExpression from + ++ ", " + ++ prettyPrintExpression to + ++ ") (\\" + ++ var + ++ " ->\n" + ++ statement step + ++ ") <| \\_ ->\n" + ++ statement next + + Equals -> + "TODO branch 'Equals' not implemented" + + NotEquals -> + "TODO branch 'NotEquals' not implemented" + + Assign -> + "TODO branch 'Assign' not implemented" If cond ifTrue next -> "if_ " @@ -150,23 +161,57 @@ statement stat = Nop -> "nop\n" - Def t n v next -> + Def { type_, var, val } next -> "def " - ++ t + ++ prettyPrintType type_ ++ "T \"" - ++ n + ++ var ++ "\" (" - ++ prettyPrintExpression v + ++ prettyPrintExpression val ++ ") <| \\" - ++ n + ++ var ++ " -> \n" ++ statement next - Decl _ _ _ -> + Decl _ _ -> "TODO branch 'Decl _ _ _' not implemented" - For _ _ _ _ _ _ _ -> - "TODO branch 'For _ _ _ _ _ _ _' not implemented" + +prettyPrintType : Type -> String +prettyPrintType type_ = + case type_ of + TFloat -> + "float" + + TInt -> + "int" + + TVec2 -> + "vec2" + + TIVec2 -> + "ivec2" + + TIVec3 -> + "ivec3" + + TIVec4 -> + "ivec4" + + TVec3 -> + "vec3" + + TVec4 -> + "vec4" + + TMat3 -> + "mat3" + + TVoid -> + "void" + + TBool -> + "bool" prettyPrintExpression : Expression -> String diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm index eced8817..8a3d6050 100644 --- a/codegen/Glsl/Types.elm +++ b/codegen/Glsl/Types.elm @@ -5,7 +5,8 @@ type alias Function = { returnType : Type , name : String , args : List ( Type, String ) - , body : Statement + , stat : Statement + , body : String , hasSuffix : Bool } diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl/Helper.elm index ccc0f4ed..de4ed848 100644 --- a/codegen/helpers/Glsl/Helper.elm +++ b/codegen/helpers/Glsl/Helper.elm @@ -1,4 +1,4 @@ -module Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Mat3(..), RelationOperation(..), Stat(..), Statement(..), TypingFunction, Vec2(..), Vec3(..), Vec4(..), innerCall) +module Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Mat3(..), Name(..), RelationOperation(..), Stat(..), Statement(..), TypingFunction, Vec2(..), Vec3(..), Vec4(..), innerCall) import Set exposing (Set) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 4aadb9a5..b6a19aaf 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,8 +1,7 @@ module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) -import Expression exposing (RelationOperation(..)) -import Glsl.Helper exposing (Expression(..), Expression1, Expression2, Expression3, Expression4, ExpressionX, Statement) +import Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Name(..), RelationOperation(..), Stat(..), Statement(..)) import Set @@ -42,88 +41,89 @@ funDeclToGlsl (FunDecl { body }) = statementToGlsl : Statement s -> String statementToGlsl (Statement r) = - let - go i c = - case c of - If cond t n -> - [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") - , go (i + 1) t - , indent i "}" - , "" - , go i n - ] - |> String.join "\n" - - IfElse cond t ((If _ _ _) as f) n -> - [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") - , go (i + 1) t - , indent i <| "} else " ++ String.trimLeft (go i f) - , go i n - ] - |> String.join "\n" - - IfElse cond t ((IfElse _ _ _ _) as f) n -> - [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") - , go (i + 1) t - , indent i <| "} else " ++ String.trimLeft (go i f) - , go i n - ] - |> String.join "\n" - - IfElse cond t f n -> - [ indent i ("if (" ++ expressionToGlsl (Expression cond) ++ ") {") - , go (i + 1) t - , indent i "} else {" - , go (i + 1) f - , indent i "}" - , "" - , go i n - ] - |> String.join "\n" - - For var from rel to step loop next -> - [ indent i ("for (int " ++ var ++ " = " ++ expressionToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ expressionToGlsl (Expression to) ++ "; " ++ expressionToGlsl (Expression step) ++ ") {") - , go (i + 1) loop - , indent i "}" - , "" - , go i next - ] - |> String.join "\n" - - Line l -> - indent i l ++ ";" - - Return e -> - indent i <| "return " ++ expressionToGlsl (Expression e) ++ ";" - - Break -> - indent i "break;" - - Continue -> - indent i "continue;" - - ExpressionStatement e Nop -> - indent i (expressionToGlsl (Expression e) ++ ";") - - Decl t (Name n) (Just e) Nop -> - indent i (t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";") - - Decl t (Name n) Nothing Nop -> - indent i (t ++ " " ++ n ++ ";") - - ExpressionStatement e next -> - indent i (expressionToGlsl (Expression e) ++ ";\n") ++ go i next - - Decl t (Name n) (Just e) next -> - indent i (t ++ " " ++ n ++ " = " ++ expressionToGlsl (Expression e) ++ ";\n") ++ go i next - - Decl t (Name n) Nothing next -> - indent i (t ++ " " ++ n ++ ";\n") ++ go i next - - Nop -> - "" - in - go 1 r + statToGlsl 1 r + + +statToGlsl : Int -> Stat -> String +statToGlsl i c = + case c of + If cond t n -> + [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + , statToGlsl (i + 1) t + , indent i "}" + , "" + , statToGlsl i n + ] + |> String.join "\n" + + IfElse cond t ((If _ _ _) as f) n -> + [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + , statToGlsl (i + 1) t + , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) + , statToGlsl i n + ] + |> String.join "\n" + + IfElse cond t ((IfElse _ _ _ _) as f) n -> + [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + , statToGlsl (i + 1) t + , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) + , statToGlsl i n + ] + |> String.join "\n" + + IfElse cond t f n -> + [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + , statToGlsl (i + 1) t + , indent i "} else {" + , statToGlsl (i + 1) f + , indent i "}" + , "" + , statToGlsl i n + ] + |> String.join "\n" + + For var from rel to step loop next -> + [ indent i ("for (int " ++ var ++ " = " ++ exprToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ exprToGlsl (Expression to) ++ "; " ++ exprToGlsl (Expression step) ++ ") {") + , statToGlsl (i + 1) loop + , indent i "}" + , "" + , statToGlsl i next + ] + |> String.join "\n" + + Line l -> + indent i l ++ ";" + + Return e -> + indent i <| "return " ++ exprToGlsl (Expression e) ++ ";" + + Break -> + indent i "break;" + + Continue -> + indent i "continue;" + + ExpressionStatement e Nop -> + indent i (exprToGlsl (Expression e) ++ ";") + + Decl t (Name n) (Just e) Nop -> + indent i (t ++ " " ++ n ++ " = " ++ exprToGlsl (Expression e) ++ ";") + + Decl t (Name n) Nothing Nop -> + indent i (t ++ " " ++ n ++ ";") + + ExpressionStatement e next -> + indent i (exprToGlsl (Expression e) ++ ";\n") ++ statToGlsl i next + + Decl t (Name n) (Just e) next -> + indent i (t ++ " " ++ n ++ " = " ++ exprToGlsl (Expression e) ++ ";\n") ++ statToGlsl i next + + Decl t (Name n) Nothing next -> + indent i (t ++ " " ++ n ++ ";\n") ++ statToGlsl i next + + Nop -> + "" relationToString : RelationOperation -> String @@ -160,6 +160,11 @@ internalNop () = expressionToGlsl : Expression t -> String expressionToGlsl (Expression tree) = + exprToGlsl tree.expr + + +exprToGlsl : Expr -> String +exprToGlsl tree = let -- The numbers are precedence numbers from the GLSL spec go : Bool -> Expr -> String From 06d16c61c601cf7a7120101c9b8ce985e607021c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 10 Dec 2022 14:38:35 +0100 Subject: [PATCH 078/139] Generating bindings for builtins, removing obsolete code --- Makefile | 5 +- codegen/Generate.elm | 481 +++-- codegen/Glsl/GlslConverter.elm | 5 +- codegen/functions.frag | 5 +- codegen/helpers/Glsl/Helper.elm | 129 +- src/elm/UI/Glsl.elm | 10 +- src/elm/UI/Glsl/Code.elm | 3117 +------------------------------ src/elm/UI/Glsl/Generator.elm | 546 ++---- src/shaders/declarations.frag | 66 - 9 files changed, 534 insertions(+), 3830 deletions(-) delete mode 100644 src/shaders/declarations.frag diff --git a/Makefile b/Makefile index 56516183..4f04244c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ .PHONY: all all: generated/Glsl.elm -generated/Glsl.elm: codegen/functions.frag codegen/Generate.elm codegen/helpers/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile +generated/Glsl.elm: codegen/functions.frag codegen/Generate.elm codegen/Gen/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile elm-codegen run --flags-from $< + +codegen/Gen/Glsl/Helper.elm: codegen/helpers/Glsl/Helper.elm + elm-codegen install diff --git a/codegen/Generate.elm b/codegen/Generate.elm index b03345e9..ee46025d 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -44,7 +44,7 @@ generate glsl = (List.map Tuple.first args) returnType ) - { functionsEnv = builtinFunctions + { functionsEnv = builtinFunctions |> Dict.map (\_ -> Tuple.second) , variablesEnv = builtinUniforms } functions @@ -57,7 +57,7 @@ generate glsl = in case maybeDecls of Ok decls -> - declarationsDictionary functions :: List.concat decls + declarationsDictionary functions :: List.concat decls ++ builtinDecls Err e -> "Error generating file" @@ -155,16 +155,6 @@ type alias Env = functionToDeclarations : Env -> Function -> Result String (List Elm.Declaration) functionToDeclarations env function = let - argDecls : List ( String, Maybe Type.Annotation ) - argDecls = - List.map - (\( _, name ) -> - ( name - , Just Gen.Glsl.Helper.annotation_.expression - ) - ) - function.args - envWithArgs : Env envWithArgs = List.foldl (\( type_, name ) -> variableHasType name type_) env function.args @@ -176,29 +166,100 @@ functionToDeclarations env function = in Result.map (\deps -> - let - expr : List Elm.Expression -> Elm.Expression - expr args = - Gen.Glsl.Helper.call_.call - (Elm.string function.name) - (Elm.list args) - (deps - |> Set.toList - |> List.map Elm.string - |> Elm.list - ) - |> Elm.withType Gen.Glsl.Helper.annotation_.expression - in [ Elm.string function.body |> Elm.declaration (function.name ++ "Body") - , Elm.function argDecls expr - |> Elm.declaration function.name - |> Elm.expose + , wrapFunction function.name function.args function.returnType deps ] ) maybeDeps +wrapFunction : String -> List ( Type, String ) -> Type -> Set String -> Elm.Declaration +wrapFunction name args returnType deps = + let + argDecls : List ( String, Maybe Type.Annotation ) + argDecls = + List.map + (\( type_, argName ) -> + ( argName + , Just <| Gen.Glsl.Helper.annotation_.expression (typeToAnnotation type_) + ) + ) + args + + innerCall argValues _ = + case argValues of + [] -> + Gen.Glsl.Helper.unsafeCall0 name + + [ arg0 ] -> + Gen.Glsl.Helper.unsafeCall1 name arg0 + + [ arg0, arg1 ] -> + Gen.Glsl.Helper.unsafeCall2 name arg0 arg1 + + [ arg0, arg1, arg2 ] -> + Gen.Glsl.Helper.unsafeCall3 name arg0 arg1 arg2 + + [ arg0, arg1, arg2, arg3 ] -> + Gen.Glsl.Helper.unsafeCall4 name arg0 arg1 arg2 arg3 + + _ :: _ :: _ -> + Elm.string "TODO" + + expr : List Elm.Expression -> Elm.Expression + expr argValues = + innerCall + argValues + (deps + |> Set.toList + |> List.map Elm.string + |> Elm.list + ) + |> Elm.withType (Gen.Glsl.Helper.annotation_.expression (typeToAnnotation returnType)) + in + Elm.function argDecls expr + |> Elm.declaration name + |> Elm.expose + + +typeToAnnotation : Type -> Type.Annotation +typeToAnnotation type_ = + case type_ of + TBool -> + Type.bool + + TFloat -> + Type.float + + TInt -> + Type.int + + TVec2 -> + Gen.Glsl.Helper.annotation_.vec2 + + TIVec2 -> + Gen.Glsl.Helper.annotation_.iVec2 + + TVec3 -> + Gen.Glsl.Helper.annotation_.vec3 + + TIVec3 -> + Gen.Glsl.Helper.annotation_.iVec3 + + TVec4 -> + Gen.Glsl.Helper.annotation_.vec4 + + TIVec4 -> + Gen.Glsl.Helper.annotation_.iVec4 + + TMat3 -> + Gen.Glsl.Helper.annotation_.mat3 + + TVoid -> + Gen.Glsl.Helper.annotation_.void + + variableHasType : String -> Type -> Env -> Env variableHasType var type_ env = { env | variablesEnv = Dict.insert var type_ env.variablesEnv } @@ -480,44 +541,44 @@ binaryOperationToString bop = fullName : String -> List Type -> String fullName baseName argTypes = - let - typeToShort : Type -> String - typeToShort t = - case t of - TFloat -> - "1" + String.concat (baseName :: List.map typeToShort argTypes) + + +typeToShort : Type -> String +typeToShort t = + case t of + TFloat -> + "1" - TInt -> - "i1" + TInt -> + "i1" - TVec2 -> - "2" + TVec2 -> + "2" - TIVec2 -> - "i2" + TIVec2 -> + "i2" - TVec3 -> - "3" + TVec3 -> + "3" - TIVec3 -> - "i3" + TIVec3 -> + "i3" - TVec4 -> - "4" + TVec4 -> + "4" - TIVec4 -> - "i4" + TIVec4 -> + "i4" - TMat3 -> - "m3" + TMat3 -> + "m3" - TVoid -> - "v" + TVoid -> + "v" - TBool -> - "b1" - in - String.concat (baseName :: List.map typeToShort argTypes) + TBool -> + "b1" builtinUniforms : Dict String Type @@ -535,17 +596,17 @@ builtinUniforms = |> Dict.fromList -builtinFunctions : Dict String Type +builtinFunctions : Dict String ( List Type, Type ) builtinFunctions = let - overload : List String -> List ( String, Type ) -> List ( String, Type ) + overload : List String -> List ( List Type, Type ) -> List ( String, List Type, Type ) overload names kinds = List.Extra.lift2 - (\name ( suffix, result ) -> ( name ++ suffix, result )) + (\name ( inTypes, result ) -> ( name, inTypes, result )) names kinds - regular : List ( String, Type ) + regular : List ( String, List Type, Type ) regular = [ builtin_v_v , builtin_v_s @@ -560,7 +621,7 @@ builtinFunctions = ] |> List.concatMap (\( names, kinds ) -> overload names kinds) - vecs : List ( String, Type ) + vecs : List ( String, List Type, Type ) vecs = [ ( 2, TVec2 ) , ( 3, TVec3 ) @@ -569,135 +630,133 @@ builtinFunctions = |> List.concatMap (\( size, type_ ) -> List.map - (\opt -> - ( "vec" ++ String.fromInt size ++ opt, type_ ) + (\inTypes -> + ( "vec" ++ String.fromInt size, inTypes, type_ ) ) - ([ "1", "i1" ] + ([ TFloat, TInt ] |> List.repeat size |> List.Extra.cartesianProduct - |> List.map String.concat - |> (++) [ "i1", "1", "13" ] + |> (++) [ [ TInt ], [ TFloat ], [ TFloat, TVec3 ] ] ) ) - ivecs : List ( String, Type ) + ivecs : List ( String, List Type, Type ) ivecs = [ ( 2, TVec2 ) , ( 3, TVec3 ) , ( 4, TVec4 ) ] - |> List.concatMap + |> List.map (\( size, type_ ) -> - List.map - (\opt -> - ( "ivec" ++ String.fromInt size ++ opt, type_ ) - ) - ([ "i1" ] - |> List.repeat size - |> List.Extra.cartesianProduct - |> List.map String.concat - |> (++) [ "i1" ] - ) + ( "ivec" ++ String.fromInt size, List.repeat size TInt, type_ ) ) - others : List ( String, Type ) + others : List ( String, List Type, Type ) others = - [ ( "cross33", TVec3 ) - , ( "floati1", TFloat ) - , ( "int1", TInt ) + [ ( "cross", [ TVec3, TVec3 ], TVec3 ) + , ( "float", [ TInt ], TFloat ) + , ( "int", [ TFloat ], TInt ) ] in - Dict.fromList <| regular ++ vecs ++ ivecs ++ others + (regular ++ vecs ++ ivecs ++ others) + |> List.map + (\( name, inTypes, resultType ) -> + ( fullName name inTypes, ( inTypes, resultType ) ) + ) + |> Dict.fromList -builtin_vv_s : ( List String, List ( String, Type ) ) -builtin_vv_s = +builtin_v_s : ( List String, List ( List Type, Type ) ) +builtin_v_s = ( [ -- Geometric - "distance" - , "dot" + "length" ] - , [ ( "11", TFloat ) - , ( "22", TFloat ) - , ( "33", TFloat ) - , ( "44", TFloat ) + , [ ( [ TFloat ], TFloat ) + , ( [ TVec2 ], TFloat ) + , ( [ TVec3 ], TFloat ) + , ( [ TVec4 ], TFloat ) ] ) -builtin_vvs_v : ( List String, List ( String, Type ) ) -builtin_vvs_v = - ( [ --Geometric - "refract" - - -- Other - , "mix" - ] - , [ ( "111", TFloat ) - , ( "221", TVec2 ) - , ( "331", TVec3 ) - , ( "441", TVec4 ) - ] - ) +builtin_v_v : ( List String, List ( List Type, Type ) ) +builtin_v_v = + ( [ -- Rounding + "ceil" + , "floor" + , "round" + , "fract" + -- Complex and power + , "sign" + , "exp" + , "log" + , "abs" + , "exp2" + , "log2" + , "sqrt" + , "inversesqrt" -builtin_ssv_v : ( List String, List ( String, Type ) ) -builtin_ssv_v = - ( [ -- Other - "smoothstep" + -- Trig + , "radians" + , "degrees" + , "sin" + , "cos" + , "tan" + , "asin" + , "acos" + , "atan" + , "normalize" ] - , [ ( "111", TFloat ) - , ( "112", TVec2 ) - , ( "113", TVec3 ) - , ( "114", TVec4 ) + , [ ( [ TFloat ], TFloat ) + , ( [ TVec2 ], TVec2 ) + , ( [ TVec3 ], TVec3 ) + , ( [ TVec4 ], TVec4 ) ] ) -builtin_vss_v : ( List String, List ( String, Type ) ) -builtin_vss_v = - ( [ -- Other - "clamp" - ] - , [ ( "111", TFloat ) - , ( "211", TVec2 ) - , ( "311", TVec3 ) - , ( "411", TVec4 ) - ] - ) +builtin_vv_v : ( List String, List ( List Type, Type ) ) +builtin_vv_v = + ( [ -- Comparison + "min" + , "max" + -- Complex and power + , "pow" -builtin_vvv_v : ( List String, List ( String, Type ) ) -builtin_vvv_v = - ( [ -- Other - "clamp" - , "mix" - , "smoothstep" + -- Trig + , "atan" -- Geometry - , "faceforward" + , "reflect" + + -- Other + , "mod" + , "step" ] - , [ ( "111", TFloat ) - , ( "222", TVec2 ) - , ( "333", TVec3 ) - , ( "444", TVec4 ) + , [ ( [ TFloat, TFloat ], TFloat ) + , ( [ TVec2, TVec2 ], TVec2 ) + , ( [ TVec3, TVec3 ], TVec3 ) + , ( [ TVec4, TVec4 ], TVec4 ) ] ) -builtin_sv_v : ( List String, List ( String, Type ) ) +builtin_sv_v : ( List String, List ( List Type, Type ) ) builtin_sv_v = ( [ -- Other "step" ] - , [ ( "11", TFloat ) - , ( "12", TVec2 ) - , ( "13", TVec3 ) - , ( "14", TVec4 ) + , [ ( [ TFloat, TFloat ], TFloat ) + , ( [ TFloat, TVec2 ], TVec2 ) + , ( [ TFloat, TVec3 ], TVec3 ) + , ( [ TFloat, TVec4 ], TVec4 ) ] ) -builtin_vs_v : ( List String, List ( String, Type ) ) +builtin_vs_v : ( List String, List ( List Type, Type ) ) builtin_vs_v = ( [ -- Comparison "min" @@ -706,91 +765,111 @@ builtin_vs_v = -- Other , "mod" ] - , [ ( "11", TFloat ) - , ( "21", TVec2 ) - , ( "31", TVec3 ) - , ( "41", TVec4 ) + , [ ( [ TFloat, TFloat ], TFloat ) + , ( [ TVec2, TFloat ], TVec2 ) + , ( [ TVec3, TFloat ], TVec3 ) + , ( [ TVec4, TFloat ], TVec4 ) ] ) -builtin_vv_v : ( List String, List ( String, Type ) ) -builtin_vv_v = - ( [ -- Comparison - "min" - , "max" - - -- Complex and power - , "pow" +builtin_vv_s : ( List String, List ( List Type, Type ) ) +builtin_vv_s = + ( [ -- Geometric + "distance" + , "dot" + ] + , [ ( [ TFloat, TFloat ], TFloat ) + , ( [ TVec2, TVec2 ], TFloat ) + , ( [ TVec3, TVec3 ], TFloat ) + , ( [ TVec4, TVec4 ], TFloat ) + ] + ) - -- Trig - , "atan" - -- Geometry - , "reflect" +builtin_vvs_v : ( List String, List ( List Type, Type ) ) +builtin_vvs_v = + ( [ --Geometric + "refract" -- Other - , "mod" - , "step" + , "mix" ] - , [ ( "11", TFloat ) - , ( "22", TVec2 ) - , ( "33", TVec3 ) - , ( "44", TVec4 ) + , [ ( [ TFloat, TFloat, TFloat ], TFloat ) + , ( [ TVec2, TVec2, TFloat ], TVec2 ) + , ( [ TVec3, TVec3, TFloat ], TVec3 ) + , ( [ TVec4, TVec4, TFloat ], TVec4 ) ] ) -builtin_v_s : ( List String, List ( String, Type ) ) -builtin_v_s = - ( [ -- Geometric - "length" +builtin_ssv_v : ( List String, List ( List Type, Type ) ) +builtin_ssv_v = + ( [ -- Other + "smoothstep" ] - , [ ( "1", TFloat ) - , ( "2", TFloat ) - , ( "3", TFloat ) - , ( "4", TFloat ) + , [ ( [ TFloat, TFloat, TFloat ], TFloat ) + , ( [ TFloat, TFloat, TVec2 ], TVec2 ) + , ( [ TFloat, TFloat, TVec3 ], TVec3 ) + , ( [ TFloat, TFloat, TVec4 ], TVec4 ) ] ) -builtin_v_v : ( List String, List ( String, Type ) ) -builtin_v_v = - ( [ -- Rounding - "ceil" - , "floor" - , "round" - , "fract" +builtin_vss_v : ( List String, List ( List Type, Type ) ) +builtin_vss_v = + ( [ -- Other + "clamp" + ] + , [ ( [ TFloat, TFloat, TFloat ], TFloat ) + , ( [ TVec2, TFloat, TFloat ], TVec2 ) + , ( [ TVec3, TFloat, TFloat ], TVec3 ) + , ( [ TVec4, TFloat, TFloat ], TVec4 ) + ] + ) - -- Complex and power - , "sign" - , "exp" - , "log" - , "abs" - , "exp2" - , "log2" - , "sqrt" - , "inversesqrt" - -- Trig - , "radians" - , "degrees" - , "sin" - , "cos" - , "tan" - , "asin" - , "acos" - , "atan" - , "normalize" +builtin_vvv_v : ( List String, List ( List Type, Type ) ) +builtin_vvv_v = + ( [ -- Other + "clamp" + , "mix" + , "smoothstep" + + -- Geometry + , "faceforward" ] - , [ ( "1", TFloat ) - , ( "2", TVec2 ) - , ( "3", TVec3 ) - , ( "4", TVec4 ) + , [ ( [ TFloat, TFloat, TFloat ], TFloat ) + , ( [ TVec2, TVec2, TVec2 ], TVec2 ) + , ( [ TVec3, TVec3, TVec3 ], TVec3 ) + , ( [ TVec4, TVec4, TVec4 ], TVec4 ) ] ) +builtinDecls : List Elm.Declaration +builtinDecls = + builtinFunctions + |> Dict.toList + |> List.map + (\( name, ( inTypes, resultType ) ) -> + wrapFunction + name + (List.indexedMap + (\i type_ -> ( type_, indexedVar i )) + inTypes + ) + resultType + Set.empty + |> Elm.expose + ) + + +indexedVar : Int -> String +indexedVar i = + String.fromChar <| Char.fromCode <| Char.toCode 'a' + i + + parseFile : String -> Result (List Parser.DeadEnd) (List Function) parseFile glsl = Parser.run Glsl.Parser.file glsl diff --git a/codegen/Glsl/GlslConverter.elm b/codegen/Glsl/GlslConverter.elm index 9cdd6747..750a18c4 100644 --- a/codegen/Glsl/GlslConverter.elm +++ b/codegen/Glsl/GlslConverter.elm @@ -7,7 +7,6 @@ import Element.Font as Font import Element.Input as Input import Glsl.Parser as Parser import Glsl.PrettyPrinter as PrettyPrinter -import Glsl.Simplify as Simplify import Glsl.Types exposing (Function, Statement) import Html import Parser exposing ((|.), (|=), DeadEnd, Step(..), Trailing(..), oneOf, spaces, succeed) @@ -128,10 +127,10 @@ toOutput i = Debug.toString e Ok (Left o) -> - PrettyPrinter.function <| Simplify.function o + PrettyPrinter.function o Ok (Right o) -> - PrettyPrinter.statement <| Simplify.statement o + PrettyPrinter.statement o parse : String -> Result (List DeadEnd) (Either Function Statement) diff --git a/codegen/functions.frag b/codegen/functions.frag index b0405284..33734cfe 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -3,6 +3,9 @@ #define P31 2147483648 #define P32M1 4294967295 +#define PIHALF 1.5707963267948966 +#define PI 3.141592653589793 +#define TWOPI 6.283185307179586 precision highp float; @@ -213,7 +216,7 @@ vec2 ccbrt(vec2 z) { vec2 csquare(vec2 z) { return cby(z, z); } -vec2 clog10(vec2 z) { return cdiv(cln(z), vec2(log(10.), 0)); } +vec2 clog10(vec2 z) { return cln(z) / log(10.); } vec2 cre(vec2 z) { return vec2(z.x, 0); } vec2 cim(vec2 z) { return vec2(z.y, 0); } diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl/Helper.elm index de4ed848..00923c68 100644 --- a/codegen/helpers/Glsl/Helper.elm +++ b/codegen/helpers/Glsl/Helper.elm @@ -1,15 +1,45 @@ -module Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Mat3(..), Name(..), RelationOperation(..), Stat(..), Statement(..), TypingFunction, Vec2(..), Vec3(..), Vec4(..), innerCall) +module Glsl.Helper exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), IVec2, IVec3, IVec4, Mat3(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2(..), Vec3(..), Vec4(..), Void, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4) import Set exposing (Set) -innerCall : String -> List ExprWithDeps -> List String -> ExprWithDeps -innerCall name args deps = - { expr = Call name (List.map .expr args) - , deps = - List.map .deps args - |> List.foldr Set.union (Set.fromList deps) - } +unsafeCall0 : String -> Expression r +unsafeCall0 name = + unsafeCall name [] + + +unsafeCall1 : String -> Expression t -> Expression r +unsafeCall1 name (Expression arg0) = + unsafeCall name [ arg0 ] + + +unsafeCall2 : String -> Expression t -> Expression u -> Expression r +unsafeCall2 name (Expression arg0) (Expression arg1) = + unsafeCall name [ arg0, arg1 ] + + +unsafeCall3 : String -> Expression t -> Expression u -> Expression v -> Expression r +unsafeCall3 name (Expression arg0) (Expression arg1) (Expression arg2) = + unsafeCall name [ arg0, arg1, arg2 ] + + +unsafeCall4 : String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r +unsafeCall4 name (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) = + unsafeCall name [ arg0, arg1, arg2, arg3 ] + + +unsafeCall : String -> List ExprWithDeps -> Expression t +unsafeCall name args = + Expression + { expr = + args + |> List.map .expr + |> Call name + , deps = + args + |> List.map .deps + |> List.foldr Set.union (Set.singleton name) + } @@ -35,12 +65,9 @@ type Expr | Or Expr Expr | Comparison RelationOperation Expr Expr | Ternary Expr Expr Expr - | Add Expr Expr - | Subtract Expr Expr - | By Expr Expr - | Div Expr Expr + | UnaryOperation UnaryOperation Expr + | BinaryOperation BinaryOperation Expr Expr | Call String (List Expr) - | Negate Expr | PostfixIncrement Expr | PostfixDecrement Expr | Unknown String @@ -50,6 +77,17 @@ type Expr | AssignCombo ComboOperation Expr Expr +type BinaryOperation + = Add + | Subtract + | By + | Div + + +type UnaryOperation + = Negate + + type RelationOperation = LessThan | LessThanOrEquals @@ -66,47 +104,6 @@ type ComboOperation | ComboDiv -type alias ExpressionX a t = - { a | base : Expression t } - - -type alias Expression1 t = - { base : Expression t - } - - -type alias Expression2 = - { base : Expression Vec2 - , x : Expression1 Float - , y : Expression1 Float - , yx : Expression1 Vec2 - } - - -type alias Expression3 = - { base : Expression Vec3 - , x : Expression1 Float - , y : Expression1 Float - , z : Expression1 Float - } - - -type alias Expression4 = - { base : Expression Vec4 - , x : Expression1 Float - , y : Expression1 Float - , z : Expression1 Float - , w : Expression1 Float - , xy : Expression2 - , yx : Expression2 - , yzw : Expression3 - } - - -type alias Expression33 = - { base : Expression Mat3 } - - -- Typed statements @@ -131,12 +128,12 @@ type Stat | Nop -type alias TypingFunction t r = - String -> ( TypedName t r, Expression t -> r ) +type alias TypingFunction t = + String -> TypedName t -type TypedName t r - = TypedName Type Name r +type TypedName t + = TypedName Type Name type Type @@ -163,5 +160,21 @@ type Vec4 = Vec4 Vec4 +type IVec2 + = IVec2 IVec2 + + +type IVec3 + = IVec3 IVec3 + + +type IVec4 + = IVec4 IVec4 + + type Mat3 = Mat3 Mat3 + + +type Void + = Void Void diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index ffd91d22..fc288bbc 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -149,15 +149,7 @@ getGlsl rayDifferentials graph = |> List.map (requirementToGlsl interval) |> String.join "\n" in - "#define MAX_DEPTH 30\n" - ++ "#define PIHALF " - ++ String.fromFloat (pi / 2) - ++ "\n#define PI " - ++ String.fromFloat pi - ++ "\n#define TWOPI " - ++ String.fromFloat (pi * 2) - ++ "\n" - ++ declarations + declarations ++ thetaDeltaCode ++ reqs ++ "\n/* Expression */\n" diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index d44671b3..c073068a 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,2402 +1,14 @@ -module UI.Glsl.Code exposing (atanPlusDecl, cexpFunction, constantToGlsl, dupDecl, expressionToGlsl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, suffixToBisect, thetaDeltaDecl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +module UI.Glsl.Code exposing (expressionToGlsl, threshold) -import Dict exposing (Dict) +import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl.Helper exposing (Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX) -import UI.Glsl.Generator exposing (Constant, Continue, File, FunDecl, Mat3, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add33, add4, adds3, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted4, eq, exp, expr, false, fileToGlsl, float, floatCast, floatT, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, int, intCast, intT, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, uniform, unsafeCall, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +import Glsl exposing (vec211) +import Glsl.Helper exposing (Expression) +import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negate2, one, subtract, subtract2, vec2Zero, zero) import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) -type alias Uniforms = - { u_canvasHeight : Expression1 Float - , u_canvasWidth : Expression1 Float - , u_drawAxes : Expression1 Float - , u_viewportHeight : Expression1 Float - , u_viewportWidth : Expression1 Float - , u_whiteLines : Expression1 Float - , u_zoomCenter : Expression2 - , u_phi : Expression1 Float - , u_theta : Expression1 Float - , u_completelyReal : Expression1 Float - } - - -constantToGlsl : GlslConstant -> ( FunDecl, Expression2 ) -constantToGlsl c = - case c of - I -> - fun0 vec2T "i" <| - return (vec2 zero one) - - Pi -> - fun0 vec2T "pi" <| - return (vec2 constants.pi zero) - - E -> - fun0 vec2T "e" <| - return (vec2 (exp one) zero) - - -atanPlusTuple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float ) -atanPlusTuple = - fun2 floatT "atanPlus" (floatT "y") (floatT "x") <| - \y x -> - return <| mod (add constants.twopi (atan2_ y x)) constants.twopi - - -atanPlusDecl : FunDecl -atanPlusDecl = - Tuple.first atanPlusTuple - - -atanPlus : ExpressionX xa Float -> ExpressionX xb Float -> Expression1 Float -atanPlus = - Tuple.second atanPlusTuple - - -gnumTuple : ( FunDecl, ExpressionX xa Float -> Expression4 ) -gnumTuple = - fun1 vec4T "gnum" (floatT "f") <| \f -> return <| vec4 f zero zero zero - - -gnumDecl : FunDecl -gnumDecl = - Tuple.first gnumTuple - - -gnum : ExpressionX xa Float -> Expression4 -gnum = - Tuple.second gnumTuple - - -dupTuple : ( FunDecl, ExpressionX xa Float -> Expression2 ) -dupTuple = - fun1 vec2T "dup" (floatT "x") <| \x -> return <| vec2 x x - - -dupDecl : FunDecl -dupDecl = - Tuple.first dupTuple - - -dup : ExpressionX xa Float -> Expression2 -dup = - Tuple.second dupTuple - - -cby3Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) -cby3Tuple = - fun3 vec2T "cby" (vec2T "a") (vec2T "b") (vec2T "c") <| - \a b c -> - return <| cby (cby a b) c - - -cby3Decl : FunDecl -cby3Decl = - Tuple.first cby3Tuple - - -cdivTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cdivTuple = - fun2 vec2T "cdiv" (vec2T "a") (vec2T "b") <| - \a b nop -> - def floatT "k" (div one <| dot b b) <| - \k -> - def floatT "r" (by k <| dot a b) <| - \r -> - def floatT "i" (by k (subtract (by a.y b.x) (by a.x b.y))) <| - \i -> - return (vec2 r i) nop - - -cdivDecl : FunDecl -cdivDecl = - Tuple.first cdivTuple - - -cdiv : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cdiv = - Tuple.second cdivTuple - - -log10Tuple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) -log10Tuple = - fun1 floatT "log10" (floatT "x") <| - \x -> return <| div (log x) (log <| float 10) - - -log10Decl : FunDecl -log10Decl = - Tuple.first log10Tuple - - -log10 : ExpressionX xa Float -> Expression1 Float -log10 = - Tuple.second log10Tuple - - -straightOperationToGlsl : GlslOperation -> List FunDecl -straightOperationToGlsl op = - case op of - GlslAddition -> - [] - - GlslMultiplication -> - [ cbyDecl - , cby3Decl - ] - - GlslNegation -> - [] - - GlslDivision -> - [ cdivDecl ] - - GlslPower -> - [ cpowDecl ] - - GlslRelations -> - [] - - -cpowTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cpowTuple = - fun2 vec2T "cpow" (vec2T "w") (vec2T "z") <| - \w z -> - return <| - ternary - (ands - [ geq w.x zero - , eq w.y zero - , eq z.y zero - ] - ) - (vec2 (pow w.x z.x) zero) - (cexp <| cby (cln w) z) - - -cpowDecl : FunDecl -cpowDecl = - Tuple.first cpowTuple - - -cpow : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cpow = - Tuple.second cpowTuple - - -inegCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -inegCouple = - fun1 vec2T "ineg" (vec2T "v") <| - \v -> - return <| negate_ v.yx - - -inegDecl : FunDecl -inegDecl = - Tuple.first inegCouple - - -ineg : ExpressionX xa Vec2 -> Expression2 -ineg = - Tuple.second inegCouple - - -gnegCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -gnegCouple = - fun1 vec4T "gneg" (vec4T "v") <| \v -> return <| negate_ v - - -gnegDecl : FunDecl -gnegDecl = - Tuple.first gnegCouple - - -gneg : ExpressionX xa Vec4 -> Expression4 -gneg = - Tuple.second gnegCouple - - -isquareCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -isquareCouple = - fun1 vec2T "isquare" (vec2T "z") <| - \z nop -> - def vec2T "s" (by z z) <| - \s -> - def floatT "mx" (max_ s.x s.y) <| - \mx -> - if_ (ands [ leq z.x zero, geq z.y zero ]) - (return <| vec2 zero mx) - <| - \_ -> - def floatT "mn" (min_ s.x s.y) <| - \mn -> - return (vec2 mn mx) nop - - -isquareDecl : FunDecl -isquareDecl = - Tuple.first isquareCouple - - -isquare : ExpressionX xa Vec2 -> Expression2 -isquare = - Tuple.second isquareCouple - - -gsquareCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -gsquareCouple = - fun1 vec4T "gsquare" (vec4T "z") <| - \z -> - return <| vec4_1_3 (by z.x z.x) z.yzw - - -gsquareDecl : FunDecl -gsquareDecl = - Tuple.first gsquareCouple - - -gsquare : ExpressionX xa Vec4 -> Expression4 -gsquare = - Tuple.second gsquareCouple - - -gbyCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) -gbyCouple = - fun2 vec4T "gby" (vec4T "l") (vec4T "r") <| - \l r -> - return <| vec4_1_3 (by l.x r.x) (add (byF l.x r.yzw) (byF r.x l.yzw)) - - -gbyDecl : FunDecl -gbyDecl = - Tuple.first gbyCouple - - -gby : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 -gby = - Tuple.second gbyCouple - - -ibyCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -ibyCouple = - fun2 vec2T "iby" (vec2T "l") (vec2T "r") <| - \l r nop -> - def floatT "a" (by l.x r.x) <| - \a -> - def floatT "b" (by l.x r.y) <| - \b -> - def floatT "c" (by l.y r.x) <| - \c -> - def floatT "d" (by l.y r.y) <| - \d -> - def floatT "mn" (min_ (min_ a b) (min_ c d)) <| - \mn -> - def floatT "mx" (max_ (max_ a b) (max_ c d)) <| - \mx -> - return (vec2 mn mx) nop - - -ibyDecl : FunDecl -ibyDecl = - Tuple.first ibyCouple - - -iby : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -iby = - Tuple.second ibyCouple - - -iinverseCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -iinverseCouple = - fun1 vec2T "iinverse" (vec2T "y") <| - \y -> - return <| - ternary - (ands [ leq y.x zero, geq y.y zero ]) - (vec2 (div minusOne zero) (div one zero)) - (ternary - (eq y.y zero) - (vec2 (div minusOne zero) (div one y.x)) - (ternary - (eq y.x zero) - (vec2 (div one y.y) (div one zero)) - (vec2 (div one y.y) (div one y.x)) - ) - ) - - -iinverseDecl : FunDecl -iinverseDecl = - Tuple.first iinverseCouple - - -iinverse : ExpressionX xa Vec2 -> Expression2 -iinverse = - Tuple.second iinverseCouple - - -idivCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -idivCouple = - fun2 vec2T "idiv" (vec2T "l") (vec2T "r") <| - \l r -> - return <| iby l (iinverse r) - - -idivDecl : FunDecl -idivDecl = - Tuple.first idivCouple - - -idiv : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -idiv = - Tuple.second idivCouple - - -gdivCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) -gdivCouple = - fun2 vec4T "gdiv" (vec4T "l") (vec4T "r") <| - \l r -> - return <| - vec4_1_3 (div l.x r.x) - (divF - (subtract (byF r.x l.yzw) (byF l.x r.yzw)) - (pow r.x <| float 2) - ) - - -gdivDecl : FunDecl -gdivDecl = - Tuple.first gdivCouple - - -gdiv : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 -gdiv = - Tuple.second gdivCouple - - -ipowFICouple : ( FunDecl, ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float ) -ipowFICouple = - fun2 floatT "ipow" (floatT "b") (intT "e") <| - \b e nop -> - def floatT "fe" (floatCast e) <| - \fe -> - return - (ternary - (eq (mod fe (float 2.0)) zero) - (pow (abs_ b) fe) - (by b <| pow (abs_ b) (subtract fe one)) - ) - nop - - -ipowFIDecl : FunDecl -ipowFIDecl = - Tuple.first ipowFICouple - - -ipowFI : ExpressionX xa Float -> ExpressionX xb Int -> Expression1 Float -ipowFI = - Tuple.second ipowFICouple - - -ipowICouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 ) -ipowICouple = - fun2 vec2T "ipow" (vec2T "b") (intT "e") <| - \b e nop -> - if_ (eq e (int 0)) - (return <| vec2 one one) - <| - \_ -> - if_ (eq e (int 1)) - (return b) - <| - \_ -> - def floatT "xe" (ipowFI b.x e) <| - \xe -> - def floatT "ye" (ipowFI b.y e) <| - \ye -> - def floatT "mn" (min_ xe ye) <| - \mn -> - def floatT "mx" (max_ xe ye) <| - \mx -> - return - (ternary - (ands - [ eq (mod (floatCast e) (float 2)) zero - , leq b.x zero - , geq b.y zero - ] - ) - (vec2 (min_ zero mn) (max_ zero mx)) - (vec2 mn mx) - ) - nop - - -ipowIDecl : FunDecl -ipowIDecl = - Tuple.first ipowICouple - - -ipowI : ExpressionX xa Vec2 -> ExpressionX xb Int -> Expression2 -ipowI = - Tuple.second ipowICouple - - -ipowCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -ipowCouple = - fun2 vec2T "ipow" (vec2T "b") (vec2T "e") <| - \b e -> - return <| - ternary - (ands - [ lt (subtract e.y e.x) (float 0.000001) - , lt (abs_ <| subtract e.x (round_ e.x)) (float 0.000001) - ] - ) - (ipowI b <| intCast e.x) - (iexp <| iby (iln b) e) - - -ipowDecl : FunDecl -ipowDecl = - Tuple.first ipowCouple - - -ipow : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -ipow = - Tuple.second ipowCouple - - -gpowICouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 ) -gpowICouple = - fun2 vec4T "gpow" (vec4T "b") (intT "e") <| - \b e -> - return <| - vec4_1_3 - (pow b.x <| floatCast e) - (byF (by b.x <| floatCast <| subtract e (int 1)) b.yzw) - - -gpowIDecl : FunDecl -gpowIDecl = - Tuple.first gpowICouple - - -gpowI : ExpressionX xa Vec4 -> ExpressionX xb Int -> Expression4 -gpowI = - Tuple.second gpowICouple - - -gpowCouple : ( FunDecl, ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 ) -gpowCouple = - fun2 vec4T "gpow" (vec4T "b") (vec4T "e") <| - \b e nop -> - def intT "ie" (intCast e.x) <| - \ie -> - if_ (ands [ eq (floatCast ie) e.x, eq e.y zero, eq e.z zero, eq e.w zero ]) - (return <| gpowI b ie) - <| - \_ -> - return (gexp <| gby (gln b) e) nop - - -gpowDecl : FunDecl -gpowDecl = - Tuple.first gpowCouple - - -gpow : ExpressionX xa Vec4 -> ExpressionX xb Vec4 -> Expression4 -gpow = - Tuple.second gpowCouple - - -iltCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -iltCouple = - fun2 vec2T "ilt" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx - - -iltDecl : FunDecl -iltDecl = - Tuple.first iltCouple - - -ilt : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -ilt = - Tuple.second iltCouple - - -ileqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -ileqCouple = - fun2 vec2T "ileq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx - - -ileqDecl : FunDecl -ileqDecl = - Tuple.first ileqCouple - - -ileq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -ileq = - Tuple.second ileqCouple - - -ineqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -ineqCouple = - fun2 vec2T "ineq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract r l.yx - - -ineqDecl : FunDecl -ineqDecl = - Tuple.first ineqCouple - - -ineq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -ineq = - Tuple.second ineqCouple - - -ieqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -ieqCouple = - fun2 vec2T "ieq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx - - -ieqDecl : FunDecl -ieqDecl = - Tuple.first ieqCouple - - -ieq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -ieq = - Tuple.second ieqCouple - - -igeqCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -igeqCouple = - fun2 vec2T "igeq" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx - - -igeqDecl : FunDecl -igeqDecl = - Tuple.first igeqCouple - - -igeq : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -igeq = - Tuple.second igeqCouple - - -igtCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -igtCouple = - fun2 vec2T "igt" (vec2T "l") (vec2T "r") <| \l r -> return <| subtract l r.yx - - -igtDecl : FunDecl -igtDecl = - Tuple.first igtCouple - - -igt : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -igt = - Tuple.second igtCouple - - -iabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -iabsCouple = - fun1 vec2T "iabs" (vec2T "z") <| - \z -> - return <| - ternary - (ands [ leq z.x zero, geq z.y zero ]) - (vec2 zero <| max_ z.y <| abs_ z.x) - (ternary - (leq z.x zero) - (negate_ z.yx) - z - ) - - -iabsDecl : FunDecl -iabsDecl = - Tuple.first iabsCouple - - -iabs : ExpressionX xa Vec2 -> Expression2 -iabs = - Tuple.second iabsCouple - - -iacosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -iacosCouple = - fun1 vec2T "iacos" (vec2T "z") <| - \z nop -> - -- Don't use clamp so if z is fully outside range the result is empty - def vec2T "clamped" (vec2 (max_ z.x (negate_ one)) (min_ z.y one)) <| - \clamped -> - return (acos2 clamped).yx nop - - -iacosDecl : FunDecl -iacosDecl = - Tuple.first iacosCouple - - -iacos : ExpressionX xa Vec2 -> Expression2 -iacos = - Tuple.second iacosCouple - - -gacosCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -gacosCouple = - fun1 vec4T "gacos" (vec4T "v") <| - \v -> - return <| - vec4_1_3 - (acos_ v.x) - (divF (negate_ v.yzw) (sqrt_ (subtract one (by v.x v.x)))) - - -gacosDecl : FunDecl -gacosDecl = - Tuple.first gacosCouple - - -gacos : ExpressionX xa Vec4 -> Expression4 -gacos = - Tuple.second gacosCouple - - -gabsCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -gabsCouple = - fun1 vec4T "gabs" (vec4T "v") <| \v -> return <| vec4_1_3 (abs_ v.x) (byF (sign v.x) v.yzw) - - -gabsDecl : FunDecl -gabsDecl = - Tuple.first gabsCouple - - -gabs : ExpressionX xa Vec4 -> Expression4 -gabs = - Tuple.second gabsCouple - - -iexpCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -iexpCouple = - fun1 vec2T "iexp" (vec2T "z") <| \z -> return <| exp z - - -iexpDecl : FunDecl -iexpDecl = - Tuple.first iexpCouple - - -iexp : ExpressionX xa Vec2 -> Expression2 -iexp = - Tuple.second iexpCouple - - -gexpCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -gexpCouple = - fun1 vec4T "gexp" (vec4T "z") <| \z -> return <| vec4_1_3 z.x (byF (exp z.x) z.yzw) - - -gexpDecl : FunDecl -gexpDecl = - Tuple.first gexpCouple - - -gexp : ExpressionX xa Vec4 -> Expression4 -gexp = - Tuple.second gexpCouple - - -ilnCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ilnCouple = - fun1 vec2T "iln" (vec2T "z") <| \z -> return <| log z - - -ilnDecl : FunDecl -ilnDecl = - Tuple.first ilnCouple - - -iln : ExpressionX xa Vec2 -> Expression2 -iln = - Tuple.second ilnCouple - - -glnCouple : ( FunDecl, ExpressionX xa Vec4 -> Expression4 ) -glnCouple = - fun1 vec4T "gln" (vec4T "z") <| \z -> return <| vec4_1_3 (log z.x) (divF z.yzw z.x) - - -glnDecl : FunDecl -glnDecl = - Tuple.first glnCouple - - -gln : ExpressionX xa Vec4 -> Expression4 -gln = - Tuple.second glnCouple - - -csinCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -csinCouple = - fun1 vec2T "csin" (vec2T "z") <| - \z nop -> - def floatT "s" (sin_ z.x) <| - \s -> - return - (ternary - (eq z.y zero) - (vec2 s zero) - (vec2 - (by s (cosh z.y)) - (by (cos_ z.x) (sinh z.y)) - ) - ) - nop - - -csinDecl : FunDecl -csinDecl = - Tuple.first csinCouple - - -csin : ExpressionX xa Vec2 -> Expression2 -csin = - Tuple.second csinCouple - - -ccosCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ccosCouple = - fun1 vec2T "ccos" (vec2T "z") <| - \z nop -> - def floatT "c" (cos_ z.x) <| - \c -> - return - (ternary - (eq z.y zero) - (vec2 c zero) - (vec2 - (by c (cosh z.y)) - (by (sin_ z.x) (sinh z.y)) - ) - ) - nop - - -ccosDecl : FunDecl -ccosDecl = - Tuple.first ccosCouple - - -ccos : ExpressionX xa Vec2 -> Expression2 -ccos = - Tuple.second ccosCouple - - -ctanCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ctanCouple = - fun1 vec2T "ctan" (vec2T "z") <| - \z -> - return <| - ternary (eq z.y zero) - (vec2 (tan_ z.x) zero) - (cdiv (csin z) (ccos z)) - - -ctanDecl : FunDecl -ctanDecl = - Tuple.first ctanCouple - - -ctan : ExpressionX xa Vec2 -> Expression2 -ctan = - Tuple.second ctanCouple - - -casinTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -casinTuple = - fun1 vec2T "casin" (vec2T "z") <| - \z nop -> - def vec2T "s" (csqrt <| subtract (vec2 one zero) (cby z z)) <| - \s -> - def vec2T "arg" (subtract s <| cby (vec2 zero one) z) <| - \arg_ -> - return (cby (vec2 zero one) (cln arg_)) nop - - -casinDecl : FunDecl -casinDecl = - Tuple.first casinTuple - - -casin : ExpressionX xa Vec2 -> Expression2 -casin = - Tuple.second casinTuple - - -cacosTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cacosTuple = - fun1 vec2T "cacos" (vec2T "z") <| - \z -> - return <| subtract (vec2 constants.pihalf zero) (casin z) - - -cacosDecl : FunDecl -cacosDecl = - Tuple.first cacosTuple - - -cacos : ExpressionX xa Vec2 -> Expression2 -cacos = - Tuple.second cacosTuple - - -catanTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -catanTuple = - fun1 vec2T "catan" (vec2T "z") <| - \z nop -> - if_ (eq z.y zero) - (return <| vec2 (atan_ z.x) zero) - <| - \_ -> - def vec2T "o" (vec2 one zero) <| - \o -> - def vec2T "iz" (cby (vec2 zero one) z) <| - \iz -> - def vec2T "l" (cdiv (add o iz) (subtract o iz)) <| - \l -> - return (byF (float -0.5) <| cby (vec2 zero one) (cln l)) nop - - -catanDecl : FunDecl -catanDecl = - Tuple.first catanTuple - - -catan : ExpressionX xa Vec2 -> Expression2 -catan = - Tuple.second catanTuple - - -catan2Tuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -catan2Tuple = - fun2 vec2T "catan2" (vec2T "y") (vec2T "x") <| - \y x nop -> - def vec2T "z" (vec2 (subtract x.x y.y) (add x.y y.x)) <| - \z -> - return (vec2 (atan2_ z.y z.x) zero) nop - - -catan2Decl : FunDecl -catan2Decl = - Tuple.first catan2Tuple - - -catan2 : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -catan2 = - Tuple.second catan2Tuple - - -csinhTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -csinhTuple = - fun1 vec2T "csinh" (vec2T "z") <| - \z -> - return <| byF (float 0.5) (subtract (cexp z) (cexp <| negate_ z)) - - -csinhDecl : FunDecl -csinhDecl = - Tuple.first csinhTuple - - -csinh : ExpressionX xa Vec2 -> Expression2 -csinh = - Tuple.second csinhTuple - - -ccoshTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ccoshTuple = - fun1 vec2T "ccosh" (vec2T "z") <| - \z -> - return <| byF (float 0.5) (add (cexp z) (cexp <| negate_ z)) - - -ccoshDecl : FunDecl -ccoshDecl = - Tuple.first ccoshTuple - - -ccosh : ExpressionX xa Vec2 -> Expression2 -ccosh = - Tuple.second ccoshTuple - - -ctanhCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ctanhCouple = - fun1 vec2T "ctanh" (vec2T "z") <| - \z nop -> - def vec2T "p" (cexp z) <| - \p -> - def vec2T "m" (cexp (negate_ z)) <| - \m -> - return (cdiv (subtract p m) (add p m)) nop - - -ctanhDecl : FunDecl -ctanhDecl = - Tuple.first ctanhCouple - - -ctanh : ExpressionX xa Vec2 -> Expression2 -ctanh = - Tuple.second ctanhCouple - - -cabsCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cabsCouple = - fun1 vec2T "cabs" (vec2T "z") <| \z -> return <| vec2 (length z) zero - - -cabsDecl : FunDecl -cabsDecl = - Tuple.first cabsCouple - - -cabs : ExpressionX xa Vec2 -> Expression2 -cabs = - Tuple.second cabsCouple - - -csignCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -csignCouple = - fun1 vec2T "csign" (vec2T "z") <| \z -> return <| sign z - - -csignDecl : FunDecl -csignDecl = - Tuple.first csignCouple - - -csign : ExpressionX xa Vec2 -> Expression2 -csign = - Tuple.second csignCouple - - -intervalOperationToGlsl : GlslOperation -> List FunDecl -intervalOperationToGlsl op = - case op of - GlslAddition -> - [] - - GlslNegation -> - [ inegDecl, gnegDecl ] - - GlslMultiplication -> - [ ibyDecl, gbyDecl ] - - GlslDivision -> - [ iinverseDecl, idivDecl, gdivDecl ] - - GlslPower -> - [ ipowFIDecl, ipowIDecl, ipowDecl, gpowIDecl, gpowDecl ] - - GlslRelations -> - [ iltDecl, ileqDecl, ineqDecl, ieqDecl, igeqDecl, igtDecl ] - - -straightFunctionToGlsl : GlslFunction -> List FunDecl -straightFunctionToGlsl name = - case name of - Sinh11 -> - [ Tuple.first <| - fun1 floatT "sinh" (floatT "x") <| - \x -> return <| by (float 0.5) <| subtract (exp x) (exp <| negate_ x) - ] - - Cosh11 -> - [ Tuple.first <| - fun1 floatT "cosh" (floatT "x") <| - \x -> return <| by (float 0.5) <| add (exp x) (exp <| negate_ x) - ] - - Tanh11 -> - [ Tuple.first <| - fun1 floatT "tanh" (floatT "x") <| - \x nop -> - if_ (gt (abs_ x) (float 10)) - (return <| sign x) - <| - \_ -> - def floatT "p" (exp x) <| - \p -> - def floatT "m" (exp <| negate_ x) <| - \m -> - return (div (subtract p m) (add p m)) nop - ] - - Sin22 -> - [ csinDecl ] - - Cos22 -> - [ ccosDecl ] - - Tan22 -> - [ ctanDecl ] - - Asin22 -> - [ casinDecl ] - - Acos22 -> - [ cacosDecl ] - - Atan22 -> - [ catanDecl ] - - Atan222 -> - [ catan2Decl ] - - Sinh22 -> - [ csinhDecl ] - - Cosh22 -> - [ ccoshDecl ] - - Tanh22 -> - [ ctanhDecl ] - - Abs22 -> - [ cabsDecl ] - - Sign22 -> - [ csignDecl ] - - Sqrt22 -> - [ csqrtDecl ] - - Cbrt22 -> - [ ccbrtDecl ] - - Square22 -> - [ csquareDecl ] - - Ln22 -> - [ clnDecl ] - - Log1022 -> - [ clog10Decl ] - - Exp22 -> - [ cexpDecl ] - - Re22 -> - [ creDecl ] - - Im22 -> - [ cimDecl ] - - Arg22 -> - [ argDecl, cargDecl ] - - Pw22 -> - [ cpwDecl ] - - Ceiling22 -> - [ cceilingDecl ] - - Floor22 -> - [ cfloorDecl ] - - Round22 -> - [ croundDecl ] - - Min222 -> - [ cminDecl ] - - Max222 -> - [ cmaxDecl ] - - Mod22 -> - [ cmodDecl ] - - Mbrot22 -> - [ cmbrotDecl ] - - -cexpTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cexpTuple = - fun1 vec2T "cexp" (vec2T "z") cexpFunction - - -cexpFunction : Expression2 -> Continue () -> Statement Vec2 -cexpFunction z = - return <| - byF (exp z.x) <| - ternary - (eq z.y zero) - (vec2 one zero) - (vec2 (cos_ z.y) (sin_ z.y)) - - -cexpDecl : FunDecl -cexpDecl = - Tuple.first cexpTuple - - -cexp : ExpressionX xa Vec2 -> Expression2 -cexp = - Tuple.second cexpTuple - - -creTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -creTuple = - fun1 vec2T "cre" (vec2T "z") <| \z -> return <| vec2 z.x zero - - -creDecl : FunDecl -creDecl = - Tuple.first creTuple - - -cre : ExpressionX xa Vec2 -> Expression2 -cre = - Tuple.second creTuple - - -cimCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cimCouple = - fun1 vec2T "cim" (vec2T "z") <| \z -> return <| vec2 z.y zero - - -cimDecl : FunDecl -cimDecl = - Tuple.first cimCouple - - -cim : ExpressionX xa Vec2 -> Expression2 -cim = - Tuple.second cimCouple - - -argTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression1 Float ) -argTuple = - fun1 floatT "arg" (vec2T "v") <| \v -> return <| atan2_ v.y v.x - - -argDecl : FunDecl -argDecl = - Tuple.first argTuple - - -arg : ExpressionX xa Vec2 -> Expression1 Float -arg = - Tuple.second argTuple - - -cargTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cargTuple = - fun1 vec2T "carg" (vec2T "v") <| \v -> return <| vec2 (atan2_ v.y v.x) zero - - -cargDecl : FunDecl -cargDecl = - Tuple.first cargTuple - - -carg : ExpressionX xa Vec2 -> Expression2 -carg = - Tuple.second cargTuple - - -cpwCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 ) -cpwCouple = - fun3 vec2T "cpw" (vec2T "c") (vec2T "t") (vec2T "f") <| - \c t f -> return <| ternary (gt c.x zero) t f - - -cpwDecl : FunDecl -cpwDecl = - Tuple.first cpwCouple - - -cpw : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> ExpressionX xc Vec2 -> Expression2 -cpw = - Tuple.second cpwCouple - - -cceilingCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cceilingCouple = - fun1 vec2T "cceiling" (vec2T "z") <| \z -> return <| ceil_ z - - -cceilingDecl : FunDecl -cceilingDecl = - Tuple.first cceilingCouple - - -cceiling : ExpressionX xa Vec2 -> Expression2 -cceiling = - Tuple.second cceilingCouple - - -cfloorCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -cfloorCouple = - fun1 vec2T "cfloor" (vec2T "z") <| \z -> return <| floor_ z - - -cfloorDecl : FunDecl -cfloorDecl = - Tuple.first cfloorCouple - - -cfloor : ExpressionX xa Vec2 -> Expression2 -cfloor = - Tuple.second cfloorCouple - - -croundCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -croundCouple = - fun1 vec2T "cround" (vec2T "z") <| - \z -> - return <| floor_ (add z (vec2 (float 0.5) (float 0.5))) - - -croundDecl : FunDecl -croundDecl = - Tuple.first croundCouple - - -cround : ExpressionX xa Vec2 -> Expression2 -cround = - Tuple.second croundCouple - - -cminTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cminTuple = - fun2 vec2T "cmin" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (lt l.x r.x) l r - - -cminDecl : FunDecl -cminDecl = - Tuple.first cminTuple - - -cmin : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cmin = - Tuple.second cminTuple - - -cmaxTuple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cmaxTuple = - fun2 vec2T "cmax" (vec2T "l") (vec2T "r") <| \l r -> return <| ternary (gt l.x r.x) l r - - -cmaxDecl : FunDecl -cmaxDecl = - Tuple.first cmaxTuple - - -cmax : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cmax = - Tuple.second cmaxTuple - - -cmodCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cmodCouple = - fun2 vec2T "cmod" (vec2T "l") (vec2T "r") <| - \l r -> - return <| vec2 (mod l.x r.x) zero - - -cmodDecl : FunDecl -cmodDecl = - Tuple.first cmodCouple - - -cmod : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cmod = - Tuple.second cmodCouple - - -cmbrotCouple : ( FunDecl, ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 ) -cmbrotCouple = - fun2 vec2T "cmbrot" (vec2T "x") (vec2T "y") <| - \x y nop -> - def vec2T "c" (add x (vec2 (negate_ y.y) y.x)) <| - \c -> - def floatT "p" (length (subtract c (vec2 (float 0.25) zero))) <| - \p -> - if_ (or (leq c.x (add (subtract p (by (by (float 2) p) p)) (float 0.25))) (leq (length (add c (vec2 one zero))) (float 0.25))) - (return vec2Zero) - <| - \_ -> - def vec2T "z" c <| - \z -> - for ( "i", int 0, int 4000 ) - (\i cont -> - expr (assign z (add (vec2 (subtract (by z.x z.x) (by z.y z.y)) (by (by (float 2) z.x) z.y)) c)) <| - \_ -> - if_ (gt (length z) (float 1000000)) - (\_ -> - def floatT "logLength" (log (length z)) <| - \logLength -> - def floatT "nu" (div (log (div logLength (log (float 2)))) (log (float 2))) <| - \nu -> - def floatT "fi" (subtract (floatCast i) nu) <| - \fi -> - return (vec2 (sin_ fi) (cos_ fi)) nop - ) - <| - cont - ) - <| - \_ -> - return vec2Zero nop - - -cmbrotDecl : FunDecl -cmbrotDecl = - Tuple.first cmbrotCouple - - -cmbrot : ExpressionX xa Vec2 -> ExpressionX xb Vec2 -> Expression2 -cmbrot = - Tuple.second cmbrotCouple - - -csqrtTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -csqrtTuple = - fun1 vec2T "csqrt" (vec2T "z") <| - \z nop -> - if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (sqrt_ z.x) zero) - <| - \_ -> - def floatT "r" (pow (dot z z) (float 0.25)) <| - \r -> - def floatT "t" (byF (float 0.5) (atan2_ z.y z.x)) <| - \t -> - return (byF r <| vec2 (cos_ t) (sin_ t)) nop - - -csqrtDecl : FunDecl -csqrtDecl = - Tuple.first csqrtTuple - - -csqrt : ExpressionX xa Vec2 -> Expression2 -csqrt = - Tuple.second csqrtTuple - - -ccbrtCouple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -ccbrtCouple = - fun1 vec2T "ccbrt" (vec2T "z") <| - \z nop -> - if_ (eq z.y zero) - (return <| vec2 (by (sign z.x) (pow z.x (div one (float 3)))) zero) - <| - \_ -> - def floatT "r" (pow (dot z z) (div one (float 6))) <| - \r -> - def floatT - "t" - (add (div (atan2_ z.y z.x) (float 3)) - (ternary - (gt z.x zero) - zero - (radians_ (float 120)) - ) - ) - <| - \t -> - return (byF r (vec2 (cos_ t) (sin_ t))) nop - - -ccbrtDecl : FunDecl -ccbrtDecl = - Tuple.first ccbrtCouple - - -ccbrt : ExpressionX xa Vec2 -> Expression2 -ccbrt = - Tuple.second ccbrtCouple - - -csquareTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -csquareTuple = - fun1 vec2T "csquare" (vec2T "z") <| \z -> return <| cby z z - - -csquareDecl : FunDecl -csquareDecl = - Tuple.first csquareTuple - - -csquare : ExpressionX xa Vec2 -> Expression2 -csquare = - Tuple.second csquareTuple - - -clnTuple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -clnTuple = - fun1 vec2T "cln" (vec2T "z") <| - \z nop -> - if_ (ands [ eq z.y zero, geq z.x zero ]) - (return <| vec2 (log z.x) zero) - <| - \_ -> - def floatT "px" (length z) <| - \px -> - def floatT "py" (atan2_ z.y z.x) <| - \py -> - return (vec2 (log px) py) nop - - -clnDecl : FunDecl -clnDecl = - Tuple.first clnTuple - - -cln : ExpressionX xa Vec2 -> Expression2 -cln = - Tuple.second clnTuple - - -clog10Couple : ( FunDecl, ExpressionX xa Vec2 -> Expression2 ) -clog10Couple = - fun1 vec2T "clog10" (vec2T "z") <| \z -> return <| cdiv (cln z) (vec2 (log (float 10)) zero) - - -clog10Decl : FunDecl -clog10Decl = - Tuple.first clog10Couple - - -clog10 : ExpressionX xa Vec2 -> Expression2 -clog10 = - Tuple.second clog10Couple - - -intervalFunctionToGlsl : GlslFunction -> String -intervalFunctionToGlsl name = - case name of - Abs22 -> - fileToGlsl [ iabsDecl, gabsDecl ] - - Acos22 -> - fileToGlsl [ iacosDecl, gacosDecl ] - - Arg22 -> - """ - vec2 iarg(vec2 z) { - if(z.y < 0.0) - return dup(PI); - if(z.x >= 0.0) - return vec2(0); - return vec2(0.0, PI); - } - - vec4 garg(vec4 z) { - return gnum(z.x >= 0.0 ? 0.0 : PI); - } - """ - - Sign22 -> - """ - vec2 isign(vec2 z) { - return sign(z); - } - - vec4 gsign(vec4 v) { - return gnum(sign(v.x)); - } - """ - - Asin22 -> - """ - vec2 iasin(vec2 z) { - // Don't use clamp so if z is fully outside range the result is empty - vec2 clamped = vec2( - max(z.x, -1.0), - min(z.y, 1.0) - ); - return asin(clamped); - } - - vec4 gasin(vec4 v) { - return vec4(asin(v.x), v.yzw / sqrt(1.0 - v.x * v.x)); - } - """ - - Atan22 -> - """ - vec2 iatan(vec2 z) { - return atan(z); - } - - vec4 gatan(vec4 v) { - return vec4(atan(v.x), v.yzw / (1.0 + v.x * v.x)); - } - """ - - Atan222 -> - """ - vec2 iatan2(vec2 y, vec2 x) { - // TODO: improve this - vec2 r = vec2(atan(y.x, x.x), atan(y.y, x.x)); - vec2 q = vec2(atan(y.x, x.y), atan(y.y, x.y)); - vec2 rs = vec2(min(r.x, r.y), max(r.x, r.y)); - vec2 qs = vec2(min(q.x, q.y), max(q.x, q.y)); - return vec2(min(rs.x,qs.x),max(rs.y,qs.y)); - } - - vec4 gatan2(vec4 y, vec4 x) { - return vec4(atan(y.x, x.x), y.yzw / x.yzw / (1.0 + y.x * y.x / x.x / x.x)); - } - """ - - Ceiling22 -> - """ - vec2 iceiling(vec2 z) { - return ceil(z); - } - - vec4 gceiling(vec4 z) { - return gnum(ceil(z.x)); - } - """ - - Cos22 -> - """ - vec2 icos(vec2 v) { - vec2 shift = radians(90.0) * vec2(1,1); - return isin(v + shift); - } - - vec4 gcos(vec4 v) { - return vec4(cos(v.x), -sin(v.x) * v.yzw); - } - """ - - Cosh11 -> - "" - - Cosh22 -> - """ - vec2 icosh(vec2 z) { - if(z.x <= 0.0 && z.y >= 0.0) - return vec2(cosh(0.0), max(z.y, abs(z.x))); - if(z.x <= 0.0) - return vec2(cosh(-z.y), cosh(-z.x)); - return vec2(cosh(z.x), cosh(z.y)); - } - - vec4 gcosh(vec4 v) { - return vec4(cosh(v.x), sinh(v.x) * v.yzw); - } - """ - - Exp22 -> - fileToGlsl [ iexpDecl, gexpDecl ] - - Floor22 -> - """ - vec2 ifloor(vec2 z) { - return floor(z); - } - - vec4 gfloor(vec4 z) { - return gnum(floor(z.x)); - } - """ - - Ln22 -> - fileToGlsl [ ilnDecl, glnDecl ] - - Log1022 -> - """ - vec2 ilog10(vec2 z) { - return log(z) / log(10.0); - } - - vec4 glog10(vec4 z) { - return vec4(log(z.x), z.yzw / z.x) / log(10.0); - } - """ - - Pw22 -> - """ - vec2 ipw(vec2 c, vec2 t, vec2 f) { - if(c.y <= 0.0) - return f; - if(c.x > 0.0) - return t; - return vec2(min(t.x, f.x), max(t.y, f.y)); - } - - vec4 gpw(vec4 c, vec4 t, vec4 f) { - return c.x > 0.0 ? t : f; - } - """ - - Re22 -> - """ - vec2 ire(vec2 v) { - return v; - } - - vec4 gre(vec4 v) { - return v; - } - """ - - Im22 -> - """ - vec2 iim(vec2 v) { - return vec2(0); - } - - vec4 gim(vec4 v) { - return vec4(0, 0, 0, 1.0); - } - """ - - Round22 -> - """ - vec2 iround(vec2 z) { - return round(z); - } - - vec4 ground(vec4 z) { - return gnum(round(z.x)); - } - """ - - Sin22 -> - """ - bool between(float x, float low, float high) { - return low <= x && x <= high; - } - - vec2 isin(vec2 v) { - if(v.y - v.x > TWOPI) { - return vec2(-1.0, 1.0); - } - float from = mod(v.x, TWOPI); // [0, 360°] - float to = from + v.y - v.x; // [0, 720°] - vec2 s = sin(vec2(from, to)); - vec2 res = vec2(min(s.x, s.y), max(s.x, s.y)); - if(between(radians(90.0), from, to) || between(radians(90.0 + 360.0), from, to)) - res.y = 1.0; - if(between(radians(270.0), from, to) || between(radians(270.0 + 360.0), from, to)) - res.x = -1.0; - return res; - } - - vec4 gsin(vec4 v) { - return vec4(sin(v.x), cos(v.x) * v.yzw); - } - """ - - Sinh11 -> - "" - - Sinh22 -> - """ - vec2 isinh(vec2 v) { - return vec2(sinh(v.x), sinh(v.y)); - } - - vec4 gsinh(vec4 v) { - return vec4(sinh(v.x), cosh(v.x) * v.yzw); - } - """ - - Sqrt22 -> - """ - vec2 isqrt(vec2 v) { - return sqrt(max(vec2(0,0), v)); - } - - vec4 gsqrt(vec4 v) { - return vec4(sqrt(v.x), 0.5 * pow(v.x, -0.5) * v.yzw); - } - """ - - Cbrt22 -> - """ - float cbrt(float v) { - return sign(v) * pow(abs(v), 1.0 / 3.0); - } - - vec2 icbrt(vec2 v) { - return vec2(cbrt(v.x), cbrt(v.y)); - } - - vec4 gcbrt(vec4 v) { - return vec4(cbrt(v.x), pow(v.x, -2.0 / 3.0) / 3.0 * v.yzw); - } - """ - - Square22 -> - fileToGlsl [ isquareDecl, gsquareDecl ] - - Tan22 -> - """ - vec2 itan(vec2 z) { - return idiv(isin(z), icos(z)); - } - - vec4 gtan(vec4 z) { - float c = cos(z.x); - return vec4(tan(z.x), 1.0 / (c * c) * z.yzw); - } - """ - - Tanh11 -> - """ - """ - - Tanh22 -> - """ - vec2 itanh(vec2 z) { - return vec2(tanh(z.x), tanh(z.y)); - } - - vec4 gtanh(vec4 z) { - float c = 1.0 / cosh(z.x); - return vec4(tanh(z.x), c * c * z.yzw); - } - """ - - Min222 -> - """ - vec2 imin(vec2 l, vec2 r) { - return min(l, r); - } - - vec4 gmin(vec4 l, vec4 r) { - return l.x < r.x ? l : r; - } - """ - - Max222 -> - """ - vec2 imax(vec2 l, vec2 r) { - return max(l, r); - } - - vec4 gmax(vec4 l, vec4 r) { - return l.x > r.x ? l : r; - } - """ - - Mod22 -> - """ - vec2 imod(vec2 x, vec2 y) { - return x + ineg(iby(y, ifloor(idiv(x, y)))); - } - - vec4 gmod(vec4 l, vec4 r) { - return vec4(mod(l.x, r.x), l.yzw); - } - """ - - Mbrot22 -> - """TODO""" - - -toSrcImplicit : - String - -> Expression.Expression - -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcImplicit suffix e = - let - antialiasingSamples = - 7 - - ( fDecl, f ) = - fun2 floatT ("f" ++ suffix) (floatT "x") (floatT "y") <| - \x y nop -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| - \complex -> - return - (ternary (gt (abs_ complex.y) (float epsilon)) - zero - (ternary (gt complex.x zero) one minusOne) - ) - nop - - ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX _ x y cont -> - def floatT "sum" zero <| - \sum -> - def floatT "samples" (float <| antialiasingSamples * 2 + 1) <| - \samples -> - assignBy samples samples <| - \_ -> - def floatT "coeff" (float 0.0875) <| - \coeff -> - forLeq ( "w", int <| -antialiasingSamples, int antialiasingSamples ) - (\w cont2 -> - forLeq ( "h", int <| -antialiasingSamples, int antialiasingSamples ) - (\h _ -> - def floatT - "piece" - (f - (add x <| by (by deltaX coeff) <| floatCast w) - (add y <| by (by deltaX coeff) <| floatCast h) - ) - <| - \piece -> - if_ (eq piece zero) - (return vec3Zero) - <| - \_ -> - assignAdd sum piece cont2 - ) - cont2 - ) - <| - \_ -> - def floatT "perc" (div (subtract samples <| abs_ sum) samples) <| - \perc -> - expr (assign perc (pow perc <| float 0.2)) <| - \_ -> - return (byF perc (vec3 one one one)) cont - in - ( [ fDecl, pixelDecl ], pixel ) - - -toSrcPolar : - String - -> Expression.Expression - -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcPolar suffix e = - let - ( fDecl, f ) = - fun4 floatT ("f" ++ suffix) (floatT "x") (floatT "y") (floatT "deltaT") (floatT "ot") <| - \x y deltaT ot cont -> - def floatT "r" (length <| vec2 x y) <| - \r -> - def floatT "t" (add (atanPlus y x) deltaT) <| - \t -> - -- Avoid the branch cut at {x > 0, y = 0} - if_ (gt (abs_ <| subtract t ot) constants.pi) - (assignAdd t (ternary (lt t ot) constants.twopi (negate_ constants.twopi))) - <| - \_ -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ), ( "r", r ), ( "t", t ) ] e) <| - \complex -> - return - (ternary (gt (abs_ complex.y) (float epsilon)) - minusOne - (ternary (gt complex.x zero) - one - zero - ) - ) - cont - - ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y cont -> - assignAdd x (div deltaX <| float 2) <| - \_ -> - assignAdd y (div deltaY <| float 2) <| - \_ -> - def floatT "t" zero <| - \t -> - def floatT "ot" (atanPlus y x) <| - \ot -> - for ( "i", int 0, divConst constants.maxIterations (int 10) ) - (\_ cont2 -> - def floatT "h" (f x y t ot) <| - \h -> - def floatT "l" (f (subtract x deltaX) y t ot) <| - \l -> - def floatT "u" (f x (subtract y deltaY) t ot) <| - \u -> - def floatT "ul" (f (subtract x deltaX) (subtract y deltaY) t ot) <| - \ul -> - if_ (ors [ lt h zero, lt l zero, lt u zero, lt ul zero ]) - break - <| - \_ -> - if_ (ors [ neq h l, neq h u, neq h ul ]) - (return <| vec3 one one one) - <| - \_ -> - assignAdd t constants.twopi <| - \_ -> - assignAdd ot constants.twopi cont2 - ) - <| - \_ -> - return vec3Zero cont - in - ( [ fDecl, pixelDecl ], pixel ) - - -constants : - { maxIterations : ExpressionX { isConstant : Constant } Int - , maxDepth : ExpressionX { isConstant : Constant } Int - , pihalf : ExpressionX { isConstant : Constant } Float - , pi : ExpressionX { isConstant : Constant } Float - , twopi : ExpressionX { isConstant : Constant } Float - , vectorSpacing : ExpressionX { isConstant : Constant } Float - , xPoints : ExpressionX { isConstant : Constant } Int - , yPoints : ExpressionX { isConstant : Constant } Int - } -constants = - { maxIterations = constant intT "MAX_ITERATIONS" - , maxDepth = constant intT "MAX_DEPTH" - , pihalf = constant floatT "PIHALF" - , pi = constant floatT "PI" - , twopi = constant floatT "TWOPI" - , vectorSpacing = constant floatT "VECTOR_SPACING" - , xPoints = constant intT "X_POINTS" - , yPoints = constant intT "Y_POINTS" - } - - -toSrcParametric : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcParametric suffix e = - let - ( intervalDecl, interval ) = - fun3 vec2T ("interval" ++ suffix) (vec2T "p") (floatT "from") (floatT "to") <| - \p from to cont -> - def vec2T "x" (vec2 p.x p.x) <| - \x -> - def vec2T "y" (vec2 p.y p.y) <| - \y -> - def vec2T "t" (vec2 (min_ from to) (max_ from to)) <| - \t -> - return - (expressionToIntervalGlsl - (Dict.fromList - [ ( "x", x ) - , ( "y", y ) - , ( "t", t ) - ] - ) - (toPrintExpression e) - ) - cont - - ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y cont -> - def floatT "max_distance" (float <| 2 ^ 10) <| - \max_distance -> - def floatT "from" (div (negate_ max_distance) (float 2)) <| - \from -> - def floatT "to" (div max_distance (float 2)) <| - \to -> - def vec2T "p" (vec2 x y) <| - \p -> - def intT "depth" (int 0) <| - \depth -> - def intT "choices" (int 0) <| - \choices -> - def floatT "ithreshold" (by (by (float 10) deltaX) deltaX) <| - \ithreshold -> - for ( "it", int 0, constants.maxIterations ) - (innerLoop from to p depth choices ithreshold) - <| - \_ -> - return vec3Zero cont - - innerLoop : - Expression1 Float - -> Expression1 Float - -> Expression2 - -> Expression1 Int - -> Expression1 Int - -> Expression1 Float - -> Expression1 Int - -> Continue Vec3 - -> Statement Vec3 - innerLoop from to p depth choices ithreshold _ cont = - def floatT "midpoint" (mix from to <| float 0.5) <| - \midpoint -> - def vec2T "front" (interval p from midpoint) <| - \front -> - def vec2T "back" (interval p midpoint to) <| - \back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands - [ lt (subtract front.y front.x) ithreshold - , leq front.x zero - , geq front.y zero - ] - , ands - [ lt (subtract back.y back.x) ithreshold - , leq back.x zero - , geq back.y zero - ] - ] - ) - (return <| vec3 one one one) - <| - \_ -> - ifElse - (ands [ leq front.x zero, geq front.y zero ]) - (\_ -> - expr (assign to midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - assignBy choices (int 2) cont - ) - (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) cont - ) - -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - (\_ -> - forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) - (\j _ -> - if_ (gt j depth) - continue - <| - \_ -> - expr (postfixDecrement depth) <| - \_ -> - expr (assign choices (div choices (int 2))) <| - \_ -> - ifElse (eq (by (div choices (int 2)) (int 2)) choices) - (\_ -> - expr (assign midpoint to) <| - \_ -> - expr (assign to (add to (subtract to from))) <| - \_ -> - expr (assign back (interval p midpoint to)) <| - \_ -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - expr (assign choices (add (by choices (int 2)) (int 1))) <| - \_ -> - break cont - ) - cont - ) - (expr (assign from (subtract from (subtract to from)))) - cont - ) - <| - \_ -> - if_ (eq depth (int 0)) - (return vec3Zero) - cont - ) - ) - cont - in - ( [ intervalDecl, pixelDecl ], pixel ) - - -uniforms : Uniforms -uniforms = - { u_canvasHeight = uniform floatT "u_canvasHeight" - , u_canvasWidth = uniform floatT "u_canvasWidth" - , u_drawAxes = uniform floatT "u_drawAxes" - , u_viewportHeight = uniform floatT "u_viewportHeight" - , u_viewportWidth = uniform floatT "u_viewportWidth" - , u_whiteLines = uniform floatT "u_whiteLines" - , u_zoomCenter = uniform vec2T "u_zoomCenter" - , u_phi = uniform floatT "u_phi" - , u_theta = uniform floatT "u_theta" - , u_completelyReal = uniform floatT "u_completelyReal" - } - - -thetaDeltaCouple : ( FunDecl, ExpressionX xa Float -> Expression1 Float ) -thetaDeltaCouple = - fun1 floatT "thetaDelta" (floatT "theta") <| - \theta cont -> - if_ (lt uniforms.u_whiteLines one) - (return <| float 100) - <| - \_ -> - def floatT "thetaSix" (add (by theta uniforms.u_whiteLines) (float 0.5)) <| - \thetaSix -> - def floatT "thetaNeigh" (float 0.05) <| - \thetaNeigh -> - return (divF (abs_ (subtract (fract thetaSix) (float 0.5))) thetaNeigh) cont - - -thetaDeltaDecl : FunDecl -thetaDeltaDecl = - Tuple.first thetaDeltaCouple - - -thetaDelta : ExpressionX xa Float -> Expression1 Float -thetaDelta = - Tuple.second thetaDeltaCouple - - -toSrcVectorField2D : - String - -> Expression.Expression - -> Expression.Expression - -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcVectorField2D suffix xexpr yexpr = - let - ( vectorDecl, vector ) = - fun2 vec2T ("vector" ++ suffix) (floatT "x") (floatT "y") <| - \x y cont -> - def vec2T "xv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] xexpr) <| - \xv -> - def vec2T "yv" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] yexpr) <| - \yv -> - return (ternary (lt (add (abs_ xv.y) (abs_ yv.y)) (float epsilon)) (vec2 xv.x yv.x) vec2Zero) cont - - ( nearDecl, near ) = - fun5 boolT "near" (vec2T "o") (vec2T "corner") (vec2T "vect") (floatT "deltaX") (floatT "mx") <| - \o corner vect deltaX mx cont -> - def floatT "angleCorner" (arg <| subtract o corner) <| - \angleCorner -> - def floatT "angleVector" (arg vect) <| - \angleVector -> - def floatT "delta" (mod (subtract angleCorner angleVector) constants.twopi) <| - \delta -> - def floatT "l" (div (length vect) mx) <| - \l -> - def floatT - "maxLength" - (by (by deltaX constants.vectorSpacing) - (ternary - (lt l (float epsilon)) - zero - (add (div l (float 2)) (float 0.5)) - ) - ) - <| - \maxLength -> - def floatT "wantedLength" (length (subtract o corner)) <| - \wantedLength -> - def floatT "angularDistance" (mix (float 180) zero (pow (div wantedLength maxLength) (float 0.3))) <| - \angularDistance -> - return - (ands - [ ors - [ lt delta (radians_ angularDistance) - , gt delta (radians_ (subtract (float 360) angularDistance)) - ] - , lt wantedLength maxLength - ] - ) - cont - - ( pixelDecl, pixel ) = - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y cont -> - def vec2T "o" (vec2 x y) <| - \o -> - def floatT "mx" zero <| - \mx -> - def floatT "k" (by deltaX constants.vectorSpacing) <| - \k -> - forLeq ( "xi", negateConst constants.xPoints, constants.xPoints ) - (\xi cont2 -> - forLeq ( "yi", negateConst constants.yPoints, constants.yPoints ) - (\yi _ -> - def vec2T - "p" - (add uniforms.u_zoomCenter - (vec2 - (by k (floatCast xi)) - (by k (floatCast yi)) - ) - ) - <| - \p -> - def vec2T "v" (vector p.x p.y) <| - \v -> - expr (assign mx (max_ mx (length v))) cont2 - ) - cont2 - ) - <| - \_ -> - def vec3T "colorA" (vec3 zero one zero) <| - \colorA -> - def vec3T "colorB" (vec3 zero zero one) <| - \colorB -> - expr (assign x (subtract o.x (mod o.x k))) <| - \_ -> - expr (assign y (subtract o.y (mod o.y k))) <| - \_ -> - def vec2T "bl" (vector x y) <| - \bl -> - def vec2T "br" (vector (add x k) y) <| - \br -> - def vec2T "ul" (vector x (add y k)) <| - \ul -> - def vec2T "ur" (vector (add x k) (add y k)) <| - \ur -> - def vec2T "corner" (vec2 x y) <| - \corner -> - def floatT "l" (div (length bl) mx) <| - \l -> - if_ (near o corner bl deltaX mx) - (return <| mix colorA colorB l) - <| - \_ -> - expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) y)) <| - \_ -> - expr (assign l (div (length br) mx)) <| - \_ -> - if_ (near o corner br deltaX mx) - (return <| mix colorA colorB l) - <| - \_ -> - expr (assign corner (vec2 x (add y (by deltaX constants.vectorSpacing)))) <| - \_ -> - expr (assign l (div (length ul) mx)) <| - \_ -> - if_ (near o corner ul deltaX mx) - (return <| mix colorA colorB l) - <| - \_ -> - expr (assign corner (vec2 (add x (by deltaX constants.vectorSpacing)) (add y (by deltaX constants.vectorSpacing)))) <| - \_ -> - expr (assign l (div (length ur) mx)) <| - \_ -> - if_ (near o corner ur deltaX mx) - (return <| mix colorA colorB l) - <| - \_ -> - return vec3Zero cont - in - ( [ vectorDecl, nearDecl, pixelDecl ], pixel ) - - -toSrcContour : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcContour suffix expr = - let - ( pixelODecl, pixelO ) = - fun4 vec3T ("pixel" ++ suffix ++ "_o") (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \_ _ x y cont -> - def vec2T "z" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] expr) <| - \z -> - def floatT "theta" (div (atan2_ z.y z.x) constants.twopi) <| - \theta -> - def floatT "logRadius" (log2 <| length z) <| - \logRadius -> - def floatT "powerRemainder" (fract logRadius) <| - \powerRemainder -> - def floatT "squished" (subtract (float 0.7) (by powerRemainder <| float 0.4)) <| - \squished -> - if_ (gt uniforms.u_completelyReal zero) - (\_ -> - def floatT "haf" (div powerRemainder <| float 6.0) <| - \haf -> - return - (ternary (gt z.x zero) - (hl2rgb (add haf <| float 0.3) squished) - (hl2rgb (subtract haf <| float 0.2) (subtract one squished)) - ) - cont - ) - <| - \_ -> - def floatT "td" (thetaDelta theta) <| - \td -> - def floatT "l" (mix one squished <| smoothstep zero one td) <| - \l -> - return (hl2rgb theta l) cont - - ( pixelDecl, pixel ) = - let - dist = - 1 / 3 - in - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \deltaX deltaY x y cont -> - def floatT "deltaXr" (by deltaX <| float dist) <| - \deltaXr -> - def floatT "deltaYr" (by deltaY <| float dist) <| - \deltaYr -> - -- Antialiasing - def vec3T "a" (pixelO deltaX deltaY (add x deltaXr) (add y deltaYr)) <| - \a -> - def vec3T "b" (pixelO deltaX deltaY (subtract x deltaXr) (subtract y deltaYr)) <| - \b -> - def vec3T "c" (pixelO deltaX deltaY (add x deltaXr) (subtract y deltaYr)) <| - \c -> - def vec3T "d" (pixelO deltaX deltaY (subtract x deltaXr) (add y deltaYr)) <| - \d -> - def vec3T "mn" (min_ a <| min_ b <| min_ c d) <| - \mn -> - def vec3T "mx" (max_ a <| max_ b <| max_ c d) <| - \mx -> - def vec3T "diff" (abs_ (subtract mx mn)) <| - \diff -> - if_ (ands [ lt diff.x (float dist), lt diff.y (float dist), lt diff.z (float dist) ]) - (return <| divF (adds3 [ a, b, c, d ]) (float 4)) - <| - \_ -> - assignBy deltaXr (float 2) <| - \_ -> - assignBy deltaYr (float 2) <| - \_ -> - def vec3T "e" (pixelO deltaX deltaY (add x deltaXr) y) <| - \e -> - def vec3T "f" (pixelO deltaX deltaY (subtract x deltaXr) y) <| - \f -> - def vec3T "g" (pixelO deltaX deltaY x (subtract y deltaYr)) <| - \g -> - def vec3T "h" (pixelO deltaX deltaY x (add y deltaYr)) <| - \h -> - return (divF (adds3 [ a, b, c, d, e, f, g, h ]) (float 8)) cont - in - ( [ pixelODecl, pixelDecl ], pixel ) - - -toSrcRelation : String -> Expression.Expression -> ( List FunDecl, ExpressionX xa Float -> ExpressionX xb Float -> ExpressionX xc Float -> ExpressionX xd Float -> Expression3 ) -toSrcRelation suffix e = - Tuple.mapFirst (\d -> [ d ]) <| - fun4 vec3T ("pixel" ++ suffix) (floatT "deltaX") (floatT "deltaY") (floatT "x") (floatT "y") <| - \_ _ x y cont -> - def vec2T "complex" (expressionToGlsl [ ( "x", x ), ( "y", y ) ] e) <| - \complex -> - return - (ternary - (ands - [ gt complex.x zero - , lt (abs_ complex.y) (float epsilon) - ] - ) - (vec3 (float 0.8) (float 0.5) (float 0.5)) - vec3Zero - ) - cont - - -epsilon : Float -epsilon = - 0.00001 - - -expressionToGlsl : List ( String, Expression1 Float ) -> Expression.Expression -> Expression2 +expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 expressionToGlsl context = let ctx = @@ -2413,27 +25,27 @@ expressionToGlsl context = go expr = case expr of PVariable "i" -> - vec2 zero one + vec211 zero one PVariable "pi" -> - vec2 constants.pi zero + vec211 constants.pi zero PVariable "e" -> - vec2 (exp one) zero + vec211 (exp one) zero PVariable v -> case Dict.get v ctx of Just w -> - vec2 w zero + vec211 w zero Nothing -> vec2Zero PInteger v -> - vec2 (float <| toFloat v) zero + vec211 (float <| toFloat v) zero PFloat f -> - vec2 (float f) zero + vec211 (float f) zero PNegate expression -> negate2 <| go expression @@ -2581,709 +193,6 @@ expressionToGlsl context = toPrintExpression >> go -expressionToIntervalGlsl : Dict String Expression2 -> PrintExpression -> Expression2 -expressionToIntervalGlsl vars expr = - let - unsafeApply name ex = - let - _ = - Debug.todo - in - dotted2 <| unsafeCall name (List.map (go >> .base) ex) - - go = - expressionToIntervalGlsl vars - in - case expr of - PVariable "pi" -> - dup constants.pi - - PVariable "e" -> - dup <| exp one - - PVariable v -> - case Dict.get v vars of - Just w -> - w - - Nothing -> - vec2Zero - - PInteger v -> - dup <| float <| toFloat v - - PFloat f -> - dup <| float f - - PNegate expression -> - ineg <| go expression - - PAdd l r -> - add2 (go l) (go r) - - PRel op l r -> - case op of - LessThan -> - ilt (go l) (go r) - - LessThanOrEquals -> - ileq (go l) (go r) - - Equals -> - ieq (go l) (go r) - - NotEquals -> - ineq (go l) (go r) - - GreaterThanOrEquals -> - igeq (go l) (go r) - - GreaterThan -> - igt (go l) (go r) - - PBy l r -> - iby (go l) (go r) - - PDiv l r -> - idiv (go l) (go r) - - PPower (PVariable "i") (PInteger 2) -> - dup <| float -1 - - PPower l (PInteger 2) -> - isquare (go l) - - PPower l (PFloat f) -> - if f == 2.0 then - isquare (go l) - - else - ipow (go l) (go <| PFloat f) - - PPower l (PInteger ri) -> - ipow (go l) (go <| PInteger ri) - - PPower l r -> - ipow (go l) (go r) - - PApply name ex -> - if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map go ex of - [] -> - vec2Zero - - head :: tail -> - dotted2 <| List.foldl (\e a -> unsafeCall ("i" ++ Expression.functionNameToString name) [ a, e.base ]) head.base tail - - else - unsafeApply ("i" ++ Expression.functionNameToString name) ex - - PReplace var e -> - go (Expression.pfullSubstitute var e) - - -- If this happens, it's too late - PLambda _ _ -> - vec2Zero - - PList _ -> - vec2Zero - - -expressionToNormalGlsl : { x : Expression1 Float, y : Expression1 Float, z : Expression1 Float } -> Expression.Expression -> Expression4 -expressionToNormalGlsl { x, y, z } = - let - go expr = - case expr of - PVariable "pi" -> - gnum constants.pi - - PVariable "e" -> - gnum <| exp one - - PVariable "x" -> - vec4 x one zero zero - - PVariable "y" -> - vec4 y zero one zero - - PVariable "z" -> - vec4 z zero zero one - - PInteger v -> - gnum <| float <| toFloat v - - PFloat f -> - gnum <| float f - - PNegate expression -> - gneg (go expression) - - PAdd l r -> - add4 (go l) (go r) - - PRel op l r -> - case op of - LessThan -> - subtract4 (go r) (go l) - - LessThanOrEquals -> - subtract4 (go r) (go l) - - NotEquals -> - abs4 <| subtract (go r) (go l) - - Equals -> - abs4 <| subtract (go r) (go l) - - GreaterThanOrEquals -> - subtract4 (go l) (go r) - - GreaterThan -> - subtract4 (go l) (go r) - - PBy l r -> - gby (go l) (go r) - - PDiv l r -> - dotted4 (gdiv (go l) (go r)).base - - PPower l (PInteger 2) -> - gsquare (go l) - - PPower l (PInteger ri) -> - gpowI (go l) (int ri) - - PPower l r -> - gpow (go l) (go r) - - PApply name ex -> - if List.any (\( _, v ) -> name == KnownFunction v) Expression.variadicFunctions then - case List.map (go >> .base) ex of - [] -> - vec4Zero - - head :: tail -> - dotted4 <| List.foldl (\e a -> unsafeCall ("g" ++ Expression.functionNameToString name) [ a, e ]) head tail - - else - dotted4 (unsafeCall ("g" ++ Expression.functionNameToString name) (List.map (go >> .base) ex)) - - PList es -> - dotted4 (unsafeCall ("vec" ++ String.fromInt (List.length es)) (List.map (go >> .base) es)) - - PReplace var e -> - go (Expression.pfullSubstitute var e) - - PVariable _ -> - vec4Zero - - -- If this happens, it's too late - PLambda _ _ -> - vec4Zero - in - toPrintExpression >> go - - -mainGlsl : - Bool - -> - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } - -> List (Expression3 -> Expression1 Mat3 -> Expression1 Float -> Expression3 -> Expression1 Bool) - -> String -mainGlsl rayDifferentials pixel2Def pixel3Def = - case ( pixel2Def, pixel3Def ) of - ( _, [] ) -> - let - ( pixel2Decl, pixel2 ) = - main2D pixel2Def - in - fileToGlsl <| - pixel2Decl - ++ [ Tuple.first <| - fun0 voidT "main" <| - expr (assign gl_FragColor pixel2) - ] - - ( [], _ ) -> - let - ( pixel3Decl, pixel3 ) = - main3D rayDifferentials pixel3Def - in - pixel3Decl - ++ "\n\n" - ++ fileToGlsl - [ Tuple.first <| - fun0 voidT "main" <| - expr (assign gl_FragColor pixel3) - ] - - _ -> - let - ( pixel2Decl, pixel2 ) = - main2D pixel2Def - - ( pixel3Decl, pixel3 ) = - main3D rayDifferentials pixel3Def - in - fileToGlsl pixel2Decl - ++ "\n\n" - ++ pixel3Decl - ++ fileToGlsl - [ Tuple.first <| - fun0 voidT "main" <| - expr (assign gl_FragColor (max4 pixel2 pixel3)) - ] - - -main2D : - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } - -> ( File, Expression4 ) -main2D pixels = - let - ( pixel2Decl, pixel2 ) = - pixel2Tuple pixels - in - ( [ log10Decl - , axisDecl - , pixel2Decl - ] - , pixel2 - ) - - -pixel2Tuple : - List - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } - -> ( FunDecl, Expression4 ) -pixel2Tuple pixels = - let - inner deltaX deltaY x y px curr cont = - List.foldl (\( i, p ) -> addPixel deltaX deltaY x y px curr i p) cont (List.indexedMap Tuple.pair pixels) - in - fun0 vec4T "pixel2" <| - \cont -> - def vec2T "canvasSize" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| - \canvasSize -> - def vec2T "uv_centered" (subtract2 gl_FragCoord.xy (byF (float 0.5) canvasSize)) <| - \uv_centered -> - def vec2T "viewportSize" (byF (div uniforms.u_viewportWidth uniforms.u_canvasWidth) canvasSize) <| - \viewportSize -> - def vec2T "uv" (by2 (div2 uv_centered canvasSize) viewportSize) <| - \uv -> - def vec2T "c" (add uniforms.u_zoomCenter uv) <| - \c -> - def floatT "x" c.x <| - \x -> - def floatT "y" c.y <| - \y -> - def floatT "deltaX" (div uniforms.u_viewportWidth uniforms.u_canvasWidth) <| - \deltaX -> - def floatT "deltaY" (div uniforms.u_viewportWidth uniforms.u_canvasHeight) <| - \deltaY -> - def vec3T "px" vec3Zero <| - \px -> - decl vec3T "curr" <| - \curr -> - inner deltaX deltaY x y px curr <| - def floatT "maxDelta" (max_ deltaX deltaY) <| - \maxDelta -> - def vec3T "yax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis x y maxDelta) (vec3 zero one zero)) vec3Zero) <| - \yax -> - def vec3T "xax" (ternary3 (eq uniforms.u_drawAxes one) (byF (axis y x maxDelta) (vec3 one zero zero)) vec3Zero) <| - \xax -> - return (vec4_3_1 (max3 px (max3 xax yax)) one) cont - - -addPixel : - Expression1 Float - -> Expression1 Float - -> Expression1 Float - -> Expression1 Float - -> Expression3 - -> Expression3 - -> Int - -> - { call : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression3 - , color : Bool - } - -> (Statement f -> Statement f) -addPixel deltaX deltaY x y px curr i { call, color } next = - let - k = - if color then - let - h = - float <| (toFloat (i + 2) / pi) - in - by3 (hl2rgb h (float 0.5)) (call deltaX deltaY x y) - - else - call deltaX deltaY x y - in - expr (assign curr k) <| - \_ -> - expr (assign px (ternary3 (eq curr vec3Zero) px curr)) <| - \_ -> - next - - -axisTuple : ( FunDecl, Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float ) -axisTuple = - fun3 floatT "axis" (floatT "coord") (floatT "otherCoord") (floatT "maxDelta") <| - \coord otherCoord maxDelta cont -> - def floatT "across" (subtract one <| abs_ <| div coord maxDelta) <| - \across -> - if_ (lt across (float -12)) - (return zero) - <| - \_ -> - def floatT "smallUnit" (pow (float 10) (ceil_ (log10 maxDelta))) <| - \smallUnit -> - if_ (ands [ lt across zero, lt (abs_ otherCoord) (by maxDelta (float 2)) ]) - (return zero) - <| - \_ -> - def floatT - "unit" - (ternary - (lt across (float -6)) - (by smallUnit (float 100)) - (ternary - (lt across (float -0.1)) - (by smallUnit (float 10)) - (by smallUnit (float 5)) - ) - ) - <| - \unit -> - def floatT "parallel" (ternary (lt (mod (abs_ otherCoord) unit) maxDelta) one zero) <| - \parallel -> - return (max_ zero (max_ across parallel)) cont - - -axis : Expression1 Float -> Expression1 Float -> Expression1 Float -> Expression1 Float -axis = - Tuple.second axisTuple - - -axisDecl : FunDecl -axisDecl = - Tuple.first axisTuple - - -toSrc3D : - String - -> Expression.Expression - -> ( List FunDecl, ExpressionX xa Mat3 -> ExpressionX xb Mat3 -> Expression2 ) -toSrc3D suffix e = - let - ( intervalDecl, interval ) = - fun2 vec2T ("interval" ++ suffix) (mat3T "f") (mat3T "t") <| - \f t cont -> - def vec3T "mn" (min_ (arr f <| int 0) (arr t <| int 0)) <| - \mn -> - def vec3T "mx" (max_ (arr f <| int 1) (arr t <| int 1)) <| - \mx -> - def vec2T "x" (vec2 mn.x mx.x) <| - \x -> - def vec2T "y" (vec2 mn.y mx.y) <| - \y -> - def vec2T "z" (vec2 mn.z mx.z) <| - \z -> - return (expressionToIntervalGlsl (Dict.fromList [ ( "x", x ), ( "y", y ), ( "z", z ) ]) <| toPrintExpression e) cont - in - ( [ Tuple.first <| - fun1 vec3T ("normal" ++ suffix) (vec3T "p") <| - \p cont -> - def floatT "x" p.x <| - \x -> - def floatT "y" p.y <| - \y -> - def floatT "z" p.z <| - \z -> - def vec4T "gradient" (expressionToNormalGlsl { x = x, y = y, z = z } e) <| - \gradient -> - return (normalize gradient.yzw) cont - , intervalDecl - ] - , interval - ) - - - ---main3D : Bool -> List String -> ( String, Expression4 ) - - -main3D : Bool -> List (Expression3 -> Expression1 Mat3 -> Expression1 Float -> Expression3 -> Expression1 Bool) -> ( String, Expression4 ) -main3D rayDifferentials bisects = - let - kValue = - if rayDifferentials then - 0.001 - - else - 0.0 - - ( block, pixel3 ) = - fun0 vec4T "pixel3" <| - \cont -> - def floatT "eye_dist" (byF (float 2) uniforms.u_viewportWidth) <| - \eyeDist -> - def vec2T "canvas_size" (vec2 uniforms.u_canvasWidth uniforms.u_canvasHeight) <| - \canvasSize -> - def vec2T "uv_centered" (subtract gl_FragCoord.xy <| byF (float 0.5) canvasSize) <| - \uvCentered -> - def vec2T "uv_normalized" (byF (div one uniforms.u_canvasHeight) uvCentered) <| - \uvNormalized -> - def floatT "t" (add uniforms.u_theta <| float 0.58) <| - \t -> - def floatT "p" (by (float -2.0) uniforms.u_phi) <| - \p -> - def vec3T "eye" (eyePosition eyeDist t p) <| - \eye -> - def vec3T "target" vec3Zero <| - \target -> - def vec3T "to_target" (normalize <| subtract target eye) <| - \toTarget -> - def vec3T "across" (normalize <| cross toTarget <| vec3 zero zero one) <| - \across -> - def vec3T "up" (normalize <| cross across toTarget) <| - \up -> - def vec3T "canvas_center" (add eye toTarget) <| - \canvasCenter -> - def vec3T "canvas_point" (add (add canvasCenter <| byF uvNormalized.x across) (byF uvNormalized.y up)) <| - \canvasPoint -> - def vec3T "ray_direction" (normalize3 <| subtract canvasPoint eye) <| - \rayDirection -> - def vec3T "diffs" (abs_ <| fwidth rayDirection) <| - \diffs -> - def floatT "k" (float kValue) <| - \k -> - def mat3T "d" (dValue rayDirection k diffs) <| - \d -> - def floatT "max_distance" (by (float 100) eyeDist) <| - \maxDistance -> - return (raytraceF canvasPoint d maxDistance) cont - - dValue : ExpressionX a Vec3 -> ExpressionX b Float -> ExpressionX c Vec3 -> Expression33 - dValue rayDirection k diffs = - mat3_3_3_3 - (subtract3 rayDirection <| byF k diffs) - (add rayDirection <| byF k diffs) - vec3Zero - - ( raytraceDecl, raytraceF ) = - raytrace bisects - - eyePosition eyeDist t p = - byF eyeDist <| - normalize <| - vec3 - (by (cos_ t) (sin_ p)) - (by (cos_ t) (negate_ <| cos_ p)) - (sin_ t) - in - ( fileToGlsl [ raytraceDecl, block ], pixel3 ) - - -raytrace : - List - (Expression3 - -> Expression1 Mat3 - -> Expression1 Float - -> Expression3 - -> Expression1 Bool - ) - -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> Expression4 ) -raytrace bisects = - let - colorCoeff = - float (1.19 - 0.2 * toFloat (List.length bisects)) - in - fun3 vec4T "ratytrace" (vec3T "o") (mat3T "d") (floatT "max_distance") <| - \o d maxDistance cont -> - def vec3T "found" vec3Zero <| - \found -> - def floatT "curr_distance" maxDistance <| - \currDistance -> - def intT "found_index" (int -1) <| - \foundIndex -> - def vec3T "f" vec3Zero <| - \f -> - let - innerTrace : Statement q -> Statement q - innerTrace next = - List.foldl - (\bisect ( i, s ) -> - ( i + 1 - , bisectToRay i bisect s - ) - ) - ( 0, next ) - bisects - |> Tuple.second - - bisectToRay : - Int - -> - (Expression3 - -> Expression1 Mat3 - -> Expression1 Float - -> Expression3 - -> Expression1 Bool - ) - -> Statement q - -> Statement q - bisectToRay i bisect next = - if_ (ands [ bisect o d maxDistance f, lt (length (subtract f o)) currDistance ]) - (\cont2 -> - expr (assign foundIndex <| int i) <| - \_ -> - expr (assign found f) <| - \_ -> - expr (assign currDistance <| length <| subtract found o) cont2 - ) - <| - \_ -> - next - in - innerTrace <| - if_ (lt foundIndex <| int 0) - (return <| vec4 zero zero zero one) - <| - \_ -> - def vec3T "ld" (normalize <| vec3 (float -0.3) zero one) <| - \ld -> - def vec3T "diffs" (subtract (arr d (int 1)) (arr d (int 0))) <| - \diffs -> - def floatT "light_distance" maxDistance <| - \lightDistance -> - def vec3T "offseted" (add found <| byF (by (float 0.0001) maxDistance) <| normalize <| subtract o found) <| - \offseted -> - def floatT "hue_based_on_index" (by (floatCast foundIndex) <| float <| radians (360 / 1.1)) <| - \hueBasedOnIndex -> - def mat3T "light_direction" (mat3_3_3_3 (subtract ld <| byF (float 0.5) diffs) (add ld <| byF (float 0.5) diffs) vec3Zero) <| - \lightDirection -> - def floatT "light_coeff" (ternary (ors (List.map (\bisect -> bisect offseted lightDirection lightDistance f) bisects)) (float 0.2) (float 0.45)) <| - \lightCoeff -> - def vec3T "px" (mix (hl2rgb hueBasedOnIndex lightCoeff) (hl2rgb (by (float 0.5) found.z) lightCoeff) (max_ (float 0.2) colorCoeff)) <| - \px -> - return (vec4_3_1 px one) cont - - -threshold : ExpressionX x Float -> Expression1 Float +threshold : Expression Float -> Expression Float threshold max_distance = by (float 0.000001) max_distance - - -suffixToBisect : (Expression33 -> Expression33 -> Expression2) -> String -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) -suffixToBisect interval suffix = - let - mainLoop found from to ithreshold depth choices _ cont = - def mat3T "midpoint" (byF (float 0.5) (add33 from to)) <| - \midpoint -> - def vec2T "front" (interval from midpoint) <| - \front -> - def vec2T "back" (interval midpoint to) <| - \back -> - if_ - (ors - [ geq depth constants.maxDepth - , ands [ lt (subtract front.y front.x) ithreshold, leq front.x zero, geq front.y zero ] - , ands [ lt (subtract back.y back.x) ithreshold, leq back.x zero, geq back.y zero ] - ] - ) - (\_ -> - expr (assign found (mix (arr midpoint (int 0)) (arr midpoint (int 1)) (float 0.5))) <| - \_ -> - return (bool True) cont - ) - <| - \_ -> - ifElse (ands [ leq front.x zero, geq front.y zero ]) - (\_ -> - expr (assign to midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift" [ choices.base ])) cont - ) - (ifElse (ands [ leq back.x zero, geq back.y zero ]) - (backtrackLeft from to depth choices midpoint) - (backtrackRight from to depth choices midpoint) - ) - cont - - backtrackLeft from _ depth choices midpoint cont = - expr (assign from midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - expr (assign choices (dotted1 <| unsafeCall "left_shift_increment" [ choices.base ])) cont - - backtrackRight from to depth choices midpoint cont = - -- This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch - forDown ( "j", subtractConst constants.maxDepth (int 1), int 0 ) - (\j _ -> - if_ (gt j depth) - continue - <| - \_ -> - expr (postfixDecrement depth) <| - \_ -> - expr (assign choices <| dotted1 <| unsafeCall "right_shift" [ choices.base ]) <| - \_ -> - ifElse (dotted1 <| unsafeCall "is_even" [ choices.base ]) - (\_ -> - expr (assign midpoint to) <| - \_ -> - expr (assign to <| add to (subtract to from)) <| - \_ -> - def vec2T "back" (interval midpoint to) <| - \back -> - if_ (ands [ leq back.x zero, geq back.y zero ]) - (\_ -> - expr (assign from midpoint) <| - \_ -> - expr (postfixIncrement depth) <| - \_ -> - expr (assign choices <| dotted1 <| unsafeCall "left_shift_increment" [ choices.base ]) <| - \_ -> - break cont - ) - cont - ) - (expr (assign from <| subtract from (subtract to from))) - cont - ) - <| - \_ -> - if_ (eq depth (int 0)) - (return false) - cont - in - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found cont -> - def mat3T "from" (mat3_3_3_3 o o vec3Zero) <| - \from -> - def mat3T "to" (add from <| byF maxDistance d) <| - \to -> - def floatT "ithreshold" (threshold maxDistance) <| - \ithreshold -> - def intT "depth" (int 0) <| - \depth -> - def intT "choices" (int 0) <| - \choices -> - for ( "it", int 0, constants.maxIterations ) - (mainLoop found from to ithreshold depth choices) - <| - \_ -> - return (bool False) cont diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index b6a19aaf..a3360e90 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,7 +1,7 @@ module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) -import Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Expression1, Expression2, Expression3, Expression33, Expression4, ExpressionX, Name(..), RelationOperation(..), Stat(..), Statement(..)) +import Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction) import Set @@ -377,22 +377,22 @@ indent i line = --EXPRESSIONS -ternary : ExpressionX a Bool -> ExpressionX b t -> ExpressionX c t -> Expression1 t +ternary : ExpressionXBool -> Expression t -> Expression t -> Expression t ternary = expr3 Ternary -ternary3 : ExpressionX xa Bool -> ExpressionX xb Vec3 -> ExpressionX xc Vec3 -> Expression3 +ternary3 : ExpressionX xa Bool -> ExpressionX xb Vec3 -> ExpressionX xc Vec3 -> Expression Vec3 ternary3 = expr33 Ternary -and : ExpressionX a Bool -> ExpressionX b Bool -> Expression1 Bool +and : Expression Bool -> Expression Bool -> Expression Bool and = expr2 And -ands : List (Expression1 Bool) -> Expression1 Bool +ands : List (Expression Bool) -> Expression Bool ands es = case es of [] -> @@ -402,12 +402,12 @@ ands es = List.foldl (\e a -> expr2 And a e) h t -or : ExpressionX a Bool -> ExpressionX b Bool -> Expression1 Bool +or : Expression Bool -> Expression Bool -> Expression Bool or = expr2 Or -ors : List (Expression1 Bool) -> Expression1 Bool +ors : List (Expression Bool) -> Expression Bool ors es = case es of [] -> @@ -417,7 +417,7 @@ ors es = List.foldl (\e a -> expr2 Or a e) h t -adds2 : List Expression2 -> Expression2 +adds2 : List (Expression Vec2) -> Expression Vec2 adds2 es = case es of [] -> @@ -427,7 +427,7 @@ adds2 es = List.foldl (\e a -> add2 a e) h t -adds3 : List Expression3 -> Expression3 +adds3 : List (Expression Vec3) -> Expression Vec3 adds3 es = case es of [] -> @@ -437,7 +437,7 @@ adds3 es = List.foldl (\e a -> add3 a e) h t -adds4 : List Expression4 -> Expression4 +adds4 : List (Expression Vec4) -> Expression Vec4 adds4 es = case es of [] -> @@ -447,63 +447,19 @@ adds4 es = List.foldl (\e a -> add4 a e) h t -true : Expression1 Bool -true = - dotted1 <| Expression <| Bool True - - -false : Expression1 Bool -false = - dotted1 <| Expression <| Bool False - - -expr1 : (Expr -> Expr) -> ExpressionX a l -> Expression1 t -expr1 f e = - dotted1Internal (f (unwrapExpression e)) - - -expr2 : (Expr -> Expr -> Expr) -> ExpressionX a l -> ExpressionX b r -> Expression1 t -expr2 f l r = - dotted1Internal (f (unwrapExpression l) (unwrapExpression r)) - - -expr22 : (Expr -> Expr -> Expr) -> ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 -expr22 f l r = - dotted2Internal (f (unwrapExpression l) (unwrapExpression r)) - - -expr23 : (Expr -> Expr -> Expr) -> ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 -expr23 f l r = - dotted3Internal (f (unwrapExpression l) (unwrapExpression r)) +pure : Expr -> Expression t +pure e = + Expression { expr = e, deps = Set.empty } -expr24 : (Expr -> Expr -> Expr) -> ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 -expr24 f l r = - dotted4Internal (f (unwrapExpression l) (unwrapExpression r)) - - -expr233 : (Expr -> Expr -> Expr) -> ExpressionX a Mat3 -> ExpressionX b Mat3 -> Expression33 -expr233 f l r = - dotted33Internal (f (unwrapExpression l) (unwrapExpression r)) - - -expr3 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX a l -> ExpressionX b m -> ExpressionX c r -> Expression1 t -expr3 f l m r = - dotted1Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) - - -expr33 : (Expr -> Expr -> Expr -> Expr) -> ExpressionX xa a -> ExpressionX xb b -> ExpressionX xc c -> Expression3 -expr33 f l m r = - dotted3Internal (f (unwrapExpression l) (unwrapExpression m) (unwrapExpression r)) +true : Expression Bool +true = + pure <| Bool True -unwrapExpression : ExpressionX a e -> Expr -unwrapExpression { base } = - let - (Expression e) = - base - in - e +false : Expression Bool +false = + pure <| Bool False @@ -512,32 +468,32 @@ unwrapExpression { base } = ------------------------------ -add : ExpressionX a t -> ExpressionX b t -> Expression1 t +add : Expression t -> Expression t -> Expression t add = expr2 Add -add2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +add2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 add2 = expr22 Add -add3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +add3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 add3 = expr23 Add -add4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +add4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 add4 = expr24 Add -add33 : ExpressionX a Mat3 -> ExpressionX b Mat3 -> Expression33 +add33 : Expression Mat3 -> Expression Mat3 -> Expression Mat3 add33 = expr233 Add -subtract : ExpressionX a t -> ExpressionX b t -> Expression1 t +subtract : Expression t -> Expression t -> Expression t subtract = expr2 Subtract @@ -549,22 +505,22 @@ subtractConst l r = } -subtract2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +subtract2 : ExpressionXVec2 -> Expression Vec2 -> Expression Vec2 subtract2 = expr22 Subtract -subtract3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +subtract3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 subtract3 = expr23 Subtract -subtract4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +subtract4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 subtract4 = expr24 Subtract -negate_ : ExpressionX a t -> Expression1 t +negate_ : Expression t -> Expression t negate_ = expr1 Negate @@ -576,377 +532,313 @@ negateConst l = } -negate2 : ExpressionX a Vec2 -> Expression2 +negate2 : Expression Vec2 -> Expression Vec2 negate2 e = dotted2Internal (Negate <| unwrapExpression e) -postfixIncrement : ExpressionX a t -> Expression1 t +postfixIncrement : Expression t -> Expression t postfixIncrement = expr1 PostfixIncrement -postfixDecrement : ExpressionX a t -> Expression1 t +postfixDecrement : Expression t -> Expression t postfixDecrement = expr1 PostfixDecrement -by : ExpressionX a t -> ExpressionX b t -> Expression1 t +by : Expression t -> Expression t -> Expression t by = expr2 By -by2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +by2 : ExpressionXVec2 -> Expression Vec2 -> Expression Vec2 by2 = expr22 By -by3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +by3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 by3 = expr23 By -byF : ExpressionX a Float -> ExpressionX b t -> Expression1 t +byF : Expression Float -> Expression t -> Expression t byF = expr2 By -divF : ExpressionX a t -> ExpressionX b Float -> Expression1 t +divF : Expression t -> Expression Float -> Expression t divF = expr2 Div -div : ExpressionX a t -> ExpressionX b t -> Expression1 t +div : Expression t -> Expression t -> Expression t div = expr2 Div -div2 : ExpressionX a Vec2 -> ExpressionX b Vec2 -> Expression2 +div2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 div2 = expr22 Div -divConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { b | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t -divConst l r = - { base = (expr2 Div l r).base - , isConstant = Constant - } - - -lt : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +lt : Expression t -> Expression t -> Expression Bool lt = expr2 (Comparison LessThan) -leq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +leq : Expression t -> Expression t -> Expression Bool leq = expr2 (Comparison LessThanOrEquals) -eq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +eq : Expression t -> Expression t -> Expression Bool eq = expr2 (Comparison Equals) -neq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +neq : Expression t -> Expression t -> Expression Bool neq = expr2 (Comparison NotEquals) -geq : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +geq : Expression t -> Expression t -> Expression Bool geq = expr2 (Comparison GreaterThanOrEquals) -gt : ExpressionX a t -> ExpressionX b t -> Expression1 Bool +gt : Expression t -> Expression t -> Expression Bool gt = expr2 (Comparison GreaterThan) -abs_ : ExpressionX a t -> Expression1 t +abs_ : Expression t -> Expression t abs_ = - dotted1 << call1Internal "abs" + call1Internal "abs" -abs2 : ExpressionX a Vec2 -> Expression2 +abs2 : Expression Vec2 -> Expression Vec2 abs2 = dotted2 << call1Internal "abs" -abs4 : ExpressionX a Vec4 -> Expression4 +abs4 : Expression Vec4 -> Expression Vec4 abs4 = dotted4 << call1Internal "abs" -mix : ExpressionX a t -> ExpressionX b t -> ExpressionX c Float -> Expression1 t +mix : Expression t -> Expression t -> Expression Float -> Expression t mix x y a = dotted1 <| call3Internal "mix" x y a -smoothstep : ExpressionX a Float -> ExpressionX b Float -> ExpressionX c Float -> Expression1 t +smoothstep : Expression Float -> Expression Float -> Expression Float -> Expression t smoothstep x y a = dotted1 <| call3Internal "smoothstep" x y a -exp : ExpressionX a t -> Expression1 t +exp : Expression t -> Expression t exp = - dotted1 << call1Internal "exp" + call1Internal "exp" -sqrt_ : ExpressionX a t -> Expression1 t +sqrt_ : Expression t -> Expression t sqrt_ = - dotted1 << call1Internal "sqrt" + call1Internal "sqrt" -sin_ : ExpressionX a t -> Expression1 t +sin_ : Expression t -> Expression t sin_ = - dotted1 << call1Internal "sin" + call1Internal "sin" -cos_ : ExpressionX a t -> Expression1 t +cos_ : Expression t -> Expression t cos_ = - dotted1 << call1Internal "cos" + call1Internal "cos" -tan_ : ExpressionX a t -> Expression1 t +tan_ : Expression t -> Expression t tan_ = - dotted1 << call1Internal "tan" + call1Internal "tan" -acos_ : ExpressionX a t -> Expression1 t +acos_ : Expression t -> Expression t acos_ = - dotted1 << call1Internal "acos" + call1Internal "acos" -acos2 : ExpressionX a Vec2 -> Expression2 +acos2 : Expression Vec2 -> Expression Vec2 acos2 = dotted2 << call1Internal "acos" -sinh : ExpressionX a t -> Expression1 t +sinh : Expression t -> Expression t sinh = - dotted1 << call1Internal "sinh" + call1Internal "sinh" -cosh : ExpressionX a t -> Expression1 t +cosh : Expression t -> Expression t cosh = - dotted1 << call1Internal "cosh" + call1Internal "cosh" -log : ExpressionX a t -> Expression1 t +log : Expression t -> Expression t log = - dotted1 << call1Internal "log" + call1Internal "log" -mod : ExpressionX a t -> ExpressionX b t -> Expression1 t +mod : Expression t -> Expression t -> Expression t mod l r = dotted1 (call2Internal "mod" l r) -min_ : ExpressionX a t -> ExpressionX b t -> Expression1 t +min_ : Expression t -> Expression t -> Expression t min_ l r = dotted1 (call2Internal "min" l r) -max_ : ExpressionX a t -> ExpressionX b t -> Expression1 t +max_ : Expression t -> Expression t -> Expression t max_ l r = dotted1 (call2Internal "max" l r) -max3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +max3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 max3 l r = dotted3 (call2Internal "max" l r) -max4 : ExpressionX a Vec4 -> ExpressionX b Vec4 -> Expression4 +max4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 max4 l r = dotted4 (call2Internal "max" l r) -hl2rgb : ExpressionX a Float -> ExpressionX b Float -> Expression3 +hl2rgb : ExpressionXFloat -> Expression Float -> Expression Vec3 hl2rgb h l = dotted3 (call2Internal "hl2rgb" h l) -pow : ExpressionX a Float -> ExpressionX b Float -> Expression1 Float +pow : Expression Float -> Expression Float -> Expression Float pow l r = dotted1 (call2Internal "pow" l r) -log2 : ExpressionX a Float -> Expression1 Float +log2 : ExpressionXFloat -> Expression Float log2 = - dotted1 << call1Internal "log2" + call1Internal "log2" -ceil_ : ExpressionX a t -> Expression1 t +ceil_ : Expression t -> Expression t ceil_ = - dotted1 << call1Internal "ceil" + call1Internal "ceil" -floor_ : ExpressionX a t -> Expression1 t +floor_ : Expression t -> Expression t floor_ = - dotted1 << call1Internal "floor" + call1Internal "floor" -round_ : ExpressionX a t -> Expression1 t +round_ : Expression t -> Expression t round_ = - dotted1 << call1Internal "round" + call1Internal "round" -sign : ExpressionX a t -> Expression1 t +sign : Expression t -> Expression t sign = - dotted1 << call1Internal "sign" + call1Internal "sign" -radians_ : ExpressionX a Float -> Expression1 Float +radians_ : Expression Float -> Expression Float radians_ = - dotted1 << call1Internal "radians" + call1Internal "radians" -normalize : ExpressionX a t -> Expression1 t +normalize : Expression t -> Expression t normalize = - dotted1 << call1Internal "normalize" + call1Internal "normalize" -normalize3 : ExpressionX a Vec3 -> Expression3 +normalize3 : ExpressionXVec3 -> Expression Vec3 normalize3 = dotted3 << call1Internal "normalize" -length : ExpressionX a t -> Expression1 Float +length : Expression t -> Expression Float length = - dotted1 << call1Internal "length" + call1Internal "length" -fwidth : ExpressionX a t -> Expression1 t +fwidth : Expression t -> Expression t fwidth = - dotted1 << call1Internal "fwidth" + call1Internal "fwidth" -cross : ExpressionX a Vec3 -> ExpressionX b Vec3 -> Expression3 +cross : Expression Vec3 -> Expression Vec3 -> Expression Vec3 cross l r = dotted3 <| call2Internal "cross" l r -atan_ : ExpressionX a Float -> Expression1 Float +atan_ : Expression Float -> Expression Float atan_ = - dotted1 << call1Internal "atan" + call1Internal "atan" -atan2_ : ExpressionX a Float -> ExpressionX b Float -> Expression1 Float +atan2_ : ExpressionXFloat -> Expression Float -> Expression Float atan2_ l r = dotted1 <| call2Internal "atan" l r -intCast : ExpressionX a Float -> Expression1 Int +intCast : Expression Float -> Expression Int intCast = - dotted1 << call1Internal "int" + call1Internal "int" -floatCast : ExpressionX a Int -> Expression1 Float +floatCast : ExpressionXInt -> Expression Float floatCast = - dotted1 << call1Internal "float" + call1Internal "float" -fract : ExpressionX a Float -> Expression1 Float +fract : Expression Float -> Expression Float fract = - dotted1 << call1Internal "fract" + call1Internal "fract" -arr : ExpressionX a Mat3 -> ExpressionX b Int -> Expression1 Vec3 +arr : ExpressionXMat3 -> Expression Int -> Expression Vec3 arr = expr2 Array -dot : ExpressionX a t -> ExpressionX b t -> Expression1 Float +dot : Expression t -> Expression t -> Expression Float dot l r = dotted1 (call2Internal "dot" l r) -vec2 : ExpressionX a Float -> ExpressionX b Float -> Expression2 -vec2 x y = - { base = call2Internal "vec2" x y - , x = { base = x.base } - , y = { base = y.base } - , yx = { base = call2Internal "vec2" y x } - } - - -vec3 : - ExpressionX a Float - -> ExpressionX b Float - -> ExpressionX c Float - -> Expression3 -vec3 x y z = - { base = call3Internal "vec3" x y z - , x = { base = x.base } - , y = { base = y.base } - , z = { base = z.base } - } - - -vec4 : - ExpressionX a Float - -> ExpressionX b Float - -> ExpressionX c Float - -> ExpressionX d Float - -> Expression4 -vec4 x y z w = - { base = call4Internal "vec4" x y z w - , x = { base = x.base } - , y = { base = y.base } - , z = { base = z.base } - , w = { base = w.base } - , xy = dotted2 <| call2Internal "vec2" x y - , yx = dotted2 <| call2Internal "vec2" y x - , yzw = dotted3 <| call3Internal "vec3" y z w - } - - -vec4_3_1 : ExpressionX a Vec3 -> ExpressionX b Float -> Expression4 -vec4_3_1 xyz w = - call2Internal "vec4" xyz w - |> dotted4 - - -vec4_1_3 : ExpressionX a Float -> ExpressionX b Vec3 -> Expression4 -vec4_1_3 x yzw = - call2Internal "vec4" x yzw - |> dotted4 - - -mat3_3_3_3 : ExpressionX a Vec3 -> ExpressionX b Vec3 -> ExpressionX c Vec3 -> Expression33 -mat3_3_3_3 c0 c1 c2 = - call3Internal "mat3" c0 c1 c2 |> dotted33 - - --------------- -- CONSTANTS -- --------------- -vec2Zero : Expression2 +vec2Zero : Expression Vec2 vec2Zero = vec2 zero zero -vec3Zero : Expression3 +vec3Zero : Expression Vec3 vec3Zero = vec3 zero zero zero -vec4Zero : Expression4 +vec4Zero : Expression Vec4 vec4Zero = vec4 zero zero zero zero -gl_FragColor : Expression4 +gl_FragColor : Expression Vec4 gl_FragColor = dottedVariable4 "gl_FragColor" -gl_FragCoord : Expression4 +gl_FragCoord : Expression Vec4 gl_FragCoord = dottedVariable4 "gl_FragCoord" @@ -966,43 +858,43 @@ type Constant = Constant -zero : ExpressionX { isConstant : Constant } Float +zero : Expression Float zero = float 0 -one : ExpressionX { isConstant : Constant } Float +one : Expression Float one = float 1 -minusOne : ExpressionX { isConstant : Constant } Float +minusOne : Expression Float minusOne = float -1 -float : Float -> ExpressionX { isConstant : Constant } Float +float : Float -> Expression Float float f = { base = Expression (Float f) , isConstant = Constant } -int : Int -> ExpressionX { isConstant : Constant } Int +int : Int -> Expression Int int i = { base = Expression <| Int i , isConstant = Constant } -bool : Bool -> ExpressionX { isConstant : Constant } Bool +bool : Bool -> Expression Bool bool b = { base = Expression <| Bool b , isConstant = Constant } -constant : TypingFunction t r -> String -> ExpressionX { isConstant : Constant } t +constant : TypingFunction t r -> String -> Expression t constant _ name = { base = Expression <| Variable name , isConstant = Constant @@ -1022,132 +914,12 @@ floatToGlsl f = s ++ "." -call0Internal : String -> Expression t -call0Internal name = - Expression (Call name []) - - -call1Internal : String -> ExpressionX a l -> Expression t -call1Internal name arg0 = - Expression (Call name [ unwrapExpression arg0 ]) - - -call2Internal : String -> ExpressionX a l -> ExpressionX b r -> Expression t -call2Internal name arg0 arg1 = - Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1 ]) - - -call3Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c r -> Expression t -call3Internal name arg0 arg1 arg2 = - Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2 ]) - - -call4Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c n -> ExpressionX d r -> Expression t -call4Internal name arg0 arg1 arg2 arg3 = - Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2, unwrapExpression arg3 ]) - - -call5Internal : String -> ExpressionX a l -> ExpressionX b m -> ExpressionX c n -> ExpressionX d r -> ExpressionX e s -> Expression t -call5Internal name arg0 arg1 arg2 arg3 arg4 = - Expression (Call name [ unwrapExpression arg0, unwrapExpression arg1, unwrapExpression arg2, unwrapExpression arg3, unwrapExpression arg4 ]) - - -dotted1 : Expression t -> Expression1 t -dotted1 (Expression e) = - dotted1Internal e - - -dotted1Internal : Expr -> Expression1 t -dotted1Internal e = - { base = Expression e - } - - -dotted2 : Expression Vec2 -> Expression2 -dotted2 (Expression e) = - dotted2Internal e - - -dotInternal : Expr -> String -> Expression1 t -dotInternal e v = - dotted1 (Expression (Dot e v)) - - -dotted2Internal : Expr -> Expression2 -dotted2Internal e = - { base = Expression e - , x = dotInternal e "x" - , y = dotInternal e "y" - , yx = dotInternal e "yx" - } - - -dotted3 : Expression Vec3 -> Expression3 -dotted3 (Expression e) = - dotted3Internal e - - -dotted3Internal : Expr -> Expression3 -dotted3Internal e = - { base = Expression e - , x = dotInternal e "x" - , y = dotInternal e "y" - , z = dotInternal e "z" - } - - -dotted4 : Expression Vec4 -> Expression4 -dotted4 (Expression e) = - dotted4Internal e - - -dotted4Internal : Expr -> Expression4 -dotted4Internal e = - { base = Expression e - , x = dotInternal e "x" - , y = dotInternal e "y" - , z = dotInternal e "z" - , w = dotInternal e "w" - , xy = dotted2 <| Expression <| Dot e "xy" - , yx = dotted2 <| Expression <| Dot e "yx" - , yzw = dotted3 <| Expression <| Dot e "yzw" - } - - -dotted33 : Expression Mat3 -> Expression33 -dotted33 (Expression e) = - dotted33Internal e - - -dotted33Internal : Expr -> Expression33 -dotted33Internal e = - { base = Expression e } - - -uniform : TypingFunction t c -> String -> c -uniform typeF name = - let - ( TypedName _ _ e, _ ) = - typeF name - in - e - - -unknown : String -> Expression t -unknown = - let - _ = - Debug.todo - in - Expression << Unknown - - -- STATEMENTS -funInternal : TypedName t c -> List ( String, String ) -> Statement t -> FunDecl -funInternal (TypedName (Type rt) (Name name) _) args body = +funInternal : TypedName t -> List ( String, String ) -> Statement t -> FunDecl +funInternal (TypedName (Type rt) (Name name)) args body = let argsList = String.join ", " (List.map (\( t, n ) -> t ++ " " ++ n) args) @@ -1167,14 +939,14 @@ funInternal (TypedName (Type rt) (Name name) _) args body = } -argToString : TypedName t c -> ( String, String ) -argToString (TypedName (Type t) (Name n) _) = +argToString : TypedName t -> ( String, String ) +argToString (TypedName (Type t) (Name n)) = ( t, n ) -toVar : TypedName t c -> c -toVar (TypedName _ _ e) = - e +toVar : TypedName t -> Expression t +toVar (TypedName _ (Name n)) = + pure <| Variable n fun0 : @@ -1302,22 +1074,22 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body ) -dottedVariable1 : String -> Expression1 t +dottedVariable1 : String -> Expression t dottedVariable1 v = dotted1 (Expression (Variable v)) -dottedVariable2 : String -> Expression2 +dottedVariable2 : String -> Expression Vec2 dottedVariable2 v = dotted2 (Expression (Variable v)) -dottedVariable3 : String -> Expression3 +dottedVariable3 : String -> Expression Vec3 dottedVariable3 v = dotted3 (Expression (Variable v)) -dottedVariable4 : String -> Expression4 +dottedVariable4 : String -> Expression Vec4 dottedVariable4 v = dotted4 (Expression (Variable v)) @@ -1326,19 +1098,19 @@ type alias Continue s = () -> Statement s -if_ : Expression1 Bool -> (Continue r -> Statement r) -> Continue r -> Statement r +if_ : Expression Bool -> (Continue r -> Statement r) -> Continue r -> Statement r if_ cond ifTrue next = Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) -ifElse : Expression1 Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s +ifElse : Expression Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s ifElse cond ifTrue ifFalse next = Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) for : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> Continue r -> Statement r) + -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r for ( var, from, to ) loop next = @@ -1354,7 +1126,7 @@ for ( var, from, to ) loop next = forLeq : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> Continue r -> Statement r) + -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r forLeq ( var, from, to ) loop next = @@ -1370,7 +1142,7 @@ forLeq ( var, from, to ) loop next = forDown : ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) - -> (Expression1 Int -> Continue r -> Statement r) + -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r forDown ( var, from, to ) loop next = @@ -1384,7 +1156,7 @@ forDown ( var, from, to ) loop next = (unwrapLazyStatement next) -return : ExpressionX a r -> Continue x -> Statement r +return : ExpressionXr -> Continue x -> Statement r return e _ = Statement <| Return <| unwrapExpression e @@ -1423,7 +1195,7 @@ def typeF name v k = Statement <| Decl t n (Just <| unwrapExpression v) ks -assign : ExpressionX a t -> ExpressionX b t -> Expression1 t +assign : Expression t -> Expression t -> Expression t assign name e = dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) @@ -1442,17 +1214,17 @@ unwrapStatement (Statement next) = next -expr : ExpressionX a t -> Continue q -> Statement q +expr : Expression t -> Continue q -> Statement q expr e next = Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) -assignAdd : ExpressionX a t -> ExpressionX b t -> Continue q -> Statement q +assignAdd : Expression t -> Expression t -> Continue q -> Statement q assignAdd name e next = Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) -assignBy : ExpressionX a t -> ExpressionX b t -> Continue q -> Statement q +assignBy : Expression t -> Expression t -> Continue q -> Statement q assignBy name e next = Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) @@ -1477,53 +1249,53 @@ type Mat3 = Mat3 Mat3 -voidT : TypingFunction () (Never -> a) +voidT : TypingFunction () voidT n = - ( TypedName (Type "void") (Name n) never, always never ) + TypedName (Type "void") (Name n) -boolT : TypingFunction Bool (Expression1 Bool) +boolT : TypingFunction Bool boolT n = - ( TypedName (Type "bool") (Name n) (dottedVariable1 n), dotted1 ) + TypedName (Type "bool") (Name n) -intT : TypingFunction Int (Expression1 Int) +intT : TypingFunction Int intT n = - ( TypedName (Type "int") (Name n) (dottedVariable1 n), dotted1 ) + TypedName (Type "int") (Name n) -floatT : TypingFunction Float (Expression1 Float) +floatT : TypingFunction Float floatT n = - ( TypedName (Type "float") (Name n) (dottedVariable1 n), dotted1 ) + TypedName (Type "float") (Name n) -vec2T : TypingFunction Vec2 Expression2 +vec2T : TypingFunction Vec2 vec2T n = - ( TypedName (Type "vec2") (Name n) (dottedVariable2 n), dotted2 ) + TypedName (Type "vec2") (Name n) -vec3T : TypingFunction Vec3 Expression3 +vec3T : TypingFunction Vec3 vec3T n = - ( TypedName (Type "vec3") (Name n) (dottedVariable3 n), dotted3 ) + TypedName (Type "vec3") (Name n) -vec4T : TypingFunction Vec4 Expression4 +vec4T : TypingFunction Vec4 vec4T n = - ( TypedName (Type "vec4") (Name n) (dottedVariable4 n), dotted4 ) + TypedName (Type "vec4") (Name n) -mat3T : TypingFunction Mat3 (Expression1 Mat3) +mat3T : TypingFunction Mat3 mat3T n = - ( TypedName (Type "mat3") (Name n) (dottedVariable1 n), dotted1 ) + TypedName (Type "mat3") (Name n) out : TypingFunction t r -> TypingFunction t r out inner n = let - ( TypedName (Type t) name v, c ) = + (TypedName (Type t) name v) = inner n in - ( TypedName (Type <| "out " ++ t) name v, c ) + TypedName (Type <| "out " ++ t) name v in_ : TypingFunction t r -> TypingFunction t r diff --git a/src/shaders/declarations.frag b/src/shaders/declarations.frag deleted file mode 100644 index b0c3fa5f..00000000 --- a/src/shaders/declarations.frag +++ /dev/null @@ -1,66 +0,0 @@ -precision highp float; - -uniform float u_whiteLines; -uniform float u_completelyReal; -uniform float u_drawAxes; -uniform vec2 u_zoomCenter; -uniform float u_viewportWidth; -uniform float u_canvasWidth; -uniform float u_canvasHeight; -uniform float u_phi; -uniform float u_theta; - -vec3 hl2rgb(float h, float l) -{ - vec3 rgb = clamp(abs(mod(h*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0,0.0,1.0); - return l + (rgb - 0.5) * (1.0 - abs(2.0 * l - 1.0)); -} - -#define P31 2147483648 -#define P32M1 4294967295 - -int left_shift(int i) { - return i * 2; -} - -int left_shift_increment(int i) { - return i * 2 + 1; -} - -ivec2 increment(ivec2 i) { - return i.x == P32M1 - ? ivec2(0, i.y + 1) - : ivec2(i.x + 1, i.y); -} - -ivec2 left_shift(ivec2 i) { - return i.x >= P31 - ? ivec2(2 * (i.x - P31), i.y * 2 + 1) - : 2 * i; -} - -ivec2 left_shift_increment(ivec2 i) { - return increment(left_shift(i)); -} - -bool is_even(int i) { - return i / 2 * 2 == i; -} - -bool is_odd(int i) { - return i / 2 * 2 != i; -} - -bool is_even(ivec2 i) { - return is_even(i.x); -} - -ivec2 right_shift(ivec2 i) { - return is_odd(i.y) - ? ivec2(i.x / 2 + P31, i.y / 2) - : i / 2; -} - -int right_shift(int i) { - return i / 2; -} From b16da4961493d5dbe9adafedaa6dd7a95534118e Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 10 Dec 2022 14:57:45 +0100 Subject: [PATCH 079/139] Cleanup --- codegen/Generate.elm | 44 ++-- codegen/Glsl/GlslConverter.elm | 146 ----------- codegen/Glsl/Types.elm | 1 + src/elm/UI/Glsl.elm | 433 +-------------------------------- src/elm/UI/Glsl/Code.elm | 1 - src/elm/UI/Glsl/Model.elm | 51 ---- 6 files changed, 26 insertions(+), 650 deletions(-) delete mode 100644 codegen/Glsl/GlslConverter.elm delete mode 100644 src/elm/UI/Glsl/Model.elm diff --git a/codegen/Generate.elm b/codegen/Generate.elm index ee46025d..e0348e17 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -76,11 +76,21 @@ declarationsDictionary : List Function -> Elm.Declaration declarationsDictionary functions = functions |> List.map - (\{ name } -> + (\{ name, args, deps } -> + let + fname : String + fname = + fullName name (List.map Tuple.first args) + in Elm.tuple - (Elm.string name) - (Elm.withType Type.string <| - Elm.val (name ++ "Body") + (Elm.string fname) + (Elm.record + [ ( "body" + , Elm.withType Type.string <| + Elm.val (fname ++ "Body") + ) + , ( "deps", deps ) + ] ) ) |> Gen.Dict.fromList @@ -152,26 +162,12 @@ type alias Env = } -functionToDeclarations : Env -> Function -> Result String (List Elm.Declaration) -functionToDeclarations env function = - let - envWithArgs : Env - envWithArgs = - List.foldl (\( type_, name ) -> variableHasType name type_) env function.args - - maybeDeps : Result String (Set String) - maybeDeps = - findDepsStatement envWithArgs function.stat - |> Result.mapError (\e -> e ++ " while generating " ++ function.name) - in - Result.map - (\deps -> - [ Elm.string function.body - |> Elm.declaration (function.name ++ "Body") - , wrapFunction function.name function.args function.returnType deps - ] - ) - maybeDeps +functionToDeclarations : Function -> List Elm.Declaration +functionToDeclarations function = + [ Elm.string function.body + |> Elm.declaration (function.name ++ "Body") + , wrapFunction function.name function.args function.returnType function.deps + ] wrapFunction : String -> List ( Type, String ) -> Type -> Set String -> Elm.Declaration diff --git a/codegen/Glsl/GlslConverter.elm b/codegen/Glsl/GlslConverter.elm deleted file mode 100644 index 750a18c4..00000000 --- a/codegen/Glsl/GlslConverter.elm +++ /dev/null @@ -1,146 +0,0 @@ -module Glsl.GlslConverter exposing (main) - -import Browser -import Element as Element exposing (Element, column, el, fill, height, padding, paragraph, row, scrollbars, spacing, text, width) -import Element.Border as Border -import Element.Font as Font -import Element.Input as Input -import Glsl.Parser as Parser -import Glsl.PrettyPrinter as PrettyPrinter -import Glsl.Types exposing (Function, Statement) -import Html -import Parser exposing ((|.), (|=), DeadEnd, Step(..), Trailing(..), oneOf, spaces, succeed) - - -type alias Model = - { input : String - , output : String - } - - -type Msg - = Input String - - -type Either l r - = Left l - | Right r - - -main : Program () Model Msg -main = - Browser.sandbox - { init = init - , view = Element.layout [ width fill, height fill ] << view - , update = update - } - - -init : Model -init = - let - i = - """{ - - - -}""" - in - { input = i - , output = toOutput i - } - - -view : Model -> Element Msg -view model = - row - [ padding 10 - , spacing 10 - , width fill - , height fill - ] - [ input model.input - , output model.output - ] - - -input : String -> Element Msg -input value = - Input.multiline - [ width fill - , height fill - , spacing 10 - ] - { onChange = Input - , text = value - , placeholder = Nothing - , label = Input.labelAbove [] <| text "Input (GLSL function or expression)" - , spellcheck = False - } - - -output : String -> Element Msg -output value = - let - bordering = - el - [ width fill - , height fill - , Border.width 1 - , Font.family [ Font.typeface "Fira Code", Font.monospace ] - , padding 10 - , scrollbars - ] - in - if String.contains "problem" value then - paragraph [] [ text value ] - |> bordering - - else - let - tc = - Html.pre [] [ Html.text value ] - |> Element.html - |> bordering - in - column - [ spacing 10 - , width fill - , height fill - ] - [ text "Output (Elm code)" - , tc - ] - - -update : Msg -> Model -> Model -update msg model = - case msg of - Input i -> - { model | input = i, output = toOutput i } - - -toOutput : String -> String -toOutput i = - case parse i of - Err e -> - Debug.toString e - - Ok (Left o) -> - PrettyPrinter.function o - - Ok (Right o) -> - PrettyPrinter.statement o - - -parse : String -> Result (List DeadEnd) (Either Function Statement) -parse = - Parser.run <| - succeed identity - |. spaces - |= oneOf - [ Parser.map Left Parser.function - , Parser.map Right Parser.statement - ] - |. spaces - |. Parser.end diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm index 8a3d6050..514c082e 100644 --- a/codegen/Glsl/Types.elm +++ b/codegen/Glsl/Types.elm @@ -8,6 +8,7 @@ type alias Function = , stat : Statement , body : String , hasSuffix : Bool + , deps : Set String } diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index fc288bbc..fe232700 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -9,7 +9,6 @@ import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, expr, fileToGlsl, unknown) -import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere @@ -219,11 +218,11 @@ tryGlslFromPolynomial : { expr : Expression , funDecls : List FunDecl , bisect : - ExpressionX xa Vec3 - -> ExpressionX xb Mat3 - -> ExpressionX xc Float - -> ExpressionX xd Vec3 - -> Expression1 Bool + Glsl.Helper.Expression Vec3 + -> Glsl.Helper.Expression Mat3 + -> Glsl.Helper.Expression Float + -> Glsl.Helper.Expression Vec3 + -> Glsl.Helper.Expression Bool } tryGlslFromPolynomial suffix e = let @@ -280,425 +279,3 @@ tryGlslFromPolynomial suffix e = , bisect = bisect } ) - - -transitiveClosure : List Requirement -> List Requirement -transitiveClosure = - let - go set ls = - case ls of - [] -> - Set.toList set - - x :: xs -> - if Set.member x set then - go set xs - - else - let - deps = - dependenciesOf x - in - if List.all (\d -> Set.member d set) deps then - go (Set.insert x set) xs - - else - go set (deps ++ ls) - in - go Set.empty - - -requirementSort : Requirement -> Requirement -> Order -requirementSort l r = - if l |> dependsOn r then - GT - - else if r |> dependsOn l then - LT - - else - EQ - - -dependsOn : Requirement -> Requirement -> Bool -dependsOn r l = - let - d = - dependenciesOf l - in - List.member r d || List.any (dependsOn r) d - - -type Requirement - = RequireFunction GlslFunction - | RequireConstant GlslConstant - | RequireOperation GlslOperation - - -type RequiresInterval - = IntervalOnly - | StraightOnly - | IntervalAndStraight - - -requirementToGlsl : RequiresInterval -> Requirement -> String -requirementToGlsl i r = - case r of - RequireFunction f -> - functionToGlsl i f - - RequireConstant c -> - constantToGlsl c - |> Tuple.first - |> (\l -> [ l ]) - |> fileToGlsl - - RequireOperation o -> - operationToGlsl i o |> fileToGlsl - - -expressionToRequirements : Expression -> List Requirement -expressionToRequirements e = - case e of - Apply (KnownFunction n) args -> - case toGlslFunction n of - Just gf -> - RequireFunction gf :: List.concatMap expressionToRequirements args - - Nothing -> - List.concatMap expressionToRequirements args - - Apply (UserFunction _) args -> - List.concatMap expressionToRequirements args - - Integer _ -> - [] - - Float _ -> - [] - - Variable _ -> - [] - - UnaryOperation _ c -> - RequireOperation GlslNegation :: expressionToRequirements c - - BinaryOperation Power (Variable v) (Integer _) -> - if v == "i" then - [ RequireOperation GlslPower ] - - else - [ RequireOperation GlslPower, RequireOperation GlslMultiplication, RequireFunction Square22 ] - - BinaryOperation Power b (Integer _) -> - [ RequireOperation GlslPower, RequireOperation GlslMultiplication, RequireFunction Square22 ] ++ expressionToRequirements b - - BinaryOperation Power b (Float _) -> - [ RequireOperation GlslPower, RequireOperation GlslMultiplication, RequireFunction Square22 ] ++ expressionToRequirements b - - BinaryOperation op l r -> - let - op_ = - case op of - Power -> - GlslPower - - Division -> - GlslDivision - in - RequireOperation op_ :: List.concatMap expressionToRequirements [ l, r ] - - RelationOperation _ l r -> - RequireOperation GlslRelations :: List.concatMap expressionToRequirements [ l, r ] - - AssociativeOperation op l m r -> - let - op_ = - case op of - Addition -> - GlslAddition - - Multiplication -> - GlslMultiplication - in - RequireOperation op_ :: List.concatMap expressionToRequirements (l :: m :: r) - - Replace ctx c -> - List.concatMap expressionToRequirements <| c :: List.filterMap identity (Dict.values ctx) - - List args -> - List.concatMap expressionToRequirements args - - Lambda _ f -> - expressionToRequirements f - - -toGlslFunction : KnownFunction -> Maybe GlslFunction -toGlslFunction name = - case name of - Sin -> - Just Sin22 - - Cos -> - Just Cos22 - - Tan -> - Just Tan22 - - Asin -> - Just Asin22 - - Acos -> - Just Acos22 - - Atan -> - Just Atan22 - - Atan2 -> - Just Atan222 - - Sinh -> - Just Sinh22 - - Cosh -> - Just Cosh22 - - Tanh -> - Just Tanh22 - - Abs -> - Just Abs22 - - Sign -> - Just Sign22 - - Root 2 -> - Just Sqrt22 - - Root 3 -> - Just Cbrt22 - - Root _ -> - Nothing - - Ln -> - Just Ln22 - - Log10 -> - Just Log1022 - - Exp -> - Just Exp22 - - Re -> - Just Re22 - - Im -> - Just Im22 - - Arg -> - Just Arg22 - - Gra -> - Nothing - - Pw -> - Just Pw22 - - Floor -> - Just Floor22 - - Ceiling -> - Just Ceiling22 - - Round -> - Just Round22 - - Min -> - Just Min222 - - Max -> - Just Max222 - - Mod -> - Just Mod22 - - Det -> - Nothing - - Dd -> - Nothing - - Ii -> - Nothing - - Plot -> - Nothing - - APlot -> - Nothing - - Simplify -> - Nothing - - StepSimplify -> - Nothing - - Solve -> - Nothing - - Mbrot -> - Just Mbrot22 - - For -> - Nothing - - -dependenciesOf : Requirement -> List Requirement -dependenciesOf req = - case req of - RequireFunction Sin22 -> - List.map RequireFunction [ Sinh11, Cosh11 ] - - RequireFunction Cos22 -> - List.map RequireFunction [ Sin22, Sinh11, Cosh11 ] - - RequireFunction Tan22 -> - RequireOperation GlslDivision :: List.map RequireFunction [ Sin22, Cos22 ] - - RequireFunction Asin22 -> - RequireOperation GlslMultiplication :: List.map RequireFunction [ Sqrt22, Ln22 ] - - RequireFunction Acos22 -> - [ RequireConstant Pi, RequireFunction Asin22 ] - - RequireFunction Atan22 -> - [ RequireConstant I, RequireOperation GlslMultiplication, RequireOperation GlslDivision, RequireFunction Ln22 ] - - RequireFunction Atan222 -> - [ RequireFunction Atan22, RequireOperation GlslMultiplication, RequireFunction Sign22 ] - - RequireFunction Sinh22 -> - [ RequireFunction Exp22, RequireFunction Sinh11 ] - - RequireFunction Cosh22 -> - [ RequireFunction Exp22 ] - - RequireFunction Tanh22 -> - [ RequireFunction Cosh11, RequireFunction Tanh11, RequireFunction Exp22, RequireOperation GlslDivision ] - - RequireFunction Abs22 -> - [] - - RequireFunction Sign22 -> - [] - - RequireFunction Sqrt22 -> - [] - - RequireFunction Cbrt22 -> - [ RequireOperation GlslPower ] - - RequireFunction Square22 -> - [] - - RequireFunction Min222 -> - [] - - RequireFunction Max222 -> - [] - - RequireFunction Mod22 -> - [ RequireOperation GlslDivision, RequireOperation GlslMultiplication, RequireFunction Floor22, RequireOperation GlslNegation ] - - RequireFunction Ln22 -> - [] - - RequireFunction Log1022 -> - [ RequireFunction Ln22, RequireOperation GlslDivision ] - - RequireFunction Exp22 -> - [] - - RequireFunction Re22 -> - [] - - RequireFunction Im22 -> - [] - - RequireFunction Arg22 -> - [] - - RequireFunction Pw22 -> - [] - - RequireFunction Sinh11 -> - [] - - RequireFunction Cosh11 -> - [] - - RequireFunction Tanh11 -> - [] - - RequireFunction Ceiling22 -> - [] - - RequireFunction Floor22 -> - [] - - RequireFunction Round22 -> - [] - - RequireFunction Mbrot22 -> - [ RequireOperation GlslMultiplication ] - - RequireOperation GlslPower -> - RequireOperation GlslMultiplication :: List.map RequireFunction [ Exp22, Ln22 ] - - RequireOperation GlslAddition -> - [] - - RequireOperation GlslMultiplication -> - [] - - RequireOperation GlslDivision -> - [ RequireOperation GlslMultiplication ] - - RequireOperation GlslNegation -> - [] - - RequireOperation GlslRelations -> - [] - - RequireConstant _ -> - [] - - -operationToGlsl : RequiresInterval -> GlslOperation -> List FunDecl -operationToGlsl interval op = - case interval of - StraightOnly -> - straightOperationToGlsl op - - IntervalOnly -> - intervalOperationToGlsl op - - IntervalAndStraight -> - straightOperationToGlsl op - ++ intervalOperationToGlsl op - - -functionToGlsl : RequiresInterval -> GlslFunction -> String -functionToGlsl interval name = - case interval of - StraightOnly -> - Generator.fileToGlsl <| straightFunctionToGlsl name - - IntervalOnly -> - intervalFunctionToGlsl name - - IntervalAndStraight -> - Generator.fileToGlsl (straightFunctionToGlsl name) - ++ "\n" - ++ intervalFunctionToGlsl name diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index c073068a..21db3ae8 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -5,7 +5,6 @@ import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression import Glsl exposing (vec211) import Glsl.Helper exposing (Expression) import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negate2, one, subtract, subtract2, vec2Zero, zero) -import UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 diff --git a/src/elm/UI/Glsl/Model.elm b/src/elm/UI/Glsl/Model.elm deleted file mode 100644 index 54fb7b91..00000000 --- a/src/elm/UI/Glsl/Model.elm +++ /dev/null @@ -1,51 +0,0 @@ -module UI.Glsl.Model exposing (GlslConstant(..), GlslFunction(..), GlslOperation(..)) - - -type GlslFunction - = Abs22 - | Acos22 - | Arg22 - | Asin22 - | Atan22 - | Atan222 - | Ceiling22 - | Cos22 - | Cosh11 - | Cosh22 - | Exp22 - | Floor22 - | Im22 - | Ln22 - | Log1022 - | Max222 - | Min222 - | Mod22 - | Mbrot22 - | Pw22 - | Re22 - | Round22 - | Sign22 - | Sin22 - | Sinh11 - | Sinh22 - | Sqrt22 - | Cbrt22 - | Square22 - | Tan22 - | Tanh11 - | Tanh22 - - -type GlslConstant - = E - | Pi - | I - - -type GlslOperation - = GlslAddition - | GlslMultiplication - | GlslNegation - | GlslDivision - | GlslPower - | GlslRelations From 575b61380fa95f7137ea53c203a2cece82bb8dbc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 14 Dec 2022 02:26:56 +0100 Subject: [PATCH 080/139] Moving towards included dependencies --- codegen/Generate.elm | 137 +++--- codegen/Glsl/Types.elm | 1 - codegen/functions.frag | 6 +- src/elm/Complex.elm | 6 +- src/elm/Expression.elm | 9 +- src/elm/Expression/Derivative.elm | 2 +- src/elm/Expression/Value.elm | 4 +- src/elm/UI/Glsl.elm | 102 +---- src/elm/UI/Glsl/Code.elm | 71 +-- src/elm/UI/Glsl/Generator.elm | 26 +- tests/raytracing/head.h | 731 +++++++++++++----------------- 11 files changed, 481 insertions(+), 614 deletions(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index e0348e17..e366d13f 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -5,7 +5,6 @@ import Elm import Elm.Annotation as Type import Gen.CodeGen.Generate as Generate import Gen.Debug -import Gen.Dict import Gen.Glsl.Helper import Glsl.Parser import Glsl.Types exposing (BinaryOperation(..), Expression(..), Function, Statement(..), Type(..)) @@ -19,7 +18,18 @@ main : Program String () () main = Generate.fromText (\glsl -> - [ Elm.file [ "Glsl" ] (generate glsl) + [ Elm.fileWith [ "Glsl" ] + { docs = + List.map + (\{ group, members } -> + Elm.docs + { group = group + , members = List.sort members + } + ) + , aliases = [] + } + (generate glsl) ] ) @@ -44,7 +54,10 @@ generate glsl = (List.map Tuple.first args) returnType ) - { functionsEnv = builtinFunctions |> Dict.map (\_ -> Tuple.second) + { functionsEnv = + builtinFunctions + |> Dict.map + (\_ { return } -> return) , variablesEnv = builtinUniforms } functions @@ -57,7 +70,7 @@ generate glsl = in case maybeDecls of Ok decls -> - declarationsDictionary functions :: List.concat decls ++ builtinDecls + List.concat decls ++ builtinDecls Err e -> "Error generating file" @@ -72,32 +85,6 @@ functionHasType baseName argTypes returnType env = { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } -declarationsDictionary : List Function -> Elm.Declaration -declarationsDictionary functions = - functions - |> List.map - (\{ name, args, deps } -> - let - fname : String - fname = - fullName name (List.map Tuple.first args) - in - Elm.tuple - (Elm.string fname) - (Elm.record - [ ( "body" - , Elm.withType Type.string <| - Elm.val (fname ++ "Body") - ) - , ( "deps", deps ) - ] - ) - ) - |> Gen.Dict.fromList - |> Elm.declaration "declarationsDictionary" - |> Elm.expose - - errorToString : List Parser.DeadEnd -> String errorToString deadEnds = deadEnds @@ -162,17 +149,43 @@ type alias Env = } -functionToDeclarations : Function -> List Elm.Declaration -functionToDeclarations function = - [ Elm.string function.body - |> Elm.declaration (function.name ++ "Body") - , wrapFunction function.name function.args function.returnType function.deps - ] +functionToDeclarations : Env -> Function -> Result String (List Elm.Declaration) +functionToDeclarations env function = + let + fname = + fullName function.name (List.map Tuple.first function.args) + + envWithArgs : Env + envWithArgs = + List.foldl (\( type_, name ) -> variableHasType name type_) env function.args + maybeDeps : Result String (Set String) + maybeDeps = + findDepsStatement envWithArgs function.stat + |> Result.mapError (\e -> e ++ " while generating " ++ fname) + in + Result.map + (\deps -> + [ Elm.string function.body + |> Elm.declaration (fname ++ "Body") + , deps + |> Set.toList + |> List.map Elm.string + |> Elm.list + |> Elm.withType (Type.list Type.string) + |> Elm.declaration (fname ++ "Deps") + , wrapFunction function.name function.args function.returnType + ] + ) + maybeDeps -wrapFunction : String -> List ( Type, String ) -> Type -> Set String -> Elm.Declaration -wrapFunction name args returnType deps = + +wrapFunction : String -> List ( Type, String ) -> Type -> Elm.Declaration +wrapFunction name args returnType = let + fname = + fullName name (List.map Tuple.first args) + argDecls : List ( String, Maybe Type.Annotation ) argDecls = List.map @@ -183,7 +196,7 @@ wrapFunction name args returnType deps = ) args - innerCall argValues _ = + innerCall argValues = case argValues of [] -> Gen.Glsl.Helper.unsafeCall0 name @@ -207,16 +220,23 @@ wrapFunction name args returnType deps = expr argValues = innerCall argValues - (deps - |> Set.toList - |> List.map Elm.string - |> Elm.list - ) |> Elm.withType (Gen.Glsl.Helper.annotation_.expression (typeToAnnotation returnType)) in Elm.function argDecls expr - |> Elm.declaration name - |> Elm.expose + |> Elm.declaration fname + |> Elm.exposeWith + { exposeConstructor = False + , group = + Just <| + if + List.member (String.left 1 name) [ "g", "i", "c" ] + && not (List.member name [ "cbrt" ]) + then + String.dropLeft 1 name + + else + name + } typeToAnnotation : Type -> Type.Annotation @@ -592,7 +612,7 @@ builtinUniforms = |> Dict.fromList -builtinFunctions : Dict String ( List Type, Type ) +builtinFunctions : Dict String { baseName : String, args : List Type, return : Type } builtinFunctions = let overload : List String -> List ( List Type, Type ) -> List ( String, List Type, Type ) @@ -653,12 +673,15 @@ builtinFunctions = , ( "float", [ TInt ], TFloat ) , ( "int", [ TFloat ], TInt ) ] + + builtTuple : + ( String, List Type, Type ) + -> ( String, { baseName : String, args : List Type, return : Type } ) + builtTuple ( name, inTypes, resultType ) = + ( fullName name inTypes, { baseName = name, args = inTypes, return = resultType } ) in (regular ++ vecs ++ ivecs ++ others) - |> List.map - (\( name, inTypes, resultType ) -> - ( fullName name inTypes, ( inTypes, resultType ) ) - ) + |> List.map builtTuple |> Dict.fromList @@ -680,7 +703,6 @@ builtin_v_v = ( [ -- Rounding "ceil" , "floor" - , "round" , "fract" -- Complex and power @@ -848,16 +870,15 @@ builtinDecls = builtinFunctions |> Dict.toList |> List.map - (\( name, ( inTypes, resultType ) ) -> + (\( _, { baseName, args, return } ) -> wrapFunction - name + baseName (List.indexedMap (\i type_ -> ( type_, indexedVar i )) - inTypes + args ) - resultType - Set.empty - |> Elm.expose + return + |> Elm.exposeWith { exposeConstructor = False, group = Just baseName } ) diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm index 514c082e..8a3d6050 100644 --- a/codegen/Glsl/Types.elm +++ b/codegen/Glsl/Types.elm @@ -8,7 +8,6 @@ type alias Function = , stat : Statement , body : String , hasSuffix : Bool - , deps : Set String } diff --git a/codegen/functions.frag b/codegen/functions.frag index 33734cfe..571dcde9 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -227,7 +227,7 @@ vec2 carg(vec2 v) { return vec2(atan(v.y, v.x), 0); } vec2 cpw(vec2 c, vec2 t, vec2 f) { return c.x > 0. ? t : f; } // Rounding -vec2 cceiling(vec2 z) { return ceil(z); } +vec2 cceil(vec2 z) { return ceil(z); } vec2 cfloor(vec2 z) { return floor(z); } vec2 cround(vec2 z) { return floor(z + vec2(0.5, 0.5)); } @@ -424,7 +424,7 @@ vec2 isquare(vec2 z) { vec2 isqrt(vec2 v) { return vec2(sqrt(max(0., v.x)), sqrt(max(0., v.y))); } vec2 icbrt(vec2 v) { return vec2(cbrt(v.x), cbrt(v.y)); } -vec2 iceiling(vec2 z) { return ceil(z); } +vec2 iceil(vec2 z) { return ceil(z); } vec2 ifloor(vec2 z) { return floor(z); } vec2 iround(vec2 z) { return round(z); } @@ -499,6 +499,6 @@ vec4 gmod(vec4 l, vec4 r) { return vec4(mod(l.x, r.x), l.yzw); } vec4 gsign(vec4 v) { return gnum(sign(v.x)); } -vec4 gceiling(vec4 z) { return gnum(ceil(z.x)); } +vec4 gceil(vec4 z) { return gnum(ceil(z.x)); } vec4 gfloor(vec4 z) { return gnum(floor(z.x)); } vec4 ground(vec4 z) { return gnum(round(z.x)); } diff --git a/src/elm/Complex.elm b/src/elm/Complex.elm index 71484d54..a1d3706a 100644 --- a/src/elm/Complex.elm +++ b/src/elm/Complex.elm @@ -1,4 +1,4 @@ -module Complex exposing (Complex(..), abs, acos, arg, asin, atan, atan2, by, ceiling, cos, cosh, div, exp, floor, fromReal, i, im, ln, max, min, minus, negate, one, plus, power, re, round, sign, sin, sinh, sqrt, tan, tanh, toString, zero) +module Complex exposing (Complex(..), abs, acos, arg, asin, atan, atan2, by, ceil, cos, cosh, div, exp, floor, fromReal, i, im, ln, max, min, minus, negate, one, plus, power, re, round, sign, sin, sinh, sqrt, tan, tanh, toString, zero) type Complex @@ -232,8 +232,8 @@ floor (Complex x y) = Complex (toFloat <| Basics.floor x) (toFloat <| Basics.floor y) -ceiling : Complex -> Complex -ceiling (Complex x y) = +ceil : Complex -> Complex +ceil (Complex x y) = Complex (toFloat <| Basics.ceiling x) (toFloat <| Basics.ceiling y) diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index 23aa9684..ab22b923 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -106,7 +106,7 @@ type KnownFunction | Max | Round | Floor - | Ceiling + | Ceil | Pw | Plot | APlot @@ -744,8 +744,7 @@ unaryFunctions = , ( "simplify", Simplify ) , ( "stepsimplify", StepSimplify ) , ( "floor", Floor ) - , ( "ceil", Ceiling ) - , ( "ceiling", Ceiling ) + , ( "ceil", Ceil ) , ( "round", Round ) ] in @@ -950,8 +949,8 @@ functionNameToString name = KnownFunction Floor -> "floor" - KnownFunction Ceiling -> - "ceiling" + KnownFunction Ceil -> + "ceil" KnownFunction Round -> "round" diff --git a/src/elm/Expression/Derivative.elm b/src/elm/Expression/Derivative.elm index 76e57656..4e441d57 100644 --- a/src/elm/Expression/Derivative.elm +++ b/src/elm/Expression/Derivative.elm @@ -209,7 +209,7 @@ knownDerivative name x = Floor -> zero - Ceiling -> + Ceil -> zero Pw -> diff --git a/src/elm/Expression/Value.elm b/src/elm/Expression/Value.elm index 348ed1ea..8b859c70 100644 --- a/src/elm/Expression/Value.elm +++ b/src/elm/Expression/Value.elm @@ -237,8 +237,8 @@ applyValue context name args = KnownFunction Floor -> unaryFunctionValue context args Floor Complex.floor - KnownFunction Ceiling -> - unaryFunctionValue context args Ceiling Complex.ceiling + KnownFunction Ceil -> + unaryFunctionValue context args Ceil Complex.ceil KnownFunction Round -> unaryFunctionValue context args Round Complex.round diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index fe232700..bfb97d88 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -5,6 +5,7 @@ import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expre import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, minus, plus, square) +import Glsl.Helper import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) @@ -17,7 +18,7 @@ import UI.Glsl.Sphere as Sphere getGlsl : Bool -> Graph -> String getGlsl rayDifferentials graph = let - { expr, funDecls, interval, usesThetaDelta, pixel2D, pixel3D } = + { expr, funDecls, usesThetaDelta, pixel2D, pixel3D } = extract "" graph build2d toSrc e = @@ -27,7 +28,6 @@ getGlsl rayDifferentials graph = in { expr = e , funDecls = decl - , interval = StraightOnly , usesThetaDelta = False , pixel2D = [ { call = call, color = True } ] , pixel3D = [] @@ -47,21 +47,11 @@ getGlsl rayDifferentials graph = build2d (toSrcPolar prefix) e Parametric2D x y -> - let - ( src, call ) = - toSrcParametric prefix e - - e = - plus - [ square (minus (Variable "x") x) - , square (minus (Variable "y") y) - ] - in - { expr = e - , funDecls = src - , interval = IntervalOnly - , usesThetaDelta = False - , pixel2D = [ { call = call, color = True } ] + { pixel2D = + [ { call = toSrcParametric prefix e + , color = True + } + ] , pixel3D = [] } @@ -69,15 +59,7 @@ getGlsl rayDifferentials graph = build2d (toSrcRelation prefix) e Contour e -> - let - ( src, pixel ) = - toSrcContour prefix e - in - { expr = e - , funDecls = src - , interval = StraightOnly - , usesThetaDelta = True - , pixel2D = [ { call = pixel, color = False } ] + { pixel2D = [ { call = toSrcContour prefix e, color = False } ] , pixel3D = [] } @@ -87,9 +69,6 @@ getGlsl rayDifferentials graph = get3DSource prefix e in { expr = f.expr - , funDecls = f.funDecls - , interval = IntervalAndStraight - , usesThetaDelta = True , pixel2D = [] , pixel3D = [ f.bisect ] } @@ -102,39 +81,15 @@ getGlsl rayDifferentials graph = extracted = List.indexedMap (extract << prefix_) children in - { expr = List <| List.map .expr extracted - , funDecls = List.concatMap .funDecls extracted - , interval = - if List.any (\c -> c.interval /= StraightOnly) extracted then - IntervalAndStraight - - else - StraightOnly - , usesThetaDelta = List.any .usesThetaDelta extracted - , pixel2D = List.concatMap .pixel2D extracted + { pixel2D = List.concatMap .pixel2D extracted , pixel3D = List.concatMap .pixel3D extracted } VectorField2D x y -> - let - ( src, pixel ) = - toSrcVectorField2D prefix x y - in - { expr = Apply (KnownFunction Arg) [ x, y ] - , funDecls = src - , interval = StraightOnly - , usesThetaDelta = True - , pixel2D = [ { call = pixel, color = False } ] + { pixel2D = [ { call = toSrcVectorField2D prefix x y, color = False } ] , pixel3D = [] } - thetaDeltaCode = - if usesThetaDelta then - Generator.fileToGlsl [ UI.Glsl.Code.thetaDeltaDecl ] - - else - "" - reqs = let _ = @@ -143,52 +98,35 @@ getGlsl rayDifferentials graph = in expr |> expressionToRequirements - |> transitiveClosure |> List.sortWith requirementSort |> List.map (requirementToGlsl interval) |> String.join "\n" in - declarations - ++ thetaDeltaCode - ++ reqs + reqs ++ "\n/* Expression */\n" ++ Generator.fileToGlsl funDecls ++ mainGlsl rayDifferentials pixel2D pixel3D -declarations : String -declarations = - [ atanPlusDecl, gnumDecl, dupDecl ] - |> Generator.fileToGlsl - - get3DSource : String -> Expression -> - { expr : Expression - , funDecls : List FunDecl - , bisect : - ExpressionX xa Vec3 - -> ExpressionX xb Mat3 - -> ExpressionX xc Float - -> ExpressionX xd Vec3 - -> Expression1 Bool - } + (Glsl.Helper.Expression Vec3 + -> Glsl.Helper.Expression Mat3 + -> Glsl.Helper.Expression Float + -> Glsl.Helper.Expression Vec3 + -> Glsl.Helper.Expression Bool + ) get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of - Just ( glsl, bisect ) -> - { expr = e - , funDecls = [ glsl ] - , bisect = bisect - } + Just bisect -> + bisect Nothing -> case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of Just ( glsl, bisect ) -> - { expr = e - , funDecls = [ glsl ] - , bisect = bisect + { bisect = bisect } Nothing -> diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 21db3ae8..df1202b5 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (expressionToGlsl, threshold) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl exposing (vec211) +import Glsl exposing (cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, vec21, vec211) import Glsl.Helper exposing (Expression) import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negate2, one, subtract, subtract2, vec2Zero, zero) @@ -10,9 +10,11 @@ import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negat expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 expressionToGlsl context = let + ctx : Dict.Dict String (Expression Float) ctx = Dict.fromList context + variadic : (Expression Vec2 -> Expression Vec2 -> Expression Vec2) -> List PrintExpression -> Expression Vec2 variadic f es = case List.map go es of [] -> @@ -21,6 +23,7 @@ expressionToGlsl context = head :: tail -> List.foldl (\e a -> f a e) head tail + go : PrintExpression -> Expression Vec2 go expr = case expr of PVariable "i" -> @@ -38,7 +41,7 @@ expressionToGlsl context = vec211 w zero Nothing -> - vec2Zero + vec21 zero PInteger v -> vec211 (float <| toFloat v) zero @@ -76,105 +79,105 @@ expressionToGlsl context = subtract2 (go l) (go r) PBy l r -> - cby (go l) (go r) + cby22 (go l) (go r) PDiv l r -> - cdiv (go l) (go r) + cdiv22 (go l) (go r) PPower (PVariable v) (PInteger 2) -> case Dict.get v ctx of Just w -> - vec2 (by w w) zero + vec211 (by w w) zero Nothing -> vec2Zero PPower l (PInteger 2) -> - csquare (go l) + csquare2 (go l) PPower l r -> - cpow (go l) (go r) + cpow22 (go l) (go r) PApply (KnownFunction Simplify) [ e ] -> go e PApply (KnownFunction Sin) [ e ] -> - csin (go e) + csin2 (go e) PApply (KnownFunction Cos) [ e ] -> - ccos (go e) + ccos2 (go e) PApply (KnownFunction Tan) [ e ] -> - ctan (go e) + ctan2 (go e) PApply (KnownFunction Asin) [ e ] -> - casin (go e) + casin2 (go e) PApply (KnownFunction Acos) [ e ] -> - cacos (go e) + cacos2 (go e) PApply (KnownFunction Atan) [ e ] -> - catan (go e) + catan2 (go e) PApply (KnownFunction Atan2) [ l, r ] -> - catan2 (go l) (go r) + catan222 (go l) (go r) PApply (KnownFunction Sinh) [ e ] -> - csinh (go e) + csinh2 (go e) PApply (KnownFunction Cosh) [ e ] -> - ccosh (go e) + ccosh2 (go e) PApply (KnownFunction Tanh) [ e ] -> - ctanh (go e) + ctanh2 (go e) PApply (KnownFunction Abs) [ e ] -> - cabs (go e) + cabs2 (go e) PApply (KnownFunction Ln) [ e ] -> - cln (go e) + cln2 (go e) PApply (KnownFunction Log10) [ e ] -> - clog10 (go e) + clog102 (go e) PApply (KnownFunction Exp) [ e ] -> - cexp (go e) + cexp2 (go e) PApply (KnownFunction Sign) [ e ] -> - csign (go e) + csign2 (go e) PApply (KnownFunction Re) [ e ] -> - cre (go e) + cre2 (go e) PApply (KnownFunction Im) [ e ] -> - cim (go e) + cim2 (go e) PApply (KnownFunction Arg) [ e ] -> - carg (go e) + carg2 (go e) PApply (KnownFunction Round) [ e ] -> - cround (go e) + cround2 (go e) PApply (KnownFunction Floor) [ e ] -> - cfloor (go e) + cfloor2 (go e) - PApply (KnownFunction Ceiling) [ e ] -> - cceiling (go e) + PApply (KnownFunction Ceil) [ e ] -> + cceil2 (go e) PApply (KnownFunction Pw) [ c, t, f ] -> - cpw (go c) (go t) (go f) + cpw222 (go c) (go t) (go f) PApply (KnownFunction Mod) [ l, r ] -> - cmod (go l) (go r) + cmod22 (go l) (go r) PApply (KnownFunction Mbrot) [ x, y ] -> - cmbrot (go x) (go y) + cmbrot22 (go x) (go y) PApply (KnownFunction Min) es -> - variadic cmin es + variadic cmin22 es PApply (KnownFunction Max) es -> - variadic cmax es + variadic cmax22 es PReplace var e -> go (Expression.pfullSubstitute var e) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index a3360e90..c93b0d86 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,7 +1,7 @@ -module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Statement, TypedName, TypingFunction, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divConst, divF, dot, dotted1, dotted2, dotted3, dotted33, dotted4, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, mat3_3_3_3, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divF, dot, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) import Dict exposing (Dict) -import Glsl.Helper exposing (ComboOperation(..), Expr(..), Expression(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction) +import Glsl.Helper exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction) import Set @@ -1289,22 +1289,22 @@ mat3T n = TypedName (Type "mat3") (Name n) -out : TypingFunction t r -> TypingFunction t r +out : TypingFunction t -> TypingFunction t out inner n = let - (TypedName (Type t) name v) = + (TypedName (Type t) name) = inner n in - TypedName (Type <| "out " ++ t) name v + TypedName (Type <| "out " ++ t) name -in_ : TypingFunction t r -> TypingFunction t r +in_ : TypingFunction t -> TypingFunction t in_ inner n = let - ( TypedName (Type t) name v, c ) = + (TypedName (Type t) name) = inner n in - ( TypedName (Type <| "in " ++ t) name v, c ) + TypedName (Type <| "in " ++ t) name @@ -1363,7 +1363,7 @@ valueToString v = value : Context -> Expression t -> Result ErrorValue ( Context, GlslValue ) value initialContext (Expression input) = - innerValue initialContext input + innerValue initialContext input.expr innerValue : Context -> Expr -> Result ErrorValue ( Context, GlslValue ) @@ -1437,13 +1437,13 @@ innerValue ctx e = Ternary _ _ _ -> Debug.todo "branch 'Ternary _ _ _' not implemented" - Add _ _ -> + BinaryOperation Add _ _ -> Debug.todo "branch 'Add _ _' not implemented" - Subtract _ _ -> + BinaryOperation Subtract _ _ -> Debug.todo "branch 'Subtract _ _' not implemented" - By l r -> + BinaryOperation By l r -> innerValue2 ctx l r <| \ctx2 vl vr -> case ( vl, vr ) of @@ -1455,7 +1455,7 @@ innerValue ctx e = InvalidTypes ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) - Div _ _ -> + BinaryOperation Div _ _ -> Debug.todo "branch 'Div _ _' not implemented" Call "vec2" [ l, r ] -> diff --git a/tests/raytracing/head.h b/tests/raytracing/head.h index 46d6d918..b998fedb 100644 --- a/tests/raytracing/head.h +++ b/tests/raytracing/head.h @@ -1,490 +1,397 @@ #pragma once -#include #include +#include #define main() main_() #define float double // Yes, really struct ivec2 { - int x; - int y; - ivec2(int x, int y) : x(x), y(y) {} + int x; + int y; + ivec2(int x, int y) : x(x), y(y) {} - friend ivec2 operator * (int d, ivec2 r) { - return ivec2(d * r.x, d * r.y); - } + friend ivec2 operator*(int d, ivec2 r) { return ivec2(d * r.x, d * r.y); } - friend ivec2 operator / (ivec2 l, int r) { - return ivec2(l.x / r, l.y / r); - } + friend ivec2 operator/(ivec2 l, int r) { return ivec2(l.x / r, l.y / r); } }; struct vec2 { - double x; - double y; - vec2() : x(0), y(0) {} - vec2(double x, double y) : x(x), y(y) {} - - friend vec2 operator + (vec2 l, vec2 r) { - return vec2(l.x + r.x, l.y + r.y); - } - - friend vec2 operator - (vec2 l, vec2 r) { - return vec2(l.x - r.x, l.y - r.y); - } - - friend vec2 operator - (vec2 r) { - return vec2(-r.x, -r.y); - } - - friend vec2 operator * (double d, vec2 r) { - return vec2(d * r.x, d * r.y); - } - - friend vec2 operator * (vec2 l, vec2 r) { - return vec2(l.x * r.x, l.y * r.y); - } - - friend vec2 operator / (vec2 l, double r) { - return vec2(l.x / r, l.y / r); - } - - friend vec2 operator / (vec2 l, vec2 r) { - return vec2(l.x / r.x, l.y / r.y); - } + double x; + double y; + vec2() : x(0), y(0) {} + vec2(double x, double y) : x(x), y(y) {} + + friend vec2 operator+(vec2 l, vec2 r) { return vec2(l.x + r.x, l.y + r.y); } + + friend vec2 operator-(vec2 l, vec2 r) { return vec2(l.x - r.x, l.y - r.y); } + + friend vec2 operator-(vec2 r) { return vec2(-r.x, -r.y); } + + friend vec2 operator*(double d, vec2 r) { return vec2(d * r.x, d * r.y); } + + friend vec2 operator*(vec2 l, vec2 r) { return vec2(l.x * r.x, l.y * r.y); } + + friend vec2 operator/(vec2 l, double r) { return vec2(l.x / r, l.y / r); } + + friend vec2 operator/(vec2 l, vec2 r) { return vec2(l.x / r.x, l.y / r.y); } }; struct vec3 { - double x; - double y; - double z; - vec3() : x(0), y(0), z(0) {} - vec3(vec2 xy, double z) : x(xy.x), y(xy.y), z(z) {} - vec3(double x) : x(x), y(0), z(0) {} - vec3(double x, double y, double z) : x(x), y(y), z(z) {} - - friend vec3 operator + (double d, vec3 r) { - return vec3(d + r.x, d + r.y, d + r.z); - } - - friend vec3 operator + (vec3 l, vec3 r) { - return vec3(l.x + r.x, l.y + r.y, l.z + r.z); - } - - friend vec3 operator - (vec3 r, double d) { - return vec3(r.x - d, r.y - d, r.z - d); - } - - friend vec3 operator - (vec3 l, vec3 r) { - return vec3(l.x - r.x, l.y - r.y, l.z - r.z); - } - - friend vec3 operator - (vec3 l) { - return vec3(-l.x, -l.y, -l.z); - } - - friend vec3 operator * (vec3 l, vec3 r) { - return vec3(l.x * r.x, l.y * r.y, l.z * r.z); - } - - friend vec3 operator * (vec3 r, double d) { - return vec3(d * r.x, d * r.y, d * r.z); - } - - friend vec3 operator * (double d, vec3 r) { - return vec3(d * r.x, d * r.y, d * r.z); - } - - friend vec3 operator / (vec3 r, double d) { - return vec3(r.x / d, r.y / d, r.z / d); - } - - friend bool operator == (vec3 l, vec3 r) { - return l.x == r.x && l.y == r.y && l.z == r.z; - } + double x; + double y; + double z; + vec3() : x(0), y(0), z(0) {} + vec3(vec2 xy, double z) : x(xy.x), y(xy.y), z(z) {} + vec3(double x) : x(x), y(0), z(0) {} + vec3(double x, double y, double z) : x(x), y(y), z(z) {} + + friend vec3 operator+(double d, vec3 r) { + return vec3(d + r.x, d + r.y, d + r.z); + } + + friend vec3 operator+(vec3 l, vec3 r) { + return vec3(l.x + r.x, l.y + r.y, l.z + r.z); + } + + friend vec3 operator-(vec3 r, double d) { + return vec3(r.x - d, r.y - d, r.z - d); + } + + friend vec3 operator-(vec3 l, vec3 r) { + return vec3(l.x - r.x, l.y - r.y, l.z - r.z); + } + + friend vec3 operator-(vec3 l) { return vec3(-l.x, -l.y, -l.z); } + + friend vec3 operator*(vec3 l, vec3 r) { + return vec3(l.x * r.x, l.y * r.y, l.z * r.z); + } + + friend vec3 operator*(vec3 r, double d) { + return vec3(d * r.x, d * r.y, d * r.z); + } + + friend vec3 operator*(double d, vec3 r) { + return vec3(d * r.x, d * r.y, d * r.z); + } + + friend vec3 operator/(vec3 r, double d) { + return vec3(r.x / d, r.y / d, r.z / d); + } + + friend bool operator==(vec3 l, vec3 r) { + return l.x == r.x && l.y == r.y && l.z == r.z; + } }; struct vec4 { - double x; - double y; - double z; - double w; - vec4() : x(0), y(0), z(0), w(0) {} - vec4(vec3 xyz, double w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) {} - vec4(double x, vec3 yzw) : x(x), y(yzw.x), z(yzw.y), w(yzw.z) {} - vec4(double x, double y, double z, double w) : x(x), y(y), z(z), w(w) {} - - friend vec4 operator + (vec4 l, vec4 r) { - return vec4(l.x + r.x, l.y + r.y, l.z + r.z, l.w + r.w); - } - - friend vec4 operator - (vec4 r) { - return vec4(-r.x, -r.y, -r.z, -r.w); - } - - friend vec4 operator - (vec4 l, vec4 r) { - return vec4(l.x - r.x, l.y - r.y, l.z - r.z, l.w - r.w); - } - - friend vec4 operator / (vec4 l, double r) { - return vec4(l.x / r, l.y / r, l.z / r, l.w / r); - } - - friend vec4 operator * (double l, vec4 r) { - return vec4(l * r.x, l * r.y, l * r.z, l * r.w); - } - - friend vec4 operator * (vec4 l, double r) { - return vec4(l.x * r, l.y * r, l.z * r, l.w * r); - } - - vec3 ywz() { - return vec3(y, w, z); - } - - vec3 yzw() { - return vec3(y, z, w); - } + double x; + double y; + double z; + double w; + vec4() : x(0), y(0), z(0), w(0) {} + vec4(vec3 xyz, double w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) {} + vec4(double x, vec3 yzw) : x(x), y(yzw.x), z(yzw.y), w(yzw.z) {} + vec4(double x, double y, double z, double w) : x(x), y(y), z(z), w(w) {} + + friend vec4 operator+(vec4 l, vec4 r) { + return vec4(l.x + r.x, l.y + r.y, l.z + r.z, l.w + r.w); + } + + friend vec4 operator-(vec4 r) { return vec4(-r.x, -r.y, -r.z, -r.w); } + + friend vec4 operator-(vec4 l, vec4 r) { + return vec4(l.x - r.x, l.y - r.y, l.z - r.z, l.w - r.w); + } + + friend vec4 operator/(vec4 l, double r) { + return vec4(l.x / r, l.y / r, l.z / r, l.w / r); + } + + friend vec4 operator*(double l, vec4 r) { + return vec4(l * r.x, l * r.y, l * r.z, l * r.w); + } + + friend vec4 operator*(vec4 l, double r) { + return vec4(l.x * r, l.y * r, l.z * r, l.w * r); + } + + vec3 ywz() { return vec3(y, w, z); } + + vec3 yzw() { return vec3(y, z, w); } }; struct FragCoord { - vec2 xy; - FragCoord() {} - FragCoord(vec2 xy) : xy(xy) {} + vec2 xy; + FragCoord() {} + FragCoord(vec2 xy) : xy(xy) {} }; FragCoord gl_FragCoord; -FILE* debugFile; +FILE *debugFile; -double abs_(double i) { - return fabs(i); -} +double abs_(double i) { return fabs(i); } -vec2 abs_(vec2 x) { - return vec2(fabs(x.x), fabs(x.y)); -} +vec2 abs_(vec2 x) { return vec2(fabs(x.x), fabs(x.y)); } -vec3 abs_(vec3 x) { - return vec3(fabs(x.x), fabs(x.y), fabs(x.z)); -} +vec3 abs_(vec3 x) { return vec3(fabs(x.x), fabs(x.y), fabs(x.z)); } -vec4 abs_(vec4 x) { - return vec4(fabs(x.x), fabs(x.y), fabs(x.z), fabs(x.w)); -} +vec4 abs_(vec4 x) { return vec4(fabs(x.x), fabs(x.y), fabs(x.z), fabs(x.w)); } -double mod(double x, double y) { - return x - y * floor(x / y); -} +double mod(double x, double y) { return x - y * floor(x / y); } vec3 mod(vec3 l, double r) { - return vec3(mod(l.x, r), mod(l.y, r), mod(l.z, r)); + return vec3(mod(l.x, r), mod(l.y, r), mod(l.z, r)); } double clamp(double l, double mn, double mx) { - return l < mn ? mn : l > mx ? mx : l; + return l < mn ? mn : l > mx ? mx : l; } vec3 clamp(vec3 l, double mn, double mx) { - return vec3( - clamp(l.x, mn, mx), - clamp(l.y, mn, mx), - clamp(l.z, mn, mx) - ); + return vec3(clamp(l.x, mn, mx), clamp(l.y, mn, mx), clamp(l.z, mn, mx)); } double fract(double d) { - return d >= 0 ? d - floor(d) : floor(d) - d; // probably wrong for negative numbers + return d >= 0 ? d - floor(d) + : floor(d) - d; // probably wrong for negative numbers } -double min(double l, double r) { - return l <= r ? l : r; -} +double min(double l, double r) { return l <= r ? l : r; } -double max(double l, double r) { - return l >= r ? l : r; -} +double max(double l, double r) { return l >= r ? l : r; } vec3 min(vec3 l, vec3 r) { - return vec3(min(l.x, r.x), min(l.y, r.y), min(l.z, r.z)); + return vec3(min(l.x, r.x), min(l.y, r.y), min(l.z, r.z)); } vec3 max(vec3 l, vec3 r) { - return vec3(max(l.x, r.x), max(l.y, r.y), max(l.z, r.z)); + return vec3(max(l.x, r.x), max(l.y, r.y), max(l.z, r.z)); } -double length(vec2 l) { - return sqrt(l.x * l.x + l.y * l.y); -} +double length(vec2 l) { return sqrt(l.x * l.x + l.y * l.y); } -double length(vec3 l) { - return sqrt(l.x * l.x + l.y * l.y + l.z * l.z); -} +double length(vec3 l) { return sqrt(l.x * l.x + l.y * l.y + l.z * l.z); } double length(vec4 l) { - return sqrt(l.x * l.x + l.y * l.y + l.z * l.z + l.w * l.w); + return sqrt(l.x * l.x + l.y * l.y + l.z * l.z + l.w * l.w); } -double atan(double y, double x) { - return atan2(y, x); -} +double atan(double y, double x) { return atan2(y, x); } -double radians(double deg) { - return M_PI * deg / 180.0; -} +double radians(double deg) { return M_PI * deg / 180.0; } -template -T mix(T x, T y, double a) { - return x * (1 - a) + y * a; -} +template T mix(T x, T y, double a) { return x * (1 - a) + y * a; } -template -T _(T x) { - return x; -} +template T _(T x) { return x; } vec2 normalize_(vec2 x) { - double l = length(x); - if(l == 0) return x; - return x / l; + double l = length(x); + if (l == 0) + return x; + return x / l; } vec3 normalize_(vec3 x) { - double l = length(x); - if(l == 0) return x; - return x / l; + double l = length(x); + if (l == 0) + return x; + return x / l; } vec4 normalize_(vec4 x) { - double l = length(x); - if(l == 0) return x; - return x / l; + double l = length(x); + if (l == 0) + return x; + return x / l; } vec3 cross_(vec3 a, vec3 b) { - return vec3( - a.y * b.z - a.z * b.y, - a.z * b.x - a.x * b.z, - a.x * b.y - a.y * b.x - ); -} - -double dot(vec2 l, vec2 r) { - return l.x * r.x + l.y * r.y; -} - -double dot(vec3 l, vec3 r) { - return l.x * r.x + l.y * r.y + l.z * r.z; -} - -vec2 sin_(vec2 input) { - return vec2(sin(input.x), sin(input.y)); -} - -double sign_(double x) { - return x > 0 ? 1 : x < 0 ? -1 : 0; -} - -vec2 sign_(vec2 input) { - return vec2(sign_(input.x), sign_(input.y)); -} - -vec2 ceil(vec2 input) { - return vec2(ceil(input.x), ceil(input.y)); -} - -#define notrace1(f) \ - float f ## _(float z); \ - float f (float z) { \ - return f ## _(z); \ - } - -#define trace2(f) \ - vec2 f ## _(vec2 z); \ - vec2 f (vec2 z) { \ - vec2 res = f ## _(z); \ - if(trace) fprintf(debugFile, " " #f "(%lf, %lf) = [%lf, %lf]\n", z.x, z.y, res.x, res.y); \ - return res; \ - } - -#define notrace2(f) \ - vec2 f ## _(vec2 z); \ - vec2 f (vec2 z) { \ - return f ## _(z); \ - } - -#define trace3(f) \ - vec3 f ## _(vec3 z); \ - vec3 f (vec3 z) { \ - vec3 res = f ## _(z); \ - if(trace) fprintf(debugFile, " " #f "(%lf, %lf, %lf) = (%lf, %lf, %lf) [%lf]\n", z.x, z.y, z.z, res.x, res.y, res.z, length(res)); \ - return res; \ - } - -#define notrace3(f) \ - vec3 f ## _(vec3 z); \ - vec3 f (vec3 z) { \ - return f ## _(z); \ - } - -#define trace4(f) \ - vec4 f ## _(vec4 z); \ - vec4 f (vec4 z) { \ - vec4 res = f ## _(z); \ - if(trace) fprintf(debugFile, " " #f "(%lf, %lf, %lf, %lf) = (%lf, %lf, %lf, %lf) [%lf]\n", z.x, z.y, z.z, z.w, res.x, res.y, res.z, res.w, length(res)); \ - return res; \ - } - -#define notrace4(f) \ - vec4 f ## _(vec4 z); \ - vec4 f (vec4 z) { \ - return f ## _(z); \ - } - -#define trace22(f) \ - vec2 f ## _(vec2 l, vec2 r); \ - vec2 f (vec2 l, vec2 r) { \ - vec2 res = f ## _(l, r); \ - if(trace) fprintf(debugFile, " " #f "((%lf, %lf), (%lf, %lf)) = [%lf, %lf]\n", l.x, l.y, r.x, r.y, res.x, res.y); \ - return res; \ - } - -#define notrace22(f) \ - vec2 f ## _(vec2 l, vec2 r); \ - vec2 f (vec2 l, vec2 r) { \ - return f ## _(l, r); \ - } - -#define notrace33(f) \ - vec3 f ## _(vec3 l, vec3 r); \ - vec3 f (vec3 l, vec3 r) { \ - return f ## _(l, r); \ - } - -#define trace33_2(f) \ - vec2 f ## _(vec3 l, vec3 r); \ - vec2 f (vec3 l, vec3 r) { \ - vec2 res = f ## _(l, r); \ - if(trace) fprintf(debugFile, " " #f "((%lf, %lf, %lf), (%lf, %lf, %lf)) = [%lf, %lf]\n", l.x, l.y, l.z, r.x, r.y, r.z, res.x, res.y); \ - return res; \ - } - -#define notrace33_2(f) \ - vec2 f ## _(vec3 l, vec3 r); \ - vec2 f (vec3 l, vec3 r) { \ - return f ## _(l, r); \ - } - -#define trace222(f) \ - vec2 f ## _(vec2 l, vec2 m, vec2 r); \ - vec2 f (vec2 l, vec2 m, vec2 r) { \ - vec2 res = f ## _(l, m, r); \ - if(trace) fprintf(debugFile, " " #f "((%lf, %lf), (%lf, %lf), (%lf, %lf)) = [%lf, %lf]\n", \ - l.x, l.y, m.x, m.y, r.x, r.y, res.x, res.y); \ - return res; \ - } - -#define notrace222(f) \ - vec2 f ## _(vec2 l, vec2 m, vec2 r); \ - vec2 f (vec2 l, vec2 m, vec2 r) { \ - return f ## _(l, m, r); \ - } - -#define trace211_2(f) \ - vec2 f ## _(vec2 a, float b, float c); \ - vec2 f (vec2 a, float b, float c) { \ - vec2 res = f ## _(a, b, c); \ - if(trace) fprintf(debugFile, " " #f "((%lf, %lf), %lf, %lf) = [%lf, %lf]\n", a.x, a.y, b, c, res.x, res.y); \ - return res; \ - } - -#define notrace211_2(f) \ - vec2 f ## _(vec2 a, float b, float c); \ - vec2 f (vec2 a, float b, float c) { \ - return f ## _(a, b, c); \ - } + return vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, + a.x * b.y - a.y * b.x); +} + +double dot(vec2 l, vec2 r) { return l.x * r.x + l.y * r.y; } + +double dot(vec3 l, vec3 r) { return l.x * r.x + l.y * r.y + l.z * r.z; } + +vec2 sin_(vec2 input) { return vec2(sin(input.x), sin(input.y)); } + +double sign_(double x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } + +vec2 sign_(vec2 input) { return vec2(sign_(input.x), sign_(input.y)); } + +vec2 ceil(vec2 input) { return vec2(ceil(input.x), ceil(input.y)); } + +#define notrace1(f) \ + float f##_(float z); \ + float f(float z) { return f##_(z); } + +#define trace2(f) \ + vec2 f##_(vec2 z); \ + vec2 f(vec2 z) { \ + vec2 res = f##_(z); \ + if (trace) \ + fprintf(debugFile, " " #f "(%lf, %lf) = [%lf, %lf]\n", z.x, z.y, res.x, \ + res.y); \ + return res; \ + } + +#define notrace2(f) \ + vec2 f##_(vec2 z); \ + vec2 f(vec2 z) { return f##_(z); } + +#define trace3(f) \ + vec3 f##_(vec3 z); \ + vec3 f(vec3 z) { \ + vec3 res = f##_(z); \ + if (trace) \ + fprintf(debugFile, " " #f "(%lf, %lf, %lf) = (%lf, %lf, %lf) [%lf]\n", \ + z.x, z.y, z.z, res.x, res.y, res.z, length(res)); \ + return res; \ + } + +#define notrace3(f) \ + vec3 f##_(vec3 z); \ + vec3 f(vec3 z) { return f##_(z); } + +#define trace4(f) \ + vec4 f##_(vec4 z); \ + vec4 f(vec4 z) { \ + vec4 res = f##_(z); \ + if (trace) \ + fprintf(debugFile, \ + " " #f "(%lf, %lf, %lf, %lf) = (%lf, %lf, %lf, %lf) [%lf]\n", \ + z.x, z.y, z.z, z.w, res.x, res.y, res.z, res.w, length(res)); \ + return res; \ + } + +#define notrace4(f) \ + vec4 f##_(vec4 z); \ + vec4 f(vec4 z) { return f##_(z); } + +#define trace22(f) \ + vec2 f##_(vec2 l, vec2 r); \ + vec2 f(vec2 l, vec2 r) { \ + vec2 res = f##_(l, r); \ + if (trace) \ + fprintf(debugFile, " " #f "((%lf, %lf), (%lf, %lf)) = [%lf, %lf]\n", \ + l.x, l.y, r.x, r.y, res.x, res.y); \ + return res; \ + } + +#define notrace22(f) \ + vec2 f##_(vec2 l, vec2 r); \ + vec2 f(vec2 l, vec2 r) { return f##_(l, r); } + +#define notrace33(f) \ + vec3 f##_(vec3 l, vec3 r); \ + vec3 f(vec3 l, vec3 r) { return f##_(l, r); } + +#define trace33_2(f) \ + vec2 f##_(vec3 l, vec3 r); \ + vec2 f(vec3 l, vec3 r) { \ + vec2 res = f##_(l, r); \ + if (trace) \ + fprintf(debugFile, \ + " " #f "((%lf, %lf, %lf), (%lf, %lf, %lf)) = [%lf, %lf]\n", \ + l.x, l.y, l.z, r.x, r.y, r.z, res.x, res.y); \ + return res; \ + } + +#define notrace33_2(f) \ + vec2 f##_(vec3 l, vec3 r); \ + vec2 f(vec3 l, vec3 r) { return f##_(l, r); } + +#define trace222(f) \ + vec2 f##_(vec2 l, vec2 m, vec2 r); \ + vec2 f(vec2 l, vec2 m, vec2 r) { \ + vec2 res = f##_(l, m, r); \ + if (trace) \ + fprintf(debugFile, \ + " " #f "((%lf, %lf), (%lf, %lf), (%lf, %lf)) = [%lf, %lf]\n", \ + l.x, l.y, m.x, m.y, r.x, r.y, res.x, res.y); \ + return res; \ + } + +#define notrace222(f) \ + vec2 f##_(vec2 l, vec2 m, vec2 r); \ + vec2 f(vec2 l, vec2 m, vec2 r) { return f##_(l, m, r); } + +#define trace211_2(f) \ + vec2 f##_(vec2 a, float b, float c); \ + vec2 f(vec2 a, float b, float c) { \ + vec2 res = f##_(a, b, c); \ + if (trace) \ + fprintf(debugFile, " " #f "((%lf, %lf), %lf, %lf) = [%lf, %lf]\n", a.x, \ + a.y, b, c, res.x, res.y); \ + return res; \ + } + +#define notrace211_2(f) \ + vec2 f##_(vec2 a, float b, float c); \ + vec2 f(vec2 a, float b, float c) { return f##_(a, b, c); } bool trace; -notrace1(abs) -notrace1(sign) -notrace2(cexp) -notrace2(cln) -notrace2(iabs) -notrace2(iceiling) -notrace2(icos) -notrace2(icosh) -notrace2(iexp) -notrace2(iinverse) -notrace2(iln) -notrace2(ineg) -notrace2(isin) -notrace2(isqrt) -notrace2(isquare) -notrace2(sin) -notrace2(sign) -notrace22(by) -notrace22(iby) -notrace22(idiv) -notrace22(ieq) -notrace22(igt) -notrace22(ileq) -notrace22(ilt) -notrace22(ipow) -notrace22(merge) -notrace222(ipw) -notrace3(abs) -notrace3(normal_0) -notrace3(normal_1) -notrace3(normal) -notrace3(normalize) -notrace33(cross) -notrace4(abs) -trace2(abs) -trace211_2(interval) -trace33_2(interval_0) -trace33_2(interval_1) -trace33_2(interval) - -bool bisect_(vec3 o, vec3 d, float max_distance, vec3& found, vec3& n); -bool bisect(vec3 l, vec3 r, float max_distance, vec3& found, vec3& n) { - bool res = bisect_(l, r, max_distance, found, n); - vec3 to = l + max_distance * r; - if(trace) - fprintf(debugFile, "bisect((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, %lf, %lf), normal = (%lf, %lf, %lf) [found - eye = %lf]\n\n", - l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, - found.x, found.y, found.z, n.x, n.y, n.z, length(found - l)); - return res; -} - -bool bisect_0_(vec3 o, vec3 d, float max_distance, vec3& found, vec3& n); -bool bisect_0(vec3 l, vec3 r, float max_distance, vec3& found, vec3& n) { - bool res = bisect_0_(l, r, max_distance, found, n); - vec3 to = l + max_distance * r; - if(trace) - fprintf(debugFile, "bisect_0((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, %lf, %lf), normal = (%lf, %lf, %lf) [%lf]\n\n", - l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, - found.x, found.y, found.z, n.x, n.y, n.z, length(found - l)); - return res; -} - -bool bisect_1_(vec3 o, vec3 d, float max_distance, vec3& found, vec3& n); -bool bisect_1(vec3 l, vec3 r, float max_distance, vec3& found, vec3& n) { - bool res = bisect_1_(l, r, max_distance, found, n); - vec3 to = l + max_distance * r; - if(trace) - fprintf(debugFile, "bisect_1((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, %lf, %lf), normal = (%lf, %lf, %lf) [%lf]\n\n", - l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, - found.x, found.y, found.z, n.x, n.y, n.z, length(found - l)); - return res; -} - -vec4 vec4_(vec3 l, double r) { - return vec4(l, r); -} +notrace1(abs) notrace1(sign) notrace2(cexp) notrace2(cln) notrace2(iabs) + notrace2(iceil) notrace2(icos) notrace2(icosh) notrace2(iexp) notrace2( + iinverse) notrace2(iln) notrace2(ineg) notrace2(isin) notrace2(isqrt) + notrace2(isquare) notrace2(sin) notrace2(sign) notrace22(by) + notrace22(iby) notrace22(idiv) notrace22(ieq) notrace22(igt) + notrace22(ileq) notrace22(ilt) notrace22(ipow) notrace22(merge) + notrace222(ipw) notrace3(abs) notrace3(normal_0) + notrace3(normal_1) notrace3(normal) notrace3(normalize) + notrace33(cross) notrace4(abs) trace2(abs) + trace211_2(interval) trace33_2(interval_0) + trace33_2(interval_1) trace33_2(interval) + + bool bisect_(vec3 o, vec3 d, + float max_distance, + vec3 &found, vec3 &n); +bool bisect(vec3 l, vec3 r, float max_distance, vec3 &found, vec3 &n) { + bool res = bisect_(l, r, max_distance, found, n); + vec3 to = l + max_distance * r; + if (trace) + fprintf(debugFile, + "bisect((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, %lf, " + "%lf), normal = (%lf, %lf, %lf) [found - eye = %lf]\n\n", + l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, found.x, found.y, + found.z, n.x, n.y, n.z, length(found - l)); + return res; +} + +bool bisect_0_(vec3 o, vec3 d, float max_distance, vec3 &found, vec3 &n); +bool bisect_0(vec3 l, vec3 r, float max_distance, vec3 &found, vec3 &n) { + bool res = bisect_0_(l, r, max_distance, found, n); + vec3 to = l + max_distance * r; + if (trace) + fprintf(debugFile, + "bisect_0((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, " + "%lf, %lf), normal = (%lf, %lf, %lf) [%lf]\n\n", + l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, found.x, found.y, + found.z, n.x, n.y, n.z, length(found - l)); + return res; +} + +bool bisect_1_(vec3 o, vec3 d, float max_distance, vec3 &found, vec3 &n); +bool bisect_1(vec3 l, vec3 r, float max_distance, vec3 &found, vec3 &n) { + bool res = bisect_1_(l, r, max_distance, found, n); + vec3 to = l + max_distance * r; + if (trace) + fprintf(debugFile, + "bisect_1((%lf, %lf, %lf), (%lf, %lf, %lf)) = %d, found = (%lf, " + "%lf, %lf), normal = (%lf, %lf, %lf) [%lf]\n\n", + l.x, l.y, l.z, to.x, to.y, to.z, res ? 1 : 0, found.x, found.y, + found.z, n.x, n.y, n.z, length(found - l)); + return res; +} + +vec4 vec4_(vec3 l, double r) { return vec4(l, r); } vec4 raytrace_(vec3 o, vec3 d, float max_distance); vec4 raytrace(vec3 o, vec3 d, float max_distance) { - return raytrace_(o, d, max_distance); + return raytrace_(o, d, max_distance); } From ca68666c0d8aaa2dc07581c066ebb9cf879839a6 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 14 Dec 2022 02:29:51 +0100 Subject: [PATCH 081/139] Better grouping --- codegen/Generate.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index e366d13f..3bf7cbed 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -230,7 +230,7 @@ wrapFunction name args returnType = Just <| if List.member (String.left 1 name) [ "g", "i", "c" ] - && not (List.member name [ "cbrt" ]) + && not (List.member name [ "cbrt", "increment", "cosh", "is_even", "is_odd" ]) then String.dropLeft 1 name From c9719873e645b01110d070cee6ebb4fa4faacbde Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 14 Dec 2022 03:00:33 +0100 Subject: [PATCH 082/139] Generating more --- codegen/Generate.elm | 82 +++++++++++++++++++-------------- codegen/elm.json | 3 +- codegen/helpers/Glsl/Helper.elm | 39 ++++++++-------- codegen/helpers/SortedSet.elm | 55 ++++++++++++++++++++++ 4 files changed, 124 insertions(+), 55 deletions(-) create mode 100644 codegen/helpers/SortedSet.elm diff --git a/codegen/Generate.elm b/codegen/Generate.elm index 3bf7cbed..1ddc6737 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -12,6 +12,7 @@ import List.Extra import Parser import Result.Extra import Set exposing (Set) +import SortedSet exposing (SortedSet) main : Program String () () @@ -54,7 +55,12 @@ generate glsl = (List.map Tuple.first args) returnType ) - { functionsEnv = + { constantsEnv = + Dict.fromList + [ ( "P32M1", TInt ) + , ( "P31", TInt ) + ] + , functionsEnv = builtinFunctions |> Dict.map (\_ { return } -> return) @@ -144,7 +150,8 @@ problemToString problem = type alias Env = - { functionsEnv : Dict String Type + { constantsEnv : Dict String Type + , functionsEnv : Dict String Type , variablesEnv : Dict String Type } @@ -159,7 +166,7 @@ functionToDeclarations env function = envWithArgs = List.foldl (\( type_, name ) -> variableHasType name type_) env function.args - maybeDeps : Result String (Set String) + maybeDeps : Result String (SortedSet String) maybeDeps = findDepsStatement envWithArgs function.stat |> Result.mapError (\e -> e ++ " while generating " ++ fname) @@ -168,20 +175,14 @@ functionToDeclarations env function = (\deps -> [ Elm.string function.body |> Elm.declaration (fname ++ "Body") - , deps - |> Set.toList - |> List.map Elm.string - |> Elm.list - |> Elm.withType (Type.list Type.string) - |> Elm.declaration (fname ++ "Deps") - , wrapFunction function.name function.args function.returnType + , wrapFunction function.name (SortedSet.insert fname deps) function.args function.returnType ] ) maybeDeps -wrapFunction : String -> List ( Type, String ) -> Type -> Elm.Declaration -wrapFunction name args returnType = +wrapFunction : String -> SortedSet String -> List ( Type, String ) -> Type -> Elm.Declaration +wrapFunction name deps args returnType = let fname = fullName name (List.map Tuple.first args) @@ -196,22 +197,29 @@ wrapFunction name args returnType = ) args + depsExpr : Elm.Expression + depsExpr = + deps + |> SortedSet.toList + |> List.map (\dep -> Elm.val <| dep ++ "Body") + |> Elm.list + innerCall argValues = case argValues of [] -> - Gen.Glsl.Helper.unsafeCall0 name + Gen.Glsl.Helper.call_.unsafeCall0 (Elm.string name) depsExpr [ arg0 ] -> - Gen.Glsl.Helper.unsafeCall1 name arg0 + Gen.Glsl.Helper.call_.unsafeCall1 (Elm.string name) depsExpr arg0 [ arg0, arg1 ] -> - Gen.Glsl.Helper.unsafeCall2 name arg0 arg1 + Gen.Glsl.Helper.call_.unsafeCall2 (Elm.string name) depsExpr arg0 arg1 [ arg0, arg1, arg2 ] -> - Gen.Glsl.Helper.unsafeCall3 name arg0 arg1 arg2 + Gen.Glsl.Helper.call_.unsafeCall3 (Elm.string name) depsExpr arg0 arg1 arg2 [ arg0, arg1, arg2, arg3 ] -> - Gen.Glsl.Helper.unsafeCall4 name arg0 arg1 arg2 arg3 + Gen.Glsl.Helper.call_.unsafeCall4 (Elm.string name) depsExpr arg0 arg1 arg2 arg3 _ :: _ :: _ -> Elm.string "TODO" @@ -281,12 +289,12 @@ variableHasType var type_ env = { env | variablesEnv = Dict.insert var type_ env.variablesEnv } -union : List (Result String (Set comparable)) -> Result String (Set comparable) +union : List (Result String (SortedSet comparable)) -> Result String (SortedSet comparable) union = - List.foldl (Result.map2 Set.union) (Ok Set.empty) + List.foldl (Result.map2 SortedSet.insertAll) (Ok SortedSet.empty) -findDepsStatement : Env -> Statement -> Result String (Set String) +findDepsStatement : Env -> Statement -> Result String (SortedSet String) findDepsStatement env statement = case statement of If cond true false -> @@ -338,23 +346,23 @@ findDepsStatement env statement = findDepsStatement newEnv cont Nop -> - Ok Set.empty + Ok SortedSet.empty -findDepsExpression : Env -> Expression -> Result String (Set String) +findDepsExpression : Env -> Expression -> Result String (SortedSet String) findDepsExpression env = let - go : Expression -> Result String ( Type, Set String ) + go : Expression -> Result String ( Type, SortedSet String ) go expr = case expr of Float _ -> - Ok ( TFloat, Set.empty ) + Ok ( TFloat, SortedSet.empty ) Int _ -> - Ok ( TInt, Set.empty ) + Ok ( TInt, SortedSet.empty ) Bool _ -> - Ok ( TBool, Set.empty ) + Ok ( TBool, SortedSet.empty ) Dot e field -> Result.andThen @@ -390,13 +398,13 @@ findDepsExpression env = Err <| "Couldn't find variable " ++ v Just t -> - Ok ( t, Set.empty ) + Ok ( t, SortedSet.empty ) Constant "P32M1" -> - Ok ( TInt, Set.empty ) + Ok ( TInt, SortedSet.empty ) Constant "P31" -> - Ok ( TInt, Set.empty ) + Ok ( TInt, SortedSet.empty ) Constant c -> Err <| "TODO: findDepsExpression _ (Constant \"" ++ c ++ "\")" @@ -410,10 +418,10 @@ findDepsExpression env = let deps = if Dict.member fname builtinFunctions then - List.foldl Set.union Set.empty argDeps + List.foldl SortedSet.insertAll SortedSet.empty argDeps else - List.foldl Set.union (Set.singleton fname) argDeps + List.foldl SortedSet.insertAll (SortedSet.singleton fname) argDeps fname = fullName f argTypes @@ -433,7 +441,10 @@ findDepsExpression env = Ternary c t f -> Result.map3 (\( _, cd ) ( tt, td ) ( _, fd ) -> - ( tt, Set.union cd td |> Set.union fd ) + ( tt + , SortedSet.insertAll cd td + |> SortedSet.insertAll fd + ) ) (go c) (go t) @@ -446,7 +457,7 @@ findDepsExpression env = Result.andThen (\( ( lt, ld ), ( rt, rd ) ) -> Result.map - (\t -> ( t, Set.union ld rd )) + (\t -> ( t, SortedSet.insertAll ld rd )) (if lt == rt then Ok lt @@ -482,13 +493,13 @@ findDepsExpression env = ( _, deps ) = List.unzip res in - ( TBool, List.foldl Set.union Set.empty deps ) + ( TBool, List.foldl SortedSet.insertAll SortedSet.empty deps ) ) RelationOperation _ l r -> Result.map2 (\( _, ld ) ( _, rd ) -> - ( TBool, Set.union ld rd ) + ( TBool, SortedSet.insertAll ld rd ) ) (go l) (go r) @@ -873,6 +884,7 @@ builtinDecls = (\( _, { baseName, args, return } ) -> wrapFunction baseName + SortedSet.empty (List.indexedMap (\i type_ -> ( type_, indexedVar i )) args diff --git a/codegen/elm.json b/codegen/elm.json index 545c6944..da3bb94e 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -1,7 +1,8 @@ { "type": "application", "source-directories": [ - "." + ".", + "helpers" ], "elm-version": "0.19.1", "dependencies": { diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl/Helper.elm index 00923c68..54cb08f3 100644 --- a/codegen/helpers/Glsl/Helper.elm +++ b/codegen/helpers/Glsl/Helper.elm @@ -1,35 +1,36 @@ module Glsl.Helper exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), IVec2, IVec3, IVec4, Mat3(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2(..), Vec3(..), Vec4(..), Void, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4) import Set exposing (Set) +import SortedSet exposing (SortedSet) -unsafeCall0 : String -> Expression r -unsafeCall0 name = - unsafeCall name [] +unsafeCall0 : String -> List String -> Expression r +unsafeCall0 name deps = + unsafeCall name deps [] -unsafeCall1 : String -> Expression t -> Expression r -unsafeCall1 name (Expression arg0) = - unsafeCall name [ arg0 ] +unsafeCall1 : String -> List String -> Expression t -> Expression r +unsafeCall1 name deps (Expression arg0) = + unsafeCall name deps [ arg0 ] -unsafeCall2 : String -> Expression t -> Expression u -> Expression r -unsafeCall2 name (Expression arg0) (Expression arg1) = - unsafeCall name [ arg0, arg1 ] +unsafeCall2 : String -> List String -> Expression t -> Expression u -> Expression r +unsafeCall2 name deps (Expression arg0) (Expression arg1) = + unsafeCall name deps [ arg0, arg1 ] -unsafeCall3 : String -> Expression t -> Expression u -> Expression v -> Expression r -unsafeCall3 name (Expression arg0) (Expression arg1) (Expression arg2) = - unsafeCall name [ arg0, arg1, arg2 ] +unsafeCall3 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression r +unsafeCall3 name deps (Expression arg0) (Expression arg1) (Expression arg2) = + unsafeCall name deps [ arg0, arg1, arg2 ] -unsafeCall4 : String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r -unsafeCall4 name (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) = - unsafeCall name [ arg0, arg1, arg2, arg3 ] +unsafeCall4 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r +unsafeCall4 name deps (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) = + unsafeCall name deps [ arg0, arg1, arg2, arg3 ] -unsafeCall : String -> List ExprWithDeps -> Expression t -unsafeCall name args = +unsafeCall : String -> List String -> List ExprWithDeps -> Expression t +unsafeCall name deps args = Expression { expr = args @@ -38,7 +39,7 @@ unsafeCall name args = , deps = args |> List.map .deps - |> List.foldr Set.union (Set.singleton name) + |> List.foldl SortedSet.insertAll (SortedSet.fromList deps) } @@ -52,7 +53,7 @@ type Expression t type alias ExprWithDeps = { expr : Expr - , deps : Set String + , deps : SortedSet String } diff --git a/codegen/helpers/SortedSet.elm b/codegen/helpers/SortedSet.elm new file mode 100644 index 00000000..4e782477 --- /dev/null +++ b/codegen/helpers/SortedSet.elm @@ -0,0 +1,55 @@ +module SortedSet exposing (SortedSet, empty, fromList, insert, insertAll, singleton, toList) + +import Set exposing (Set) + + +type SortedSet a + = SortedSet + { reverseOrder : List a + , set : Set a + } + + +empty : SortedSet a +empty = + SortedSet + { reverseOrder = [] + , set = Set.empty + } + + +singleton : comparable -> SortedSet comparable +singleton x = + SortedSet + { reverseOrder = [ x ] + , set = Set.singleton x + } + + +fromList : List comparable -> SortedSet comparable +fromList order = + List.foldl insert empty order + + +toList : SortedSet a -> List a +toList (SortedSet { reverseOrder }) = + List.reverse reverseOrder + + +insert : comparable -> SortedSet comparable -> SortedSet comparable +insert elem ((SortedSet { set, reverseOrder }) as s) = + if Set.member elem set then + s + + else + SortedSet + { set = Set.insert elem set + , reverseOrder = elem :: reverseOrder + } + + +{-| Insert all the elements from the first argument into the set given by the second argument. +-} +insertAll : SortedSet comparable -> SortedSet comparable -> SortedSet comparable +insertAll (SortedSet l) ((SortedSet _) as r) = + List.foldr insert r l.reverseOrder From c73317ef81ac8114994b7fb7f8ae09e1431c4998 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 14 Dec 2022 03:01:13 +0100 Subject: [PATCH 083/139] Cleanup --- codegen/Generate.elm | 1 - 1 file changed, 1 deletion(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index 1ddc6737..b4c52873 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -11,7 +11,6 @@ import Glsl.Types exposing (BinaryOperation(..), Expression(..), Function, State import List.Extra import Parser import Result.Extra -import Set exposing (Set) import SortedSet exposing (SortedSet) From a7c172482617ece06c58bba2b4f587cc85b7a0f1 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 01:18:55 +0100 Subject: [PATCH 084/139] Simplifying Glsl --- codegen/Generate.elm | 11 ++++++----- src/elm/UI/Glsl/Generator.elm | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index b4c52873..e2283d6d 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -16,9 +16,10 @@ import SortedSet exposing (SortedSet) main : Program String () () main = - Generate.fromText - (\glsl -> - [ Elm.fileWith [ "Glsl" ] + let + file : String -> Elm.File + file glsl = + Elm.fileWith [ "Glsl" ] { docs = List.map (\{ group, members } -> @@ -30,8 +31,8 @@ main = , aliases = [] } (generate glsl) - ] - ) + in + Generate.fromText (\glsl -> [ file glsl ]) generate : String -> List Elm.Declaration diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index c93b0d86..217c1ae3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -48,7 +48,7 @@ statToGlsl : Int -> Stat -> String statToGlsl i c = case c of If cond t n -> - [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + [ indent i ("if (" ++ exprToGlsl cond ++ ") {") , statToGlsl (i + 1) t , indent i "}" , "" @@ -57,7 +57,7 @@ statToGlsl i c = |> String.join "\n" IfElse cond t ((If _ _ _) as f) n -> - [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + [ indent i ("if (" ++ exprToGlsl cond ++ ") {") , statToGlsl (i + 1) t , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) , statToGlsl i n @@ -65,7 +65,7 @@ statToGlsl i c = |> String.join "\n" IfElse cond t ((IfElse _ _ _ _) as f) n -> - [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + [ indent i ("if (" ++ exprToGlsl cond ++ ") {") , statToGlsl (i + 1) t , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) , statToGlsl i n @@ -73,7 +73,7 @@ statToGlsl i c = |> String.join "\n" IfElse cond t f n -> - [ indent i ("if (" ++ exprToGlsl (Expression cond) ++ ") {") + [ indent i ("if (" ++ exprToGlsl cond ++ ") {") , statToGlsl (i + 1) t , indent i "} else {" , statToGlsl (i + 1) f From 82be7718959b1273df34bbc20d20e4a13b1f102f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 01:22:24 +0100 Subject: [PATCH 085/139] Add missing dependency in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f04244c..61d62d2d 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,5 @@ all: generated/Glsl.elm generated/Glsl.elm: codegen/functions.frag codegen/Generate.elm codegen/Gen/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile elm-codegen run --flags-from $< -codegen/Gen/Glsl/Helper.elm: codegen/helpers/Glsl/Helper.elm +codegen/Gen/Glsl/Helper.elm: codegen/helpers/Glsl/Helper.elm codegen/elm.codegen.json elm-codegen install From 3e14978b14b53e0773006acc16c80c5356940431 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 01:54:50 +0100 Subject: [PATCH 086/139] Update review rules --- review/elm.json | 42 +++++++++++++++++++++++++------------ review/src/ReviewConfig.elm | 32 +++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/review/elm.json b/review/elm.json index 15025902..9da40ecc 100644 --- a/review/elm.json +++ b/review/elm.json @@ -9,30 +9,46 @@ "elm/core": "1.0.5", "elm/json": "1.1.3", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.5.0", - "jfmengels/elm-review-common": "1.0.4", - "jfmengels/elm-review-unused": "1.1.15", - "sparksp/elm-review-always": "1.0.5", - "sparksp/elm-review-imports": "1.0.1", - "stil4m/elm-syntax": "7.2.6", - "truqu/elm-review-nobooleancase": "1.0.0" + "jfmengels/elm-review": "2.12.2", + "jfmengels/elm-review-code-style": "1.1.3", + "jfmengels/elm-review-common": "1.3.2", + "jfmengels/elm-review-debug": "1.0.8", + "jfmengels/elm-review-documentation": "2.0.3", + "jfmengels/elm-review-simplify": "2.0.26", + "jfmengels/elm-review-unused": "1.1.29", + "jsuder-xx/elm-review-reducible-lambdas": "2.0.1", + "lue-bird/elm-review-record-alias-constructor": "1.1.2", + "sparksp/elm-review-always": "1.0.6", + "sparksp/elm-review-imports": "1.0.2", + "sparksp/elm-review-ports": "1.3.1", + "stil4m/elm-syntax": "7.2.9", + "truqu/elm-review-nobooleancase": "1.0.1" }, "indirect": { + "Chadtech/elm-bool-extra": "2.4.2", + "elm/bytes": "1.0.8", "elm/html": "1.0.0", "elm/parser": "1.1.0", "elm/random": "1.0.0", + "elm/regex": "1.0.0", "elm/time": "1.0.0", - "elm/virtual-dom": "1.0.2", - "elm-community/list-extra": "8.3.1", - "elm-explorations/test": "1.2.2", - "miniBill/elm-unicode": "1.0.2", + "elm/virtual-dom": "1.0.3", + "elm-community/basics-extra": "4.1.0", + "elm-community/list-extra": "8.7.0", + "elm-community/maybe-extra": "5.3.0", + "elm-explorations/test": "2.1.1", + "jsuder-xx/elm-ra": "1.1.1", + "miniBill/elm-unicode": "1.0.3", + "pzp1997/assoc-list": "1.0.0", "rtfeldman/elm-hex": "1.0.0", - "stil4m/structured-writer": "1.0.3" + "stil4m/structured-writer": "1.0.3", + "the-sett/elm-pretty-printer": "3.0.0", + "the-sett/elm-syntax-dsl": "6.0.2" } }, "test-dependencies": { "direct": { - "elm-explorations/test": "1.2.2" + "elm-explorations/test": "2.1.1" }, "indirect": {} } diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 4e365a64..5f3ee920 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -1,12 +1,23 @@ module ReviewConfig exposing (config) +import Docs.ReviewAtDocs import NoAlways import NoBooleanCase +import NoConfusingPrefixOperator +import NoDebug.Log +import NoDebug.TodoOrToString +import NoDuplicatePorts +import NoEtaReducibleLambdas import NoExposingEverything import NoImportingEverything import NoMissingTypeAnnotation +import NoMissingTypeAnnotationInLetIn import NoMissingTypeExpose import NoModuleOnExposedNames +import NoPrematureLetComputation +import NoRecordAliasConstructor +import NoSimpleLetBody +import NoUnsafePorts import NoUnused.CustomTypeConstructorArgs import NoUnused.CustomTypeConstructors import NoUnused.Dependencies @@ -15,18 +26,35 @@ import NoUnused.Modules import NoUnused.Parameters import NoUnused.Patterns import NoUnused.Variables -import Review.Rule exposing (Rule) +import NoUnusedPorts +import Review.Rule as Rule exposing (Rule) +import Simplify config : List Rule config = [ NoAlways.rule + , Docs.ReviewAtDocs.rule , NoBooleanCase.rule + , NoConfusingPrefixOperator.rule + , NoDebug.Log.rule + , NoDebug.TodoOrToString.rule + |> Rule.ignoreErrorsForDirectories [ "tests/" ] + , NoDuplicatePorts.rule + , NoEtaReducibleLambdas.rule + { lambdaReduceStrategy = NoEtaReducibleLambdas.AlwaysRemoveLambdaWhenPossible + , argumentNamePredicate = always True + } , NoExposingEverything.rule , NoImportingEverything.rule [] , NoMissingTypeAnnotation.rule + , NoMissingTypeAnnotationInLetIn.rule , NoMissingTypeExpose.rule , NoModuleOnExposedNames.rule + , NoPrematureLetComputation.rule + , NoRecordAliasConstructor.rule + , NoSimpleLetBody.rule + , NoUnsafePorts.rule NoUnsafePorts.any , NoUnused.CustomTypeConstructorArgs.rule , NoUnused.CustomTypeConstructors.rule [] , NoUnused.Dependencies.rule @@ -35,4 +63,6 @@ config = , NoUnused.Parameters.rule , NoUnused.Patterns.rule , NoUnused.Variables.rule + , NoUnusedPorts.rule + , Simplify.rule Simplify.defaults ] From e12fe5ff4cdfe3db8f3ae747ae53886e8edfd879 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 02:01:03 +0100 Subject: [PATCH 087/139] Fragments not needed anymore --- src/ts/nuplot.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ts/nuplot.ts b/src/ts/nuplot.ts index 6dba9d11..2549bb9c 100644 --- a/src/ts/nuplot.ts +++ b/src/ts/nuplot.ts @@ -1,5 +1,3 @@ -import declarations from "../shaders/declarations.frag"; - declare var process: { env: { NODE_ENV: string } }; declare class ClipboardItem { @@ -171,7 +169,7 @@ export class NuPlot extends HTMLElement { if (!this.compileAndAttachShader(this.gl.VERTEX_SHADER, vertex_shader)) return; - const fragment_shader = this.buildFragmentShader(this.src); + const fragment_shader = this.src; this.fragment_shader = this.compileAndAttachShader( this.gl.FRAGMENT_SHADER, fragment_shader @@ -270,10 +268,6 @@ export class NuPlot extends HTMLElement { this.reloadFragmentShader(); } - private buildFragmentShader(expr: string) { - return `${declarations}\n${expr}`; - } - compileAndAttachShader(type: number, src: string): WebGLShader | null { if (!this.gl || !this.program) return null; const shader = this.gl.createShader(type); @@ -563,7 +557,7 @@ export class NuPlot extends HTMLElement { reloadFragmentShader() { if (!this.gl || !this.program || !this.fragment_shader || !this.src) return; - const src = this.buildFragmentShader(this.src); + const src = this.src; this.sourceAndCompile(this.fragment_shader, src); From 7d0beee0bc27f7072cc5516ec171ef1399ae3018 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 17:43:17 +0100 Subject: [PATCH 088/139] Fix circular dependency --- Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 61d62d2d..d451b159 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ -.PHONY: all -all: generated/Glsl.elm +ELM_FILES = $(wildcard src/**/*.elm) +CODEGEN_FILES = $(wildcard codegen/*.elm) $(wildcard codegen/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) -generated/Glsl.elm: codegen/functions.frag codegen/Generate.elm codegen/Gen/Glsl/Helper.elm $(wildcard codegen/Glsl/*.elm) Makefile +.PHONY: build +build: generated/Glsl/Functions.elm src/optimized.js Makefile + parcel build src/index.html --public-url . + +src/optimized.js: $(ELM_FILES) Makefile + elm-optimize-level-2 src/elm/UI.elm --output $@ + +generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) Makefile + rm -rf generated elm-codegen run --flags-from $< -codegen/Gen/Glsl/Helper.elm: codegen/helpers/Glsl/Helper.elm codegen/elm.codegen.json +codegen/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile elm-codegen install + + +.PHONY: clean +clean: Makefile + rm -rf .cache dist elm-stuff From 70552efa4000d40a75cfcb2a6d62f13942d6f98e Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 17:43:27 +0100 Subject: [PATCH 089/139] Add workspace file --- nuplot.code-workspace | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nuplot.code-workspace diff --git a/nuplot.code-workspace b/nuplot.code-workspace new file mode 100644 index 00000000..f6d933f4 --- /dev/null +++ b/nuplot.code-workspace @@ -0,0 +1,14 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "codegen" + }, + { + "path": "review" + } + ], + "settings": {} +} \ No newline at end of file From 97e3495a98bc467408e05c6703a10c42b1cc9d96 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 17:43:36 +0100 Subject: [PATCH 090/139] Update package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aae054d3..b56b3d27 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "typescript": "^4.3.5" }, "scripts": { - "build": "rm -rf .cache dist elm-stuff; elm-optimize-level-2 src/elm/UI.elm --output src/optimized.js && parcel build src/index.html --public-url .", + "build": "make build", "buildForBenchmark": "rm -rf .cache elm-stuff dist; elm-optimize-level-2 src/elm/UI.elm --output src/optimized.js && parcel build --no-minify src/index.html --public-url .", "start": "parcel src/dev.html", "test": "elm-test" From 048e2e67f2b12a4d3aeec66c7db6d14a84c54389 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 17:43:48 +0100 Subject: [PATCH 091/139] Move and aggregate GLSL types --- codegen/Generate.elm | 139 ++-- codegen/Glsl/Parser.elm | 112 ++- codegen/Glsl/PrettyPrinter.elm | 36 +- codegen/Glsl/Types.elm | 84 --- codegen/helpers/{Glsl/Helper.elm => Glsl.elm} | 161 +++- codegen/helpers/Glsl/Operations.elm | 37 + src/elm/UI/Glsl/Code.elm | 3 +- src/elm/UI/Glsl/Generator.elm | 704 +++++------------- src/elm/UI/Glsl/Plane.elm | 48 +- src/elm/UI/Glsl/Sphere.elm | 45 +- 10 files changed, 572 insertions(+), 797 deletions(-) delete mode 100644 codegen/Glsl/Types.elm rename codegen/helpers/{Glsl/Helper.elm => Glsl.elm} (51%) create mode 100644 codegen/helpers/Glsl/Operations.elm diff --git a/codegen/Generate.elm b/codegen/Generate.elm index e2283d6d..d568b330 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -5,9 +5,9 @@ import Elm import Elm.Annotation as Type import Gen.CodeGen.Generate as Generate import Gen.Debug -import Gen.Glsl.Helper +import Gen.Glsl +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Function, Stat(..), Statement(..), Type(..)) import Glsl.Parser -import Glsl.Types exposing (BinaryOperation(..), Expression(..), Function, Statement(..), Type(..)) import List.Extra import Parser import Result.Extra @@ -19,7 +19,7 @@ main = let file : String -> Elm.File file glsl = - Elm.fileWith [ "Glsl" ] + Elm.fileWith [ "Glsl", "Functions" ] { docs = List.map (\{ group, members } -> @@ -192,7 +192,7 @@ wrapFunction name deps args returnType = List.map (\( type_, argName ) -> ( argName - , Just <| Gen.Glsl.Helper.annotation_.expression (typeToAnnotation type_) + , Just <| Gen.Glsl.annotation_.expression (typeToAnnotation type_) ) ) args @@ -207,19 +207,19 @@ wrapFunction name deps args returnType = innerCall argValues = case argValues of [] -> - Gen.Glsl.Helper.call_.unsafeCall0 (Elm.string name) depsExpr + Gen.Glsl.call_.unsafeCall0 (Elm.string name) depsExpr [ arg0 ] -> - Gen.Glsl.Helper.call_.unsafeCall1 (Elm.string name) depsExpr arg0 + Gen.Glsl.call_.unsafeCall1 (Elm.string name) depsExpr arg0 [ arg0, arg1 ] -> - Gen.Glsl.Helper.call_.unsafeCall2 (Elm.string name) depsExpr arg0 arg1 + Gen.Glsl.call_.unsafeCall2 (Elm.string name) depsExpr arg0 arg1 [ arg0, arg1, arg2 ] -> - Gen.Glsl.Helper.call_.unsafeCall3 (Elm.string name) depsExpr arg0 arg1 arg2 + Gen.Glsl.call_.unsafeCall3 (Elm.string name) depsExpr arg0 arg1 arg2 [ arg0, arg1, arg2, arg3 ] -> - Gen.Glsl.Helper.call_.unsafeCall4 (Elm.string name) depsExpr arg0 arg1 arg2 arg3 + Gen.Glsl.call_.unsafeCall4 (Elm.string name) depsExpr arg0 arg1 arg2 arg3 _ :: _ :: _ -> Elm.string "TODO" @@ -228,7 +228,7 @@ wrapFunction name deps args returnType = expr argValues = innerCall argValues - |> Elm.withType (Gen.Glsl.Helper.annotation_.expression (typeToAnnotation returnType)) + |> Elm.withType (Gen.Glsl.annotation_.expression (typeToAnnotation returnType)) in Elm.function argDecls expr |> Elm.declaration fname @@ -260,28 +260,28 @@ typeToAnnotation type_ = Type.int TVec2 -> - Gen.Glsl.Helper.annotation_.vec2 + Gen.Glsl.annotation_.vec2 TIVec2 -> - Gen.Glsl.Helper.annotation_.iVec2 + Gen.Glsl.annotation_.iVec2 TVec3 -> - Gen.Glsl.Helper.annotation_.vec3 + Gen.Glsl.annotation_.vec3 TIVec3 -> - Gen.Glsl.Helper.annotation_.iVec3 + Gen.Glsl.annotation_.iVec3 TVec4 -> - Gen.Glsl.Helper.annotation_.vec4 + Gen.Glsl.annotation_.vec4 TIVec4 -> - Gen.Glsl.Helper.annotation_.iVec4 + Gen.Glsl.annotation_.iVec4 TMat3 -> - Gen.Glsl.Helper.annotation_.mat3 + Gen.Glsl.annotation_.mat3 TVoid -> - Gen.Glsl.Helper.annotation_.void + Gen.Glsl.annotation_.void variableHasType : String -> Type -> Env -> Env @@ -294,23 +294,31 @@ union = List.foldl (Result.map2 SortedSet.insertAll) (Ok SortedSet.empty) -findDepsStatement : Env -> Statement -> Result String (SortedSet String) +findDepsStatement : Env -> Stat -> Result String (SortedSet String) findDepsStatement env statement = case statement of - If cond true false -> + If cond true cont -> + union + [ findDepsExpression env cond + , findDepsStatement env true + , findDepsStatement env cont + ] + + IfElse cond true false cont -> union [ findDepsExpression env cond , findDepsStatement env true , findDepsStatement env false + , findDepsStatement env cont ] - Expression e cont -> + ExpressionStatement e cont -> union [ findDepsExpression env e , findDepsStatement env cont ] - For { var, from, to, step } cont -> + For var from _ to _ step cont -> let newEnv : Env newEnv = @@ -326,33 +334,33 @@ findDepsStatement env statement = Return e -> findDepsExpression env e - Def { type_, var, val } cont -> + Decl type_ var maybeVal cont -> let newEnv : Env newEnv = variableHasType var type_ env in union - [ findDepsExpression env val + [ maybeVal + |> Maybe.map (findDepsExpression env) + |> Maybe.withDefault (Ok SortedSet.empty) , findDepsStatement newEnv cont ] - Decl { type_, var } cont -> - let - newEnv : Env - newEnv = - variableHasType var type_ env - in - findDepsStatement newEnv cont - Nop -> Ok SortedSet.empty + Break -> + Ok SortedSet.empty + + Continue -> + Ok SortedSet.empty + -findDepsExpression : Env -> Expression -> Result String (SortedSet String) +findDepsExpression : Env -> Expr -> Result String (SortedSet String) findDepsExpression env = let - go : Expression -> Result String ( Type, SortedSet String ) + go : Expr -> Result String ( Type, SortedSet String ) go expr = case expr of Float _ -> @@ -392,6 +400,12 @@ findDepsExpression env = ) (go e) + Variable "P32M1" -> + Ok ( TInt, SortedSet.empty ) + + Variable "P31" -> + Ok ( TInt, SortedSet.empty ) + Variable v -> case Dict.get v env.variablesEnv of Nothing -> @@ -400,15 +414,6 @@ findDepsExpression env = Just t -> Ok ( t, SortedSet.empty ) - Constant "P32M1" -> - Ok ( TInt, SortedSet.empty ) - - Constant "P31" -> - Ok ( TInt, SortedSet.empty ) - - Constant c -> - Err <| "TODO: findDepsExpression _ (Constant \"" ++ c ++ "\")" - Call f args -> args |> Result.Extra.combineMap go @@ -434,9 +439,23 @@ findDepsExpression env = Ok ( to, deps ) ) - Arr l r -> - --union [ go l, go r ] - Err "TODO: findDepsExpression _ (Arr _ _)" + Array l r -> + Result.andThen + (\( ( lt, ld ), ( rt, rd ) ) -> + Result.map + (\t -> ( t, SortedSet.insertAll ld rd )) + (case ( lt, rt ) of + ( TVec3, TInt ) -> + Ok TFloat + + _ -> + Err <| "Don't know what the result of " ++ typeToString lt ++ "[" ++ typeToString rt ++ "] is" + ) + ) + (Result.map2 Tuple.pair + (go l) + (go r) + ) Ternary c t f -> Result.map3 @@ -484,19 +503,7 @@ findDepsExpression env = (go r) ) - BooleanOperation _ es -> - es - |> Result.Extra.combineMap go - |> Result.map - (\res -> - let - ( _, deps ) = - List.unzip res - in - ( TBool, List.foldl SortedSet.insertAll SortedSet.empty deps ) - ) - - RelationOperation _ l r -> + Comparison _ l r -> Result.map2 (\( _, ld ) ( _, rd ) -> ( TBool, SortedSet.insertAll ld rd ) @@ -509,6 +516,14 @@ findDepsExpression env = PostfixDecrement e -> go e + + AssignCombo _ l r -> + Result.map2 + (\( lt, ld ) ( _, rd ) -> + ( lt, SortedSet.insertAll ld rd ) + ) + (go l) + (go r) in go >> Result.map Tuple.second @@ -565,6 +580,12 @@ binaryOperationToString bop = Div -> "/" + And -> + "&&" + + Or -> + "||" + fullName : String -> List Type -> String fullName baseName argTypes = diff --git a/codegen/Glsl/Parser.elm b/codegen/Glsl/Parser.elm index 30943462..b9bf28e7 100644 --- a/codegen/Glsl/Parser.elm +++ b/codegen/Glsl/Parser.elm @@ -1,6 +1,6 @@ module Glsl.Parser exposing (file, function, statement) -import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), UnaryOperation(..)) import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) import Parser.Workaround @@ -9,13 +9,18 @@ function : Parser Function function = succeed (\glsl begin returnType { name, hasSuffix } args stat end -> - { returnType = returnType - , name = name - , hasSuffix = hasSuffix - , args = args - , stat = stat - , body = String.slice begin end glsl - } + let + res : Function + res = + { returnType = returnType + , name = name + , hasSuffix = hasSuffix + , args = args + , stat = stat + , body = String.slice begin end glsl + } + in + res ) |= Parser.getSource |= Parser.getOffset @@ -79,7 +84,7 @@ typeParser = |> oneOf -statement : Parser Statement +statement : Parser Stat statement = Parser.lazy <| \_ -> @@ -94,9 +99,9 @@ statement = ] -expressionStatementParser : Parser Statement +expressionStatementParser : Parser Stat expressionStatementParser = - Parser.succeed Expression + Parser.succeed ExpressionStatement |= expressionParser |. spaces |. symbol ";" @@ -104,7 +109,7 @@ expressionStatementParser = |= maybeStatementParser -ifParser : Parser Statement +ifParser : Parser Stat ifParser = Parser.succeed If |. symbol "if" @@ -120,24 +125,14 @@ ifParser = |= maybeStatementParser -maybeStatementParser : Parser Statement +maybeStatementParser : Parser Stat maybeStatementParser = oneOf [ statement, succeed Nop ] -forParser : Parser Statement +forParser : Parser Stat forParser = - Parser.succeed - (\var from op to direction step -> - For - { var = var - , from = from - , op = op - , to = to - , direction = direction - , step = step - } - ) + Parser.succeed For |. symbol "for" |. spaces |. symbol "(" @@ -174,7 +169,7 @@ forParser = |= maybeStatementParser -returnParser : Parser Statement +returnParser : Parser Stat returnParser = Parser.succeed Return |. symbol "return" @@ -184,7 +179,7 @@ returnParser = |. symbol ";" -commentParser : Parser Statement +commentParser : Parser Stat commentParser = Parser.succeed identity |. Parser.Workaround.lineCommentAfter "//" @@ -192,7 +187,7 @@ commentParser = |= maybeStatementParser -blockParser : Parser Statement +blockParser : Parser Stat blockParser = Parser.succeed identity |. symbol "{" @@ -202,15 +197,11 @@ blockParser = |. symbol "}" -defParser : Parser Statement +defParser : Parser Stat defParser = succeed (\type_ var val -> - Def - { type_ = type_ - , var = var - , val = val - } + Decl type_ var (Just val) ) |= typeParser |. spaces @@ -225,18 +216,20 @@ defParser = |= maybeStatementParser -expressionParser : Parser Expression +expressionParser : Parser Expr expressionParser = ternaryParser -ternaryParser : Parser Expression +ternaryParser : Parser Expr ternaryParser = - Parser.succeed (\c f -> f c) + Parser.succeed (\k f -> f k) |= booleanParser |. spaces |= oneOf [ succeed (\t f c -> Ternary c t f) + -- c is passed in last in the lambda because it's passed + -- from above |. symbol "?" |. spaces |= booleanParser @@ -248,19 +241,19 @@ ternaryParser = ] -booleanParser : Parser Expression +booleanParser : Parser Expr booleanParser = multiSequence { separators = - [ ( \l r -> BooleanOperation Or [ l, r ], symbol "||" ) - , ( \l r -> BooleanOperation And [ l, r ], symbol "&&" ) + [ ( BinaryOperation Or, symbol "||" ) + , ( BinaryOperation And, symbol "&&" ) ] , item = relationParser , allowNegation = False } -relationParser : Parser Expression +relationParser : Parser Expr relationParser = let inner = @@ -268,7 +261,7 @@ relationParser = |= addsubtractionParser |. spaces |= oneOf - [ succeed (\o r l -> succeed <| RelationOperation o l r) + [ succeed (\o r l -> succeed <| Comparison o l r) |= relationOperationParser |. spaces |= addsubtractionParser @@ -291,7 +284,7 @@ relationOperationParser = ] -addsubtractionParser : Parser Expression +addsubtractionParser : Parser Expr addsubtractionParser = multiSequence { separators = @@ -304,13 +297,13 @@ addsubtractionParser = type alias SequenceData = - { separators : List ( Expression -> Expression -> Expression, Parser () ) - , item : Parser Expression + { separators : List ( Expr -> Expr -> Expr, Parser () ) + , item : Parser Expr , allowNegation : Bool } -multiSequence : SequenceData -> Parser Expression +multiSequence : SequenceData -> Parser Expr multiSequence data = succeed identity |= data.item @@ -323,8 +316,8 @@ multiSequence data = multiSequenceHelp : SequenceData - -> Expression - -> Parser (Step Expression Expression) + -> Expr + -> Parser (Step Expr Expr) multiSequenceHelp { allowNegation, separators, item } acc = let separated = @@ -355,7 +348,7 @@ multiSequenceHelp { allowNegation, separators, item } acc = ] -multidivisionParser : Parser Expression +multidivisionParser : Parser Expr multidivisionParser = multiSequence { separators = @@ -367,7 +360,7 @@ multidivisionParser = } -unaryParser : Parser Expression +unaryParser : Parser Expr unaryParser = Parser.oneOf [ succeed (UnaryOperation Negate) @@ -377,7 +370,7 @@ unaryParser = ] -atomParser : Parser Expression +atomParser : Parser Expr atomParser = succeed (\a f -> f a) |= oneOf @@ -403,13 +396,13 @@ atomParser = , trailing = Forbidden , spaces = spaces } - , succeed (\arg v -> Arr (toVariableOrConstant v) arg) + , succeed (\arg v -> Array (Variable v) arg) |. symbol "[" |. spaces |= Parser.lazy (\_ -> expressionParser) |. spaces |. symbol "]" - , succeed toVariableOrConstant + , succeed Variable ] |= maybeDot , Parser.andThen tryParseNumber <| @@ -428,16 +421,7 @@ atomParser = ] -toVariableOrConstant : String -> Expression -toVariableOrConstant s = - if String.toUpper s == s then - Constant s - - else - Variable s - - -maybeDot : Parser (Expression -> Expression) +maybeDot : Parser (Expr -> Expr) maybeDot = oneOf [ succeed (\p v -> Dot v p) @@ -447,7 +431,7 @@ maybeDot = ] -tryParseNumber : String -> Parser Expression +tryParseNumber : String -> Parser Expr tryParseNumber n = case String.toInt n of Just i -> diff --git a/codegen/Glsl/PrettyPrinter.elm b/codegen/Glsl/PrettyPrinter.elm index f71a30f2..e6454e75 100644 --- a/codegen/Glsl/PrettyPrinter.elm +++ b/codegen/Glsl/PrettyPrinter.elm @@ -217,7 +217,7 @@ prettyPrintType type_ = prettyPrintExpression : Expression -> String prettyPrintExpression e = let - lisp args = + parens args = "(" ++ String.join " " args ++ ")" in case e of @@ -229,13 +229,13 @@ prettyPrintExpression e = "one" else - lisp [ "float", String.fromFloat f ] + parens [ "float", String.fromFloat f ] Int i -> - lisp [ "int", String.fromInt i ] + parens [ "int", String.fromInt i ] Bool b -> - lisp + parens [ "bool" , if b then "True" @@ -268,7 +268,7 @@ prettyPrintExpression e = "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) Call "float" [ arg ] -> - lisp [ "floatCast", prettyPrintExpression arg ] + parens [ "floatCast", prettyPrintExpression arg ] Call n args -> if String.startsWith "vec" n then @@ -276,7 +276,7 @@ prettyPrintExpression e = n ++ "Zero" else - lisp <| + parens <| n :: List.map (\c -> @@ -291,31 +291,31 @@ prettyPrintExpression e = else if n == "atan" then if List.length args == 2 then - lisp <| "atan2_" :: List.map prettyPrintExpression args + parens <| "atan2_" :: List.map prettyPrintExpression args else - lisp <| "atan_" :: List.map prettyPrintExpression args + parens <| "atan_" :: List.map prettyPrintExpression args else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then - lisp <| (n ++ "_") :: List.map prettyPrintExpression args + parens <| (n ++ "_") :: List.map prettyPrintExpression args else - lisp <| n :: List.map prettyPrintExpression args + parens <| n :: List.map prettyPrintExpression args Arr l r -> - lisp [ "arr", prettyPrintExpression l, prettyPrintExpression r ] + parens [ "arr", prettyPrintExpression l, prettyPrintExpression r ] Ternary c l r -> - lisp [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] + parens [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] UnaryOperation Negate ex -> - lisp [ "negate_", prettyPrintExpression ex ] + parens [ "negate_", prettyPrintExpression ex ] BinaryOperation op l r -> - lisp [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] + parens [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] BooleanOperation op es -> - lisp + parens [ prettyPrintBooleanOperation op , "[" , String.join ", " <| List.map prettyPrintExpression es @@ -323,13 +323,13 @@ prettyPrintExpression e = ] RelationOperation rop l r -> - lisp [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] + parens [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] PostfixIncrement c -> - lisp [ "postfixIncrement", prettyPrintExpression c ] + parens [ "postfixIncrement", prettyPrintExpression c ] PostfixDecrement c -> - lisp [ "postfixDecrement", prettyPrintExpression c ] + parens [ "postfixDecrement", prettyPrintExpression c ] prettyPrintRelationOperation : RelationOperation -> String diff --git a/codegen/Glsl/Types.elm b/codegen/Glsl/Types.elm deleted file mode 100644 index 8a3d6050..00000000 --- a/codegen/Glsl/Types.elm +++ /dev/null @@ -1,84 +0,0 @@ -module Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) - - -type alias Function = - { returnType : Type - , name : String - , args : List ( Type, String ) - , stat : Statement - , body : String - , hasSuffix : Bool - } - - -type Type - = TFloat - | TInt - | TVec2 - | TIVec2 - | TIVec3 - | TIVec4 - | TVec3 - | TVec4 - | TMat3 - | TVoid - | TBool - - -type Statement - = Expression Expression Statement - | For { var : String, from : Expression, op : RelationOperation, to : Expression, direction : ForDirection, step : Statement } Statement - | If Expression Statement Statement - | Return Expression - | Def { type_ : Type, var : String, val : Expression } Statement - | Decl { type_ : Type, var : String } Statement - | Nop - - -type ForDirection - = PlusPlus - | MinusMinus - - -type RelationOperation - = LessThanOrEquals - | LessThan - | Equals - | NotEquals - | Assign - | GreaterThanOrEquals - | GreaterThan - - -type BinaryOperation - = Add - | Subtract - | By - | Div - - -type BooleanOperation - = And - | Or - - -type UnaryOperation - = Negate - - -type Expression - = Float Float - | Int Int - | Bool Bool - | Dot Expression String - | Variable String - | Constant String - | Call String (List Expression) - | Arr Expression Expression - | Ternary Expression Expression Expression - | UnaryOperation UnaryOperation Expression - | BinaryOperation BinaryOperation Expression Expression - | BooleanOperation BooleanOperation (List Expression) - | RelationOperation RelationOperation Expression Expression - | PostfixIncrement Expression - | PostfixDecrement Expression diff --git a/codegen/helpers/Glsl/Helper.elm b/codegen/helpers/Glsl.elm similarity index 51% rename from codegen/helpers/Glsl/Helper.elm rename to codegen/helpers/Glsl.elm index 54cb08f3..0f51bf54 100644 --- a/codegen/helpers/Glsl/Helper.elm +++ b/codegen/helpers/Glsl.elm @@ -1,9 +1,52 @@ -module Glsl.Helper exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), IVec2, IVec3, IVec4, Mat3(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2(..), Vec3(..), Vec4(..), Void, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4) +module Glsl exposing + ( Function + , Statement(..), Stat(..), ForDirection(..) + , Expression(..), Expr(..) + , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) + , true, false, int, float, var + , TypingFunction, TypedName(..), Type(..) + , Vec2(..), Vec3(..), Vec4(..), IVec2, IVec3, IVec4, Mat3(..), Void + , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4 + , unsafeMap, unsafeMap2, unsafeMap3 + ) + +{-| + + +# Types + +@docs Function +@docs Statement, Stat, ForDirection +@docs Expression, ExprWithDeps, Expr +@docs BinaryOperation, UnaryOperation, RelationOperation, ComboOperation + + +# Utils + +@docs true, false, int, float, var + + +# Typelevel types + +@docs TypingFunction, TypedName, Type +@docs Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void + + +# Escape hatches + +@docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4 +@docs unsafeMap, unsafeMap2, unsafeMap3 + +-} import Set exposing (Set) import SortedSet exposing (SortedSet) + +-- UNSAFE -- + + unsafeCall0 : String -> List String -> Expression r unsafeCall0 name deps = unsafeCall name deps [] @@ -43,10 +86,49 @@ unsafeCall name deps args = } +unsafeMap : (Expr -> Expr) -> Expression a -> Expression b +unsafeMap f (Expression l) = + Expression + { expr = f l.expr + , deps = l.deps + } + + +unsafeMap2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c +unsafeMap2 f (Expression l) (Expression r) = + Expression + { expr = f l.expr r.expr + , deps = + l.deps + |> SortedSet.insertAll r.deps + } + + +unsafeMap3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d +unsafeMap3 f (Expression l) (Expression m) (Expression r) = + Expression + { expr = f l.expr m.expr r.expr + , deps = + l.deps + |> SortedSet.insertAll m.deps + |> SortedSet.insertAll r.deps + } + + -- Typed expressions +type alias Function = + { returnType : Type + , name : String + , args : List ( Type, String ) + , stat : Stat + , body : String + , hasSuffix : Bool + } + + type Expression t = Expression ExprWithDeps @@ -62,8 +144,6 @@ type Expr | Int Int | Float Float | Variable String - | And Expr Expr - | Or Expr Expr | Comparison RelationOperation Expr Expr | Ternary Expr Expr Expr | UnaryOperation UnaryOperation Expr @@ -71,10 +151,8 @@ type Expr | Call String (List Expr) | PostfixIncrement Expr | PostfixDecrement Expr - | Unknown String | Dot Expr String | Array Expr Expr - | Assign Expr Expr | AssignCombo ComboOperation Expr Expr @@ -83,6 +161,8 @@ type BinaryOperation | Subtract | By | Div + | And + | Or type UnaryOperation @@ -96,6 +176,7 @@ type RelationOperation | NotEquals | GreaterThanOrEquals | GreaterThan + | Assign type ComboOperation @@ -119,30 +200,40 @@ type Statement r type Stat = If Expr Stat Stat | IfElse Expr Stat Stat Stat - | For String Expr RelationOperation Expr Expr Stat Stat - | Line String + | For String Expr RelationOperation Expr ForDirection Stat Stat | Return Expr | Break | Continue | ExpressionStatement Expr Stat - | Decl String Name (Maybe Expr) Stat + | Decl Type String (Maybe Expr) Stat | Nop +type ForDirection + = PlusPlus + | MinusMinus + + type alias TypingFunction t = String -> TypedName t type TypedName t - = TypedName Type Name + = TypedName Type String type Type - = Type String - - -type Name - = Name String + = TVoid + | TFloat + | TInt + | TBool + | TVec2 + | TVec3 + | TVec4 + | TIVec2 + | TIVec3 + | TIVec4 + | TMat3 @@ -179,3 +270,45 @@ type Mat3 type Void = Void Void + + + +-- Utils + + +true : Expression Bool +true = + bool True + + +false : Expression Bool +false = + bool False + + +bool : Bool -> Expression Bool +bool b = + pure <| Bool b + + +int : Int -> Expression Int +int i = + pure <| Int i + + +float : Float -> Expression Float +float i = + pure <| Float i + + +var : String -> Expression t +var v = + pure <| Variable v + + +pure : Expr -> Expression t +pure e = + Expression + { expr = e + , deps = SortedSet.empty + } diff --git a/codegen/helpers/Glsl/Operations.elm b/codegen/helpers/Glsl/Operations.elm new file mode 100644 index 00000000..c51c7fa6 --- /dev/null +++ b/codegen/helpers/Glsl/Operations.elm @@ -0,0 +1,37 @@ +module Glsl.Operations exposing (add11, add22, add33, add44) + +{-| + + +# Addition + +@docs add11, add22, add33, add44 + +-} + +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Vec2, Vec3, Vec4) + + +add11 : Expression Float -> Expression Float -> Expression Float +add11 = + add + + +add22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 +add22 = + add + + +add33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 +add33 = + add + + +add44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 +add44 = + add + + +add : Expression a -> Expression a -> Expression a +add l r = + Glsl.unsafeMap2 (BinaryOperation Add) l r diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index df1202b5..ce9a9279 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,8 +2,7 @@ module UI.Glsl.Code exposing (expressionToGlsl, threshold) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl exposing (cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, vec21, vec211) -import Glsl.Helper exposing (Expression) +import Glsl.Functions exposing (cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, vec21, vec211) import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negate2, one, subtract, subtract2, vec2Zero, zero) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 217c1ae3..22490772 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,8 +1,11 @@ -module UI.Glsl.Generator exposing (Constant, Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Vec2, Vec3, Vec4, abs2, abs4, abs_, acos2, acos_, add, add2, add3, add33, add4, adds2, adds3, adds4, and, ands, arr, assign, assignAdd, assignBy, atan2_, atan_, bool, boolT, break, by, by2, by3, byF, ceil_, constant, continue, cos_, cosh, cross, decl, def, div, div2, divF, dot, eq, exp, expr, expressionToGlsl, false, fileToGlsl, float, floatCast, floatT, floatToGlsl, floor_, for, forDown, forLeq, fract, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, fwidth, geq, gl_FragColor, gl_FragCoord, gt, hl2rgb, ifElse, if_, in_, int, intCast, intT, interpret, length, leq, log, log2, lt, mat3T, max3, max4, max_, min_, minusOne, mix, mod, negate2, negateConst, negate_, neq, normalize, normalize3, one, or, ors, out, postfixDecrement, postfixIncrement, pow, radians_, return, round_, sign, sin_, sinh, smoothstep, sqrt_, statementToGlsl, subtract, subtract2, subtract3, subtract4, subtractConst, tan_, ternary, ternary3, true, uniform, unknown, unsafeCall, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, vec4_1_3, vec4_3_1, voidT, zero) +module UI.Glsl.Generator exposing (Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Vec2, Vec3, Vec4, adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, boolT, break, continue, decl, def, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) import Dict exposing (Dict) -import Glsl.Helper exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), Name(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction) +import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), false, float, int, true, unsafeMap2, unsafeMap3) +import Glsl.Functions exposing (vec211, vec3111, vec41111) +import Glsl.Operations exposing (add11, add22, add33, add44) import Set +import SortedSet type alias File = @@ -41,7 +44,7 @@ funDeclToGlsl (FunDecl { body }) = statementToGlsl : Statement s -> String statementToGlsl (Statement r) = - statToGlsl 1 r + statToGlsl 1 r.stat statToGlsl : Int -> Stat -> String @@ -83,8 +86,8 @@ statToGlsl i c = ] |> String.join "\n" - For var from rel to step loop next -> - [ indent i ("for (int " ++ var ++ " = " ++ exprToGlsl (Expression from) ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ exprToGlsl (Expression to) ++ "; " ++ exprToGlsl (Expression step) ++ ") {") + For var from rel to direction loop next -> + [ indent i ("for (int " ++ var ++ " = " ++ exprToGlsl from ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ exprToGlsl to ++ "; " ++ var ++ directionToGlsl direction ++ ") {") , statToGlsl (i + 1) loop , indent i "}" , "" @@ -92,11 +95,8 @@ statToGlsl i c = ] |> String.join "\n" - Line l -> - indent i l ++ ";" - Return e -> - indent i <| "return " ++ exprToGlsl (Expression e) ++ ";" + indent i <| "return " ++ exprToGlsl e ++ ";" Break -> indent i "break;" @@ -105,27 +105,74 @@ statToGlsl i c = indent i "continue;" ExpressionStatement e Nop -> - indent i (exprToGlsl (Expression e) ++ ";") + indent i (exprToGlsl e ++ ";") - Decl t (Name n) (Just e) Nop -> - indent i (t ++ " " ++ n ++ " = " ++ exprToGlsl (Expression e) ++ ";") + Decl t n (Just e) Nop -> + indent i (typeToGlsl t ++ " " ++ n ++ " = " ++ exprToGlsl e ++ ";") - Decl t (Name n) Nothing Nop -> - indent i (t ++ " " ++ n ++ ";") + Decl t n Nothing Nop -> + indent i (typeToGlsl t ++ " " ++ n ++ ";") ExpressionStatement e next -> - indent i (exprToGlsl (Expression e) ++ ";\n") ++ statToGlsl i next + indent i (exprToGlsl e ++ ";\n") ++ statToGlsl i next - Decl t (Name n) (Just e) next -> - indent i (t ++ " " ++ n ++ " = " ++ exprToGlsl (Expression e) ++ ";\n") ++ statToGlsl i next + Decl t n (Just e) next -> + indent i (typeToGlsl t ++ " " ++ n ++ " = " ++ exprToGlsl e ++ ";\n") ++ statToGlsl i next - Decl t (Name n) Nothing next -> - indent i (t ++ " " ++ n ++ ";\n") ++ statToGlsl i next + Decl t n Nothing next -> + indent i (typeToGlsl t ++ " " ++ n ++ ";\n") ++ statToGlsl i next Nop -> "" +directionToGlsl : ForDirection -> String +directionToGlsl direction = + case direction of + PlusPlus -> + "++" + + MinusMinus -> + "--" + + +typeToGlsl : Type -> String +typeToGlsl type_ = + case type_ of + TVoid -> + "void" + + TFloat -> + "float" + + TInt -> + "int" + + TBool -> + "bool" + + TVec2 -> + "vec2" + + TVec3 -> + "vec3" + + TVec4 -> + "vec4" + + TIVec2 -> + "ivec2" + + TIVec3 -> + "ivec3" + + TIVec4 -> + "ivec4" + + TMat3 -> + "mat3" + + relationToString : RelationOperation -> String relationToString rel = case rel of @@ -147,15 +194,18 @@ relationToString rel = GreaterThan -> ">" + Assign -> + "=" + nop : Continue () -nop () = - Statement Nop +nop = + internalNop internalNop : Continue a internalNop () = - Statement Nop + Statement { stat = Nop, deps = Set.empty } expressionToGlsl : Expression t -> String @@ -169,12 +219,11 @@ exprToGlsl tree = -- The numbers are precedence numbers from the GLSL spec go : Bool -> Expr -> String go rec e = - case e of - Unknown u -> - u - - _ -> - go17 rec e + -- case e of + -- Unknown u -> + -- u + -- _ -> + go17 rec e go17 : Bool -> Expr -> String go17 rec e = @@ -183,7 +232,7 @@ exprToGlsl tree = go16 : Bool -> Expr -> String go16 rec e = case e of - Assign l r -> + Comparison Assign l r -> go15 False l ++ " = " ++ go15 False r AssignCombo k l r -> @@ -204,7 +253,7 @@ exprToGlsl tree = go14 : Bool -> Expr -> String go14 rec e = case e of - Or l r -> + BinaryOperation Or l r -> go14 False l ++ " || " ++ go13 False r _ -> @@ -217,7 +266,7 @@ exprToGlsl tree = go12 : Bool -> Expr -> String go12 rec e = case e of - And l r -> + BinaryOperation And l r -> go12 False l ++ " && " ++ go11 False r _ -> @@ -272,10 +321,10 @@ exprToGlsl tree = go5 : Bool -> Expr -> String go5 rec e = case e of - Add l r -> + BinaryOperation Add l r -> go5 False l ++ " + " ++ go4 False r - Subtract l r -> + BinaryOperation Subtract l r -> go5 False l ++ " - " ++ go4 False r _ -> @@ -284,10 +333,10 @@ exprToGlsl tree = go4 : Bool -> Expr -> String go4 rec e = case e of - By l r -> + BinaryOperation By l r -> go4 False l ++ " * " ++ go3 False r - Div l r -> + BinaryOperation Div l r -> go4 False l ++ " / " ++ go3 False r _ -> @@ -296,7 +345,7 @@ exprToGlsl tree = go3 : Bool -> Expr -> String go3 rec e = case e of - Negate c -> + UnaryOperation Negate c -> "-" ++ go2 False c PostfixIncrement c -> @@ -377,19 +426,19 @@ indent i line = --EXPRESSIONS -ternary : ExpressionXBool -> Expression t -> Expression t -> Expression t +ternary : Expression Bool -> Expression t -> Expression t -> Expression t ternary = - expr3 Ternary + unsafeMap3 Ternary -ternary3 : ExpressionX xa Bool -> ExpressionX xb Vec3 -> ExpressionX xc Vec3 -> Expression Vec3 +ternary3 : Expression Bool -> Expression Vec3 -> Expression Vec3 -> Expression Vec3 ternary3 = - expr33 Ternary + unsafeMap3 Ternary and : Expression Bool -> Expression Bool -> Expression Bool and = - expr2 And + unsafeMap2 (BinaryOperation And) ands : List (Expression Bool) -> Expression Bool @@ -399,12 +448,12 @@ ands es = true h :: t -> - List.foldl (\e a -> expr2 And a e) h t + List.foldl (\e a -> and a e) h t or : Expression Bool -> Expression Bool -> Expression Bool or = - expr2 Or + unsafeMap2 (BinaryOperation Or) ors : List (Expression Bool) -> Expression Bool @@ -414,7 +463,7 @@ ors es = false h :: t -> - List.foldl (\e a -> expr2 Or a e) h t + List.foldl (\e a -> or a e) h t adds2 : List (Expression Vec2) -> Expression Vec2 @@ -424,7 +473,7 @@ adds2 es = vec2Zero h :: t -> - List.foldl (\e a -> add2 a e) h t + List.foldl (\e a -> add22 a e) h t adds3 : List (Expression Vec3) -> Expression Vec3 @@ -434,7 +483,7 @@ adds3 es = vec3Zero h :: t -> - List.foldl (\e a -> add3 a e) h t + List.foldl (\e a -> add33 a e) h t adds4 : List (Expression Vec4) -> Expression Vec4 @@ -444,372 +493,7 @@ adds4 es = vec4Zero h :: t -> - List.foldl (\e a -> add4 a e) h t - - -pure : Expr -> Expression t -pure e = - Expression { expr = e, deps = Set.empty } - - -true : Expression Bool -true = - pure <| Bool True - - -false : Expression Bool -false = - pure <| Bool False - - - ------------------------------- --- FUNCTIONS AND OPERATIONS -- ------------------------------- - - -add : Expression t -> Expression t -> Expression t -add = - expr2 Add - - -add2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -add2 = - expr22 Add - - -add3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -add3 = - expr23 Add - - -add4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -add4 = - expr24 Add - - -add33 : Expression Mat3 -> Expression Mat3 -> Expression Mat3 -add33 = - expr233 Add - - -subtract : Expression t -> Expression t -> Expression t -subtract = - expr2 Subtract - - -subtractConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { b | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t -subtractConst l r = - { base = (expr2 Subtract l r).base - , isConstant = Constant - } - - -subtract2 : ExpressionXVec2 -> Expression Vec2 -> Expression Vec2 -subtract2 = - expr22 Subtract - - -subtract3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -subtract3 = - expr23 Subtract - - -subtract4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -subtract4 = - expr24 Subtract - - -negate_ : Expression t -> Expression t -negate_ = - expr1 Negate - - -negateConst : ExpressionX { a | isConstant : Constant } t -> ExpressionX { isConstant : Constant } t -negateConst l = - { base = (expr1 Negate l).base - , isConstant = Constant - } - - -negate2 : Expression Vec2 -> Expression Vec2 -negate2 e = - dotted2Internal (Negate <| unwrapExpression e) - - -postfixIncrement : Expression t -> Expression t -postfixIncrement = - expr1 PostfixIncrement - - -postfixDecrement : Expression t -> Expression t -postfixDecrement = - expr1 PostfixDecrement - - -by : Expression t -> Expression t -> Expression t -by = - expr2 By - - -by2 : ExpressionXVec2 -> Expression Vec2 -> Expression Vec2 -by2 = - expr22 By - - -by3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -by3 = - expr23 By - - -byF : Expression Float -> Expression t -> Expression t -byF = - expr2 By - - -divF : Expression t -> Expression Float -> Expression t -divF = - expr2 Div - - -div : Expression t -> Expression t -> Expression t -div = - expr2 Div - - -div2 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -div2 = - expr22 Div - - -lt : Expression t -> Expression t -> Expression Bool -lt = - expr2 (Comparison LessThan) - - -leq : Expression t -> Expression t -> Expression Bool -leq = - expr2 (Comparison LessThanOrEquals) - - -eq : Expression t -> Expression t -> Expression Bool -eq = - expr2 (Comparison Equals) - - -neq : Expression t -> Expression t -> Expression Bool -neq = - expr2 (Comparison NotEquals) - - -geq : Expression t -> Expression t -> Expression Bool -geq = - expr2 (Comparison GreaterThanOrEquals) - - -gt : Expression t -> Expression t -> Expression Bool -gt = - expr2 (Comparison GreaterThan) - - -abs_ : Expression t -> Expression t -abs_ = - call1Internal "abs" - - -abs2 : Expression Vec2 -> Expression Vec2 -abs2 = - dotted2 << call1Internal "abs" - - -abs4 : Expression Vec4 -> Expression Vec4 -abs4 = - dotted4 << call1Internal "abs" - - -mix : Expression t -> Expression t -> Expression Float -> Expression t -mix x y a = - dotted1 <| call3Internal "mix" x y a - - -smoothstep : Expression Float -> Expression Float -> Expression Float -> Expression t -smoothstep x y a = - dotted1 <| call3Internal "smoothstep" x y a - - -exp : Expression t -> Expression t -exp = - call1Internal "exp" - - -sqrt_ : Expression t -> Expression t -sqrt_ = - call1Internal "sqrt" - - -sin_ : Expression t -> Expression t -sin_ = - call1Internal "sin" - - -cos_ : Expression t -> Expression t -cos_ = - call1Internal "cos" - - -tan_ : Expression t -> Expression t -tan_ = - call1Internal "tan" - - -acos_ : Expression t -> Expression t -acos_ = - call1Internal "acos" - - -acos2 : Expression Vec2 -> Expression Vec2 -acos2 = - dotted2 << call1Internal "acos" - - -sinh : Expression t -> Expression t -sinh = - call1Internal "sinh" - - -cosh : Expression t -> Expression t -cosh = - call1Internal "cosh" - - -log : Expression t -> Expression t -log = - call1Internal "log" - - -mod : Expression t -> Expression t -> Expression t -mod l r = - dotted1 (call2Internal "mod" l r) - - -min_ : Expression t -> Expression t -> Expression t -min_ l r = - dotted1 (call2Internal "min" l r) - - -max_ : Expression t -> Expression t -> Expression t -max_ l r = - dotted1 (call2Internal "max" l r) - - -max3 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -max3 l r = - dotted3 (call2Internal "max" l r) - - -max4 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -max4 l r = - dotted4 (call2Internal "max" l r) - - -hl2rgb : ExpressionXFloat -> Expression Float -> Expression Vec3 -hl2rgb h l = - dotted3 (call2Internal "hl2rgb" h l) - - -pow : Expression Float -> Expression Float -> Expression Float -pow l r = - dotted1 (call2Internal "pow" l r) - - -log2 : ExpressionXFloat -> Expression Float -log2 = - call1Internal "log2" - - -ceil_ : Expression t -> Expression t -ceil_ = - call1Internal "ceil" - - -floor_ : Expression t -> Expression t -floor_ = - call1Internal "floor" - - -round_ : Expression t -> Expression t -round_ = - call1Internal "round" - - -sign : Expression t -> Expression t -sign = - call1Internal "sign" - - -radians_ : Expression Float -> Expression Float -radians_ = - call1Internal "radians" - - -normalize : Expression t -> Expression t -normalize = - call1Internal "normalize" - - -normalize3 : ExpressionXVec3 -> Expression Vec3 -normalize3 = - dotted3 << call1Internal "normalize" - - -length : Expression t -> Expression Float -length = - call1Internal "length" - - -fwidth : Expression t -> Expression t -fwidth = - call1Internal "fwidth" - - -cross : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -cross l r = - dotted3 <| call2Internal "cross" l r - - -atan_ : Expression Float -> Expression Float -atan_ = - call1Internal "atan" - - -atan2_ : ExpressionXFloat -> Expression Float -> Expression Float -atan2_ l r = - dotted1 <| call2Internal "atan" l r - - -intCast : Expression Float -> Expression Int -intCast = - call1Internal "int" - - -floatCast : ExpressionXInt -> Expression Float -floatCast = - call1Internal "float" - - -fract : Expression Float -> Expression Float -fract = - call1Internal "fract" - - -arr : ExpressionXMat3 -> Expression Int -> Expression Vec3 -arr = - expr2 Array - - -dot : Expression t -> Expression t -> Expression Float -dot l r = - dotted1 (call2Internal "dot" l r) + List.foldl (\e a -> add44 a e) h t @@ -820,27 +504,27 @@ dot l r = vec2Zero : Expression Vec2 vec2Zero = - vec2 zero zero + vec211 zero zero vec3Zero : Expression Vec3 vec3Zero = - vec3 zero zero zero + vec3111 zero zero zero vec4Zero : Expression Vec4 vec4Zero = - vec4 zero zero zero zero + vec41111 zero zero zero zero gl_FragColor : Expression Vec4 gl_FragColor = - dottedVariable4 "gl_FragColor" + var "gl_FragColor" gl_FragCoord : Expression Vec4 gl_FragCoord = - dottedVariable4 "gl_FragCoord" + var "gl_FragCoord" @@ -849,15 +533,6 @@ gl_FragCoord = ---------------- -unsafeCall : String -> List (Expression t) -> Expression r -unsafeCall name = - Expression << Call name << List.map (\(Expression e) -> e) - - -type Constant - = Constant - - zero : Expression Float zero = float 0 @@ -873,34 +548,6 @@ minusOne = float -1 -float : Float -> Expression Float -float f = - { base = Expression (Float f) - , isConstant = Constant - } - - -int : Int -> Expression Int -int i = - { base = Expression <| Int i - , isConstant = Constant - } - - -bool : Bool -> Expression Bool -bool b = - { base = Expression <| Bool b - , isConstant = Constant - } - - -constant : TypingFunction t r -> String -> Expression t -constant _ name = - { base = Expression <| Variable name - , isConstant = Constant - } - - floatToGlsl : Float -> String floatToGlsl f = let @@ -915,11 +562,44 @@ floatToGlsl f = +-- Utils + + +unsafeExpr1 : (Expr -> Expr) -> Expression a -> Expression b +unsafeExpr1 f (Expression l) = + Expression + { expr = f l.expr + , deps = l.deps + } + + +unsafeExpr2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c +unsafeExpr2 f (Expression l) (Expression r) = + Expression + { expr = f l.expr r.expr + , deps = + l.deps + |> SortedSet.insertAll r.deps + } + + +unsafeExpr3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d +unsafeExpr3 f (Expression l) (Expression m) (Expression r) = + Expression + { expr = f l.expr m.expr r.expr + , deps = + l.deps + |> SortedSet.insertAll m.deps + |> SortedSet.insertAll r.deps + } + + + -- STATEMENTS funInternal : TypedName t -> List ( String, String ) -> Statement t -> FunDecl -funInternal (TypedName (Type rt) (Name name)) args body = +funInternal (TypedName rt name) args body = let argsList = String.join ", " (List.map (\( t, n ) -> t ++ " " ++ n) args) @@ -927,7 +607,7 @@ funInternal (TypedName (Type rt) (Name name)) args body = FunDecl { name = name , type_ = - (args ++ [ ( rt, "" ) ]) + (args ++ [ ( typeToGlsl rt, "" ) ]) |> List.map Tuple.first |> String.join " -> " , body = @@ -940,17 +620,18 @@ funInternal (TypedName (Type rt) (Name name)) args body = argToString : TypedName t -> ( String, String ) -argToString (TypedName (Type t) (Name n)) = - ( t, n ) +argToString (TypedName t n) = + ( typeToGlsl t, n ) toVar : TypedName t -> Expression t -toVar (TypedName _ (Name n)) = - pure <| Variable n +toVar (TypedName _ n) = + --pure <| Variable n + Debug.todo "toVar" fun0 : - TypingFunction t c + TypingFunction c -> String -> (Continue () -> Statement t) -> ( FunDecl, c ) @@ -960,18 +641,19 @@ fun0 typeF name body = typeF name in ( funInternal typed [] (body nop) - , dotter <| call0Internal name + , -- dotter <| call0Internal name + Debug.todo "fun0" ) fun1 : - TypingFunction tr r + TypingFunction t -> String - -> ( TypedName ta a, Expression ta -> a ) - -> (a -> Continue () -> Statement tr) + -> ( TypedName a, Expression a -> a ) + -> (a -> Continue () -> Statement t) -> ( FunDecl - , ExpressionX xa ta -> r + , Expression a -> t ) fun1 typeF name ( arg0, _ ) body = let @@ -980,41 +662,43 @@ fun1 typeF name ( arg0, _ ) body = in ( funInternal typed [ argToString arg0 ] <| body (toVar arg0) nop - , dotter << call1Internal name + , --dotter << call1Internal name + Debug.todo "fun1" ) fun2 : - TypingFunction tr r + TypingFunction tr -> String - -> ( TypedName ta a, Expression ta -> a ) - -> ( TypedName tb b, Expression tb -> b ) + -> ( TypedName a, Expression ta -> a ) + -> ( TypedName b, Expression tb -> b ) -> (a -> b -> Continue () -> Statement tr) -> ( FunDecl - , ExpressionX xa ta -> ExpressionX xb tb -> r + , Expression ta -> Expression tb -> tr ) fun2 typeF name ( arg0, _ ) ( arg1, _ ) body = let - ( typed, dotter ) = + typed = typeF name in ( funInternal typed [ argToString arg0, argToString arg1 ] <| body (toVar arg0) (toVar arg1) nop - , \l r -> dotter (call2Internal name l r) + , -- \l r -> dotter (call2Internal name l r) + Debug.todo "fun2" ) fun3 : - TypingFunction tr r + TypingFunction tr -> String - -> ( TypedName ta a, Expression ta -> a ) - -> ( TypedName tb b, Expression tb -> b ) - -> ( TypedName tc c, Expression tc -> c ) + -> ( TypedName ta, Expression ta -> a ) + -> ( TypedName tb, Expression tb -> b ) + -> ( TypedName tc, Expression tc -> c ) -> (a -> b -> c -> Continue () -> Statement tr) -> ( FunDecl - , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> r + , Expression ta -> Expression tb -> Expression tc -> r ) fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = let @@ -1023,21 +707,22 @@ fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2 ] <| body (toVar arg0) (toVar arg1) (toVar arg2) nop - , \l m r -> dotter (call3Internal name l m r) + , --\l m r -> dotter (call3Internal name l m r) + Debug.todo "fun3" ) fun4 : - TypingFunction tr r + TypingFunction tr -> String - -> ( TypedName ta a, Expression ta -> a ) - -> ( TypedName tb b, Expression tb -> b ) - -> ( TypedName tc c, Expression tc -> c ) - -> ( TypedName td d, Expression td -> d ) + -> ( TypedName ta, Expression ta -> a ) + -> ( TypedName tb, Expression tb -> b ) + -> ( TypedName tc, Expression tc -> c ) + -> ( TypedName td, Expression td -> d ) -> (a -> b -> c -> d -> Continue () -> Statement tr) -> ( FunDecl - , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> r + , Expression ta -> Expression tb -> Expression tc -> Expression td -> r ) fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = let @@ -1046,22 +731,23 @@ fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3 ] <| body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) nop - , \l m n r -> dotter (call4Internal name l m n r) + , --\l m n r -> dotter (call4Internal name l m n r) + Debug.todo "fun4" ) fun5 : - TypingFunction tr r + TypingFunction tr -> String - -> ( TypedName ta a, Expression ta -> a ) - -> ( TypedName tb b, Expression tb -> b ) - -> ( TypedName tc c, Expression tc -> c ) - -> ( TypedName td d, Expression td -> d ) - -> ( TypedName te e, Expression te -> e ) + -> ( TypedName ta, Expression ta -> a ) + -> ( TypedName tb, Expression tb -> b ) + -> ( TypedName tc, Expression tc -> c ) + -> ( TypedName td, Expression td -> d ) + -> ( TypedName te, Expression te -> e ) -> (a -> b -> c -> d -> e -> Continue () -> Statement tr) -> ( FunDecl - , ExpressionX xa ta -> ExpressionX xb tb -> ExpressionX xc tc -> ExpressionX xd td -> ExpressionX xe te -> r + , Expression ta -> Expression tb -> Expression tc -> Expression td -> Expression te -> r ) fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body = let @@ -1070,37 +756,19 @@ fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body in ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3, argToString arg4 ] <| body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) (toVar arg4) nop - , \l m c n r -> dotter (call5Internal name l m c n r) + , -- \l m c n r -> dotter (call5Internal name l m c n r) + Debug.todo "fun5" ) -dottedVariable1 : String -> Expression t -dottedVariable1 v = - dotted1 (Expression (Variable v)) - - -dottedVariable2 : String -> Expression Vec2 -dottedVariable2 v = - dotted2 (Expression (Variable v)) - - -dottedVariable3 : String -> Expression Vec3 -dottedVariable3 v = - dotted3 (Expression (Variable v)) - - -dottedVariable4 : String -> Expression Vec4 -dottedVariable4 v = - dotted4 (Expression (Variable v)) - - type alias Continue s = () -> Statement s if_ : Expression Bool -> (Continue r -> Statement r) -> Continue r -> Statement r if_ cond ifTrue next = - Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) + -- Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) + Debug.todo "if_" ifElse : Expression Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s @@ -1109,7 +777,7 @@ ifElse cond ifTrue ifFalse next = for : - ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + ( String, Expression Int, Expression Int ) -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r @@ -1125,7 +793,7 @@ for ( var, from, to ) loop next = forLeq : - ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + ( String, Expression Int, Expression Int ) -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r @@ -1141,7 +809,7 @@ forLeq ( var, from, to ) loop next = forDown : - ( String, ExpressionX { a | isConstant : Constant } Int, ExpressionX { b | isConstant : Constant } Int ) + ( String, Expression Int, Expression Int ) -> (Expression Int -> Continue r -> Statement r) -> Continue r -> Statement r diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 6fb43f65..ea3ae7c5 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -2,9 +2,10 @@ module UI.Glsl.Plane exposing (Plane, asPlane, toGlsl) import Dict import Expression exposing (Expression) +import Glsl exposing (dot33) import Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, div, dot, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) +import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, div, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -35,24 +36,29 @@ asPlane e = ) -toGlsl : String -> Plane -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) +toGlsl : String -> Plane -> ( FunDecl, Expression Vec3 -> Expression Mat3 -> Expression Float -> Expression Vec3 -> Expression1 Bool ) toGlsl suffix (Plane { x, y, z, known }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> - -- a x + b y + c z + k = 0 - -- x = ox + t dx - -- y = oy + t dy - -- z = oz + t dz - -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 - -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) - -- t = - (k + dot abc o) / (dot abc d) - def vec3T "coeffs" (vec3 (float x) (float y) (float z)) <| \coeffs -> - def vec3T "dsum" (byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1)) <| \dsum -> - def floatT - "t" - (div - (negate_ <| add (float known) (dot coeffs o)) - (dot coeffs dsum) - ) - <| \t -> - expr (assign found <| add o <| byF t dsum) <| \_ -> - return (gt t <| threshold maxDistance) nop + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found nop -> + -- a x + b y + c z + k = 0 + -- x = ox + t dx + -- y = oy + t dy + -- z = oz + t dz + -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 + -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) + -- t = - (k + dot abc o) / (dot abc d) + def vec3T "coeffs" (vec3 (float x) (float y) (float z)) <| + \coeffs -> + def vec3T "dsum" (byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1)) <| + \dsum -> + def floatT + "t" + (div + (negate_ <| add (float known) (dot coeffs o)) + (dot33 coeffs dsum) + ) + <| + \t -> + expr (assign found <| add o <| byF t dsum) <| + \_ -> + return (gt t <| threshold maxDistance) nop diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 42f1018e..acc554ea 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -3,8 +3,9 @@ module UI.Glsl.Sphere exposing (Sphere, asSphere, toGlsl) import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) +import Glsl exposing (dot33) import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, bool, boolT, by, byF, def, dot, expr, false, float, floatT, fun4, if_, int, lt, mat3T, mix, negate_, out, return, sqrt_, subtract, true, vec3, vec3T, zero) +import UI.Glsl.Generator exposing (FunDecl, Mat3, Vec3, assign, bool, boolT, def, expr, float, floatT, fun4, if_, int, mat3T, out, return, vec3T, zero) import UI.Glsl.Polynomial as Polynomial @@ -73,20 +74,30 @@ reduce poly = ) -toGlsl : String -> Sphere -> ( FunDecl, ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool ) +toGlsl : String -> Sphere -> ( FunDecl, Expression Vec3 -> Expression Mat3 -> Expression Float -> Expression Vec3 -> Expression Bool ) toGlsl suffix (Sphere { center, radius }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> - def vec3T "center" (vec3 (float center.x) (float center.y) (float center.z)) <| \centerVar -> - def vec3T "to_center" (subtract o centerVar) <| \to_center -> - def floatT "b" (dot to_center (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))) <| \b -> - def floatT "c" (subtract (dot to_center to_center) (float <| radius * radius)) <| \c -> - def floatT "delta" (subtract (by b b) c) <| \delta -> - if_ (lt delta zero) - (return <| bool False) - <| \_ -> - def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| \x -> - if_ (lt x <| threshold maxDistance) - (return false) - <| \_ -> - expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> - return true nop + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found nop -> + def vec3T "center" (vec3 (float center.x) (float center.y) (float center.z)) <| + \centerVar -> + def vec3T "to_center" (subtract o centerVar) <| + \to_center -> + def floatT "b" (dot33 to_center (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))) <| + \b -> + def floatT "c" (subtract (dot33 to_center to_center) (float <| radius * radius)) <| + \c -> + def floatT "delta" (subtract (by b b) c) <| + \delta -> + if_ (lt delta zero) + (return <| bool False) + <| + \_ -> + def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| + \x -> + if_ (lt x <| threshold maxDistance) + (return false) + <| + \_ -> + expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| + \_ -> + return true nop From 4d481c286a8872ea79f9c4d557e2621beaa8d38b Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 18 Feb 2023 18:38:21 +0100 Subject: [PATCH 092/139] Using the new API --- Makefile | 4 +- codegen/Generate.elm | 54 +-- codegen/Glsl/PrettyPrinter.elm | 383 --------------------- codegen/helpers/Glsl.elm | 26 +- codegen/helpers/Glsl/Operations.elm | 87 ++++- codegen/helpers/Glsl/PrettyPrinter.elm | 330 ++++++++++++++++++ src/elm/UI/Glsl.elm | 5 +- src/elm/UI/Glsl/Code.elm | 30 +- src/elm/UI/Glsl/Generator.elm | 458 +++++++++++++------------ 9 files changed, 706 insertions(+), 671 deletions(-) delete mode 100644 codegen/Glsl/PrettyPrinter.elm create mode 100644 codegen/helpers/Glsl/PrettyPrinter.elm diff --git a/Makefile b/Makefile index d451b159..f8655389 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ELM_FILES = $(wildcard src/**/*.elm) -CODEGEN_FILES = $(wildcard codegen/*.elm) $(wildcard codegen/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) +CODEGEN_FILES = $(wildcard codegen/*.elm) $(wildcard codegen/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) $(wildcard codegen/helpers/*/*.elm) .PHONY: build build: generated/Glsl/Functions.elm src/optimized.js Makefile @@ -8,7 +8,7 @@ build: generated/Glsl/Functions.elm src/optimized.js Makefile src/optimized.js: $(ELM_FILES) Makefile elm-optimize-level-2 src/elm/UI.elm --output $@ -generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) Makefile +generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/Gen/Glsl.elm Makefile rm -rf generated elm-codegen run --flags-from $< diff --git a/codegen/Generate.elm b/codegen/Generate.elm index d568b330..7404a390 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -8,6 +8,7 @@ import Gen.Debug import Gen.Glsl import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Function, Stat(..), Statement(..), Type(..)) import Glsl.Parser +import Glsl.PrettyPrinter import List.Extra import Parser import Result.Extra @@ -283,6 +284,12 @@ typeToAnnotation type_ = TVoid -> Gen.Glsl.annotation_.void + TIn tt -> + Gen.Glsl.annotation_.in_ (typeToAnnotation tt) + + TOut tt -> + Gen.Glsl.annotation_.out (typeToAnnotation tt) + variableHasType : String -> Type -> Env -> Env variableHasType var type_ env = @@ -449,7 +456,7 @@ findDepsExpression env = Ok TFloat _ -> - Err <| "Don't know what the result of " ++ typeToString lt ++ "[" ++ typeToString rt ++ "] is" + Err <| "Don't know what the result of " ++ Glsl.PrettyPrinter.type_ lt ++ "[" ++ Glsl.PrettyPrinter.type_ rt ++ "] is" ) ) (Result.map2 Tuple.pair @@ -495,7 +502,7 @@ findDepsExpression env = Ok lt _ -> - Err <| "Don't know what the result of " ++ typeToString lt ++ " " ++ binaryOperationToString bop ++ " " ++ typeToString rt + Err <| "Don't know what the result of " ++ Glsl.PrettyPrinter.type_ lt ++ " " ++ binaryOperationToString bop ++ " " ++ Glsl.PrettyPrinter.type_ rt ) ) (Result.map2 Tuple.pair @@ -528,43 +535,6 @@ findDepsExpression env = go >> Result.map Tuple.second -typeToString : Type -> String -typeToString t = - case t of - TFloat -> - "float" - - TInt -> - "int" - - TVec2 -> - "vec2" - - TIVec2 -> - "ivec2" - - TVec3 -> - "vec3" - - TIVec3 -> - "ivec3" - - TVec4 -> - "vec4" - - TIVec4 -> - "ivec4" - - TMat3 -> - "mat3" - - TVoid -> - "void" - - TBool -> - "bool" - - binaryOperationToString : BinaryOperation -> String binaryOperationToString bop = case bop of @@ -628,6 +598,12 @@ typeToShort t = TBool -> "b1" + TIn tt -> + "n" ++ typeToShort tt + + TOut tt -> + "o" ++ typeToShort tt + builtinUniforms : Dict String Type builtinUniforms = diff --git a/codegen/Glsl/PrettyPrinter.elm b/codegen/Glsl/PrettyPrinter.elm deleted file mode 100644 index e6454e75..00000000 --- a/codegen/Glsl/PrettyPrinter.elm +++ /dev/null @@ -1,383 +0,0 @@ -module Glsl.PrettyPrinter exposing (function, statement) - -import Glsl.Types exposing (BinaryOperation(..), BooleanOperation(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Step(..), Trailing(..)) - - -function : Function -> String -function fun = - if fun.hasSuffix then - "(" - ++ fun.name - ++ "Decl, " - ++ fun.name - ++ ") = fun" - ++ String.fromInt (List.length fun.args) - ++ " " - ++ prettyPrintType fun.returnType - ++ "T " - ++ "(\"" - ++ fun.name - ++ "\" ++ suffix)" - ++ " " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ prettyPrintType t ++ "T \"" ++ n ++ "\")") fun.args) - ++ " <| \\" - ++ String.join " " (List.map Tuple.second fun.args) - ++ " -> " - ++ (statement fun.stat |> String.split "\n" |> String.join " ") - - else - fun.name - ++ "Couple = fun" - ++ String.fromInt (List.length fun.args) - ++ " " - ++ prettyPrintType fun.returnType - ++ "T \"" - ++ fun.name - ++ "\" " - ++ String.join " " (List.map (\( t, n ) -> "(" ++ prettyPrintType t ++ "T \"" ++ n ++ "\")") fun.args) - ++ " <| \\" - ++ String.join " " (List.map Tuple.second fun.args) - ++ " ->\n " - ++ (statement fun.stat |> String.split "\n" |> String.join "\n ") - ++ "\n\n" - ++ fun.name - ++ "Decl = Tuple.first " - ++ fun.name - ++ "Couple\n" - ++ fun.name - ++ " = Tuple.second " - ++ fun.name - ++ "Couple" - - -statement : Statement -> String -statement stat = - case stat of - Expression e next -> - "expr " - ++ prettyPrintExpression e - ++ " <| \\_ ->\n" - ++ statement next - - For { var, from, op, to, step, direction } next -> - case op of - LessThan -> - (if direction == PlusPlus then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement step - ++ ") <| \\_ ->\n" - ++ statement next - - LessThanOrEquals -> - (if direction == PlusPlus then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement step - ++ ") <| \\_ ->\n" - ++ statement next - - GreaterThan -> - (if direction == PlusPlus then - "for (\"" - - else - "forDown (\"" - ) - ++ var - ++ "\", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement step - ++ ") <| \\_ ->\n" - ++ statement next - - GreaterThanOrEquals -> - (if direction == PlusPlus then - "forLeq (\"" - - else - "forLeqDown (\"" - ) - ++ var - ++ ", " - ++ prettyPrintExpression from - ++ ", " - ++ prettyPrintExpression to - ++ ") (\\" - ++ var - ++ " ->\n" - ++ statement step - ++ ") <| \\_ ->\n" - ++ statement next - - Equals -> - "TODO branch 'Equals' not implemented" - - NotEquals -> - "TODO branch 'NotEquals' not implemented" - - Assign -> - "TODO branch 'Assign' not implemented" - - If cond ifTrue next -> - "if_ " - ++ prettyPrintExpression cond - ++ "(\n" - ++ statement ifTrue - ++ ") <| \\_ ->\n" - ++ statement next - - Return e -> - "(return <| " ++ prettyPrintExpression e ++ ")\n" - - Nop -> - "nop\n" - - Def { type_, var, val } next -> - "def " - ++ prettyPrintType type_ - ++ "T \"" - ++ var - ++ "\" (" - ++ prettyPrintExpression val - ++ ") <| \\" - ++ var - ++ " -> \n" - ++ statement next - - Decl _ _ -> - "TODO branch 'Decl _ _ _' not implemented" - - -prettyPrintType : Type -> String -prettyPrintType type_ = - case type_ of - TFloat -> - "float" - - TInt -> - "int" - - TVec2 -> - "vec2" - - TIVec2 -> - "ivec2" - - TIVec3 -> - "ivec3" - - TIVec4 -> - "ivec4" - - TVec3 -> - "vec3" - - TVec4 -> - "vec4" - - TMat3 -> - "mat3" - - TVoid -> - "void" - - TBool -> - "bool" - - -prettyPrintExpression : Expression -> String -prettyPrintExpression e = - let - parens args = - "(" ++ String.join " " args ++ ")" - in - case e of - Float f -> - if f == 0 then - "zero" - - else if f == 1 then - "one" - - else - parens [ "float", String.fromFloat f ] - - Int i -> - parens [ "int", String.fromInt i ] - - Bool b -> - parens - [ "bool" - , if b then - "True" - - else - "False" - ] - - Dot v sw -> - prettyPrintExpression v ++ "." ++ sw - - Variable v -> - v - - Constant c -> - case String.split "_" c of - [] -> - "constants.???" - - h :: t -> - let - toTitle s = - case String.uncons s of - Nothing -> - "" - - Just ( sh, st ) -> - String.cons (Char.toUpper sh) (String.toLower st) - in - "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) - - Call "float" [ arg ] -> - parens [ "floatCast", prettyPrintExpression arg ] - - Call n args -> - if String.startsWith "vec" n then - if List.all ((==) (Int 0)) args then - n ++ "Zero" - - else - parens <| - n - :: List.map - (\c -> - case c of - Int i -> - prettyPrintExpression (Float <| toFloat i) - - _ -> - prettyPrintExpression c - ) - args - - else if n == "atan" then - if List.length args == 2 then - parens <| "atan2_" :: List.map prettyPrintExpression args - - else - parens <| "atan_" :: List.map prettyPrintExpression args - - else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then - parens <| (n ++ "_") :: List.map prettyPrintExpression args - - else - parens <| n :: List.map prettyPrintExpression args - - Arr l r -> - parens [ "arr", prettyPrintExpression l, prettyPrintExpression r ] - - Ternary c l r -> - parens [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] - - UnaryOperation Negate ex -> - parens [ "negate_", prettyPrintExpression ex ] - - BinaryOperation op l r -> - parens [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] - - BooleanOperation op es -> - parens - [ prettyPrintBooleanOperation op - , "[" - , String.join ", " <| List.map prettyPrintExpression es - , "]" - ] - - RelationOperation rop l r -> - parens [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] - - PostfixIncrement c -> - parens [ "postfixIncrement", prettyPrintExpression c ] - - PostfixDecrement c -> - parens [ "postfixDecrement", prettyPrintExpression c ] - - -prettyPrintRelationOperation : RelationOperation -> String -prettyPrintRelationOperation op = - case op of - LessThan -> - "lt" - - LessThanOrEquals -> - "leq" - - Equals -> - "eq" - - Assign -> - "assign" - - NotEquals -> - "neq" - - GreaterThanOrEquals -> - "geq" - - GreaterThan -> - "gt" - - -prettyPrintBooleanOperation : BooleanOperation -> String -prettyPrintBooleanOperation op = - case op of - And -> - "ands" - - Or -> - "ors" - - -prettyPrintBinaryOperation : BinaryOperation -> String -prettyPrintBinaryOperation op = - case op of - Add -> - "add" - - Subtract -> - "subtract" - - By -> - "by" - - Div -> - "div" diff --git a/codegen/helpers/Glsl.elm b/codegen/helpers/Glsl.elm index 0f51bf54..e050752d 100644 --- a/codegen/helpers/Glsl.elm +++ b/codegen/helpers/Glsl.elm @@ -5,8 +5,8 @@ module Glsl exposing , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) , true, false, int, float, var , TypingFunction, TypedName(..), Type(..) - , Vec2(..), Vec3(..), Vec4(..), IVec2, IVec3, IVec4, Mat3(..), Void - , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4 + , Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out + , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 , unsafeMap, unsafeMap2, unsafeMap3 ) @@ -29,17 +29,16 @@ module Glsl exposing # Typelevel types @docs TypingFunction, TypedName, Type -@docs Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void +@docs Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out # Escape hatches -@docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4 +@docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 @docs unsafeMap, unsafeMap2, unsafeMap3 -} -import Set exposing (Set) import SortedSet exposing (SortedSet) @@ -72,6 +71,11 @@ unsafeCall4 name deps (Expression arg0) (Expression arg1) (Expression arg2) (Exp unsafeCall name deps [ arg0, arg1, arg2, arg3 ] +unsafeCall5 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression x -> Expression r +unsafeCall5 name deps (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) (Expression arg4) = + unsafeCall name deps [ arg0, arg1, arg2, arg3, arg4 ] + + unsafeCall : String -> List String -> List ExprWithDeps -> Expression t unsafeCall name deps args = Expression @@ -193,7 +197,7 @@ type ComboOperation type Statement r = Statement { stat : Stat - , deps : Set String + , deps : SortedSet String } @@ -234,6 +238,8 @@ type Type | TIVec3 | TIVec4 | TMat3 + | TIn Type + | TOut Type @@ -272,6 +278,14 @@ type Void = Void Void +type In t + = In (In t) + + +type Out t + = Out (Out t) + + -- Utils diff --git a/codegen/helpers/Glsl/Operations.elm b/codegen/helpers/Glsl/Operations.elm index c51c7fa6..68b65b7d 100644 --- a/codegen/helpers/Glsl/Operations.elm +++ b/codegen/helpers/Glsl/Operations.elm @@ -1,4 +1,9 @@ -module Glsl.Operations exposing (add11, add22, add33, add44) +module Glsl.Operations exposing + ( add11, add22, add33, add44 + , subtract11, subtract22, subtract33, subtract44 + , negate1, negate2, negate3, negate4 + , by11, by22, by33, by44 + ) {-| @@ -6,10 +11,13 @@ module Glsl.Operations exposing (add11, add22, add33, add44) # Addition @docs add11, add22, add33, add44 +@docs subtract11, subtract22, subtract33, subtract44 +@docs negate1, negate2, negate3, negate4 +@docs by11, by22, by33, by44 -} -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Vec2, Vec3, Vec4) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), UnaryOperation(..), Vec2, Vec3, Vec4) add11 : Expression Float -> Expression Float -> Expression Float @@ -35,3 +43,78 @@ add44 = add : Expression a -> Expression a -> Expression a add l r = Glsl.unsafeMap2 (BinaryOperation Add) l r + + +subtract11 : Expression Float -> Expression Float -> Expression Float +subtract11 = + subtract + + +subtract22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 +subtract22 = + subtract + + +subtract33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 +subtract33 = + subtract + + +subtract44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 +subtract44 = + subtract + + +subtract : Expression a -> Expression a -> Expression a +subtract l r = + Glsl.unsafeMap2 (BinaryOperation Subtract) l r + + +negate1 : Expression Float -> Expression Float +negate1 = + negate + + +negate2 : Expression Vec2 -> Expression Vec2 +negate2 = + negate + + +negate3 : Expression Vec3 -> Expression Vec3 +negate3 = + negate + + +negate4 : Expression Vec4 -> Expression Vec4 +negate4 = + negate + + +negate : Expression a -> Expression a +negate l = + Glsl.unsafeMap (UnaryOperation Negate) l + + +by11 : Expression Float -> Expression Float -> Expression Float +by11 = + by + + +by22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 +by22 = + by + + +by33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 +by33 = + by + + +by44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 +by44 = + by + + +by : Expression a -> Expression a -> Expression a +by l r = + Glsl.unsafeMap2 (BinaryOperation By) l r diff --git a/codegen/helpers/Glsl/PrettyPrinter.elm b/codegen/helpers/Glsl/PrettyPrinter.elm new file mode 100644 index 00000000..bd25f848 --- /dev/null +++ b/codegen/helpers/Glsl/PrettyPrinter.elm @@ -0,0 +1,330 @@ +module Glsl.PrettyPrinter exposing (type_) + +import Glsl exposing (BinaryOperation(..), Expression(..), ForDirection(..), RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Step(..), Trailing(..)) + + + +-- function : Function -> String +-- function fun = +-- if fun.hasSuffix then +-- "(" +-- ++ fun.name +-- ++ "Decl, " +-- ++ fun.name +-- ++ ") = fun" +-- ++ String.fromInt (List.length fun.args) +-- ++ " " +-- ++ type_ fun.returnType +-- ++ "T " +-- ++ "(\"" +-- ++ fun.name +-- ++ "\" ++ suffix)" +-- ++ " " +-- ++ String.join " " (List.map (\( t, n ) -> "(" ++ type_ t ++ "T \"" ++ n ++ "\")") fun.args) +-- ++ " <| \\" +-- ++ String.join " " (List.map Tuple.second fun.args) +-- ++ " -> " +-- ++ (statement fun.stat |> String.split "\n" |> String.join " ") +-- else +-- fun.name +-- ++ "Couple = fun" +-- ++ String.fromInt (List.length fun.args) +-- ++ " " +-- ++ type_ fun.returnType +-- ++ "T \"" +-- ++ fun.name +-- ++ "\" " +-- ++ String.join " " (List.map (\( t, n ) -> "(" ++ type_ t ++ "T \"" ++ n ++ "\")") fun.args) +-- ++ " <| \\" +-- ++ String.join " " (List.map Tuple.second fun.args) +-- ++ " ->\n " +-- ++ (statement fun.stat |> String.split "\n" |> String.join "\n ") +-- ++ "\n\n" +-- ++ fun.name +-- ++ "Decl = Tuple.first " +-- ++ fun.name +-- ++ "Couple\n" +-- ++ fun.name +-- ++ " = Tuple.second " +-- ++ fun.name +-- ++ "Couple" +-- statement : Statement -> String +-- statement stat = +-- case stat of +-- Expression e next -> +-- "expr " +-- ++ prettyPrintExpression e +-- ++ " <| \\_ ->\n" +-- ++ statement next +-- For { var, from, op, to, step, direction } next -> +-- case op of +-- LessThan -> +-- (if direction == PlusPlus then +-- "for (\"" +-- else +-- "forDown (\"" +-- ) +-- ++ var +-- ++ "\", " +-- ++ prettyPrintExpression from +-- ++ ", " +-- ++ prettyPrintExpression to +-- ++ ") (\\" +-- ++ var +-- ++ " ->\n" +-- ++ statement step +-- ++ ") <| \\_ ->\n" +-- ++ statement next +-- LessThanOrEquals -> +-- (if direction == PlusPlus then +-- "forLeq (\"" +-- else +-- "forLeqDown (\"" +-- ) +-- ++ var +-- ++ ", " +-- ++ prettyPrintExpression from +-- ++ ", " +-- ++ prettyPrintExpression to +-- ++ ") (\\" +-- ++ var +-- ++ " ->\n" +-- ++ statement step +-- ++ ") <| \\_ ->\n" +-- ++ statement next +-- GreaterThan -> +-- (if direction == PlusPlus then +-- "for (\"" +-- else +-- "forDown (\"" +-- ) +-- ++ var +-- ++ "\", " +-- ++ prettyPrintExpression from +-- ++ ", " +-- ++ prettyPrintExpression to +-- ++ ") (\\" +-- ++ var +-- ++ " ->\n" +-- ++ statement step +-- ++ ") <| \\_ ->\n" +-- ++ statement next +-- GreaterThanOrEquals -> +-- (if direction == PlusPlus then +-- "forLeq (\"" +-- else +-- "forLeqDown (\"" +-- ) +-- ++ var +-- ++ ", " +-- ++ prettyPrintExpression from +-- ++ ", " +-- ++ prettyPrintExpression to +-- ++ ") (\\" +-- ++ var +-- ++ " ->\n" +-- ++ statement step +-- ++ ") <| \\_ ->\n" +-- ++ statement next +-- Equals -> +-- "TODO branch 'Equals' not implemented" +-- NotEquals -> +-- "TODO branch 'NotEquals' not implemented" +-- Assign -> +-- "TODO branch 'Assign' not implemented" +-- If cond ifTrue next -> +-- "if_ " +-- ++ prettyPrintExpression cond +-- ++ "(\n" +-- ++ statement ifTrue +-- ++ ") <| \\_ ->\n" +-- ++ statement next +-- Return e -> +-- "(return <| " ++ prettyPrintExpression e ++ ")\n" +-- Nop -> +-- "nop\n" +-- Def { type_, var, val } next -> +-- "def " +-- ++ type_ type_ +-- ++ "T \"" +-- ++ var +-- ++ "\" (" +-- ++ prettyPrintExpression val +-- ++ ") <| \\" +-- ++ var +-- ++ " -> \n" +-- ++ statement next +-- Decl _ _ -> +-- "TODO branch 'Decl _ _ _' not implemented" + + +type_ : Type -> String +type_ t = + case t of + TFloat -> + "float" + + TInt -> + "int" + + TVec2 -> + "vec2" + + TIVec2 -> + "ivec2" + + TVec3 -> + "vec3" + + TIVec3 -> + "ivec3" + + TVec4 -> + "vec4" + + TIVec4 -> + "ivec4" + + TMat3 -> + "mat3" + + TVoid -> + "void" + + TBool -> + "bool" + + TIn tt -> + "in " ++ type_ tt + + TOut tt -> + "out " ++ type_ tt + + + +-- prettyPrintExpression : Expression -> String +-- prettyPrintExpression e = +-- let +-- parens args = +-- "(" ++ String.join " " args ++ ")" +-- in +-- case e of +-- Float f -> +-- if f == 0 then +-- "zero" +-- else if f == 1 then +-- "one" +-- else +-- parens [ "float", String.fromFloat f ] +-- Int i -> +-- parens [ "int", String.fromInt i ] +-- Bool b -> +-- parens +-- [ "bool" +-- , if b then +-- "True" +-- else +-- "False" +-- ] +-- Dot v sw -> +-- prettyPrintExpression v ++ "." ++ sw +-- Variable v -> +-- v +-- Constant c -> +-- case String.split "_" c of +-- [] -> +-- "constants.???" +-- h :: t -> +-- let +-- toTitle s = +-- case String.uncons s of +-- Nothing -> +-- "" +-- Just ( sh, st ) -> +-- String.cons (Char.toUpper sh) (String.toLower st) +-- in +-- "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) +-- Call "float" [ arg ] -> +-- parens [ "floatCast", prettyPrintExpression arg ] +-- Call n args -> +-- if String.startsWith "vec" n then +-- if List.all ((==) (Int 0)) args then +-- n ++ "Zero" +-- else +-- parens <| +-- n +-- :: List.map +-- (\c -> +-- case c of +-- Int i -> +-- prettyPrintExpression (Float <| toFloat i) +-- _ -> +-- prettyPrintExpression c +-- ) +-- args +-- else if n == "atan" then +-- if List.length args == 2 then +-- parens <| "atan2_" :: List.map prettyPrintExpression args +-- else +-- parens <| "atan_" :: List.map prettyPrintExpression args +-- else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then +-- parens <| (n ++ "_") :: List.map prettyPrintExpression args +-- else +-- parens <| n :: List.map prettyPrintExpression args +-- Arr l r -> +-- parens [ "arr", prettyPrintExpression l, prettyPrintExpression r ] +-- Ternary c l r -> +-- parens [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] +-- UnaryOperation Negate ex -> +-- parens [ "negate_", prettyPrintExpression ex ] +-- BinaryOperation op l r -> +-- parens [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] +-- BooleanOperation op es -> +-- parens +-- [ prettyPrintBooleanOperation op +-- , "[" +-- , String.join ", " <| List.map prettyPrintExpression es +-- , "]" +-- ] +-- RelationOperation rop l r -> +-- parens [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] +-- PostfixIncrement c -> +-- parens [ "postfixIncrement", prettyPrintExpression c ] +-- PostfixDecrement c -> +-- parens [ "postfixDecrement", prettyPrintExpression c ] +-- prettyPrintRelationOperation : RelationOperation -> String +-- prettyPrintRelationOperation op = +-- case op of +-- LessThan -> +-- "lt" +-- LessThanOrEquals -> +-- "leq" +-- Equals -> +-- "eq" +-- Assign -> +-- "assign" +-- NotEquals -> +-- "neq" +-- GreaterThanOrEquals -> +-- "geq" +-- GreaterThan -> +-- "gt" +-- prettyPrintBooleanOperation : BooleanOperation -> String +-- prettyPrintBooleanOperation op = +-- case op of +-- And -> +-- "ands" +-- Or -> +-- "ors" +-- prettyPrintBinaryOperation : BinaryOperation -> String +-- prettyPrintBinaryOperation op = +-- case op of +-- Add -> +-- "add" +-- Subtract -> +-- "subtract" +-- By -> +-- "by" +-- Div -> +-- "div" diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index bfb97d88..437cf120 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -5,11 +5,10 @@ import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expre import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, minus, plus, square) -import Glsl.Helper import Maybe.Extra as Maybe import SortedAnySet as Set -import UI.Glsl.Code exposing (atanPlusDecl, constantToGlsl, dupDecl, gnumDecl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, expr, fileToGlsl, unknown) +import UI.Glsl.Code exposing (constantToGlsl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, expr, fileToGlsl) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index ce9a9279..55d4e7b3 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,8 +2,10 @@ module UI.Glsl.Code exposing (expressionToGlsl, threshold) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl.Functions exposing (cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, vec21, vec211) -import UI.Glsl.Generator exposing (Vec2, abs2, add2, by, exp, expr, float, negate2, one, subtract, subtract2, vec2Zero, zero) +import Glsl exposing (Expression, Vec2, float) +import Glsl.Functions exposing (abs2, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, exp1, vec21, vec211) +import Glsl.Operations exposing (add22, by11, negate2, subtract22) +import UI.Glsl.Generator exposing (expr, one, vec2Zero, zero) expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 @@ -29,10 +31,10 @@ expressionToGlsl context = vec211 zero one PVariable "pi" -> - vec211 constants.pi zero + vec211 (float pi) zero PVariable "e" -> - vec211 (exp one) zero + vec211 (exp1 one) zero PVariable v -> case Dict.get v ctx of @@ -52,30 +54,30 @@ expressionToGlsl context = negate2 <| go expression PAdd l (PNegate r) -> - subtract2 (go l) (go r) + subtract22 (go l) (go r) PAdd l r -> - add2 (go l) (go r) + add22 (go l) (go r) PRel op l r -> case op of LessThan -> - subtract2 (go r) (go l) + subtract22 (go r) (go l) LessThanOrEquals -> - subtract2 (go r) (go l) + subtract22 (go r) (go l) NotEquals -> - abs2 <| subtract (go r) (go l) + abs2 <| subtract22 (go r) (go l) Equals -> - abs2 <| subtract (go r) (go l) + abs2 <| subtract22 (go r) (go l) GreaterThanOrEquals -> - subtract2 (go l) (go r) + subtract22 (go l) (go r) GreaterThan -> - subtract2 (go l) (go r) + subtract22 (go l) (go r) PBy l r -> cby22 (go l) (go r) @@ -86,7 +88,7 @@ expressionToGlsl context = PPower (PVariable v) (PInteger 2) -> case Dict.get v ctx of Just w -> - vec211 (by w w) zero + vec211 (by11 w w) zero Nothing -> vec2Zero @@ -196,4 +198,4 @@ expressionToGlsl context = threshold : Expression Float -> Expression Float threshold max_distance = - by (float 0.000001) max_distance + by11 (float 0.000001) max_distance diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index 22490772..daab31c2 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,7 +1,7 @@ -module UI.Glsl.Generator exposing (Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), Mat3, Vec2, Vec3, Vec4, adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, boolT, break, continue, decl, def, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) +module UI.Glsl.Generator exposing (Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, boolT, break, continue, decl, def, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) import Dict exposing (Dict) -import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), false, float, int, true, unsafeMap2, unsafeMap3) +import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, false, float, int, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var) import Glsl.Functions exposing (vec211, vec3111, vec41111) import Glsl.Operations exposing (add11, add22, add33, add44) import Set @@ -172,6 +172,12 @@ typeToGlsl type_ = TMat3 -> "mat3" + TIn t -> + "in " ++ typeToGlsl t + + TOut t -> + "out " ++ typeToGlsl t + relationToString : RelationOperation -> String relationToString rel = @@ -205,7 +211,7 @@ nop = internalNop : Continue a internalNop () = - Statement { stat = Nop, deps = Set.empty } + Statement { stat = Nop, deps = SortedSet.empty } expressionToGlsl : Expression t -> String @@ -598,25 +604,17 @@ unsafeExpr3 f (Expression l) (Expression m) (Expression r) = -- STATEMENTS -funInternal : TypedName t -> List ( String, String ) -> Statement t -> FunDecl -funInternal (TypedName rt name) args body = +functionToGlsl : TypedName t -> List ( Type, String ) -> Statement t -> String +functionToGlsl (TypedName rt name) args body = let argsList = - String.join ", " (List.map (\( t, n ) -> t ++ " " ++ n) args) + String.join ", " (List.map (\( t, n ) -> typeToGlsl t ++ " " ++ n) args) in - FunDecl - { name = name - , type_ = - (args ++ [ ( typeToGlsl rt, "" ) ]) - |> List.map Tuple.first - |> String.join " -> " - , body = - String.join "\n" <| - [ rt ++ " " ++ name ++ "(" ++ argsList ++ ") {" - , statementToGlsl body - , "}" - ] - } + String.join "\n" <| + [ typeToGlsl rt ++ " " ++ name ++ "(" ++ argsList ++ ") {" + , statementToGlsl body + , "}" + ] argToString : TypedName t -> ( String, String ) @@ -630,135 +628,140 @@ toVar (TypedName _ n) = Debug.todo "toVar" -fun0 : - TypingFunction c +funX : + (String + -> List String + -> a + ) + -> TypingFunction t -> String - -> (Continue () -> Statement t) - -> ( FunDecl, c ) -fun0 typeF name body = + -> Statement t + -> List ( Type, String ) + -> a +funX call typeF name body args = let - ( typed, dotter ) = + typed = typeF name + + (Statement s) = + body + + funGlsl = + functionToGlsl typed args body in - ( funInternal typed [] (body nop) - , -- dotter <| call0Internal name - Debug.todo "fun0" - ) + call name + (s.deps + |> SortedSet.insert funGlsl + |> SortedSet.toList + ) + + +fun0 : + TypingFunction t + -> String + -> Statement t + -> Expression t +fun0 typeF name body = + funX unsafeCall0 + typeF + name + body + [] fun1 : TypingFunction t -> String - -> ( TypedName a, Expression a -> a ) - -> (a -> Continue () -> Statement t) - -> - ( FunDecl - , Expression a -> t - ) -fun1 typeF name ( arg0, _ ) body = - let - ( typed, dotter ) = - typeF name - in - ( funInternal typed [ argToString arg0 ] <| - body (toVar arg0) nop - , --dotter << call1Internal name - Debug.todo "fun1" - ) + -> TypedName a + -> (Expression a -> Statement t) + -> Expression a + -> Expression r +fun1 typeF name (TypedName t0 arg0) body = + funX unsafeCall1 + typeF + name + (body (var arg0)) + [ ( t0, arg0 ) ] fun2 : - TypingFunction tr + TypingFunction t -> String - -> ( TypedName a, Expression ta -> a ) - -> ( TypedName b, Expression tb -> b ) - -> (a -> b -> Continue () -> Statement tr) - -> - ( FunDecl - , Expression ta -> Expression tb -> tr - ) -fun2 typeF name ( arg0, _ ) ( arg1, _ ) body = - let - typed = - typeF name - in - ( funInternal typed [ argToString arg0, argToString arg1 ] <| - body (toVar arg0) (toVar arg1) nop - , -- \l r -> dotter (call2Internal name l r) - Debug.todo "fun2" - ) + -> TypedName a + -> TypedName b + -> (Expression a -> Expression b -> Statement t) + -> Expression a + -> Expression b + -> Expression t +fun2 typeF name (TypedName t0 arg0) (TypedName t1 arg1) body = + funX unsafeCall2 + typeF + name + (body (var arg0) (var arg1)) + [ ( t0, arg0 ), ( t1, arg1 ) ] fun3 : - TypingFunction tr + TypingFunction t -> String - -> ( TypedName ta, Expression ta -> a ) - -> ( TypedName tb, Expression tb -> b ) - -> ( TypedName tc, Expression tc -> c ) - -> (a -> b -> c -> Continue () -> Statement tr) - -> - ( FunDecl - , Expression ta -> Expression tb -> Expression tc -> r - ) -fun3 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) body = - let - ( typed, dotter ) = - typeF name - in - ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) nop - , --\l m r -> dotter (call3Internal name l m r) - Debug.todo "fun3" - ) + -> TypedName a + -> TypedName b + -> TypedName c + -> (Expression a -> Expression b -> Expression c -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression t +fun3 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) body = + funX unsafeCall3 + typeF + name + (body (var arg0) (var arg1) (var arg2)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ) ] fun4 : - TypingFunction tr + TypingFunction t -> String - -> ( TypedName ta, Expression ta -> a ) - -> ( TypedName tb, Expression tb -> b ) - -> ( TypedName tc, Expression tc -> c ) - -> ( TypedName td, Expression td -> d ) - -> (a -> b -> c -> d -> Continue () -> Statement tr) - -> - ( FunDecl - , Expression ta -> Expression tb -> Expression tc -> Expression td -> r - ) -fun4 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) body = - let - ( typed, dotter ) = - typeF name - in - ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) nop - , --\l m n r -> dotter (call4Internal name l m n r) - Debug.todo "fun4" - ) + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> (Expression a -> Expression b -> Expression c -> Expression d -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression d + -> Expression t +fun4 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) body = + funX unsafeCall4 + typeF + name + (body (var arg0) (var arg1) (var arg2) (var arg3)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ) ] fun5 : - TypingFunction tr + TypingFunction t -> String - -> ( TypedName ta, Expression ta -> a ) - -> ( TypedName tb, Expression tb -> b ) - -> ( TypedName tc, Expression tc -> c ) - -> ( TypedName td, Expression td -> d ) - -> ( TypedName te, Expression te -> e ) - -> (a -> b -> c -> d -> e -> Continue () -> Statement tr) - -> - ( FunDecl - , Expression ta -> Expression tb -> Expression tc -> Expression td -> Expression te -> r - ) -fun5 typeF name ( arg0, _ ) ( arg1, _ ) ( arg2, _ ) ( arg3, _ ) ( arg4, _ ) body = - let - ( typed, dotter ) = - typeF name - in - ( funInternal typed [ argToString arg0, argToString arg1, argToString arg2, argToString arg3, argToString arg4 ] <| - body (toVar arg0) (toVar arg1) (toVar arg2) (toVar arg3) (toVar arg4) nop - , -- \l m c n r -> dotter (call5Internal name l m c n r) - Debug.todo "fun5" - ) + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> TypedName e + -> (Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression d + -> Expression e + -> Expression t +fun5 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) (TypedName t4 arg4) body = + funX unsafeCall5 + typeF + name + (body (var arg0) (var arg1) (var arg2) (var arg3) (var arg4)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ), ( t4, arg4 ) ] type alias Continue s = @@ -773,7 +776,8 @@ if_ cond ifTrue next = ifElse : Expression Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s ifElse cond ifTrue ifFalse next = - Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) + --Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) + Debug.todo "ifElse" for : @@ -782,14 +786,15 @@ for : -> Continue r -> Statement r for ( var, from, to ) loop next = - Statement <| - For var - (unwrapExpression from) - LessThan - (unwrapExpression to) - (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) internalNop) - (unwrapLazyStatement next) + -- Statement <| + -- For var + -- (unwrapExpression from) + -- LessThan + -- (unwrapExpression to) + -- (PostfixIncrement (Variable var)) + -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) + -- (unwrapLazyStatement next) + Debug.todo "for" forLeq : @@ -798,14 +803,15 @@ forLeq : -> Continue r -> Statement r forLeq ( var, from, to ) loop next = - Statement <| - For var - (unwrapExpression from) - LessThanOrEquals - (unwrapExpression to) - (PostfixIncrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) internalNop) - (unwrapLazyStatement next) + -- Statement <| + -- For var + -- (unwrapExpression from) + -- LessThanOrEquals + -- (unwrapExpression to) + -- (PostfixIncrement (Variable var)) + -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) + -- (unwrapLazyStatement next) + Debug.todo "forLeq" forDown : @@ -814,58 +820,71 @@ forDown : -> Continue r -> Statement r forDown ( var, from, to ) loop next = - Statement <| - For var - (unwrapExpression from) - GreaterThan - (unwrapExpression to) - (PostfixDecrement (Variable var)) - (unwrapStatement <| loop (dottedVariable1 var) internalNop) - (unwrapLazyStatement next) - - -return : ExpressionXr -> Continue x -> Statement r + -- Statement <| + -- For var + -- (unwrapExpression from) + -- GreaterThan + -- (unwrapExpression to) + -- (PostfixDecrement (Variable var)) + -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) + -- (unwrapLazyStatement next) + Debug.todo "forDown" + + +return : Expression r -> Continue x -> Statement r return e _ = - Statement <| Return <| unwrapExpression e + -- Statement <| Return <| unwrapExpression e + Debug.todo "return" break : Continue a -> Statement a break _ = - Statement Break + -- Statement Break + Debug.todo "break" continue : Continue a -> Statement a continue _ = - Statement Continue + -- Statement Continue + Debug.todo "continue" -decl : TypingFunction tv v -> String -> (v -> Statement tr) -> Statement tr +decl : TypingFunction t -> String -> (Expression t -> Statement r) -> Statement r decl typeF name k = let - ( TypedName (Type t) n e, _ ) = + (TypedName t n) = typeF name (Statement ks) = - k e + k (var n) in - Statement <| Decl t n Nothing ks + Statement + { stat = Decl t n Nothing ks.stat + , deps = ks.deps + } -def : TypingFunction tv v -> String -> ExpressionX xv tv -> (v -> Statement tr) -> Statement tr -def typeF name v k = +def : TypingFunction t -> String -> Expression t -> (Expression t -> Statement r) -> Statement r +def typeF name (Expression v) k = let - ( TypedName (Type t) n e, _ ) = + (TypedName t n) = typeF name (Statement ks) = - k e + k (var n) in - Statement <| Decl t n (Just <| unwrapExpression v) ks + Statement + { stat = Decl t n (Just v.expr) ks.stat + , deps = + ks.deps + |> SortedSet.insertAll v.deps + } assign : Expression t -> Expression t -> Expression t assign name e = - dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) + -- dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) + Debug.todo "assign" unwrapLazyStatement : Continue r -> Stat @@ -874,105 +893,93 @@ unwrapLazyStatement f = (Statement next) = f () in - next + -- next + Debug.todo "unwrapLazyStatement" unwrapStatement : Statement r -> Stat -unwrapStatement (Statement next) = - next +unwrapStatement (Statement { stat }) = + stat expr : Expression t -> Continue q -> Statement q expr e next = - Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) + -- Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) + Debug.todo "expr" assignAdd : Expression t -> Expression t -> Continue q -> Statement q assignAdd name e next = - Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) + -- Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) + Debug.todo "assignAdd" assignBy : Expression t -> Expression t -> Continue q -> Statement q assignBy name e next = - Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) + -- Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) + Debug.todo "assignBy" -- TYPES -type Vec2 - = Vec2 Vec2 - - -type Vec3 - = Vec3 Vec3 - - -type Vec4 - = Vec4 Vec4 - - -type Mat3 - = Mat3 Mat3 - - voidT : TypingFunction () voidT n = - TypedName (Type "void") (Name n) + TypedName TVoid n boolT : TypingFunction Bool boolT n = - TypedName (Type "bool") (Name n) + TypedName TBool n intT : TypingFunction Int intT n = - TypedName (Type "int") (Name n) + TypedName TInt n floatT : TypingFunction Float floatT n = - TypedName (Type "float") (Name n) + TypedName TFloat n vec2T : TypingFunction Vec2 vec2T n = - TypedName (Type "vec2") (Name n) + TypedName TVec2 n vec3T : TypingFunction Vec3 vec3T n = - TypedName (Type "vec3") (Name n) + TypedName TVec3 n vec4T : TypingFunction Vec4 vec4T n = - TypedName (Type "vec4") (Name n) + TypedName TVec4 n mat3T : TypingFunction Mat3 mat3T n = - TypedName (Type "mat3") (Name n) + TypedName TMat3 n -out : TypingFunction t -> TypingFunction t +out : TypingFunction t -> TypingFunction (Out t) out inner n = let - (TypedName (Type t) name) = + (TypedName t name) = inner n in - TypedName (Type <| "out " ++ t) name + TypedName (TOut t) name -in_ : TypingFunction t -> TypingFunction t +in_ : TypingFunction t -> TypingFunction (In t) in_ inner n = let - (TypedName (Type t) name) = + (TypedName t name) = inner n in - TypedName (Type <| "in " ++ t) name + TypedName (TIn t) name @@ -1054,7 +1061,21 @@ innerValue ctx e = Nothing -> Err <| MissingVariable v - And l r -> + UnaryOperation Negate c -> + innerValue ctx c + |> Result.andThen + (\( ctx2, vc ) -> + case vc of + VFloat fc -> + Ok ( ctx2, VFloat <| negate fc ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `-` for " ++ valueToString vc) + ) + + BinaryOperation And l r -> innerValue2 ctx l r <| \ctx2 vl vr -> case ( vl, vr ) of @@ -1066,7 +1087,7 @@ innerValue ctx e = InvalidTypes ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) - Or l r -> + BinaryOperation Or l r -> innerValue2 ctx l r <| \ctx2 vl vr -> case ( vl, vr ) of @@ -1150,21 +1171,12 @@ innerValue ctx e = Call name args -> Debug.todo <| "branch 'Call \"" ++ name ++ "\" [" ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) ++ " ]' not implemented" - Negate _ -> - Debug.todo "branch 'Negate _' not implemented" - - Unknown _ -> - Debug.todo "branch 'Unknown _' not implemented" - Dot _ _ -> Debug.todo "branch 'Dot _ _' not implemented" Array _ _ -> Debug.todo "branch 'Array _ _' not implemented" - Assign _ _ -> - Debug.todo "branch 'Assign _ _' not implemented" - AssignCombo _ _ _ -> Debug.todo "branch 'AssignCombo _ _' not implemented" @@ -1217,33 +1229,38 @@ autovectorizingFloatOp ctx name inner e = interpret : Context -> Statement a -> Result ErrorValue ( Context, GlslValue ) interpret ctx (Statement s) = - case s of + innerInterpret ctx s.stat + + +innerInterpret : Context -> Stat -> Result ErrorValue ( Context, GlslValue ) +innerInterpret ctx stat = + case stat of Return e -> - Expression e - |> value ctx + e + |> innerValue ctx |> Result.map (\( ctx2, val ) -> ( ctx2, val )) If c t n -> - Expression c - |> value ctx + c + |> innerValue ctx |> Result.andThen (\( ctx2, cval ) -> case cval of VBool True -> - interpret ctx2 (Statement t) + innerInterpret ctx2 t |> Result.andThen (\( ctx3, res ) -> case res of -- TODO: Fix this VVoid -> - interpret ctx3 (Statement n) + innerInterpret ctx3 n _ -> Ok ( ctx3, res ) ) VBool False -> - interpret ctx2 <| Statement n + innerInterpret ctx2 n _ -> Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval @@ -1255,9 +1272,6 @@ interpret ctx (Statement s) = Nop -> Ok ( ctx, VVoid ) - Line _ -> - Debug.todo "branch 'Line _' not implemented" - ExpressionStatement _ _ -> Debug.todo "branch 'ExpressionStatement _' not implemented" From ca705daeb5dc14e4911bd722ceab4d8e755aadb2 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 19 Feb 2023 01:26:23 +0100 Subject: [PATCH 093/139] More cleanup --- codegen/elm.json | 4 ++-- codegen/{ => src}/Generate.elm | 0 codegen/{ => src}/Glsl/Parser.elm | 0 src/elm/UI/Glsl.elm | 2 +- src/elm/UI/Glsl/Code.elm | 36 ++++++++++++++++++++++++++++++- 5 files changed, 38 insertions(+), 4 deletions(-) rename codegen/{ => src}/Generate.elm (100%) rename codegen/{ => src}/Glsl/Parser.elm (100%) diff --git a/codegen/elm.json b/codegen/elm.json index da3bb94e..563fb2f1 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -1,7 +1,7 @@ { "type": "application", "source-directories": [ - ".", + "src", "helpers" ], "elm-version": "0.19.1", @@ -35,4 +35,4 @@ "direct": {}, "indirect": {} } -} +} \ No newline at end of file diff --git a/codegen/Generate.elm b/codegen/src/Generate.elm similarity index 100% rename from codegen/Generate.elm rename to codegen/src/Generate.elm diff --git a/codegen/Glsl/Parser.elm b/codegen/src/Glsl/Parser.elm similarity index 100% rename from codegen/Glsl/Parser.elm rename to codegen/src/Glsl/Parser.elm diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 437cf120..e0d18cd0 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, minus, plus, square) import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (constantToGlsl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, expr, fileToGlsl) +import UI.Glsl.Generator as Generator exposing (FunDecl, expr, fileToGlsl) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 55d4e7b3..18a62c44 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -2,7 +2,7 @@ module UI.Glsl.Code exposing (expressionToGlsl, threshold) import Dict import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl exposing (Expression, Vec2, float) +import Glsl exposing (Expr, Expression, Vec2, float) import Glsl.Functions exposing (abs2, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, exp1, vec21, vec211) import Glsl.Operations exposing (add22, by11, negate2, subtract22) import UI.Glsl.Generator exposing (expr, one, vec2Zero, zero) @@ -199,3 +199,37 @@ expressionToGlsl context = threshold : Expression Float -> Expression Float threshold max_distance = by11 (float 0.000001) max_distance + + +toSrcImplicit : String -> Expr -> String +toSrcImplicit suffix e = + let + antialiasingSamples = + 7 + in + """ + float f_SUFFIX(float x, float y) { + vec2 complex = EXPRESSION; + if(abs(complex.y) > EPSILON) { + return 0.0; + } + return complex.x > 0.0 ? 1.0 : -1.0; + } + + vec3 pixel_SUFFIX(float deltaX, float deltaY, float x, float y) { + float sum = 0.0; + float samples = ANTIALIASING_SAMPLES * 2.0 + 1.0; + samples *= samples; + float coeff = 0.0875; + for(int w = -ANTIALIASING_SAMPLES; w <= ANTIALIASING_SAMPLES; w++) + for(int h = -ANTIALIASING_SAMPLES; h <= ANTIALIASING_SAMPLES; h++) { + float piece = f_SUFFIX(x + deltaX * coeff * float(w), y + deltaX * coeff * float(h)); + if(piece == 0.0) + return vec3(0); + sum += piece; + } + float perc = (samples - abs(sum)) / samples; + perc = pow(perc, 0.2); + return perc * vec3(1,1,1); + } + """ From 4ed2727a26e74d6f7b5e204ebac58cf429da6e93 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 19 Feb 2023 01:35:09 +0100 Subject: [PATCH 094/139] Move bindings location --- Makefile | 11 +++++++---- codegen/.gitignore | 2 +- codegen/elm.json | 3 ++- elm.json | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f8655389..1e726e65 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ELM_FILES = $(wildcard src/**/*.elm) -CODEGEN_FILES = $(wildcard codegen/*.elm) $(wildcard codegen/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) $(wildcard codegen/helpers/*/*.elm) +CODEGEN_FILES = $(wildcard codegen/src/*.elm) $(wildcard codegen/src/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) $(wildcard codegen/helpers/*/*.elm) .PHONY: build build: generated/Glsl/Functions.elm src/optimized.js Makefile @@ -8,12 +8,15 @@ build: generated/Glsl/Functions.elm src/optimized.js Makefile src/optimized.js: $(ELM_FILES) Makefile elm-optimize-level-2 src/elm/UI.elm --output $@ -generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/Gen/Glsl.elm Makefile +generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/bindings/Gen/Glsl.elm Makefile rm -rf generated - elm-codegen run --flags-from $< + elm-codegen run --flags-from $< codegen/src/Generate.elm -codegen/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile +codegen/bindings/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile + rm -rf codegen/bindings elm-codegen install + mkdir -p codegen/bindings + mv codegen/Gen codegen/bindings/ .PHONY: clean diff --git a/codegen/.gitignore b/codegen/.gitignore index 1f0e079e..4109df9c 100644 --- a/codegen/.gitignore +++ b/codegen/.gitignore @@ -1 +1 @@ -/Gen +/bindings diff --git a/codegen/elm.json b/codegen/elm.json index 563fb2f1..52be2eb4 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -2,7 +2,8 @@ "type": "application", "source-directories": [ "src", - "helpers" + "helpers", + "bindings" ], "elm-version": "0.19.1", "dependencies": { diff --git a/elm.json b/elm.json index abbee705..a2179591 100644 --- a/elm.json +++ b/elm.json @@ -3,7 +3,8 @@ "source-directories": [ "src/elm", "src/elm-extra", - "generated" + "generated", + "codegen/helpers" ], "elm-version": "0.19.1", "dependencies": { @@ -45,4 +46,4 @@ "elm/random": "1.0.0" } } -} +} \ No newline at end of file From 178c636b92b68359b85d4d5ecde88415350b8d73 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 19 Feb 2023 03:26:03 +0100 Subject: [PATCH 095/139] More functions, operations, conversion --- codegen/helpers/Glsl.elm | 90 ++++++++++++++ codegen/helpers/Glsl/Operations.elm | 120 +++++++++++++++++- src/elm/UI/Glsl.elm | 57 ++------- src/elm/UI/Glsl/Generator.elm | 174 +++++++++++++------------- src/elm/UI/Glsl/Plane.elm | 40 +++--- src/elm/UI/Glsl/Polynomial.elm | 181 ++++++++++++++-------------- src/elm/UI/Glsl/Sphere.elm | 55 +++++---- 7 files changed, 455 insertions(+), 262 deletions(-) diff --git a/codegen/helpers/Glsl.elm b/codegen/helpers/Glsl.elm index e050752d..6ad71c3a 100644 --- a/codegen/helpers/Glsl.elm +++ b/codegen/helpers/Glsl.elm @@ -3,11 +3,14 @@ module Glsl exposing , Statement(..), Stat(..), ForDirection(..) , Expression(..), Expr(..) , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) + , BisectSignature , true, false, int, float, var + , unsafeDot, dot2X, dot2Y, dot3X, dot3Y, dot3Z , TypingFunction, TypedName(..), Type(..) , Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 , unsafeMap, unsafeMap2, unsafeMap3 + , buildStatement, statement, unsafeExprStat, unsafeStat1, withExpression, withStatement ) {-| @@ -19,11 +22,13 @@ module Glsl exposing @docs Statement, Stat, ForDirection @docs Expression, ExprWithDeps, Expr @docs BinaryOperation, UnaryOperation, RelationOperation, ComboOperation +@docs BisectSignature # Utils @docs true, false, int, float, var +@docs unsafeDot, dot2X, dot2Y, dot3X, dot3Y, dot3Z # Typelevel types @@ -119,6 +124,53 @@ unsafeMap3 f (Expression l) (Expression m) (Expression r) = } +unsafeStat1 : (Stat -> Stat) -> Statement r -> Statement r +unsafeStat1 f (Statement stat) = + Statement + { stat = f stat.stat + , deps = stat.deps + } + + +unsafeExprStat : (Expr -> Stat -> Stat) -> Expression a -> Statement s -> Statement t +unsafeExprStat f (Expression l) (Statement r) = + Statement + { stat = f l.expr r.stat + , deps = + l.deps + |> SortedSet.insertAll r.deps + } + + +type StatementBuilder k + = StatementBuilder k (SortedSet String) + + +statement : k -> StatementBuilder k +statement k = + StatementBuilder k SortedSet.empty + + +withExpression : Expression e -> StatementBuilder (Expr -> k) -> StatementBuilder k +withExpression (Expression e) (StatementBuilder k deps) = + StatementBuilder (k e.expr) + (deps |> SortedSet.insertAll e.deps) + + +withStatement : Statement r -> StatementBuilder (Stat -> k) -> StatementBuilder k +withStatement (Statement s) (StatementBuilder k deps) = + StatementBuilder (k s.stat) + (deps |> SortedSet.insertAll s.deps) + + +buildStatement : StatementBuilder Stat -> Statement r +buildStatement (StatementBuilder stat deps) = + Statement + { stat = stat + , deps = deps + } + + -- Typed expressions @@ -190,6 +242,14 @@ type ComboOperation | ComboDiv +type alias BisectSignature = + Expression Vec3 + -> Expression Mat3 + -> Expression Float + -> Expression (Out Vec3) + -> Expression Bool + + -- Typed statements @@ -320,6 +380,36 @@ var v = pure <| Variable v +dot2X : Expression Vec2 -> Expression Float +dot2X e = + unsafeDot e "x" + + +dot2Y : Expression Vec2 -> Expression Float +dot2Y e = + unsafeDot e "y" + + +dot3X : Expression Vec3 -> Expression Float +dot3X e = + unsafeDot e "x" + + +dot3Y : Expression Vec3 -> Expression Float +dot3Y e = + unsafeDot e "y" + + +dot3Z : Expression Vec3 -> Expression Float +dot3Z e = + unsafeDot e "z" + + +unsafeDot : Expression t -> String -> Expression a +unsafeDot ex v = + unsafeMap (\e -> Dot e v) ex + + pure : Expr -> Expression t pure e = Expression diff --git a/codegen/helpers/Glsl/Operations.elm b/codegen/helpers/Glsl/Operations.elm index 68b65b7d..43cd7766 100644 --- a/codegen/helpers/Glsl/Operations.elm +++ b/codegen/helpers/Glsl/Operations.elm @@ -3,6 +3,11 @@ module Glsl.Operations exposing , subtract11, subtract22, subtract33, subtract44 , negate1, negate2, negate3, negate4 , by11, by22, by33, by44 + , by12, by13 + , by31 + , div11, div22, div33, div44 + , array33 + , lt, gt ) {-| @@ -11,13 +16,47 @@ module Glsl.Operations exposing # Addition @docs add11, add22, add33, add44 + + +# Subtraction + @docs subtract11, subtract22, subtract33, subtract44 + + +# Negate + @docs negate1, negate2, negate3, negate4 + + +# Multiplication + @docs by11, by22, by33, by44 +@docs by12, by13 +@docs by31 + + +# Division + +@docs div11, div22, div33, div44 + + +# Array access + +@docs array33 + + +# Comparison + +@docs lt, gt -} -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), UnaryOperation(..), Vec2, Vec3, Vec4) +import Expression exposing (BinaryOperation(..)) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Mat3, RelationOperation(..), UnaryOperation(..), Vec2, Vec3, Vec4) + + + +-- Addition add11 : Expression Float -> Expression Float -> Expression Float @@ -45,6 +84,10 @@ add l r = Glsl.unsafeMap2 (BinaryOperation Add) l r + +-- Subtraction + + subtract11 : Expression Float -> Expression Float -> Expression Float subtract11 = subtract @@ -70,6 +113,10 @@ subtract l r = Glsl.unsafeMap2 (BinaryOperation Subtract) l r + +-- Negation + + negate1 : Expression Float -> Expression Float negate1 = negate @@ -95,6 +142,10 @@ negate l = Glsl.unsafeMap (UnaryOperation Negate) l + +-- Multiplication + + by11 : Expression Float -> Expression Float -> Expression Float by11 = by @@ -115,6 +166,73 @@ by44 = by +by12 : Expression Float -> Expression Vec2 -> Expression Vec2 +by12 l r = + Glsl.unsafeMap2 (BinaryOperation By) l r + + +by13 : Expression Float -> Expression Vec3 -> Expression Vec3 +by13 l r = + Glsl.unsafeMap2 (BinaryOperation By) l r + + +by31 : Expression Vec3 -> Expression Float -> Expression Vec3 +by31 l r = + Glsl.unsafeMap2 (BinaryOperation By) l r + + by : Expression a -> Expression a -> Expression a by l r = Glsl.unsafeMap2 (BinaryOperation By) l r + + + +-- Division + + +div11 : Expression Float -> Expression Float -> Expression Float +div11 = + div + + +div22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 +div22 = + div + + +div33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 +div33 = + div + + +div44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 +div44 = + div + + +div : Expression a -> Expression a -> Expression a +div l r = + Glsl.unsafeMap2 (BinaryOperation Div) l r + + + +-- Array access + + +array33 : Expression Mat3 -> Expression Int -> Expression Vec3 +array33 = + Glsl.unsafeMap2 Array + + + +-- Comparisons + + +lt : Expression Float -> Expression Float -> Expression Bool +lt = + Glsl.unsafeMap2 (Comparison LessThan) + + +gt : Expression Float -> Expression Float -> Expression Bool +gt = + Glsl.unsafeMap2 (Comparison GreaterThan) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index e0d18cd0..9f790212 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -5,6 +5,7 @@ import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expre import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, minus, plus, square) +import Glsl exposing (BisectSignature, Mat3, Out, Vec3) import Maybe.Extra as Maybe import SortedAnySet as Set import UI.Glsl.Code exposing (constantToGlsl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) @@ -107,16 +108,7 @@ getGlsl rayDifferentials graph = ++ mainGlsl rayDifferentials pixel2D pixel3D -get3DSource : - String - -> Expression - -> - (Glsl.Helper.Expression Vec3 - -> Glsl.Helper.Expression Mat3 - -> Glsl.Helper.Expression Float - -> Glsl.Helper.Expression Vec3 - -> Glsl.Helper.Expression Bool - ) +get3DSource : String -> Expression -> BisectSignature get3DSource prefix e = case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of Just bisect -> @@ -124,9 +116,8 @@ get3DSource prefix e = Nothing -> case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of - Just ( glsl, bisect ) -> - { bisect = bisect - } + Just bisect -> + bisect Nothing -> case tryGlslFromPolynomial prefix e of @@ -134,33 +125,10 @@ get3DSource prefix e = o Nothing -> - let - ( glsl, interval ) = - toSrc3D prefix e - - ( decl, bisect ) = - UI.Glsl.Code.suffixToBisect interval prefix - in - { expr = e - , funDecls = glsl ++ [ decl ] - , bisect = bisect - } - - -tryGlslFromPolynomial : - String - -> Expression - -> - Maybe - { expr : Expression - , funDecls : List FunDecl - , bisect : - Glsl.Helper.Expression Vec3 - -> Glsl.Helper.Expression Mat3 - -> Glsl.Helper.Expression Float - -> Glsl.Helper.Expression Vec3 - -> Glsl.Helper.Expression Bool - } + UI.Glsl.Code.suffixToBisect (toSrc3D prefix e) prefix + + +tryGlslFromPolynomial : String -> Expression -> Maybe BisectSignature tryGlslFromPolynomial suffix e = let t = @@ -208,11 +176,8 @@ tryGlslFromPolynomial suffix e = |> Maybe.map Dict.fromList |> Maybe.withDefault Dict.empty in - UI.Glsl.Polynomial.glslFromPolySolutions suffix { base = unknown "max_distance" } poly + UI.Glsl.Polynomial.glslFromPolySolutions suffix (var "max_distance") poly |> Maybe.map - (\{ funDecls, bisect } -> - { funDecls = funDecls - , expr = Expression.Utils.div Expression.Utils.one <| Expression.Utils.sqrt_ <| Expression.Utils.cbrt <| Expression.Utils.ipow e 3 - , bisect = bisect - } + (\{ bisect } -> + bisect ) diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index daab31c2..caa14043 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,9 +1,9 @@ -module UI.Glsl.Generator exposing (Context, Continue, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, boolT, break, continue, decl, def, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) import Dict exposing (Dict) -import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, false, float, int, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var) +import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, buildStatement, false, float, statement, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeExprStat, unsafeMap2, unsafeMap3, unsafeStat1, var, withExpression, withStatement) import Glsl.Functions exposing (vec211, vec3111, vec41111) -import Glsl.Operations exposing (add11, add22, add33, add44) +import Glsl.Operations exposing (add22, add33, add44) import Set import SortedSet @@ -204,16 +204,6 @@ relationToString rel = "=" -nop : Continue () -nop = - internalNop - - -internalNop : Continue a -internalNop () = - Statement { stat = Nop, deps = SortedSet.empty } - - expressionToGlsl : Expression t -> String expressionToGlsl (Expression tree) = exprToGlsl tree.expr @@ -764,26 +754,29 @@ fun5 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (Typ [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ), ( t4, arg4 ) ] -type alias Continue s = - () -> Statement s - - -if_ : Expression Bool -> (Continue r -> Statement r) -> Continue r -> Statement r +if_ : Expression Bool -> Statement r -> Statement r -> Statement r if_ cond ifTrue next = - -- Statement <| If (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapLazyStatement next) - Debug.todo "if_" + statement If + |> withExpression cond + |> withStatement ifTrue + |> withStatement next + |> buildStatement -ifElse : Expression Bool -> (Continue s -> Statement s) -> (Continue s -> Statement s) -> Continue s -> Statement s +ifElse : Expression Bool -> Statement s -> Statement s -> Statement s -> Statement s ifElse cond ifTrue ifFalse next = - --Statement <| IfElse (unwrapExpression cond) (unwrapStatement <| ifTrue internalNop) (unwrapStatement <| ifFalse internalNop) (unwrapLazyStatement next) - Debug.todo "ifElse" + statement IfElse + |> withExpression cond + |> withStatement ifTrue + |> withStatement ifFalse + |> withStatement next + |> buildStatement for : ( String, Expression Int, Expression Int ) - -> (Expression Int -> Continue r -> Statement r) - -> Continue r + -> (Expression Int -> Statement r -> Statement r) + -> Statement r -> Statement r for ( var, from, to ) loop next = -- Statement <| @@ -799,8 +792,8 @@ for ( var, from, to ) loop next = forLeq : ( String, Expression Int, Expression Int ) - -> (Expression Int -> Continue r -> Statement r) - -> Continue r + -> (Expression Int -> Statement r -> Statement r) + -> Statement r -> Statement r forLeq ( var, from, to ) loop next = -- Statement <| @@ -816,8 +809,8 @@ forLeq ( var, from, to ) loop next = forDown : ( String, Expression Int, Expression Int ) - -> (Expression Int -> Continue r -> Statement r) - -> Continue r + -> (Expression Int -> Statement r -> Statement r) + -> Statement r -> Statement r forDown ( var, from, to ) loop next = -- Statement <| @@ -831,22 +824,23 @@ forDown ( var, from, to ) loop next = Debug.todo "forDown" -return : Expression r -> Continue x -> Statement r -return e _ = - -- Statement <| Return <| unwrapExpression e - Debug.todo "return" +return : Expression r -> Statement r +return e = + statement Return + |> withExpression e + |> buildStatement -break : Continue a -> Statement a -break _ = - -- Statement Break - Debug.todo "break" +break : Statement a +break = + statement Break + |> buildStatement -continue : Continue a -> Statement a -continue _ = - -- Statement Continue - Debug.todo "continue" +continue : Statement a +continue = + statement Continue + |> buildStatement decl : TypingFunction t -> String -> (Expression t -> Statement r) -> Statement r @@ -854,67 +848,85 @@ decl typeF name k = let (TypedName t n) = typeF name - - (Statement ks) = - k (var n) in - Statement - { stat = Decl t n Nothing ks.stat - , deps = ks.deps - } + statement (Decl t n Nothing) + |> withStatement (k (var n)) + |> buildStatement def : TypingFunction t -> String -> Expression t -> (Expression t -> Statement r) -> Statement r -def typeF name (Expression v) k = - let - (TypedName t n) = - typeF name +def typeF name val k = + def1 ( typeF name, val ) k - (Statement ks) = - k (var n) + +def1 : + ( TypedName a, Expression a ) + -> (Expression a -> Statement r) + -> Statement r +def1 ( tn0, val0 ) k = + let + (TypedName t0 n0) = + tn0 in - Statement - { stat = Decl t n (Just v.expr) ks.stat - , deps = - ks.deps - |> SortedSet.insertAll v.deps - } + statement + (\v0 k0 -> Decl t0 n0 (Just v0) k0) + |> withExpression val0 + |> withStatement (k (var n0)) + |> buildStatement -assign : Expression t -> Expression t -> Expression t -assign name e = - -- dotted1Internal <| Assign (unwrapExpression name) (unwrapExpression e) - Debug.todo "assign" +def2 : + ( TypedName a, Expression a ) + -> ( TypedName b, Expression b ) + -> (Expression a -> Expression b -> Statement r) + -> Statement r +def2 ( tn0, val0 ) ( tn1, val1 ) k = + def1 ( tn0, val0 ) + (\v0 -> + def1 ( tn1, val1 ) + (\v1 -> k v0 v1) + ) -unwrapLazyStatement : Continue r -> Stat -unwrapLazyStatement f = - let - (Statement next) = - f () - in - -- next - Debug.todo "unwrapLazyStatement" +def3 : + ( TypedName a, Expression a ) + -> ( TypedName b, Expression b ) + -> ( TypedName c, Expression c ) + -> (Expression a -> Expression b -> Expression c -> Statement r) + -> Statement r +def3 ( tn0, val0 ) ( tn1, val1 ) ( tn2, val2 ) k = + def1 ( tn0, val0 ) + (\v0 -> + def1 ( tn1, val1 ) + (\v1 -> + def1 ( tn2, val2 ) + (\v2 -> k v0 v1 v2) + ) + ) + + +assign : Expression t -> Expression t -> Expression t +assign name e = + unsafeMap2 (Comparison Assign) name e -unwrapStatement : Statement r -> Stat -unwrapStatement (Statement { stat }) = - stat +assignOut : Expression (Out t) -> Expression t -> Expression t +assignOut name e = + unsafeMap2 (Comparison Assign) name e -expr : Expression t -> Continue q -> Statement q -expr e next = - -- Statement <| ExpressionStatement (unwrapExpression e) (unwrapLazyStatement next) - Debug.todo "expr" +expr : Expression t -> Statement r -> Statement r +expr = + unsafeExprStat ExpressionStatement -assignAdd : Expression t -> Expression t -> Continue q -> Statement q +assignAdd : Expression t -> Expression t -> Statement q -> Statement q assignAdd name e next = -- Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) Debug.todo "assignAdd" -assignBy : Expression t -> Expression t -> Continue q -> Statement q +assignBy : Expression t -> Expression t -> Statement q -> Statement q assignBy name e next = -- Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) Debug.todo "assignBy" diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index ea3ae7c5..7440789c 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -2,10 +2,12 @@ module UI.Glsl.Plane exposing (Plane, asPlane, toGlsl) import Dict import Expression exposing (Expression) -import Glsl exposing (dot33) +import Glsl exposing (BisectSignature, float, int) +import Glsl.Functions exposing (dot33, mix331, vec3111) +import Glsl.Operations exposing (add11, add33, array33, by13, div11, gt, negate1) import Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, arr, assign, boolT, byF, def, div, expr, float, floatT, fun4, gt, int, mat3T, negate_, out, return, vec3, vec3T) +import UI.Glsl.Generator exposing (assignOut, boolT, def, def2, expr, floatT, fun4, mat3T, out, return, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -36,10 +38,10 @@ asPlane e = ) -toGlsl : String -> Plane -> ( FunDecl, Expression Vec3 -> Expression Mat3 -> Expression Float -> Expression Vec3 -> Expression1 Bool ) +toGlsl : String -> Plane -> BisectSignature toGlsl suffix (Plane { x, y, z, known }) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found nop -> + \o d maxDistance found -> -- a x + b y + c z + k = 0 -- x = ox + t dx -- y = oy + t dy @@ -47,18 +49,18 @@ toGlsl suffix (Plane { x, y, z, known }) = -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) -- t = - (k + dot abc o) / (dot abc d) - def vec3T "coeffs" (vec3 (float x) (float y) (float z)) <| - \coeffs -> - def vec3T "dsum" (byF (float 0.5) <| add (arr d <| int 0) (arr d <| int 1)) <| - \dsum -> - def floatT - "t" - (div - (negate_ <| add (float known) (dot coeffs o)) - (dot33 coeffs dsum) - ) - <| - \t -> - expr (assign found <| add o <| byF t dsum) <| - \_ -> - return (gt t <| threshold maxDistance) nop + def2 + ( vec3T "coeffs", vec3111 (float x) (float y) (float z) ) + ( vec3T "dMix", mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5) ) + <| + \coeffs dMix -> + def floatT + "t" + (div11 + (negate1 <| add11 (float known) (dot33 coeffs o)) + (dot33 coeffs dMix) + ) + <| + \t -> + expr (assignOut found <| add33 o <| by13 t dMix) <| + return (gt t <| threshold maxDistance) diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 35d026f5..194f057d 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -4,9 +4,12 @@ import Dict exposing (Dict) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), RelationOperation(..), UnaryOperation(..)) import Expression.Polynomial exposing (Exponents) import Expression.Utils +import Glsl exposing (BisectSignature, Stat(..), Statement, Vec3, dot2X, dot2Y, dot3X, dot3Y, dot3Z, float, int) +import Glsl.Functions exposing (abs1, cby22, cdiv22, csqrt2, min11, mix331) +import Glsl.Operations exposing (add22, add33, array33, by11, by12, by13, gt, lt, negate2, subtract22) import Maybe.Extra as Maybe import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator as Generator exposing (Expression1, ExpressionX, FunDecl, Mat3, Vec3, add, ands, arr, assign, boolT, by, byF, def, dotted1, expr, float, floatT, fun4, gt, int, lt, mat3T, mix, out, return, unknown, vec3T, zero) +import UI.Glsl.Generator exposing (ands, assign, assignOut, boolT, def, def2, def3, expr, floatT, fun4, mat3T, or, out, return, ternary, vec2T, vec3T, zero) getDegree : Dict (List ( a, number )) b -> number @@ -64,7 +67,19 @@ toFloat e = Nothing -getSolutions : ExpressionX x Float -> Dict Int Expression -> Maybe ( Int, List ( String, String ) ) +getSolutions : + Glsl.Expression Float + -> Dict Int Expression + -> + Maybe + ( Int + , { t : Glsl.Expression Float + , o : Glsl.Expression Vec3 + , dMix : Glsl.Expression Vec3 + } + -> Statement r + -> Statement r + ) getSolutions maxDistance poly = let deg = @@ -73,53 +88,70 @@ getSolutions maxDistance poly = |> List.maximum |> Maybe.withDefault 0 - get d = - Dict.get d poly + get { dMix, o } degree = + Dict.get degree poly |> Maybe.withDefault Expression.Utils.zero |> UI.Glsl.Code.expressionToGlsl - [ ( "dx", dotted1 <| unknown "dx" ) - , ( "dy", dotted1 <| unknown "dy" ) - , ( "dz", dotted1 <| unknown "dz" ) - , ( "o.x", dotted1 <| unknown "o.x" ) - , ( "o.y", dotted1 <| unknown "o.y" ) - , ( "o.z", dotted1 <| unknown "o.z" ) + [ ( "dx", dot3X dMix ) + , ( "dy", dot3Y dMix ) + , ( "dz", dot3Z dMix ) + , ( "o.x", dot3X o ) + , ( "o.y", dot3Y o ) + , ( "o.z", dot3Z o ) ] - |> .base - |> Generator.expressionToGlsl - tFrom v = - ( "t", v ++ ".x < 0.0 || abs(" ++ v ++ ".y) > " ++ Generator.expressionToGlsl (threshold maxDistance).base ++ " ? t : min(" ++ v ++ ".x, t)" ) + -- tFrom : Glsl.Expression Vec2 -> Glsl.Statement r -> Glsl.Statement r + tFrom { t } v = + expr + (assign t + (ternary + (or + (lt (dot2X v) (float 0)) + (gt (abs1 <| dot2Y v) (threshold maxDistance)) + ) + t + (min11 (dot2X v) t) + ) + ) sols = case deg of 1 -> - -- ax + b = 0 - -- x = -b / a - [ ( "!dx", "mix(d[0].x, d[1].x, 0.5)" ) - , ( "!dy", "mix(d[0].y, d[1].y, 0.5)" ) - , ( "!dz", "mix(d[0].z, d[1].z, 0.5)" ) - , ( "a", get 1 ) - , ( "b", get 0 ) - , ( "x", "cdiv(-b, a)" ) - , tFrom "x" - ] + Just <| + \vars cont -> + -- ax + b = 0 + -- x = -b / a + def vec2T "a" (get vars 1) <| + \a -> + def vec2T "b" (get vars 0) <| + \b -> + def vec2T "x" (cdiv22 (negate2 b) a) <| + \x -> + tFrom vars x cont 2 -> - -- ax² + bx + c = 0 - [ ( "!dx", "mix(d[0].x, d[1].x, 0.5)" ) - , ( "!dy", "mix(d[0].y, d[1].y, 0.5)" ) - , ( "!dz", "mix(d[0].z, d[1].z, 0.5)" ) - , ( "a", get 2 ) - , ( "b", get 1 ) - , ( "c", get 0 ) - , ( "delta", "cby(b,b) - 4.0 * cby(a,c)" ) - , ( "sqdelta", "csqrt(delta)" ) - , ( "den", "2.0 * a" ) - , ( "pos", "cdiv(- b + sqdelta, den)" ) - , tFrom "pos" - , ( "neg", "cdiv(- b - sqdelta, den)" ) - , tFrom "neg" - ] + Just <| + \vars cont -> + -- ax² + bx + c = 0 + def3 + ( vec2T "a", get vars 2 ) + ( vec2T "b", get vars 1 ) + ( vec2T "c", get vars 1 ) + <| + \a b c -> + def vec2T "delta" (subtract22 (cby22 b b) (by12 (float 4.0) (cby22 a c))) <| + \delta -> + def2 + ( vec2T "sqdelta", csqrt2 delta ) + ( vec2T "den", by12 (float 2.0) a ) + <| + \sqdelta den -> + def vec2T "pos" (cdiv22 (add22 (negate2 b) sqdelta) den) <| + \pos -> + tFrom vars pos <| + def vec2T "neg" (cdiv22 (add22 (negate2 b) (negate2 sqdelta)) den) <| + \neg -> + tFrom vars neg cont {- 3 -> [ ( "!dx", "mix(d[0].x, d[1].x, 0.5)" ) @@ -149,67 +181,38 @@ getSolutions maxDistance poly = ] -} _ -> - [] + Nothing in - if List.isEmpty sols then - Nothing - - else - Just ( deg, sols ) + Maybe.map (Tuple.pair deg) sols glslFromSolutions : String - -> List ( String, String ) -> - { funDecls : List FunDecl - , bisect : ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool - } + ({ t : Glsl.Expression Float + , o : Glsl.Expression Vec3 + , dMix : Glsl.Expression Vec3 + } + -> Statement Bool + -> Statement Bool + ) + -> BisectSignature glslFromSolutions suffix sols = - let - checks = - sols - |> List.foldl - (\( k, v ) ( known, f ) -> - let - ( decl, drop ) = - if List.member k known then - ( "", 0 ) - - else if String.startsWith "!" k then - ( "float ", 1 ) - - else - ( "vec2 ", 0 ) - - newLine = - \n -> f <| expr (dotted1 <| unknown (decl ++ String.dropLeft drop k ++ " = " ++ v ++ ";")) <| \_ -> n - in - ( k :: known, newLine ) - ) - ( [ "t" ], identity ) - |> Tuple.second - - ( funDecl, bisect ) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found nop -> - def floatT "t" (by maxDistance <| float 2) <| \t -> - checks <| - expr (assign found (add o (byF t (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| \_ -> - return (ands [ lt t maxDistance, gt t zero ]) nop - in - { funDecls = [ funDecl ] - , bisect = bisect - } + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> + def vec3T "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5)) <| + \dMix -> + def floatT "t" (by11 maxDistance <| float 2) <| + \t -> + sols { dMix = dMix, o = o, t = t } <| + expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5))))) <| + return (ands [ lt t maxDistance, gt t zero ]) glslFromPolySolutions : String - -> ExpressionX xm Float + -> Glsl.Expression Float -> Dict Int Expression - -> - Maybe - { funDecls : List FunDecl - , bisect : ExpressionX xa Vec3 -> ExpressionX xb Mat3 -> ExpressionX xc Float -> ExpressionX xd Vec3 -> Expression1 Bool - } + -> Maybe BisectSignature glslFromPolySolutions suffix maxDistance poly = getSolutions maxDistance poly |> Maybe.map (\( _, sols ) -> glslFromSolutions suffix sols) diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index acc554ea..15c8b7fc 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -3,9 +3,11 @@ module UI.Glsl.Sphere exposing (Sphere, asSphere, toGlsl) import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) -import Glsl exposing (dot33) +import Glsl exposing (BisectSignature, false, float, int, true) +import Glsl.Functions exposing (dot33, mix331, sqrt1, vec3111) +import Glsl.Operations exposing (add33, array33, by11, by13, lt, negate1, subtract11, subtract33) import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (FunDecl, Mat3, Vec3, assign, bool, boolT, def, expr, float, floatT, fun4, if_, int, mat3T, out, return, vec3T, zero) +import UI.Glsl.Generator exposing (assignOut, boolT, def, def2, expr, floatT, fun4, if_, mat3T, out, return, vec3T, zero) import UI.Glsl.Polynomial as Polynomial @@ -74,30 +76,31 @@ reduce poly = ) -toGlsl : String -> Sphere -> ( FunDecl, Expression Vec3 -> Expression Mat3 -> Expression Float -> Expression Vec3 -> Expression Bool ) +toGlsl : String -> Sphere -> BisectSignature toGlsl suffix (Sphere { center, radius }) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found nop -> - def vec3T "center" (vec3 (float center.x) (float center.y) (float center.z)) <| - \centerVar -> - def vec3T "to_center" (subtract o centerVar) <| + \o d maxDistance found -> + def2 + ( vec3T "center", vec3111 (float center.x) (float center.y) (float center.z) ) + ( vec3T "dMix", mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5) ) + <| + \centerVar dMix -> + def vec3T "to_center" (subtract33 o centerVar) <| \to_center -> - def floatT "b" (dot33 to_center (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))) <| - \b -> - def floatT "c" (subtract (dot33 to_center to_center) (float <| radius * radius)) <| - \c -> - def floatT "delta" (subtract (by b b) c) <| - \delta -> - if_ (lt delta zero) - (return <| bool False) - <| - \_ -> - def floatT "x" (subtract (negate_ b) (sqrt_ delta)) <| - \x -> - if_ (lt x <| threshold maxDistance) - (return false) - <| - \_ -> - expr (assign found (add o (byF x (mix (arr d (int 0)) (arr d (int 1)) (float 0.5))))) <| - \_ -> - return true nop + def2 + ( floatT "b", dot33 to_center dMix ) + ( floatT "c", subtract11 (dot33 to_center to_center) (float <| radius * radius) ) + <| + \b c -> + def floatT "delta" (subtract11 (by11 b b) c) <| + \delta -> + if_ (lt delta zero) + (return false) + <| + def floatT "x" (subtract11 (negate1 b) (sqrt1 delta)) <| + \x -> + if_ (lt x <| threshold maxDistance) + (return false) + <| + expr (assignOut found (add33 o (by13 x dMix))) <| + return true From be501be7941448162453ae25e086eac61fe6090a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 16 Apr 2023 21:00:58 +0200 Subject: [PATCH 096/139] Update elm-review --- review/elm.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/review/elm.json b/review/elm.json index 9da40ecc..98ff6ff8 100644 --- a/review/elm.json +++ b/review/elm.json @@ -9,15 +9,15 @@ "elm/core": "1.0.5", "elm/json": "1.1.3", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.12.2", + "jfmengels/elm-review": "2.13.0", "jfmengels/elm-review-code-style": "1.1.3", "jfmengels/elm-review-common": "1.3.2", "jfmengels/elm-review-debug": "1.0.8", "jfmengels/elm-review-documentation": "2.0.3", - "jfmengels/elm-review-simplify": "2.0.26", + "jfmengels/elm-review-simplify": "2.0.28", "jfmengels/elm-review-unused": "1.1.29", "jsuder-xx/elm-review-reducible-lambdas": "2.0.1", - "lue-bird/elm-review-record-alias-constructor": "1.1.2", + "lue-bird/elm-review-record-alias-constructor": "1.1.3", "sparksp/elm-review-always": "1.0.6", "sparksp/elm-review-imports": "1.0.2", "sparksp/elm-review-ports": "1.3.1", @@ -38,6 +38,7 @@ "elm-community/maybe-extra": "5.3.0", "elm-explorations/test": "2.1.1", "jsuder-xx/elm-ra": "1.1.1", + "miniBill/elm-fast-dict": "1.0.0", "miniBill/elm-unicode": "1.0.3", "pzp1997/assoc-list": "1.0.0", "rtfeldman/elm-hex": "1.0.0", From 61ad3b6c9cc1d92e87eb0185d0fe2a1cdb4dca21 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 16 Apr 2023 21:01:11 +0200 Subject: [PATCH 097/139] Add ineq and ipow --- codegen/functions.frag | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/codegen/functions.frag b/codegen/functions.frag index 571dcde9..8f08eb0a 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -310,6 +310,12 @@ vec2 ipow(vec2 b, int e) { vec2 iln(vec2 z) { return log(z); } vec2 iexp(vec2 z) { return exp(z); } +vec2 ipow(vec2 b, float e) { + if (abs(e.x - round(e.x)) < .000001) + return ipow(b, int(e.x)); + return iexp(e * iln(b)); +} + vec2 ipow(vec2 b, vec2 e) { if (e.y - e.x < .000001 && abs(e.x - round(e.x)) < .000001) return ipow(b, int(e.x)); @@ -319,6 +325,7 @@ vec2 ipow(vec2 b, vec2 e) { // Relations vec2 ilt(vec2 l, vec2 r) { return vec2(r.x - l.y, r.y - l.x); } vec2 ileq(vec2 l, vec2 r) { return vec2(r.x - l.y, r.y - l.x); } +vec2 ineq(vec2 l, vec2 r) { return vec2(r.x - l.y, r.y - l.x); } vec2 ieq(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } vec2 igeq(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } vec2 igt(vec2 l, vec2 r) { return vec2(l.x - r.y, l.y - r.x); } From 3c34989ddbef2d2e89d4280657d1c388e2bafca8 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Apr 2023 22:55:18 +0200 Subject: [PATCH 098/139] Updating libraries --- elm.json | 16 ++++++++-------- review/elm.json | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/elm.json b/elm.json index a2179591..b44b86ad 100644 --- a/elm.json +++ b/elm.json @@ -10,7 +10,7 @@ "dependencies": { "direct": { "avh4/elm-color": "1.0.0", - "dillonkearns/elm-markdown": "7.0.0", + "dillonkearns/elm-markdown": "7.0.1", "elm/browser": "1.0.2", "elm/bytes": "1.0.8", "elm/core": "1.0.5", @@ -20,19 +20,19 @@ "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/url": "1.0.0", - "elm-community/list-extra": "8.5.1", - "elm-community/maybe-extra": "5.2.0", + "elm-community/list-extra": "8.7.0", + "elm-community/maybe-extra": "5.3.0", "elm-community/result-extra": "2.4.0", "lemol/ant-design-icons-elm-ui": "1.0.0", "miniBill/elm-codec": "2.0.0", - "miniBill/elm-ui-with-context": "1.1.0", - "miniBill/elm-unicode": "1.0.2" + "miniBill/elm-ui-with-context": "2.0.0", + "miniBill/elm-unicode": "1.0.3" }, "indirect": { "elm/regex": "1.0.0", "elm/svg": "1.0.1", "elm/time": "1.0.0", - "elm/virtual-dom": "1.0.2", + "elm/virtual-dom": "1.0.3", "lemol/ant-design-icons-elm": "2.0.0", "mdgriffith/elm-ui": "1.1.8", "rtfeldman/elm-hex": "1.0.0" @@ -40,10 +40,10 @@ }, "test-dependencies": { "direct": { - "elm-explorations/test": "1.2.2" + "elm-explorations/test": "2.1.1" }, "indirect": { "elm/random": "1.0.0" } } -} \ No newline at end of file +} diff --git a/review/elm.json b/review/elm.json index 98ff6ff8..dfd4ee41 100644 --- a/review/elm.json +++ b/review/elm.json @@ -10,11 +10,11 @@ "elm/json": "1.1.3", "elm/project-metadata-utils": "1.0.2", "jfmengels/elm-review": "2.13.0", - "jfmengels/elm-review-code-style": "1.1.3", + "jfmengels/elm-review-code-style": "1.1.4", "jfmengels/elm-review-common": "1.3.2", "jfmengels/elm-review-debug": "1.0.8", "jfmengels/elm-review-documentation": "2.0.3", - "jfmengels/elm-review-simplify": "2.0.28", + "jfmengels/elm-review-simplify": "2.0.29", "jfmengels/elm-review-unused": "1.1.29", "jsuder-xx/elm-review-reducible-lambdas": "2.0.1", "lue-bird/elm-review-record-alias-constructor": "1.1.3", From 9d4e8365b75af0411b5a04a1da8d50a4c25acb36 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Apr 2023 22:59:16 +0200 Subject: [PATCH 099/139] =?UTF-8?q?Switched=20to=20yarn=20=F0=9F=A4=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9adbb46..4b5444d6 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ It's a rewrite in Elm of "mePlot", which was a formerly J2ME, then Android appli It's pre-1.0, and there is much to do. -To test it, `pnpm install` and then `pnpm start`. +To test it, `yarn install` and then `yarn start`. From bbd5edf837fbc3ca5194124e5492a4d3a1d43893 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Apr 2023 23:28:13 +0200 Subject: [PATCH 100/139] Update KaTeX --- src/dev.html | 9 ++++----- src/index.html | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/dev.html b/src/dev.html index 815fe08e..9ef5b6e4 100644 --- a/src/dev.html +++ b/src/dev.html @@ -15,13 +15,12 @@ - + - diff --git a/src/index.html b/src/index.html index 3a595154..417c858a 100644 --- a/src/index.html +++ b/src/index.html @@ -15,13 +15,12 @@ - + - From 90b625e7b070c0f6f2da2aada0a1a0da1909b39a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Apr 2023 23:29:24 +0200 Subject: [PATCH 101/139] Switch to parcel 2 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b56b3d27..bbd204d8 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ }, "scripts": { "build": "make build", - "buildForBenchmark": "rm -rf .cache elm-stuff dist; elm-optimize-level-2 src/elm/UI.elm --output src/optimized.js && parcel build --no-minify src/index.html --public-url .", - "start": "parcel src/dev.html", + "buildForBenchmark": "rm -rf .cache elm-stuff dist; elm-optimize-level-2 src/elm/UI.elm --output src/optimized.js && yarn parcel build --no-minify src/index.html --public-url .", + "start": "yarn parcel src/dev.html", "test": "elm-test" }, "name": "nuplot", From 7c37d9f4a0c6ffdf8e43eafeb9afc19e6f530a29 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Fri, 21 Apr 2023 01:34:21 +0200 Subject: [PATCH 102/139] Updating service worker setup --- .gitignore | 2 +- package.json | 1 + src/dev.html | 7 +------ src/index.html | 7 +------ src/service-worker.js | 23 ----------------------- src/service-worker.ts | 37 +++++++++++++++++++++++++++++++++++++ src/ts/dev.ts | 6 ++++++ src/ts/index.ts | 6 ++++++ tsconfig.json | 2 +- 9 files changed, 54 insertions(+), 37 deletions(-) delete mode 100644 src/service-worker.js create mode 100644 src/service-worker.ts diff --git a/.gitignore b/.gitignore index 0cabce1d..b935dbdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ elm-stuff -.cache +.parcel-cache node_modules /dist /src/optimized.js diff --git a/package.json b/package.json index bbd204d8..09e0c8ff 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "name": "nuplot", "description": "A small CAS and plotter", + "license": "MIT", "pwaManifest": { "name": "NuPlot", "shortName": "NuPlot", diff --git a/src/dev.html b/src/dev.html index 9ef5b6e4..169d0ee8 100644 --- a/src/dev.html +++ b/src/dev.html @@ -27,15 +27,10 @@
- + - - \ No newline at end of file diff --git a/src/index.html b/src/index.html index 417c858a..3702f16b 100644 --- a/src/index.html +++ b/src/index.html @@ -27,15 +27,10 @@
- + - - \ No newline at end of file diff --git a/src/service-worker.js b/src/service-worker.js deleted file mode 100644 index d3e7eea9..00000000 --- a/src/service-worker.js +++ /dev/null @@ -1,23 +0,0 @@ -self.addEventListener("install", function (event) { - event.waitUntil( - caches.open("progressive-elm").then(function (cache) { - return cache.addAll(['/', '/index.html']).then( - cache.addAll(SERVICE_WORKER_MANIFEST_ENTRIES.map(entry => entry.url)) - ); - }).catch(function (ex) { - console.error(ex); - }) - ) -}); - -self.addEventListener("fetch", function (event) { - event.respondWith(caches.open("progressive-elm").then((cache) => - fetch(event.request).then(function (response) { - cache.put(event.request, response.clone()); - return response; - }).catch(function (ex) { - console.error(ex); - return caches.match(event.request); - })) - ) -}); diff --git a/src/service-worker.ts b/src/service-worker.ts new file mode 100644 index 00000000..b6c2ff48 --- /dev/null +++ b/src/service-worker.ts @@ -0,0 +1,37 @@ +import { manifest, version } from "@parcel/runtime-service-worker"; + +async function install() { + debugger; + const cache = await caches.open(version); + + await cache.addAll(["/", "/index.html"]); + await cache.addAll(manifest); +} +addEventListener("install", (e) => e.waitUntil(install())); + +async function activate() { + const keys = await caches.keys(); + await Promise.all(keys.map((key) => key !== version && caches.delete(key))); +} +addEventListener("activate", (e) => e.waitUntil(activate())); + +async function putInCache(request: Request, response: Response) { + const cache = await caches.open(version); + await cache.put(request, response); +} + +async function response(event: FetchEvent): Promise { + var cachedResponse = await caches.match(event.request); + if (cachedResponse) { + return cachedResponse; + } + + const response = await fetch(event.request); + // Intentionall not awaited + putInCache(event.request, response.clone()); + return response; +} + +addEventListener("fetch", (e) => { + e.respondWith(response(e)); +}); diff --git a/src/ts/dev.ts b/src/ts/dev.ts index cbefc806..9e685ad3 100644 --- a/src/ts/dev.ts +++ b/src/ts/dev.ts @@ -2,3 +2,9 @@ import { Elm } from "../elm/UI.elm"; import { init } from "./main"; init(Elm); + +if ("serviceWorker" in navigator) + navigator.serviceWorker.register( + new URL("../service-worker.ts", import.meta.url), + { type: "module" } + ); diff --git a/src/ts/index.ts b/src/ts/index.ts index 18f3a62e..2c654469 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -2,3 +2,9 @@ import { Elm } from "../optimized.js"; import { init } from "./main"; init(Elm); + +if ("serviceWorker" in navigator) + navigator.serviceWorker.register( + new URL("../service-worker.ts", import.meta.url), + { type: "module" } + ); diff --git a/tsconfig.json b/tsconfig.json index f4bf5b14..94fc39d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, - "module": "es6", + "module": "es2020", "target": "es6", "strict": true, "sourceMap": true, From b3eb09a9fc2e6bf3227b388dc30b4ab64d4a2c09 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 17 Sep 2023 16:31:56 +0200 Subject: [PATCH 103/139] Use elm-codegen through yarn --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1e726e65..826873fa 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,15 @@ build: generated/Glsl/Functions.elm src/optimized.js Makefile parcel build src/index.html --public-url . src/optimized.js: $(ELM_FILES) Makefile - elm-optimize-level-2 src/elm/UI.elm --output $@ + yarn elm-optimize-level-2 src/elm/UI.elm --output $@ generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/bindings/Gen/Glsl.elm Makefile rm -rf generated - elm-codegen run --flags-from $< codegen/src/Generate.elm + yarn elm-codegen run --flags-from $< codegen/src/Generate.elm codegen/bindings/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile rm -rf codegen/bindings - elm-codegen install + yarn elm-codegen install mkdir -p codegen/bindings mv codegen/Gen codegen/bindings/ From 090f7caffc74be5659204d36652dbbbe0f588d5f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sun, 31 Dec 2023 14:13:30 +0100 Subject: [PATCH 104/139] Re-add elm-codegen --- package.json | 1 + yarn.lock | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 09e0c8ff..9369cea7 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ ] }, "devDependencies": { + "elm-codegen": "^0.5.0", "elm-optimize-level-2": "^0.1.5", "elm-review": "^2.10.2", "elm-watch": "^1.1.2", diff --git a/yarn.lock b/yarn.lock index 94327ee6..f787296e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,7 +304,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.0.0, chalk@npm:^4.1.0": +"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1": version: 4.1.2 resolution: "chalk@npm:4.1.2" dependencies: @@ -314,7 +314,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:^3.5.2, chokidar@npm:^3.5.3": +"chokidar@npm:^3.5.1, chokidar@npm:^3.5.2, chokidar@npm:^3.5.3": version: 3.5.3 resolution: "chokidar@npm:3.5.3" dependencies: @@ -402,6 +402,13 @@ __metadata: languageName: node linkType: hard +"commander@npm:^8.3.0": + version: 8.3.0 + resolution: "commander@npm:8.3.0" + checksum: 8b043bb8322ea1c39664a1598a95e0495bfe4ca2fad0d84a92d7d1d8d213e2a155b441d2470c8e08de7c4a28cf2bc6e169211c49e1b21d9f7edc6ae4d9356060 + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -477,6 +484,20 @@ __metadata: languageName: node linkType: hard +"elm-codegen@npm:^0.5.0": + version: 0.5.0 + resolution: "elm-codegen@npm:0.5.0" + dependencies: + chalk: "npm:^4.1.1" + chokidar: "npm:^3.5.1" + commander: "npm:^8.3.0" + node-elm-compiler: "npm:^5.0.6" + bin: + elm-codegen: bin/elm-codegen + checksum: 5e4e2fa3a9502e2545ab52405c4e72d25941e4ae01d733f8742a8173e0d904ffab199001153f020a780f02eaf28967ce08bb5148e0ef7c819489356f4366e8e8 + languageName: node + linkType: hard + "elm-optimize-level-2@npm:^0.1.5": version: 0.1.5 resolution: "elm-optimize-level-2@npm:0.1.5" @@ -1289,7 +1310,7 @@ __metadata: languageName: node linkType: hard -"node-elm-compiler@npm:^5.0.4": +"node-elm-compiler@npm:^5.0.4, node-elm-compiler@npm:^5.0.6": version: 5.0.6 resolution: "node-elm-compiler@npm:5.0.6" dependencies: @@ -1350,6 +1371,7 @@ __metadata: version: 0.0.0-use.local resolution: "nuplot@workspace:." dependencies: + elm-codegen: "npm:^0.5.0" elm-optimize-level-2: "npm:^0.1.5" elm-review: "npm:^2.10.2" elm-watch: "npm:^1.1.2" From b3c41d2f6f01d335bf05d6979d546eaa927394d3 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 16 Jan 2024 19:54:12 +0100 Subject: [PATCH 105/139] Rebase --- .gitignore | 4 +++ yarn.lock | 75 ++++++++++++++++++++++++------------------------------ 2 files changed, 37 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index b935dbdf..7c057efa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,12 @@ node_modules /src/optimized.js generated + # Ignore Yarn caches .yarn/* +!.yarn/patches !.yarn/releases !.yarn/plugins +!.yarn/sdks +!.yarn/versions .pnp.* diff --git a/yarn.lock b/yarn.lock index f787296e..ec9c04bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -77,9 +77,9 @@ __metadata: linkType: hard "@types/http-cache-semantics@npm:*": - version: 4.0.4 - resolution: "@types/http-cache-semantics@npm:4.0.4" - checksum: 51b72568b4b2863e0fe8d6ce8aad72a784b7510d72dc866215642da51d84945a9459fa89f49ec48f1e9a1752e6a78e85a4cda0ded06b1c73e727610c925f9ce6 + version: 4.0.1 + resolution: "@types/http-cache-semantics@npm:4.0.1" + checksum: 6d6068110a04cac213bdc0fff9c7bac028b5a2da390492204328987d8ddc500adc10d9cf5747a6333dab261712655dcfe120ea1d5527c205d012a39cdccc2a7b languageName: node linkType: hard @@ -93,20 +93,18 @@ __metadata: linkType: hard "@types/node@npm:*": - version: 20.10.6 - resolution: "@types/node@npm:20.10.6" - dependencies: - undici-types: "npm:~5.26.4" - checksum: 6692ccfa8552ef60c4069fda3c8de726c23e8d403cdf788e3c7efa769987e80fbda5f02723dd857f9de7df24a5fa40b3ed4580ec3c5cbac04eba44cf7b2ab1dc + version: 18.15.12 + resolution: "@types/node@npm:18.15.12" + checksum: cba269e5e5a5e277d017ee98edb3fea244ea9eccc6242aa8356f1c3eb6d9340f6444f96eefa7ef7e21b53652d22b69f6e37b80d719903759d6b95de085396a0c languageName: node linkType: hard "@types/responselike@npm:^1.0.0": - version: 1.0.3 - resolution: "@types/responselike@npm:1.0.3" + version: 1.0.0 + resolution: "@types/responselike@npm:1.0.0" dependencies: "@types/node": "npm:*" - checksum: a58ba341cb9e7d74f71810a88862da7b2a6fa42e2a1fc0ce40498f6ea1d44382f0640117057da779f74c47039f7166bf48fad02dc876f94e005c7afa50f5e129 + checksum: 474ac2402e6d43c007eee25f50d01eb1f67255ca83dd8e036877292bbe8dd5d2d1e50b54b408e233b50a8c38e681ff3ebeaf22f18b478056eddb65536abb003a languageName: node linkType: hard @@ -263,8 +261,8 @@ __metadata: linkType: hard "cacache@npm:^18.0.0": - version: 18.0.1 - resolution: "cacache@npm:18.0.1" + version: 18.0.2 + resolution: "cacache@npm:18.0.2" dependencies: "@npmcli/fs": "npm:^3.1.0" fs-minipass: "npm:^3.0.0" @@ -278,7 +276,7 @@ __metadata: ssri: "npm:^10.0.0" tar: "npm:^6.1.11" unique-filename: "npm:^3.0.0" - checksum: a31666805a80a8b16ad3f85faf66750275a9175a3480896f4f6d31b5d53ef190484fabd71bdb6d2ea5603c717fbef09f4af03d6a65b525c8ef0afaa44c361866 + checksum: 7992665305cc251a984f4fdbab1449d50e88c635bc43bf2785530c61d239c61b349e5734461baa461caaee65f040ab14e2d58e694f479c0810cffd181ba5eabc languageName: node linkType: hard @@ -290,8 +288,8 @@ __metadata: linkType: hard "cacheable-request@npm:^7.0.2": - version: 7.0.4 - resolution: "cacheable-request@npm:7.0.4" + version: 7.0.2 + resolution: "cacheable-request@npm:7.0.2" dependencies: clone-response: "npm:^1.0.2" get-stream: "npm:^5.1.0" @@ -300,7 +298,7 @@ __metadata: lowercase-keys: "npm:^2.0.0" normalize-url: "npm:^6.0.1" responselike: "npm:^2.0.0" - checksum: 0834a7d17ae71a177bc34eab06de112a43f9b5ad05ebe929bec983d890a7d9f2bc5f1aa8bb67ea2b65e07a3bc74bea35fa62dd36dbac52876afe36fdcf83da41 + checksum: 681bad13691d0d5d10652d409374747a2ce8676f854b0d454ee8fc65e0a10a52ea83cd1f6c367ada08572fd4982f2aa2582dc38983d4e958e053e181c433765e languageName: node linkType: hard @@ -357,9 +355,9 @@ __metadata: linkType: hard "cli-spinners@npm:^2.5.0": - version: 2.9.2 - resolution: "cli-spinners@npm:2.9.2" - checksum: 907a1c227ddf0d7a101e7ab8b300affc742ead4b4ebe920a5bf1bc6d45dce2958fcd195eb28fa25275062fe6fa9b109b93b63bc8033396ed3bcb50297008b3a3 + version: 2.8.0 + resolution: "cli-spinners@npm:2.8.0" + checksum: b4c4ec516e9367d1cdcead1b390e303251fc78e5035a7854164305493f8face4481a54a352d06a60f3ce4065e5f2808935c68df19e23cb5440d520daa330540b languageName: node linkType: hard @@ -725,18 +723,18 @@ __metadata: linkType: hard "fsevents@npm:~2.3.2": - version: 2.3.3 - resolution: "fsevents@npm:2.3.3" + version: 2.3.2 + resolution: "fsevents@npm:2.3.2" dependencies: node-gyp: "npm:latest" - checksum: a1f0c44595123ed717febbc478aa952e47adfc28e2092be66b8ab1635147254ca6cfe1df792a8997f22716d4cbafc73309899ff7bfac2ac3ad8cf2e4ecc3ec60 + checksum: be78a3efa3e181cda3cf7a4637cb527bcebb0bd0ea0440105a3bb45b86f9245b307dc10a2507e8f4498a7d4ec349d1910f4d73e4d4495b16103106e07eee735b conditions: os=darwin languageName: node linkType: hard "fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin": - version: 2.3.3 - resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin::version=2.3.3&hash=df0bf1" + version: 2.3.2 + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin::version=2.3.2&hash=df0bf1" dependencies: node-gyp: "npm:latest" conditions: os=darwin @@ -1029,11 +1027,11 @@ __metadata: linkType: hard "keyv@npm:^4.0.0": - version: 4.5.4 - resolution: "keyv@npm:4.5.4" + version: 4.5.2 + resolution: "keyv@npm:4.5.2" dependencies: json-buffer: "npm:3.0.1" - checksum: aa52f3c5e18e16bb6324876bb8b59dd02acf782a4b789c7b2ae21107fab95fab3890ed448d4f8dba80ce05391eeac4bfabb4f02a20221342982f806fa2cf271e + checksum: b633bf53a5afa5591f383d326746226e110e59f13c7e1e8d3e3c9580d2c2345c5eefc21cce168cd5be7fa34b9163e391927146fbd2b7ee7aa2f3aa02b7f0a7de languageName: node linkType: hard @@ -1635,11 +1633,11 @@ __metadata: linkType: hard "semver@npm:^5.5.0": - version: 5.7.2 - resolution: "semver@npm:5.7.2" + version: 5.7.1 + resolution: "semver@npm:5.7.1" bin: - semver: bin/semver - checksum: e4cf10f86f168db772ae95d86ba65b3fd6c5967c94d97c708ccb463b778c2ee53b914cd7167620950fc07faf5a564e6efe903836639e512a1aa15fbc9667fa25 + semver: ./bin/semver + checksum: d4884f2aeca28bff35d0bd40ff0a9b2dfc4b36a883bf0ea5dc15d10d9a01bdc9041035b05f825d4b5ac8a56e490703dbf0d986d054de82cc5e9bad3f02ca6e00 languageName: node linkType: hard @@ -1916,13 +1914,6 @@ __metadata: languageName: node linkType: hard -"undici-types@npm:~5.26.4": - version: 5.26.5 - resolution: "undici-types@npm:5.26.5" - checksum: bb673d7876c2d411b6eb6c560e0c571eef4a01c1c19925175d16e3a30c4c428181fb8d7ae802a261f283e4166a0ac435e2f505743aa9e45d893f9a3df017b501 - languageName: node - linkType: hard - "unique-filename@npm:^3.0.0": version: 3.0.0 resolution: "unique-filename@npm:3.0.0" @@ -1942,9 +1933,9 @@ __metadata: linkType: hard "universalify@npm:^2.0.0": - version: 2.0.1 - resolution: "universalify@npm:2.0.1" - checksum: 73e8ee3809041ca8b818efb141801a1004e3fc0002727f1531f4de613ea281b494a40909596dae4a042a4fb6cd385af5d4db2e137b1362e0e91384b828effd3a + version: 2.0.0 + resolution: "universalify@npm:2.0.0" + checksum: 07092b9f46df61b823d8ab5e57f0ee5120c178b39609a95e4a15a98c42f6b0b8e834e66fbb47ff92831786193be42f1fd36347169b88ce8639d0f9670af24a71 languageName: node linkType: hard From 25f6b143d00b2272c4010ecf19b59102903c7e36 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 16 Jan 2024 19:54:42 +0100 Subject: [PATCH 106/139] Add item to TODO --- TODO.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO.md b/TODO.md index 5df5cdc4..4c0e96c5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,6 @@ # Todo +- https://samuelj.li/complex-function-plotter/#1%2Fz - solve `x² - 3pi x² + 3 pi² x - pi³ = 0` - Fuzzy test the solver - User functions From 80f00e6e04b525b0d334b2600b00bcbb7e6c1375 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Wed, 10 Apr 2024 16:09:44 +0200 Subject: [PATCH 107/139] Updated packages --- package.json | 13 +- yarn.lock | 3096 +++++++++++++++++--------------------------------- 2 files changed, 1051 insertions(+), 2058 deletions(-) diff --git a/package.json b/package.json index 9369cea7..7854065d 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,11 @@ ] }, "devDependencies": { - "elm-codegen": "^0.5.0", - "elm-optimize-level-2": "^0.1.5", - "elm-review": "^2.10.2", - "elm-watch": "^1.1.2", - "typescript": "^4.3.5" + "elm-codegen": "^0.5.3", + "elm-optimize-level-2": "^0.3.5", + "elm-review": "^2.11.1", + "elm-watch": "^2.0.0-beta.2", + "typescript": "^5.4.4" }, "scripts": { "build": "make build", @@ -55,6 +55,5 @@ }, "dependencies": { "localforage": "^1.9.0" - }, - "packageManager": "yarn@4.0.2" + } } diff --git a/yarn.lock b/yarn.lock index ec9c04bd..dca608b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1,2051 +1,1045 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 8 - cacheKey: 10c0 - -"@isaacs/cliui@npm:^8.0.2": - version: 8.0.2 - resolution: "@isaacs/cliui@npm:8.0.2" - dependencies: - string-width: "npm:^5.1.2" - string-width-cjs: "npm:string-width@^4.2.0" - strip-ansi: "npm:^7.0.1" - strip-ansi-cjs: "npm:strip-ansi@^6.0.1" - wrap-ansi: "npm:^8.1.0" - wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" - checksum: b1bf42535d49f11dc137f18d5e4e63a28c5569de438a221c369483731e9dac9fb797af554e8bf02b6192d1e5eba6e6402cf93900c3d0ac86391d00d04876789e - languageName: node - linkType: hard - -"@npmcli/agent@npm:^2.0.0": - version: 2.2.0 - resolution: "@npmcli/agent@npm:2.2.0" - dependencies: - agent-base: "npm:^7.1.0" - http-proxy-agent: "npm:^7.0.0" - https-proxy-agent: "npm:^7.0.1" - lru-cache: "npm:^10.0.1" - socks-proxy-agent: "npm:^8.0.1" - checksum: 7b89590598476dda88e79c473766b67c682aae6e0ab0213491daa6083dcc0c171f86b3868f5506f22c09aa5ea69ad7dfb78f4bf39a8dca375d89a42f408645b3 - languageName: node - linkType: hard - -"@npmcli/fs@npm:^3.1.0": - version: 3.1.0 - resolution: "@npmcli/fs@npm:3.1.0" - dependencies: - semver: "npm:^7.3.5" - checksum: 162b4a0b8705cd6f5c2470b851d1dc6cd228c86d2170e1769d738c1fbb69a87160901411c3c035331e9e99db72f1f1099a8b734bf1637cc32b9a5be1660e4e1e - languageName: node - linkType: hard - -"@pkgjs/parseargs@npm:^0.11.0": - version: 0.11.0 - resolution: "@pkgjs/parseargs@npm:0.11.0" - checksum: 5bd7576bb1b38a47a7fc7b51ac9f38748e772beebc56200450c4a817d712232b8f1d3ef70532c80840243c657d491cf6a6be1e3a214cff907645819fdc34aadd - languageName: node - linkType: hard - -"@sindresorhus/is@npm:^4.0.0": - version: 4.6.0 - resolution: "@sindresorhus/is@npm:4.6.0" - checksum: 33b6fb1d0834ec8dd7689ddc0e2781c2bfd8b9c4e4bacbcb14111e0ae00621f2c264b8a7d36541799d74888b5dccdf422a891a5cb5a709ace26325eedc81e22e - languageName: node - linkType: hard - -"@szmarczak/http-timer@npm:^4.0.5": - version: 4.0.6 - resolution: "@szmarczak/http-timer@npm:4.0.6" - dependencies: - defer-to-connect: "npm:^2.0.0" - checksum: 73946918c025339db68b09abd91fa3001e87fc749c619d2e9c2003a663039d4c3cb89836c98a96598b3d47dec2481284ba85355392644911f5ecd2336536697f - languageName: node - linkType: hard - -"@types/cacheable-request@npm:^6.0.1": - version: 6.0.3 - resolution: "@types/cacheable-request@npm:6.0.3" - dependencies: - "@types/http-cache-semantics": "npm:*" - "@types/keyv": "npm:^3.1.4" - "@types/node": "npm:*" - "@types/responselike": "npm:^1.0.0" - checksum: 10816a88e4e5b144d43c1d15a81003f86d649776c7f410c9b5e6579d0ad9d4ca71c541962fb403077388b446e41af7ae38d313e46692144985f006ac5e11fa03 - languageName: node - linkType: hard - -"@types/http-cache-semantics@npm:*": - version: 4.0.1 - resolution: "@types/http-cache-semantics@npm:4.0.1" - checksum: 6d6068110a04cac213bdc0fff9c7bac028b5a2da390492204328987d8ddc500adc10d9cf5747a6333dab261712655dcfe120ea1d5527c205d012a39cdccc2a7b - languageName: node - linkType: hard - -"@types/keyv@npm:^3.1.4": - version: 3.1.4 - resolution: "@types/keyv@npm:3.1.4" - dependencies: - "@types/node": "npm:*" - checksum: ff8f54fc49621210291f815fe5b15d809fd7d032941b3180743440bd507ecdf08b9e844625fa346af568c84bf34114eb378dcdc3e921a08ba1e2a08d7e3c809c - languageName: node - linkType: hard - -"@types/node@npm:*": - version: 18.15.12 - resolution: "@types/node@npm:18.15.12" - checksum: cba269e5e5a5e277d017ee98edb3fea244ea9eccc6242aa8356f1c3eb6d9340f6444f96eefa7ef7e21b53652d22b69f6e37b80d719903759d6b95de085396a0c - languageName: node - linkType: hard - -"@types/responselike@npm:^1.0.0": - version: 1.0.0 - resolution: "@types/responselike@npm:1.0.0" - dependencies: - "@types/node": "npm:*" - checksum: 474ac2402e6d43c007eee25f50d01eb1f67255ca83dd8e036877292bbe8dd5d2d1e50b54b408e233b50a8c38e681ff3ebeaf22f18b478056eddb65536abb003a - languageName: node - linkType: hard - -"abbrev@npm:^2.0.0": - version: 2.0.0 - resolution: "abbrev@npm:2.0.0" - checksum: f742a5a107473946f426c691c08daba61a1d15942616f300b5d32fd735be88fef5cba24201757b6c407fd564555fb48c751cfa33519b2605c8a7aadd22baf372 - languageName: node - linkType: hard - -"agent-base@npm:^7.0.2, agent-base@npm:^7.1.0": - version: 7.1.0 - resolution: "agent-base@npm:7.1.0" - dependencies: - debug: "npm:^4.3.4" - checksum: fc974ab57ffdd8421a2bc339644d312a9cca320c20c3393c9d8b1fd91731b9bbabdb985df5fc860f5b79d81c3e350daa3fcb31c5c07c0bb385aafc817df004ce - languageName: node - linkType: hard - -"aggregate-error@npm:^3.0.0": - version: 3.1.0 - resolution: "aggregate-error@npm:3.1.0" - dependencies: - clean-stack: "npm:^2.0.0" - indent-string: "npm:^4.0.0" - checksum: a42f67faa79e3e6687a4923050e7c9807db3848a037076f791d10e092677d65c1d2d863b7848560699f40fc0502c19f40963fb1cd1fb3d338a7423df8e45e039 - languageName: node - linkType: hard - -"ansi-escapes@npm:^4.2.1": - version: 4.3.2 - resolution: "ansi-escapes@npm:4.3.2" - dependencies: - type-fest: "npm:^0.21.3" - checksum: da917be01871525a3dfcf925ae2977bc59e8c513d4423368645634bf5d4ceba5401574eb705c1e92b79f7292af5a656f78c5725a4b0e1cec97c4b413705c1d50 - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.1": - version: 5.0.1 - resolution: "ansi-regex@npm:5.0.1" - checksum: 9a64bb8627b434ba9327b60c027742e5d17ac69277960d041898596271d992d4d52ba7267a63ca10232e29f6107fc8a835f6ce8d719b88c5f8493f8254813737 - languageName: node - linkType: hard - -"ansi-regex@npm:^6.0.1": - version: 6.0.1 - resolution: "ansi-regex@npm:6.0.1" - checksum: cbe16dbd2c6b2735d1df7976a7070dd277326434f0212f43abf6d87674095d247968209babdaad31bb00882fa68807256ba9be340eec2f1004de14ca75f52a08 - languageName: node - linkType: hard - -"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": - version: 4.3.0 - resolution: "ansi-styles@npm:4.3.0" - dependencies: - color-convert: "npm:^2.0.1" - checksum: 895a23929da416f2bd3de7e9cb4eabd340949328ab85ddd6e484a637d8f6820d485f53933446f5291c3b760cbc488beb8e88573dd0f9c7daf83dccc8fe81b041 - languageName: node - linkType: hard - -"ansi-styles@npm:^6.1.0": - version: 6.2.1 - resolution: "ansi-styles@npm:6.2.1" - checksum: 5d1ec38c123984bcedd996eac680d548f31828bd679a66db2bdf11844634dde55fec3efa9c6bb1d89056a5e79c1ac540c4c784d592ea1d25028a92227d2f2d5c - languageName: node - linkType: hard - -"anymatch@npm:~3.1.2": - version: 3.1.3 - resolution: "anymatch@npm:3.1.3" - dependencies: - normalize-path: "npm:^3.0.0" - picomatch: "npm:^2.0.4" - checksum: 57b06ae984bc32a0d22592c87384cd88fe4511b1dd7581497831c56d41939c8a001b28e7b853e1450f2bf61992dfcaa8ae2d0d161a0a90c4fb631ef07098fbac - languageName: node - linkType: hard - -"at-least-node@npm:^1.0.0": - version: 1.0.0 - resolution: "at-least-node@npm:1.0.0" - checksum: 4c058baf6df1bc5a1697cf182e2029c58cd99975288a13f9e70068ef5d6f4e1f1fd7c4d2c3c4912eae44797d1725be9700995736deca441b39f3e66d8dee97ef - languageName: node - linkType: hard - -"balanced-match@npm:^1.0.0": - version: 1.0.2 - resolution: "balanced-match@npm:1.0.2" - checksum: 9308baf0a7e4838a82bbfd11e01b1cb0f0cf2893bc1676c27c2a8c0e70cbae1c59120c3268517a8ae7fb6376b4639ef81ca22582611dbee4ed28df945134aaee - languageName: node - linkType: hard - -"base64-js@npm:^1.3.1": - version: 1.5.1 - resolution: "base64-js@npm:1.5.1" - checksum: f23823513b63173a001030fae4f2dabe283b99a9d324ade3ad3d148e218134676f1ee8568c877cd79ec1c53158dcf2d2ba527a97c606618928ba99dd930102bf - languageName: node - linkType: hard - -"binary-extensions@npm:^2.0.0": - version: 2.2.0 - resolution: "binary-extensions@npm:2.2.0" - checksum: d73d8b897238a2d3ffa5f59c0241870043aa7471335e89ea5e1ff48edb7c2d0bb471517a3e4c5c3f4c043615caa2717b5f80a5e61e07503d51dc85cb848e665d - languageName: node - linkType: hard - -"bl@npm:^4.1.0": - version: 4.1.0 - resolution: "bl@npm:4.1.0" - dependencies: - buffer: "npm:^5.5.0" - inherits: "npm:^2.0.4" - readable-stream: "npm:^3.4.0" - checksum: 02847e1d2cb089c9dc6958add42e3cdeaf07d13f575973963335ac0fdece563a50ac770ac4c8fa06492d2dd276f6cc3b7f08c7cd9c7a7ad0f8d388b2a28def5f - languageName: node - linkType: hard - -"brace-expansion@npm:^1.1.7": - version: 1.1.11 - resolution: "brace-expansion@npm:1.1.11" - dependencies: - balanced-match: "npm:^1.0.0" - concat-map: "npm:0.0.1" - checksum: 695a56cd058096a7cb71fb09d9d6a7070113c7be516699ed361317aca2ec169f618e28b8af352e02ab4233fb54eb0168460a40dc320bab0034b36ab59aaad668 - languageName: node - linkType: hard - -"brace-expansion@npm:^2.0.1": - version: 2.0.1 - resolution: "brace-expansion@npm:2.0.1" - dependencies: - balanced-match: "npm:^1.0.0" - checksum: b358f2fe060e2d7a87aa015979ecea07f3c37d4018f8d6deb5bd4c229ad3a0384fe6029bb76cd8be63c81e516ee52d1a0673edbe2023d53a5191732ae3c3e49f - languageName: node - linkType: hard - -"braces@npm:~3.0.2": - version: 3.0.3 - resolution: "braces@npm:3.0.3" - dependencies: - fill-range: "npm:^7.1.1" - checksum: 7c6dfd30c338d2997ba77500539227b9d1f85e388a5f43220865201e407e076783d0881f2d297b9f80951b4c957fcf0b51c1d2d24227631643c3f7c284b0aa04 - languageName: node - linkType: hard - -"buffer@npm:^5.5.0": - version: 5.7.1 - resolution: "buffer@npm:5.7.1" - dependencies: - base64-js: "npm:^1.3.1" - ieee754: "npm:^1.1.13" - checksum: 27cac81cff434ed2876058d72e7c4789d11ff1120ef32c9de48f59eab58179b66710c488987d295ae89a228f835fc66d088652dffeb8e3ba8659f80eb091d55e - languageName: node - linkType: hard - -"cacache@npm:^18.0.0": - version: 18.0.2 - resolution: "cacache@npm:18.0.2" - dependencies: - "@npmcli/fs": "npm:^3.1.0" - fs-minipass: "npm:^3.0.0" - glob: "npm:^10.2.2" - lru-cache: "npm:^10.0.1" - minipass: "npm:^7.0.3" - minipass-collect: "npm:^2.0.1" - minipass-flush: "npm:^1.0.5" - minipass-pipeline: "npm:^1.2.4" - p-map: "npm:^4.0.0" - ssri: "npm:^10.0.0" - tar: "npm:^6.1.11" - unique-filename: "npm:^3.0.0" - checksum: 7992665305cc251a984f4fdbab1449d50e88c635bc43bf2785530c61d239c61b349e5734461baa461caaee65f040ab14e2d58e694f479c0810cffd181ba5eabc - languageName: node - linkType: hard - -"cacheable-lookup@npm:^5.0.3": - version: 5.0.4 - resolution: "cacheable-lookup@npm:5.0.4" - checksum: a6547fb4954b318aa831cbdd2f7b376824bc784fb1fa67610e4147099e3074726072d9af89f12efb69121415a0e1f2918a8ddd4aafcbcf4e91fbeef4a59cd42c - languageName: node - linkType: hard - -"cacheable-request@npm:^7.0.2": - version: 7.0.2 - resolution: "cacheable-request@npm:7.0.2" - dependencies: - clone-response: "npm:^1.0.2" - get-stream: "npm:^5.1.0" - http-cache-semantics: "npm:^4.0.0" - keyv: "npm:^4.0.0" - lowercase-keys: "npm:^2.0.0" - normalize-url: "npm:^6.0.1" - responselike: "npm:^2.0.0" - checksum: 681bad13691d0d5d10652d409374747a2ce8676f854b0d454ee8fc65e0a10a52ea83cd1f6c367ada08572fd4982f2aa2582dc38983d4e958e053e181c433765e - languageName: node - linkType: hard - -"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: "npm:^4.1.0" - supports-color: "npm:^7.1.0" - checksum: 4a3fef5cc34975c898ffe77141450f679721df9dde00f6c304353fa9c8b571929123b26a0e4617bde5018977eb655b31970c297b91b63ee83bb82aeb04666880 - languageName: node - linkType: hard - -"chokidar@npm:^3.5.1, chokidar@npm:^3.5.2, chokidar@npm:^3.5.3": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: "npm:~3.1.2" - braces: "npm:~3.0.2" - fsevents: "npm:~2.3.2" - glob-parent: "npm:~5.1.2" - is-binary-path: "npm:~2.1.0" - is-glob: "npm:~4.0.1" - normalize-path: "npm:~3.0.0" - readdirp: "npm:~3.6.0" - dependenciesMeta: - fsevents: - optional: true - checksum: 1076953093e0707c882a92c66c0f56ba6187831aa51bb4de878c1fec59ae611a3bf02898f190efec8e77a086b8df61c2b2a3ea324642a0558bdf8ee6c5dc9ca1 - languageName: node - linkType: hard - -"chownr@npm:^2.0.0": - version: 2.0.0 - resolution: "chownr@npm:2.0.0" - checksum: 594754e1303672171cc04e50f6c398ae16128eb134a88f801bf5354fd96f205320f23536a045d9abd8b51024a149696e51231565891d4efdab8846021ecf88e6 - languageName: node - linkType: hard - -"clean-stack@npm:^2.0.0": - version: 2.2.0 - resolution: "clean-stack@npm:2.2.0" - checksum: 1f90262d5f6230a17e27d0c190b09d47ebe7efdd76a03b5a1127863f7b3c9aec4c3e6c8bb3a7bbf81d553d56a1fd35728f5a8ef4c63f867ac8d690109742a8c1 - languageName: node - linkType: hard - -"cli-cursor@npm:^3.1.0": - version: 3.1.0 - resolution: "cli-cursor@npm:3.1.0" - dependencies: - restore-cursor: "npm:^3.1.0" - checksum: 92a2f98ff9037d09be3dfe1f0d749664797fb674bf388375a2207a1203b69d41847abf16434203e0089212479e47a358b13a0222ab9fccfe8e2644a7ccebd111 - languageName: node - linkType: hard - -"cli-spinners@npm:^2.5.0": - version: 2.8.0 - resolution: "cli-spinners@npm:2.8.0" - checksum: b4c4ec516e9367d1cdcead1b390e303251fc78e5035a7854164305493f8face4481a54a352d06a60f3ce4065e5f2808935c68df19e23cb5440d520daa330540b - languageName: node - linkType: hard - -"clone-response@npm:^1.0.2": - version: 1.0.3 - resolution: "clone-response@npm:1.0.3" - dependencies: - mimic-response: "npm:^1.0.0" - checksum: 06a2b611824efb128810708baee3bd169ec9a1bf5976a5258cd7eb3f7db25f00166c6eee5961f075c7e38e194f373d4fdf86b8166ad5b9c7e82bbd2e333a6087 - languageName: node - linkType: hard - -"clone@npm:^1.0.2": - version: 1.0.4 - resolution: "clone@npm:1.0.4" - checksum: 2176952b3649293473999a95d7bebfc9dc96410f6cbd3d2595cf12fd401f63a4bf41a7adbfd3ab2ff09ed60cb9870c58c6acdd18b87767366fabfc163700f13b - languageName: node - linkType: hard - -"color-convert@npm:^2.0.1": - version: 2.0.1 - resolution: "color-convert@npm:2.0.1" - dependencies: - color-name: "npm:~1.1.4" - checksum: 37e1150172f2e311fe1b2df62c6293a342ee7380da7b9cfdba67ea539909afbd74da27033208d01d6d5cfc65ee7868a22e18d7e7648e004425441c0f8a15a7d7 - languageName: node - linkType: hard - -"color-name@npm:~1.1.4": - version: 1.1.4 - resolution: "color-name@npm:1.1.4" - checksum: a1a3f914156960902f46f7f56bc62effc6c94e84b2cae157a526b1c1f74b677a47ec602bf68a61abfa2b42d15b7c5651c6dbe72a43af720bc588dff885b10f95 - languageName: node - linkType: hard - -"commander@npm:^6.0.0": - version: 6.2.1 - resolution: "commander@npm:6.2.1" - checksum: 85748abd9d18c8bc88febed58b98f66b7c591d9b5017cad459565761d7b29ca13b7783ea2ee5ce84bf235897333706c4ce29adf1ce15c8252780e7000e2ce9ea - languageName: node - linkType: hard - -"commander@npm:^8.3.0": - version: 8.3.0 - resolution: "commander@npm:8.3.0" - checksum: 8b043bb8322ea1c39664a1598a95e0495bfe4ca2fad0d84a92d7d1d8d213e2a155b441d2470c8e08de7c4a28cf2bc6e169211c49e1b21d9f7edc6ae4d9356060 - languageName: node - linkType: hard - -"concat-map@npm:0.0.1": - version: 0.0.1 - resolution: "concat-map@npm:0.0.1" - checksum: c996b1cfdf95b6c90fee4dae37e332c8b6eb7d106430c17d538034c0ad9a1630cb194d2ab37293b1bdd4d779494beee7786d586a50bd9376fd6f7bcc2bd4c98f - languageName: node - linkType: hard - -"cross-spawn@npm:6.0.5": - version: 6.0.5 - resolution: "cross-spawn@npm:6.0.5" - dependencies: - nice-try: "npm:^1.0.4" - path-key: "npm:^2.0.1" - semver: "npm:^5.5.0" - shebang-command: "npm:^1.2.0" - which: "npm:^1.2.9" - checksum: e05544722e9d7189b4292c66e42b7abeb21db0d07c91b785f4ae5fefceb1f89e626da2703744657b287e86dcd4af57b54567cef75159957ff7a8a761d9055012 - languageName: node - linkType: hard - -"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.3": - version: 7.0.3 - resolution: "cross-spawn@npm:7.0.3" - dependencies: - path-key: "npm:^3.1.0" - shebang-command: "npm:^2.0.0" - which: "npm:^2.0.1" - checksum: 5738c312387081c98d69c98e105b6327b069197f864a60593245d64c8089c8a0a744e16349281210d56835bb9274130d825a78b2ad6853ca13cfbeffc0c31750 - languageName: node - linkType: hard - -"debug@npm:4, debug@npm:^4.1.1, debug@npm:^4.3.4": - version: 4.3.4 - resolution: "debug@npm:4.3.4" - dependencies: - ms: "npm:2.1.2" - peerDependenciesMeta: - supports-color: - optional: true - checksum: cedbec45298dd5c501d01b92b119cd3faebe5438c3917ff11ae1bff86a6c722930ac9c8659792824013168ba6db7c4668225d845c633fbdafbbf902a6389f736 - languageName: node - linkType: hard - -"decompress-response@npm:^6.0.0": - version: 6.0.0 - resolution: "decompress-response@npm:6.0.0" - dependencies: - mimic-response: "npm:^3.1.0" - checksum: bd89d23141b96d80577e70c54fb226b2f40e74a6817652b80a116d7befb8758261ad073a8895648a29cc0a5947021ab66705cb542fa9c143c82022b27c5b175e - languageName: node - linkType: hard - -"defaults@npm:^1.0.3": - version: 1.0.4 - resolution: "defaults@npm:1.0.4" - dependencies: - clone: "npm:^1.0.2" - checksum: 9cfbe498f5c8ed733775db62dfd585780387d93c17477949e1670bfcfb9346e0281ce8c4bf9f4ac1fc0f9b851113bd6dc9e41182ea1644ccd97de639fa13c35a - languageName: node - linkType: hard - -"defer-to-connect@npm:^2.0.0": - version: 2.0.1 - resolution: "defer-to-connect@npm:2.0.1" - checksum: 625ce28e1b5ad10cf77057b9a6a727bf84780c17660f6644dab61dd34c23de3001f03cedc401f7d30a4ed9965c2e8a7336e220a329146f2cf85d4eddea429782 - languageName: node - linkType: hard - -"eastasianwidth@npm:^0.2.0": - version: 0.2.0 - resolution: "eastasianwidth@npm:0.2.0" - checksum: 26f364ebcdb6395f95124fda411f63137a4bfb5d3a06453f7f23dfe52502905bd84e0488172e0f9ec295fdc45f05c23d5d91baf16bd26f0fe9acd777a188dc39 - languageName: node - linkType: hard - -"elm-codegen@npm:^0.5.0": - version: 0.5.0 - resolution: "elm-codegen@npm:0.5.0" - dependencies: - chalk: "npm:^4.1.1" - chokidar: "npm:^3.5.1" - commander: "npm:^8.3.0" - node-elm-compiler: "npm:^5.0.6" - bin: - elm-codegen: bin/elm-codegen - checksum: 5e4e2fa3a9502e2545ab52405c4e72d25941e4ae01d733f8742a8173e0d904ffab199001153f020a780f02eaf28967ce08bb5148e0ef7c819489356f4366e8e8 - languageName: node - linkType: hard - -"elm-optimize-level-2@npm:^0.1.5": - version: 0.1.5 - resolution: "elm-optimize-level-2@npm:0.1.5" - dependencies: - chalk: "npm:^4.1.0" - commander: "npm:^6.0.0" - node-elm-compiler: "npm:^5.0.4" - ts-union: "npm:^2.2.1" - typescript: "npm:^3.9.7" - bin: - elm-optimize-level-2: bin/elm-optimize-level-2.js - checksum: 2d16da5881b2b595b9cd20624fbd5df31bade797ad2cf2a630f644ba269a420c22b3d33834a3dfdba6fadfddeada15ee184df804b3959278369100e7d8d88e1d - languageName: node - linkType: hard - -"elm-review@npm:^2.10.2": - version: 2.10.3 - resolution: "elm-review@npm:2.10.3" - dependencies: - chalk: "npm:^4.0.0" - chokidar: "npm:^3.5.2" - cross-spawn: "npm:^7.0.3" - elm-tooling: "npm:^1.14.1" - fastest-levenshtein: "npm:^1.0.16" - find-up: "npm:^4.1.0" - folder-hash: "npm:^3.3.0" - fs-extra: "npm:^9.0.0" - glob: "npm:^7.1.4" - got: "npm:^11.8.5" - graceful-fs: "npm:^4.2.11" - minimist: "npm:^1.2.6" - ora: "npm:^5.4.0" - path-key: "npm:^3.1.1" - prompts: "npm:^2.2.1" - rimraf: "npm:^5.0.0" - strip-ansi: "npm:^6.0.0" - terminal-link: "npm:^2.1.1" - which: "npm:^2.0.2" - wrap-ansi: "npm:^6.2.0" - bin: - elm-review: bin/elm-review - checksum: 61e5748ee8f905e45a4ea47cb1451abb09815c633f31fd778ef43e24e0a3ac03fff043abed6d26e1032f2419d8a21f68748f666e5be93e3b2cbcab65c56ab4a8 - languageName: node - linkType: hard - -"elm-tooling@npm:^1.14.1": - version: 1.15.0 - resolution: "elm-tooling@npm:1.15.0" - bin: - elm-tooling: index.js - checksum: 224a01a904caf059b3aede4d1626338bf1e5badbdc66535db68539715b58486e67728764e262c1a78ffc8dbc49047b0c2912658b8ddbd67c1039ecd2ccec81d6 - languageName: node - linkType: hard - -"elm-watch@npm:^1.1.2": - version: 1.1.2 - resolution: "elm-watch@npm:1.1.2" - dependencies: - chokidar: "npm:^3.5.3" - cross-spawn: "npm:^7.0.3" - tiny-decoders: "npm:^7.0.1" - ws: "npm:^8.12.0" - bin: - elm-watch: index.js - checksum: 26dbb1127a3148425726c95414880f6dadda2d34db34ce91cd9194b2d9527a50b9774c74408b523ade31f6e3e4248720bc411606ccd27d711bf6aa083fcf4602 - languageName: node - linkType: hard - -"emoji-regex@npm:^8.0.0": - version: 8.0.0 - resolution: "emoji-regex@npm:8.0.0" - checksum: b6053ad39951c4cf338f9092d7bfba448cdfd46fe6a2a034700b149ac9ffbc137e361cbd3c442297f86bed2e5f7576c1b54cc0a6bf8ef5106cc62f496af35010 - languageName: node - linkType: hard - -"emoji-regex@npm:^9.2.2": - version: 9.2.2 - resolution: "emoji-regex@npm:9.2.2" - checksum: af014e759a72064cf66e6e694a7fc6b0ed3d8db680427b021a89727689671cefe9d04151b2cad51dbaf85d5ba790d061cd167f1cf32eb7b281f6368b3c181639 - languageName: node - linkType: hard - -"encoding@npm:^0.1.13": - version: 0.1.13 - resolution: "encoding@npm:0.1.13" - dependencies: - iconv-lite: "npm:^0.6.2" - checksum: 36d938712ff00fe1f4bac88b43bcffb5930c1efa57bbcdca9d67e1d9d6c57cfb1200fb01efe0f3109b2ce99b231f90779532814a81370a1bd3274a0f58585039 - languageName: node - linkType: hard - -"end-of-stream@npm:^1.1.0": - version: 1.4.4 - resolution: "end-of-stream@npm:1.4.4" - dependencies: - once: "npm:^1.4.0" - checksum: 870b423afb2d54bb8d243c63e07c170409d41e20b47eeef0727547aea5740bd6717aca45597a9f2745525667a6b804c1e7bede41f856818faee5806dd9ff3975 - languageName: node - linkType: hard - -"env-paths@npm:^2.2.0": - version: 2.2.1 - resolution: "env-paths@npm:2.2.1" - checksum: 285325677bf00e30845e330eec32894f5105529db97496ee3f598478e50f008c5352a41a30e5e72ec9de8a542b5a570b85699cd63bd2bc646dbcb9f311d83bc4 - languageName: node - linkType: hard - -"err-code@npm:^2.0.2": - version: 2.0.3 - resolution: "err-code@npm:2.0.3" - checksum: b642f7b4dd4a376e954947550a3065a9ece6733ab8e51ad80db727aaae0817c2e99b02a97a3d6cecc648a97848305e728289cf312d09af395403a90c9d4d8a66 - languageName: node - linkType: hard - -"exponential-backoff@npm:^3.1.1": - version: 3.1.1 - resolution: "exponential-backoff@npm:3.1.1" - checksum: 160456d2d647e6019640bd07111634d8c353038d9fa40176afb7cd49b0548bdae83b56d05e907c2cce2300b81cae35d800ef92fefb9d0208e190fa3b7d6bb579 - languageName: node - linkType: hard - -"fastest-levenshtein@npm:^1.0.16": - version: 1.0.16 - resolution: "fastest-levenshtein@npm:1.0.16" - checksum: 7e3d8ae812a7f4fdf8cad18e9cde436a39addf266a5986f653ea0d81e0de0900f50c0f27c6d5aff3f686bcb48acbd45be115ae2216f36a6a13a7dbbf5cad878b - languageName: node - linkType: hard - -"fill-range@npm:^7.1.1": - version: 7.1.1 - resolution: "fill-range@npm:7.1.1" - dependencies: - to-regex-range: "npm:^5.0.1" - checksum: b75b691bbe065472f38824f694c2f7449d7f5004aa950426a2c28f0306c60db9b880c0b0e4ed819997ffb882d1da02cfcfc819bddc94d71627f5269682edf018 - languageName: node - linkType: hard - -"find-elm-dependencies@npm:^2.0.4": - version: 2.0.4 - resolution: "find-elm-dependencies@npm:2.0.4" - dependencies: - firstline: "npm:^1.2.0" - lodash: "npm:^4.17.19" - bin: - find-elm-dependencies: bin/cli.js - checksum: f5fca6ab23963ea14031383b89444478075da219c27990f823c80237602c0e4e709944ed9d7cb9c28864200b3570a09e028eedc006fa6304d338188ad8e2b1fe - languageName: node - linkType: hard - -"find-up@npm:^4.1.0": - version: 4.1.0 - resolution: "find-up@npm:4.1.0" - dependencies: - locate-path: "npm:^5.0.0" - path-exists: "npm:^4.0.0" - checksum: 0406ee89ebeefa2d507feb07ec366bebd8a6167ae74aa4e34fb4c4abd06cf782a3ce26ae4194d70706f72182841733f00551c209fe575cb00bd92104056e78c1 - languageName: node - linkType: hard - -"firstline@npm:^1.2.0": - version: 1.3.1 - resolution: "firstline@npm:1.3.1" - checksum: 70c283c7f7da874756b1220bb097111e2640417d7e96ab160e65d5d0a85c357e823173e1942ccd8583597d50c79295ae930a90b5cd9becd72d5286084a5afb92 - languageName: node - linkType: hard - -"folder-hash@npm:^3.3.0": - version: 3.3.3 - resolution: "folder-hash@npm:3.3.3" - dependencies: - debug: "npm:^4.1.1" - graceful-fs: "npm:~4.2.0" - minimatch: "npm:~3.0.4" - bin: - folder-hash: bin/folder-hash - checksum: f5cfab66b1529af0ebf5304f0ffdc0083f73db6441b8a7841ea274b65916f3bc8bdd2b923bbb3257bd89d409926f05ec3480145865183e285e7e470e81f7382b - languageName: node - linkType: hard - -"foreground-child@npm:^3.1.0": - version: 3.1.1 - resolution: "foreground-child@npm:3.1.1" - dependencies: - cross-spawn: "npm:^7.0.0" - signal-exit: "npm:^4.0.1" - checksum: 9700a0285628abaeb37007c9a4d92bd49f67210f09067638774338e146c8e9c825c5c877f072b2f75f41dc6a2d0be8664f79ffc03f6576649f54a84fb9b47de0 - languageName: node - linkType: hard - -"fs-extra@npm:^9.0.0": - version: 9.1.0 - resolution: "fs-extra@npm:9.1.0" - dependencies: - at-least-node: "npm:^1.0.0" - graceful-fs: "npm:^4.2.0" - jsonfile: "npm:^6.0.1" - universalify: "npm:^2.0.0" - checksum: 9b808bd884beff5cb940773018179a6b94a966381d005479f00adda6b44e5e3d4abf765135773d849cc27efe68c349e4a7b86acd7d3306d5932c14f3a4b17a92 - languageName: node - linkType: hard - -"fs-minipass@npm:^2.0.0": - version: 2.1.0 - resolution: "fs-minipass@npm:2.1.0" - dependencies: - minipass: "npm:^3.0.0" - checksum: 703d16522b8282d7299337539c3ed6edddd1afe82435e4f5b76e34a79cd74e488a8a0e26a636afc2440e1a23b03878e2122e3a2cfe375a5cf63c37d92b86a004 - languageName: node - linkType: hard - -"fs-minipass@npm:^3.0.0": - version: 3.0.3 - resolution: "fs-minipass@npm:3.0.3" - dependencies: - minipass: "npm:^7.0.3" - checksum: 63e80da2ff9b621e2cb1596abcb9207f1cf82b968b116ccd7b959e3323144cce7fb141462200971c38bbf2ecca51695069db45265705bed09a7cd93ae5b89f94 - languageName: node - linkType: hard - -"fs.realpath@npm:^1.0.0": - version: 1.0.0 - resolution: "fs.realpath@npm:1.0.0" - checksum: 444cf1291d997165dfd4c0d58b69f0e4782bfd9149fd72faa4fe299e68e0e93d6db941660b37dd29153bf7186672ececa3b50b7e7249477b03fdf850f287c948 - languageName: node - linkType: hard - -"fsevents@npm:~2.3.2": - version: 2.3.2 - resolution: "fsevents@npm:2.3.2" - dependencies: - node-gyp: "npm:latest" - checksum: be78a3efa3e181cda3cf7a4637cb527bcebb0bd0ea0440105a3bb45b86f9245b307dc10a2507e8f4498a7d4ec349d1910f4d73e4d4495b16103106e07eee735b - conditions: os=darwin - languageName: node - linkType: hard - -"fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin": - version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin::version=2.3.2&hash=df0bf1" - dependencies: - node-gyp: "npm:latest" - conditions: os=darwin - languageName: node - linkType: hard - -"get-stream@npm:^5.1.0": - version: 5.2.0 - resolution: "get-stream@npm:5.2.0" - dependencies: - pump: "npm:^3.0.0" - checksum: 43797ffd815fbb26685bf188c8cfebecb8af87b3925091dd7b9a9c915993293d78e3c9e1bce125928ff92f2d0796f3889b92b5ec6d58d1041b574682132e0a80 - languageName: node - linkType: hard - -"glob-parent@npm:~5.1.2": - version: 5.1.2 - resolution: "glob-parent@npm:5.1.2" - dependencies: - is-glob: "npm:^4.0.1" - checksum: cab87638e2112bee3f839ef5f6e0765057163d39c66be8ec1602f3823da4692297ad4e972de876ea17c44d652978638d2fd583c6713d0eb6591706825020c9ee - languageName: node - linkType: hard - -"glob@npm:^10.2.2, glob@npm:^10.3.10, glob@npm:^10.3.7": - version: 10.3.10 - resolution: "glob@npm:10.3.10" - dependencies: - foreground-child: "npm:^3.1.0" - jackspeak: "npm:^2.3.5" - minimatch: "npm:^9.0.1" - minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0" - path-scurry: "npm:^1.10.1" - bin: - glob: dist/esm/bin.mjs - checksum: 13d8a1feb7eac7945f8c8480e11cd4a44b24d26503d99a8d8ac8d5aefbf3e9802a2b6087318a829fad04cb4e829f25c5f4f1110c68966c498720dd261c7e344d - languageName: node - linkType: hard - -"glob@npm:^7.1.3, glob@npm:^7.1.4": - version: 7.2.3 - resolution: "glob@npm:7.2.3" - dependencies: - fs.realpath: "npm:^1.0.0" - inflight: "npm:^1.0.4" - inherits: "npm:2" - minimatch: "npm:^3.1.1" - once: "npm:^1.3.0" - path-is-absolute: "npm:^1.0.0" - checksum: 65676153e2b0c9095100fe7f25a778bf45608eeb32c6048cf307f579649bcc30353277b3b898a3792602c65764e5baa4f643714dfbdfd64ea271d210c7a425fe - languageName: node - linkType: hard - -"got@npm:^11.8.5": - version: 11.8.6 - resolution: "got@npm:11.8.6" - dependencies: - "@sindresorhus/is": "npm:^4.0.0" - "@szmarczak/http-timer": "npm:^4.0.5" - "@types/cacheable-request": "npm:^6.0.1" - "@types/responselike": "npm:^1.0.0" - cacheable-lookup: "npm:^5.0.3" - cacheable-request: "npm:^7.0.2" - decompress-response: "npm:^6.0.0" - http2-wrapper: "npm:^1.0.0-beta.5.2" - lowercase-keys: "npm:^2.0.0" - p-cancelable: "npm:^2.0.0" - responselike: "npm:^2.0.0" - checksum: 754dd44877e5cf6183f1e989ff01c648d9a4719e357457bd4c78943911168881f1cfb7b2cb15d885e2105b3ad313adb8f017a67265dd7ade771afdb261ee8cb1 - languageName: node - linkType: hard - -"graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.11, graceful-fs@npm:^4.2.6, graceful-fs@npm:~4.2.0": - version: 4.2.11 - resolution: "graceful-fs@npm:4.2.11" - checksum: 386d011a553e02bc594ac2ca0bd6d9e4c22d7fa8cfbfc448a6d148c59ea881b092db9dbe3547ae4b88e55f1b01f7c4a2ecc53b310c042793e63aa44cf6c257f2 - languageName: node - linkType: hard - -"has-flag@npm:^4.0.0": - version: 4.0.0 - resolution: "has-flag@npm:4.0.0" - checksum: 2e789c61b7888d66993e14e8331449e525ef42aac53c627cc53d1c3334e768bcb6abdc4f5f0de1478a25beec6f0bd62c7549058b7ac53e924040d4f301f02fd1 - languageName: node - linkType: hard - -"http-cache-semantics@npm:^4.0.0, http-cache-semantics@npm:^4.1.1": - version: 4.1.1 - resolution: "http-cache-semantics@npm:4.1.1" - checksum: ce1319b8a382eb3cbb4a37c19f6bfe14e5bb5be3d09079e885e8c513ab2d3cd9214902f8a31c9dc4e37022633ceabfc2d697405deeaf1b8f3552bb4ed996fdfc - languageName: node - linkType: hard - -"http-proxy-agent@npm:^7.0.0": - version: 7.0.0 - resolution: "http-proxy-agent@npm:7.0.0" - dependencies: - agent-base: "npm:^7.1.0" - debug: "npm:^4.3.4" - checksum: a11574ff39436cee3c7bc67f259444097b09474605846ddd8edf0bf4ad8644be8533db1aa463426e376865047d05dc22755e638632819317c0c2f1b2196657c8 - languageName: node - linkType: hard - -"http2-wrapper@npm:^1.0.0-beta.5.2": - version: 1.0.3 - resolution: "http2-wrapper@npm:1.0.3" - dependencies: - quick-lru: "npm:^5.1.1" - resolve-alpn: "npm:^1.0.0" - checksum: 6a9b72a033e9812e1476b9d776ce2f387bc94bc46c88aea0d5dab6bd47d0a539b8178830e77054dd26d1142c866d515a28a4dc7c3ff4232c88ff2ebe4f5d12d1 - languageName: node - linkType: hard - -"https-proxy-agent@npm:^7.0.1": - version: 7.0.2 - resolution: "https-proxy-agent@npm:7.0.2" - dependencies: - agent-base: "npm:^7.0.2" - debug: "npm:4" - checksum: 7735eb90073db087e7e79312e3d97c8c04baf7ea7ca7b013382b6a45abbaa61b281041a98f4e13c8c80d88f843785bcc84ba189165b4b4087b1e3496ba656d77 - languageName: node - linkType: hard - -"iconv-lite@npm:^0.6.2": - version: 0.6.3 - resolution: "iconv-lite@npm:0.6.3" - dependencies: - safer-buffer: "npm:>= 2.1.2 < 3.0.0" - checksum: 98102bc66b33fcf5ac044099d1257ba0b7ad5e3ccd3221f34dd508ab4070edff183276221684e1e0555b145fce0850c9f7d2b60a9fcac50fbb4ea0d6e845a3b1 - languageName: node - linkType: hard - -"ieee754@npm:^1.1.13": - version: 1.2.1 - resolution: "ieee754@npm:1.2.1" - checksum: b0782ef5e0935b9f12883a2e2aa37baa75da6e66ce6515c168697b42160807d9330de9a32ec1ed73149aea02e0d822e572bca6f1e22bdcbd2149e13b050b17bb - languageName: node - linkType: hard - -"immediate@npm:~3.0.5": - version: 3.0.6 - resolution: "immediate@npm:3.0.6" - checksum: f8ba7ede69bee9260241ad078d2d535848745ff5f6995c7c7cb41cfdc9ccc213f66e10fa5afb881f90298b24a3f7344b637b592beb4f54e582770cdce3f1f039 - languageName: node - linkType: hard - -"imurmurhash@npm:^0.1.4": - version: 0.1.4 - resolution: "imurmurhash@npm:0.1.4" - checksum: 8b51313850dd33605c6c9d3fd9638b714f4c4c40250cff658209f30d40da60f78992fb2df5dabee4acf589a6a82bbc79ad5486550754bd9ec4e3fc0d4a57d6a6 - languageName: node - linkType: hard - -"indent-string@npm:^4.0.0": - version: 4.0.0 - resolution: "indent-string@npm:4.0.0" - checksum: 1e1904ddb0cb3d6cce7cd09e27a90184908b7a5d5c21b92e232c93579d314f0b83c246ffb035493d0504b1e9147ba2c9b21df0030f48673fba0496ecd698161f - languageName: node - linkType: hard - -"inflight@npm:^1.0.4": - version: 1.0.6 - resolution: "inflight@npm:1.0.6" - dependencies: - once: "npm:^1.3.0" - wrappy: "npm:1" - checksum: 7faca22584600a9dc5b9fca2cd5feb7135ac8c935449837b315676b4c90aa4f391ec4f42240178244b5a34e8bede1948627fda392ca3191522fc46b34e985ab2 - languageName: node - linkType: hard - -"inherits@npm:2, inherits@npm:^2.0.3, inherits@npm:^2.0.4": - version: 2.0.4 - resolution: "inherits@npm:2.0.4" - checksum: 4e531f648b29039fb7426fb94075e6545faa1eb9fe83c29f0b6d9e7263aceb4289d2d4557db0d428188eeb449cc7c5e77b0a0b2c4e248ff2a65933a0dee49ef2 - languageName: node - linkType: hard - -"ip@npm:^2.0.0": - version: 2.0.1 - resolution: "ip@npm:2.0.1" - checksum: cab8eb3e88d0abe23e4724829621ec4c4c5cb41a7f936a2e626c947128c1be16ed543448d42af7cca95379f9892bfcacc1ccd8d09bc7e8bea0e86d492ce33616 - languageName: node - linkType: hard - -"is-binary-path@npm:~2.1.0": - version: 2.1.0 - resolution: "is-binary-path@npm:2.1.0" - dependencies: - binary-extensions: "npm:^2.0.0" - checksum: a16eaee59ae2b315ba36fad5c5dcaf8e49c3e27318f8ab8fa3cdb8772bf559c8d1ba750a589c2ccb096113bb64497084361a25960899cb6172a6925ab6123d38 - languageName: node - linkType: hard - -"is-extglob@npm:^2.1.1": - version: 2.1.1 - resolution: "is-extglob@npm:2.1.1" - checksum: 5487da35691fbc339700bbb2730430b07777a3c21b9ebaecb3072512dfd7b4ba78ac2381a87e8d78d20ea08affb3f1971b4af629173a6bf435ff8a4c47747912 - languageName: node - linkType: hard - -"is-fullwidth-code-point@npm:^3.0.0": - version: 3.0.0 - resolution: "is-fullwidth-code-point@npm:3.0.0" - checksum: bb11d825e049f38e04c06373a8d72782eee0205bda9d908cc550ccb3c59b99d750ff9537982e01733c1c94a58e35400661f57042158ff5e8f3e90cf936daf0fc - languageName: node - linkType: hard - -"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": - version: 4.0.3 - resolution: "is-glob@npm:4.0.3" - dependencies: - is-extglob: "npm:^2.1.1" - checksum: 17fb4014e22be3bbecea9b2e3a76e9e34ff645466be702f1693e8f1ee1adac84710d0be0bd9f967d6354036fd51ab7c2741d954d6e91dae6bb69714de92c197a - languageName: node - linkType: hard - -"is-interactive@npm:^1.0.0": - version: 1.0.0 - resolution: "is-interactive@npm:1.0.0" - checksum: dd47904dbf286cd20aa58c5192161be1a67138485b9836d5a70433b21a45442e9611b8498b8ab1f839fc962c7620667a50535fdfb4a6bc7989b8858645c06b4d - languageName: node - linkType: hard - -"is-lambda@npm:^1.0.1": - version: 1.0.1 - resolution: "is-lambda@npm:1.0.1" - checksum: 85fee098ae62ba6f1e24cf22678805473c7afd0fb3978a3aa260e354cb7bcb3a5806cf0a98403188465efedec41ab4348e8e4e79305d409601323855b3839d4d - languageName: node - linkType: hard - -"is-number@npm:^7.0.0": - version: 7.0.0 - resolution: "is-number@npm:7.0.0" - checksum: b4686d0d3053146095ccd45346461bc8e53b80aeb7671cc52a4de02dbbf7dc0d1d2a986e2fe4ae206984b4d34ef37e8b795ebc4f4295c978373e6575e295d811 - languageName: node - linkType: hard - -"is-unicode-supported@npm:^0.1.0": - version: 0.1.0 - resolution: "is-unicode-supported@npm:0.1.0" - checksum: 00cbe3455c3756be68d2542c416cab888aebd5012781d6819749fefb15162ff23e38501fe681b3d751c73e8ff561ac09a5293eba6f58fdf0178462ce6dcb3453 - languageName: node - linkType: hard - -"isexe@npm:^2.0.0": - version: 2.0.0 - resolution: "isexe@npm:2.0.0" - checksum: 228cfa503fadc2c31596ab06ed6aa82c9976eec2bfd83397e7eaf06d0ccf42cd1dfd6743bf9aeb01aebd4156d009994c5f76ea898d2832c1fe342da923ca457d - languageName: node - linkType: hard - -"isexe@npm:^3.1.1": - version: 3.1.1 - resolution: "isexe@npm:3.1.1" - checksum: 9ec257654093443eb0a528a9c8cbba9c0ca7616ccb40abd6dde7202734d96bb86e4ac0d764f0f8cd965856aacbff2f4ce23e730dc19dfb41e3b0d865ca6fdcc7 - languageName: node - linkType: hard - -"jackspeak@npm:^2.3.5": - version: 2.3.6 - resolution: "jackspeak@npm:2.3.6" - dependencies: - "@isaacs/cliui": "npm:^8.0.2" - "@pkgjs/parseargs": "npm:^0.11.0" - dependenciesMeta: - "@pkgjs/parseargs": - optional: true - checksum: f01d8f972d894cd7638bc338e9ef5ddb86f7b208ce177a36d718eac96ec86638a6efa17d0221b10073e64b45edc2ce15340db9380b1f5d5c5d000cbc517dc111 - languageName: node - linkType: hard - -"json-buffer@npm:3.0.1": - version: 3.0.1 - resolution: "json-buffer@npm:3.0.1" - checksum: 0d1c91569d9588e7eef2b49b59851f297f3ab93c7b35c7c221e288099322be6b562767d11e4821da500f3219542b9afd2e54c5dc573107c1126ed1080f8e96d7 - languageName: node - linkType: hard - -"jsonfile@npm:^6.0.1": - version: 6.1.0 - resolution: "jsonfile@npm:6.1.0" - dependencies: - graceful-fs: "npm:^4.1.6" - universalify: "npm:^2.0.0" - dependenciesMeta: - graceful-fs: - optional: true - checksum: 4f95b5e8a5622b1e9e8f33c96b7ef3158122f595998114d1e7f03985649ea99cb3cd99ce1ed1831ae94c8c8543ab45ebd044207612f31a56fd08462140e46865 - languageName: node - linkType: hard - -"keyv@npm:^4.0.0": - version: 4.5.2 - resolution: "keyv@npm:4.5.2" - dependencies: - json-buffer: "npm:3.0.1" - checksum: b633bf53a5afa5591f383d326746226e110e59f13c7e1e8d3e3c9580d2c2345c5eefc21cce168cd5be7fa34b9163e391927146fbd2b7ee7aa2f3aa02b7f0a7de - languageName: node - linkType: hard - -"kleur@npm:^3.0.3": - version: 3.0.3 - resolution: "kleur@npm:3.0.3" - checksum: cd3a0b8878e7d6d3799e54340efe3591ca787d9f95f109f28129bdd2915e37807bf8918bb295ab86afb8c82196beec5a1adcaf29042ce3f2bd932b038fe3aa4b - languageName: node - linkType: hard - -"lie@npm:3.1.1": - version: 3.1.1 - resolution: "lie@npm:3.1.1" - dependencies: - immediate: "npm:~3.0.5" - checksum: d62685786590351b8e407814acdd89efe1cb136f05cb9236c5a97b2efdca1f631d2997310ad2d565c753db7596799870140e4777c9c9b8c44a0f6bf42d1804a1 - languageName: node - linkType: hard - -"localforage@npm:^1.9.0": - version: 1.10.0 - resolution: "localforage@npm:1.10.0" - dependencies: - lie: "npm:3.1.1" - checksum: 00f19f1f97002e6721587ed5017f502d58faf80dae567d5065d4d1ee0caf0762f40d2e2dba7f0ef7d3f14ee6203242daae9ecad97359bfc10ecff36df11d85a3 - languageName: node - linkType: hard - -"locate-path@npm:^5.0.0": - version: 5.0.0 - resolution: "locate-path@npm:5.0.0" - dependencies: - p-locate: "npm:^4.1.0" - checksum: 33a1c5247e87e022f9713e6213a744557a3e9ec32c5d0b5efb10aa3a38177615bf90221a5592674857039c1a0fd2063b82f285702d37b792d973e9e72ace6c59 - languageName: node - linkType: hard - -"lodash@npm:^4.17.19": - version: 4.17.21 - resolution: "lodash@npm:4.17.21" - checksum: d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c - languageName: node - linkType: hard - -"log-symbols@npm:^4.1.0": - version: 4.1.0 - resolution: "log-symbols@npm:4.1.0" - dependencies: - chalk: "npm:^4.1.0" - is-unicode-supported: "npm:^0.1.0" - checksum: 67f445a9ffa76db1989d0fa98586e5bc2fd5247260dafb8ad93d9f0ccd5896d53fb830b0e54dade5ad838b9de2006c826831a3c528913093af20dff8bd24aca6 - languageName: node - linkType: hard - -"lowercase-keys@npm:^2.0.0": - version: 2.0.0 - resolution: "lowercase-keys@npm:2.0.0" - checksum: f82a2b3568910509da4b7906362efa40f5b54ea14c2584778ddb313226f9cbf21020a5db35f9b9a0e95847a9b781d548601f31793d736b22a2b8ae8eb9ab1082 - languageName: node - linkType: hard - -"lru-cache@npm:^10.0.1, lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.1.0 - resolution: "lru-cache@npm:10.1.0" - checksum: 778bc8b2626daccd75f24c4b4d10632496e21ba064b126f526c626fbdbc5b28c472013fccd45d7646b9e1ef052444824854aed617b59cd570d01a8b7d651fc1e - languageName: node - linkType: hard - -"lru-cache@npm:^6.0.0": - version: 6.0.0 - resolution: "lru-cache@npm:6.0.0" - dependencies: - yallist: "npm:^4.0.0" - checksum: cb53e582785c48187d7a188d3379c181b5ca2a9c78d2bce3e7dee36f32761d1c42983da3fe12b55cb74e1779fa94cdc2e5367c028a9b35317184ede0c07a30a9 - languageName: node - linkType: hard - -"make-fetch-happen@npm:^13.0.0": - version: 13.0.0 - resolution: "make-fetch-happen@npm:13.0.0" - dependencies: - "@npmcli/agent": "npm:^2.0.0" - cacache: "npm:^18.0.0" - http-cache-semantics: "npm:^4.1.1" - is-lambda: "npm:^1.0.1" - minipass: "npm:^7.0.2" - minipass-fetch: "npm:^3.0.0" - minipass-flush: "npm:^1.0.5" - minipass-pipeline: "npm:^1.2.4" - negotiator: "npm:^0.6.3" - promise-retry: "npm:^2.0.1" - ssri: "npm:^10.0.0" - checksum: 43b9f6dcbc6fe8b8604cb6396957c3698857a15ba4dbc38284f7f0e61f248300585ef1eb8cc62df54e9c724af977e45b5cdfd88320ef7f53e45070ed3488da55 - languageName: node - linkType: hard - -"mimic-fn@npm:^2.1.0": - version: 2.1.0 - resolution: "mimic-fn@npm:2.1.0" - checksum: b26f5479d7ec6cc2bce275a08f146cf78f5e7b661b18114e2506dd91ec7ec47e7a25bf4360e5438094db0560bcc868079fb3b1fb3892b833c1ecbf63f80c95a4 - languageName: node - linkType: hard - -"mimic-response@npm:^1.0.0": - version: 1.0.1 - resolution: "mimic-response@npm:1.0.1" - checksum: c5381a5eae997f1c3b5e90ca7f209ed58c3615caeee850e85329c598f0c000ae7bec40196580eef1781c60c709f47258131dab237cad8786f8f56750594f27fa - languageName: node - linkType: hard - -"mimic-response@npm:^3.1.0": - version: 3.1.0 - resolution: "mimic-response@npm:3.1.0" - checksum: 0d6f07ce6e03e9e4445bee655202153bdb8a98d67ee8dc965ac140900d7a2688343e6b4c9a72cfc9ef2f7944dfd76eef4ab2482eb7b293a68b84916bac735362 - languageName: node - linkType: hard - -"minimatch@npm:^3.1.1": - version: 3.1.2 - resolution: "minimatch@npm:3.1.2" - dependencies: - brace-expansion: "npm:^1.1.7" - checksum: 0262810a8fc2e72cca45d6fd86bd349eee435eb95ac6aa45c9ea2180e7ee875ef44c32b55b5973ceabe95ea12682f6e3725cbb63d7a2d1da3ae1163c8b210311 - languageName: node - linkType: hard - -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: "npm:^2.0.1" - checksum: 85f407dcd38ac3e180f425e86553911d101455ca3ad5544d6a7cec16286657e4f8a9aa6695803025c55e31e35a91a2252b5dc8e7d527211278b8b65b4dbd5eac - languageName: node - linkType: hard - -"minimatch@npm:~3.0.4": - version: 3.0.8 - resolution: "minimatch@npm:3.0.8" - dependencies: - brace-expansion: "npm:^1.1.7" - checksum: 72b226f452dcfb5075255f53534cb83fc25565b909e79b9be4fad463d735cb1084827f7013ff41d050e77ee6e474408c6073473edd2fb72c2fd630cfb0acc6ad - languageName: node - linkType: hard - -"minimist@npm:^1.2.6": - version: 1.2.8 - resolution: "minimist@npm:1.2.8" - checksum: 19d3fcdca050087b84c2029841a093691a91259a47def2f18222f41e7645a0b7c44ef4b40e88a1e58a40c84d2ef0ee6047c55594d298146d0eb3f6b737c20ce6 - languageName: node - linkType: hard - -"minipass-collect@npm:^2.0.1": - version: 2.0.1 - resolution: "minipass-collect@npm:2.0.1" - dependencies: - minipass: "npm:^7.0.3" - checksum: 5167e73f62bb74cc5019594709c77e6a742051a647fe9499abf03c71dca75515b7959d67a764bdc4f8b361cf897fbf25e2d9869ee039203ed45240f48b9aa06e - languageName: node - linkType: hard - -"minipass-fetch@npm:^3.0.0": - version: 3.0.4 - resolution: "minipass-fetch@npm:3.0.4" - dependencies: - encoding: "npm:^0.1.13" - minipass: "npm:^7.0.3" - minipass-sized: "npm:^1.0.3" - minizlib: "npm:^2.1.2" - dependenciesMeta: - encoding: - optional: true - checksum: 1b63c1f3313e88eeac4689f1b71c9f086598db9a189400e3ee960c32ed89e06737fa23976c9305c2d57464fb3fcdc12749d3378805c9d6176f5569b0d0ee8a75 - languageName: node - linkType: hard - -"minipass-flush@npm:^1.0.5": - version: 1.0.5 - resolution: "minipass-flush@npm:1.0.5" - dependencies: - minipass: "npm:^3.0.0" - checksum: 2a51b63feb799d2bb34669205eee7c0eaf9dce01883261a5b77410c9408aa447e478efd191b4de6fc1101e796ff5892f8443ef20d9544385819093dbb32d36bd - languageName: node - linkType: hard - -"minipass-pipeline@npm:^1.2.4": - version: 1.2.4 - resolution: "minipass-pipeline@npm:1.2.4" - dependencies: - minipass: "npm:^3.0.0" - checksum: cbda57cea20b140b797505dc2cac71581a70b3247b84480c1fed5ca5ba46c25ecc25f68bfc9e6dcb1a6e9017dab5c7ada5eab73ad4f0a49d84e35093e0c643f2 - languageName: node - linkType: hard - -"minipass-sized@npm:^1.0.3": - version: 1.0.3 - resolution: "minipass-sized@npm:1.0.3" - dependencies: - minipass: "npm:^3.0.0" - checksum: 298f124753efdc745cfe0f2bdfdd81ba25b9f4e753ca4a2066eb17c821f25d48acea607dfc997633ee5bf7b6dfffb4eee4f2051eb168663f0b99fad2fa4829cb - languageName: node - linkType: hard - -"minipass@npm:^3.0.0": - version: 3.3.6 - resolution: "minipass@npm:3.3.6" - dependencies: - yallist: "npm:^4.0.0" - checksum: a114746943afa1dbbca8249e706d1d38b85ed1298b530f5808ce51f8e9e941962e2a5ad2e00eae7dd21d8a4aae6586a66d4216d1a259385e9d0358f0c1eba16c - languageName: node - linkType: hard - -"minipass@npm:^5.0.0": - version: 5.0.0 - resolution: "minipass@npm:5.0.0" - checksum: a91d8043f691796a8ac88df039da19933ef0f633e3d7f0d35dcd5373af49131cf2399bfc355f41515dc495e3990369c3858cd319e5c2722b4753c90bf3152462 - languageName: node - linkType: hard - -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0, minipass@npm:^7.0.2, minipass@npm:^7.0.3": - version: 7.0.4 - resolution: "minipass@npm:7.0.4" - checksum: 6c7370a6dfd257bf18222da581ba89a5eaedca10e158781232a8b5542a90547540b4b9b7e7f490e4cda43acfbd12e086f0453728ecf8c19e0ef6921bc5958ac5 - languageName: node - linkType: hard - -"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": - version: 2.1.2 - resolution: "minizlib@npm:2.1.2" - dependencies: - minipass: "npm:^3.0.0" - yallist: "npm:^4.0.0" - checksum: 64fae024e1a7d0346a1102bb670085b17b7f95bf6cfdf5b128772ec8faf9ea211464ea4add406a3a6384a7d87a0cd1a96263692134323477b4fb43659a6cab78 - languageName: node - linkType: hard - -"mkdirp@npm:^0.5.1": - version: 0.5.6 - resolution: "mkdirp@npm:0.5.6" - dependencies: - minimist: "npm:^1.2.6" - bin: - mkdirp: bin/cmd.js - checksum: e2e2be789218807b58abced04e7b49851d9e46e88a2f9539242cc8a92c9b5c3a0b9bab360bd3014e02a140fc4fbc58e31176c408b493f8a2a6f4986bd7527b01 - languageName: node - linkType: hard - -"mkdirp@npm:^1.0.3": - version: 1.0.4 - resolution: "mkdirp@npm:1.0.4" - bin: - mkdirp: bin/cmd.js - checksum: 46ea0f3ffa8bc6a5bc0c7081ffc3907777f0ed6516888d40a518c5111f8366d97d2678911ad1a6882bf592fa9de6c784fea32e1687bb94e1f4944170af48a5cf - languageName: node - linkType: hard - -"ms@npm:2.1.2": - version: 2.1.2 - resolution: "ms@npm:2.1.2" - checksum: a437714e2f90dbf881b5191d35a6db792efbca5badf112f87b9e1c712aace4b4b9b742dd6537f3edf90fd6f684de897cec230abde57e87883766712ddda297cc - languageName: node - linkType: hard - -"negotiator@npm:^0.6.3": - version: 0.6.3 - resolution: "negotiator@npm:0.6.3" - checksum: 3ec9fd413e7bf071c937ae60d572bc67155262068ed522cf4b3be5edbe6ddf67d095ec03a3a14ebf8fc8e95f8e1d61be4869db0dbb0de696f6b837358bd43fc2 - languageName: node - linkType: hard - -"nice-try@npm:^1.0.4": - version: 1.0.5 - resolution: "nice-try@npm:1.0.5" - checksum: 95568c1b73e1d0d4069a3e3061a2102d854513d37bcfda73300015b7ba4868d3b27c198d1dbbd8ebdef4112fc2ed9e895d4a0f2e1cce0bd334f2a1346dc9205f - languageName: node - linkType: hard - -"node-elm-compiler@npm:^5.0.4, node-elm-compiler@npm:^5.0.6": - version: 5.0.6 - resolution: "node-elm-compiler@npm:5.0.6" - dependencies: - cross-spawn: "npm:6.0.5" - find-elm-dependencies: "npm:^2.0.4" - lodash: "npm:^4.17.19" - temp: "npm:^0.9.0" - checksum: 17cf83f08b6e4b99cab3ad555d44fcb84223cf96e54af400ae334933d440e2de9772064d976da337f1e07c1795ad4ab30eaa335b4d5a9cf0501bc4af020f1599 - languageName: node - linkType: hard - -"node-gyp@npm:latest": - version: 10.0.1 - resolution: "node-gyp@npm:10.0.1" - dependencies: - env-paths: "npm:^2.2.0" - exponential-backoff: "npm:^3.1.1" - glob: "npm:^10.3.10" - graceful-fs: "npm:^4.2.6" - make-fetch-happen: "npm:^13.0.0" - nopt: "npm:^7.0.0" - proc-log: "npm:^3.0.0" - semver: "npm:^7.3.5" - tar: "npm:^6.1.2" - which: "npm:^4.0.0" - bin: - node-gyp: bin/node-gyp.js - checksum: abddfff7d873312e4ed4a5fb75ce893a5c4fb69e7fcb1dfa71c28a6b92a7f1ef6b62790dffb39181b5a82728ba8f2f32d229cf8cbe66769fe02cea7db4a555aa - languageName: node - linkType: hard - -"nopt@npm:^7.0.0": - version: 7.2.0 - resolution: "nopt@npm:7.2.0" - dependencies: - abbrev: "npm:^2.0.0" - bin: - nopt: bin/nopt.js - checksum: 9bd7198df6f16eb29ff16892c77bcf7f0cc41f9fb5c26280ac0def2cf8cf319f3b821b3af83eba0e74c85807cc430a16efe0db58fe6ae1f41e69519f585b6aff - languageName: node - linkType: hard - -"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": - version: 3.0.0 - resolution: "normalize-path@npm:3.0.0" - checksum: e008c8142bcc335b5e38cf0d63cfd39d6cf2d97480af9abdbe9a439221fd4d749763bab492a8ee708ce7a194bb00c9da6d0a115018672310850489137b3da046 - languageName: node - linkType: hard - -"normalize-url@npm:^6.0.1": - version: 6.1.0 - resolution: "normalize-url@npm:6.1.0" - checksum: 95d948f9bdd2cfde91aa786d1816ae40f8262946e13700bf6628105994fe0ff361662c20af3961161c38a119dc977adeb41fc0b41b1745eb77edaaf9cb22db23 - languageName: node - linkType: hard - -"nuplot@workspace:.": - version: 0.0.0-use.local - resolution: "nuplot@workspace:." - dependencies: - elm-codegen: "npm:^0.5.0" - elm-optimize-level-2: "npm:^0.1.5" - elm-review: "npm:^2.10.2" - elm-watch: "npm:^1.1.2" - localforage: "npm:^1.9.0" - typescript: "npm:^4.3.5" - languageName: unknown - linkType: soft - -"once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": - version: 1.4.0 - resolution: "once@npm:1.4.0" - dependencies: - wrappy: "npm:1" - checksum: 5d48aca287dfefabd756621c5dfce5c91a549a93e9fdb7b8246bc4c4790aa2ec17b34a260530474635147aeb631a2dcc8b32c613df0675f96041cbb8244517d0 - languageName: node - linkType: hard - -"onetime@npm:^5.1.0": - version: 5.1.2 - resolution: "onetime@npm:5.1.2" - dependencies: - mimic-fn: "npm:^2.1.0" - checksum: ffcef6fbb2692c3c40749f31ea2e22677a876daea92959b8a80b521d95cca7a668c884d8b2045d1d8ee7d56796aa405c405462af112a1477594cc63531baeb8f - languageName: node - linkType: hard - -"ora@npm:^5.4.0": - version: 5.4.1 - resolution: "ora@npm:5.4.1" - dependencies: - bl: "npm:^4.1.0" - chalk: "npm:^4.1.0" - cli-cursor: "npm:^3.1.0" - cli-spinners: "npm:^2.5.0" - is-interactive: "npm:^1.0.0" - is-unicode-supported: "npm:^0.1.0" - log-symbols: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - wcwidth: "npm:^1.0.1" - checksum: 10ff14aace236d0e2f044193362b22edce4784add08b779eccc8f8ef97195cae1248db8ec1ec5f5ff076f91acbe573f5f42a98c19b78dba8c54eefff983cae85 - languageName: node - linkType: hard - -"p-cancelable@npm:^2.0.0": - version: 2.1.1 - resolution: "p-cancelable@npm:2.1.1" - checksum: 8c6dc1f8dd4154fd8b96a10e55a3a832684c4365fb9108056d89e79fbf21a2465027c04a59d0d797b5ffe10b54a61a32043af287d5c4860f1e996cbdbc847f01 - languageName: node - linkType: hard - -"p-limit@npm:^2.2.0": - version: 2.3.0 - resolution: "p-limit@npm:2.3.0" - dependencies: - p-try: "npm:^2.0.0" - checksum: 8da01ac53efe6a627080fafc127c873da40c18d87b3f5d5492d465bb85ec7207e153948df6b9cbaeb130be70152f874229b8242ee2be84c0794082510af97f12 - languageName: node - linkType: hard - -"p-locate@npm:^4.1.0": - version: 4.1.0 - resolution: "p-locate@npm:4.1.0" - dependencies: - p-limit: "npm:^2.2.0" - checksum: 1b476ad69ad7f6059744f343b26d51ce091508935c1dbb80c4e0a2f397ffce0ca3a1f9f5cd3c7ce19d7929a09719d5c65fe70d8ee289c3f267cd36f2881813e9 - languageName: node - linkType: hard - -"p-map@npm:^4.0.0": - version: 4.0.0 - resolution: "p-map@npm:4.0.0" - dependencies: - aggregate-error: "npm:^3.0.0" - checksum: 592c05bd6262c466ce269ff172bb8de7c6975afca9b50c975135b974e9bdaafbfe80e61aaaf5be6d1200ba08b30ead04b88cfa7e25ff1e3b93ab28c9f62a2c75 - languageName: node - linkType: hard - -"p-try@npm:^2.0.0": - version: 2.2.0 - resolution: "p-try@npm:2.2.0" - checksum: c36c19907734c904b16994e6535b02c36c2224d433e01a2f1ab777237f4d86e6289fd5fd464850491e940379d4606ed850c03e0f9ab600b0ebddb511312e177f - languageName: node - linkType: hard - -"path-exists@npm:^4.0.0": - version: 4.0.0 - resolution: "path-exists@npm:4.0.0" - checksum: 8c0bd3f5238188197dc78dced15207a4716c51cc4e3624c44fc97acf69558f5ebb9a2afff486fe1b4ee148e0c133e96c5e11a9aa5c48a3006e3467da070e5e1b - languageName: node - linkType: hard - -"path-is-absolute@npm:^1.0.0": - version: 1.0.1 - resolution: "path-is-absolute@npm:1.0.1" - checksum: 127da03c82172a2a50099cddbf02510c1791fc2cc5f7713ddb613a56838db1e8168b121a920079d052e0936c23005562059756d653b7c544c53185efe53be078 - languageName: node - linkType: hard - -"path-key@npm:^2.0.1": - version: 2.0.1 - resolution: "path-key@npm:2.0.1" - checksum: dd2044f029a8e58ac31d2bf34c34b93c3095c1481942960e84dd2faa95bbb71b9b762a106aead0646695330936414b31ca0bd862bf488a937ad17c8c5d73b32b - languageName: node - linkType: hard - -"path-key@npm:^3.1.0, path-key@npm:^3.1.1": - version: 3.1.1 - resolution: "path-key@npm:3.1.1" - checksum: 748c43efd5a569c039d7a00a03b58eecd1d75f3999f5a28303d75f521288df4823bc057d8784eb72358b2895a05f29a070bc9f1f17d28226cc4e62494cc58c4c - languageName: node - linkType: hard - -"path-scurry@npm:^1.10.1": - version: 1.10.1 - resolution: "path-scurry@npm:1.10.1" - dependencies: - lru-cache: "npm:^9.1.1 || ^10.0.0" - minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0" - checksum: e5dc78a7348d25eec61ab166317e9e9c7b46818aa2c2b9006c507a6ff48c672d011292d9662527213e558f5652ce0afcc788663a061d8b59ab495681840c0c1e - languageName: node - linkType: hard - -"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 26c02b8d06f03206fc2ab8d16f19960f2ff9e81a658f831ecb656d8f17d9edc799e8364b1f4a7873e89d9702dff96204be0fa26fe4181f6843f040f819dac4be - languageName: node - linkType: hard - -"proc-log@npm:^3.0.0": - version: 3.0.0 - resolution: "proc-log@npm:3.0.0" - checksum: f66430e4ff947dbb996058f6fd22de2c66612ae1a89b097744e17fb18a4e8e7a86db99eda52ccf15e53f00b63f4ec0b0911581ff2aac0355b625c8eac509b0dc - languageName: node - linkType: hard - -"promise-retry@npm:^2.0.1": - version: 2.0.1 - resolution: "promise-retry@npm:2.0.1" - dependencies: - err-code: "npm:^2.0.2" - retry: "npm:^0.12.0" - checksum: 9c7045a1a2928094b5b9b15336dcd2a7b1c052f674550df63cc3f36cd44028e5080448175b6f6ca32b642de81150f5e7b1a98b728f15cb069f2dd60ac2616b96 - languageName: node - linkType: hard - -"prompts@npm:^2.2.1": - version: 2.4.2 - resolution: "prompts@npm:2.4.2" - dependencies: - kleur: "npm:^3.0.3" - sisteransi: "npm:^1.0.5" - checksum: 16f1ac2977b19fe2cf53f8411cc98db7a3c8b115c479b2ca5c82b5527cd937aa405fa04f9a5960abeb9daef53191b53b4d13e35c1f5d50e8718c76917c5f1ea4 - languageName: node - linkType: hard - -"pump@npm:^3.0.0": - version: 3.0.0 - resolution: "pump@npm:3.0.0" - dependencies: - end-of-stream: "npm:^1.1.0" - once: "npm:^1.3.1" - checksum: bbdeda4f747cdf47db97428f3a135728669e56a0ae5f354a9ac5b74556556f5446a46f720a8f14ca2ece5be9b4d5d23c346db02b555f46739934cc6c093a5478 - languageName: node - linkType: hard - -"quick-lru@npm:^5.1.1": - version: 5.1.1 - resolution: "quick-lru@npm:5.1.1" - checksum: a24cba5da8cec30d70d2484be37622580f64765fb6390a928b17f60cd69e8dbd32a954b3ff9176fa1b86d86ff2ba05252fae55dc4d40d0291c60412b0ad096da - languageName: node - linkType: hard - -"readable-stream@npm:^3.4.0": - version: 3.6.2 - resolution: "readable-stream@npm:3.6.2" - dependencies: - inherits: "npm:^2.0.3" - string_decoder: "npm:^1.1.1" - util-deprecate: "npm:^1.0.1" - checksum: e37be5c79c376fdd088a45fa31ea2e423e5d48854be7a22a58869b4e84d25047b193f6acb54f1012331e1bcd667ffb569c01b99d36b0bd59658fb33f513511b7 - languageName: node - linkType: hard - -"readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: "npm:^2.2.1" - checksum: 6fa848cf63d1b82ab4e985f4cf72bd55b7dcfd8e0a376905804e48c3634b7e749170940ba77b32804d5fe93b3cc521aa95a8d7e7d725f830da6d93f3669ce66b - languageName: node - linkType: hard - -"resolve-alpn@npm:^1.0.0": - version: 1.2.1 - resolution: "resolve-alpn@npm:1.2.1" - checksum: b70b29c1843bc39781ef946c8cd4482e6d425976599c0f9c138cec8209e4e0736161bf39319b01676a847000085dfdaf63583c6fb4427bf751a10635bd2aa0c4 - languageName: node - linkType: hard - -"responselike@npm:^2.0.0": - version: 2.0.1 - resolution: "responselike@npm:2.0.1" - dependencies: - lowercase-keys: "npm:^2.0.0" - checksum: 360b6deb5f101a9f8a4174f7837c523c3ec78b7ca8a7c1d45a1062b303659308a23757e318b1e91ed8684ad1205721142dd664d94771cd63499353fd4ee732b5 - languageName: node - linkType: hard - -"restore-cursor@npm:^3.1.0": - version: 3.1.0 - resolution: "restore-cursor@npm:3.1.0" - dependencies: - onetime: "npm:^5.1.0" - signal-exit: "npm:^3.0.2" - checksum: 8051a371d6aa67ff21625fa94e2357bd81ffdc96267f3fb0fc4aaf4534028343836548ef34c240ffa8c25b280ca35eb36be00b3cb2133fa4f51896d7e73c6b4f - languageName: node - linkType: hard - -"retry@npm:^0.12.0": - version: 0.12.0 - resolution: "retry@npm:0.12.0" - checksum: 59933e8501727ba13ad73ef4a04d5280b3717fd650408460c987392efe9d7be2040778ed8ebe933c5cbd63da3dcc37919c141ef8af0a54a6e4fca5a2af177bfe - languageName: node - linkType: hard - -"rimraf@npm:^5.0.0": - version: 5.0.5 - resolution: "rimraf@npm:5.0.5" - dependencies: - glob: "npm:^10.3.7" - bin: - rimraf: dist/esm/bin.mjs - checksum: d50dbe724f33835decd88395b25ed35995077c60a50ae78ded06e0185418914e555817aad1b4243edbff2254548c2f6ad6f70cc850040bebb4da9e8cc016f586 - languageName: node - linkType: hard - -"rimraf@npm:~2.6.2": - version: 2.6.3 - resolution: "rimraf@npm:2.6.3" - dependencies: - glob: "npm:^7.1.3" - bin: - rimraf: ./bin.js - checksum: f1e646f8c567795f2916aef7aadf685b543da6b9a53e482bb04b07472c7eef2b476045ba1e29f401c301c66b630b22b815ab31fdd60c5e1ae6566ff523debf45 - languageName: node - linkType: hard - -"safe-buffer@npm:~5.2.0": - version: 5.2.1 - resolution: "safe-buffer@npm:5.2.1" - checksum: 6501914237c0a86e9675d4e51d89ca3c21ffd6a31642efeba25ad65720bce6921c9e7e974e5be91a786b25aa058b5303285d3c15dbabf983a919f5f630d349f3 - languageName: node - linkType: hard - -"safer-buffer@npm:>= 2.1.2 < 3.0.0": - version: 2.1.2 - resolution: "safer-buffer@npm:2.1.2" - checksum: 7e3c8b2e88a1841c9671094bbaeebd94448111dd90a81a1f606f3f67708a6ec57763b3b47f06da09fc6054193e0e6709e77325415dc8422b04497a8070fa02d4 - languageName: node - linkType: hard - -"semver@npm:^5.5.0": - version: 5.7.1 - resolution: "semver@npm:5.7.1" - bin: - semver: ./bin/semver - checksum: d4884f2aeca28bff35d0bd40ff0a9b2dfc4b36a883bf0ea5dc15d10d9a01bdc9041035b05f825d4b5ac8a56e490703dbf0d986d054de82cc5e9bad3f02ca6e00 - languageName: node - linkType: hard - -"semver@npm:^7.3.5": - version: 7.5.4 - resolution: "semver@npm:7.5.4" - dependencies: - lru-cache: "npm:^6.0.0" - bin: - semver: bin/semver.js - checksum: 5160b06975a38b11c1ab55950cb5b8a23db78df88275d3d8a42ccf1f29e55112ac995b3a26a522c36e3b5f76b0445f1eef70d696b8c7862a2b4303d7b0e7609e - languageName: node - linkType: hard - -"shebang-command@npm:^1.2.0": - version: 1.2.0 - resolution: "shebang-command@npm:1.2.0" - dependencies: - shebang-regex: "npm:^1.0.0" - checksum: 7b20dbf04112c456b7fc258622dafd566553184ac9b6938dd30b943b065b21dabd3776460df534cc02480db5e1b6aec44700d985153a3da46e7db7f9bd21326d - languageName: node - linkType: hard - -"shebang-command@npm:^2.0.0": - version: 2.0.0 - resolution: "shebang-command@npm:2.0.0" - dependencies: - shebang-regex: "npm:^3.0.0" - checksum: a41692e7d89a553ef21d324a5cceb5f686d1f3c040759c50aab69688634688c5c327f26f3ecf7001ebfd78c01f3c7c0a11a7c8bfd0a8bc9f6240d4f40b224e4e - languageName: node - linkType: hard - -"shebang-regex@npm:^1.0.0": - version: 1.0.0 - resolution: "shebang-regex@npm:1.0.0" - checksum: 9abc45dee35f554ae9453098a13fdc2f1730e525a5eb33c51f096cc31f6f10a4b38074c1ebf354ae7bffa7229506083844008dfc3bb7818228568c0b2dc1fff2 - languageName: node - linkType: hard - -"shebang-regex@npm:^3.0.0": - version: 3.0.0 - resolution: "shebang-regex@npm:3.0.0" - checksum: 1dbed0726dd0e1152a92696c76c7f06084eb32a90f0528d11acd764043aacf76994b2fb30aa1291a21bd019d6699164d048286309a278855ee7bec06cf6fb690 - languageName: node - linkType: hard - -"signal-exit@npm:^3.0.2": - version: 3.0.7 - resolution: "signal-exit@npm:3.0.7" - checksum: 25d272fa73e146048565e08f3309d5b942c1979a6f4a58a8c59d5fa299728e9c2fcd1a759ec870863b1fd38653670240cd420dad2ad9330c71f36608a6a1c912 - languageName: node - linkType: hard - -"signal-exit@npm:^4.0.1": - version: 4.1.0 - resolution: "signal-exit@npm:4.1.0" - checksum: 41602dce540e46d599edba9d9860193398d135f7ff72cab629db5171516cfae628d21e7bfccde1bbfdf11c48726bc2a6d1a8fb8701125852fbfda7cf19c6aa83 - languageName: node - linkType: hard - -"sisteransi@npm:^1.0.5": - version: 1.0.5 - resolution: "sisteransi@npm:1.0.5" - checksum: 230ac975cca485b7f6fe2b96a711aa62a6a26ead3e6fb8ba17c5a00d61b8bed0d7adc21f5626b70d7c33c62ff4e63933017a6462942c719d1980bb0b1207ad46 - languageName: node - linkType: hard - -"smart-buffer@npm:^4.2.0": - version: 4.2.0 - resolution: "smart-buffer@npm:4.2.0" - checksum: a16775323e1404dd43fabafe7460be13a471e021637bc7889468eb45ce6a6b207261f454e4e530a19500cc962c4cc5348583520843b363f4193cee5c00e1e539 - languageName: node - linkType: hard - -"socks-proxy-agent@npm:^8.0.1": - version: 8.0.2 - resolution: "socks-proxy-agent@npm:8.0.2" - dependencies: - agent-base: "npm:^7.0.2" - debug: "npm:^4.3.4" - socks: "npm:^2.7.1" - checksum: a842402fc9b8848a31367f2811ca3cd14c4106588b39a0901cd7a69029998adfc6456b0203617c18ed090542ad0c24ee4e9d4c75a0c4b75071e214227c177eb7 - languageName: node - linkType: hard - -"socks@npm:^2.7.1": - version: 2.7.1 - resolution: "socks@npm:2.7.1" - dependencies: - ip: "npm:^2.0.0" - smart-buffer: "npm:^4.2.0" - checksum: 43f69dbc9f34fc8220bc51c6eea1c39715ab3cfdb115d6e3285f6c7d1a603c5c75655668a5bbc11e3c7e2c99d60321fb8d7ab6f38cda6a215fadd0d6d0b52130 - languageName: node - linkType: hard - -"ssri@npm:^10.0.0": - version: 10.0.5 - resolution: "ssri@npm:10.0.5" - dependencies: - minipass: "npm:^7.0.3" - checksum: b091f2ae92474183c7ac5ed3f9811457e1df23df7a7e70c9476eaa9a0c4a0c8fc190fb45acefbf023ca9ee864dd6754237a697dc52a0fb182afe65d8e77443d8 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0": - version: 4.2.3 - resolution: "string-width@npm:4.2.3" - dependencies: - emoji-regex: "npm:^8.0.0" - is-fullwidth-code-point: "npm:^3.0.0" - strip-ansi: "npm:^6.0.1" - checksum: 1e525e92e5eae0afd7454086eed9c818ee84374bb80328fc41217ae72ff5f065ef1c9d7f72da41de40c75fa8bb3dee63d92373fd492c84260a552c636392a47b - languageName: node - linkType: hard - -"string-width@npm:^5.0.1, string-width@npm:^5.1.2": - version: 5.1.2 - resolution: "string-width@npm:5.1.2" - dependencies: - eastasianwidth: "npm:^0.2.0" - emoji-regex: "npm:^9.2.2" - strip-ansi: "npm:^7.0.1" - checksum: ab9c4264443d35b8b923cbdd513a089a60de339216d3b0ed3be3ba57d6880e1a192b70ae17225f764d7adbf5994e9bb8df253a944736c15a0240eff553c678ca - languageName: node - linkType: hard - -"string_decoder@npm:^1.1.1": - version: 1.3.0 - resolution: "string_decoder@npm:1.3.0" - dependencies: - safe-buffer: "npm:~5.2.0" - checksum: 810614ddb030e271cd591935dcd5956b2410dd079d64ff92a1844d6b7588bf992b3e1b69b0f4d34a3e06e0bd73046ac646b5264c1987b20d0601f81ef35d731d - languageName: node - linkType: hard - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": - version: 6.0.1 - resolution: "strip-ansi@npm:6.0.1" - dependencies: - ansi-regex: "npm:^5.0.1" - checksum: 1ae5f212a126fe5b167707f716942490e3933085a5ff6c008ab97ab2f272c8025d3aa218b7bd6ab25729ca20cc81cddb252102f8751e13482a5199e873680952 - languageName: node - linkType: hard - -"strip-ansi@npm:^7.0.1": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: "npm:^6.0.1" - checksum: a198c3762e8832505328cbf9e8c8381de14a4fa50a4f9b2160138158ea88c0f5549fb50cb13c651c3088f47e63a108b34622ec18c0499b6c8c3a5ddf6b305ac4 - languageName: node - linkType: hard - -"supports-color@npm:^7.0.0, supports-color@npm:^7.1.0": - version: 7.2.0 - resolution: "supports-color@npm:7.2.0" - dependencies: - has-flag: "npm:^4.0.0" - checksum: afb4c88521b8b136b5f5f95160c98dee7243dc79d5432db7efc27efb219385bbc7d9427398e43dd6cc730a0f87d5085ce1652af7efbe391327bc0a7d0f7fc124 - languageName: node - linkType: hard - -"supports-hyperlinks@npm:^2.0.0": - version: 2.3.0 - resolution: "supports-hyperlinks@npm:2.3.0" - dependencies: - has-flag: "npm:^4.0.0" - supports-color: "npm:^7.0.0" - checksum: 4057f0d86afb056cd799602f72d575b8fdd79001c5894bcb691176f14e870a687e7981e50bc1484980e8b688c6d5bcd4931e1609816abb5a7dc1486b7babf6a1 - languageName: node - linkType: hard - -"tar@npm:^6.1.11, tar@npm:^6.1.2": - version: 6.2.1 - resolution: "tar@npm:6.2.1" - dependencies: - chownr: "npm:^2.0.0" - fs-minipass: "npm:^2.0.0" - minipass: "npm:^5.0.0" - minizlib: "npm:^2.1.1" - mkdirp: "npm:^1.0.3" - yallist: "npm:^4.0.0" - checksum: a5eca3eb50bc11552d453488344e6507156b9193efd7635e98e867fab275d527af53d8866e2370cd09dfe74378a18111622ace35af6a608e5223a7d27fe99537 - languageName: node - linkType: hard - -"temp@npm:^0.9.0": - version: 0.9.4 - resolution: "temp@npm:0.9.4" - dependencies: - mkdirp: "npm:^0.5.1" - rimraf: "npm:~2.6.2" - checksum: 7a1cd75efa65b9ca97fc0dfa752673842d23fa41d9c641a447d86ca986eb7662f0d17771e1edf8d0149e76de3c6e7005faf2ccaa3baf64811c86d1d1a951dda7 - languageName: node - linkType: hard - -"terminal-link@npm:^2.1.1": - version: 2.1.1 - resolution: "terminal-link@npm:2.1.1" - dependencies: - ansi-escapes: "npm:^4.2.1" - supports-hyperlinks: "npm:^2.0.0" - checksum: 947458a5cd5408d2ffcdb14aee50bec8fb5022ae683b896b2f08ed6db7b2e7d42780d5c8b51e930e9c322bd7c7a517f4fa7c76983d0873c83245885ac5ee13e3 - languageName: node - linkType: hard - -"tiny-decoders@npm:^7.0.1": - version: 7.0.1 - resolution: "tiny-decoders@npm:7.0.1" - checksum: 29c25343b78fa1b3434b3aca9479cfa25f992724b3e3cbb723fda1569e40974ede8957f17d930e309bee3c90a308b4d5698cb0a8a995b5b059c274a86f603fd2 - languageName: node - linkType: hard - -"to-regex-range@npm:^5.0.1": - version: 5.0.1 - resolution: "to-regex-range@npm:5.0.1" - dependencies: - is-number: "npm:^7.0.0" - checksum: 487988b0a19c654ff3e1961b87f471702e708fa8a8dd02a298ef16da7206692e8552a0250e8b3e8759270f62e9d8314616f6da274734d3b558b1fc7b7724e892 - languageName: node - linkType: hard - -"ts-union@npm:^2.2.1": - version: 2.3.0 - resolution: "ts-union@npm:2.3.0" - checksum: ce8c53bd1f829d589f1bcc5b0d88b4544b107043e5ff945350873fe66db00243e9c008b87e11b712707605e84b5f0f271ee027c5e1e68dbdcd58717d791e4105 - languageName: node - linkType: hard - -"type-fest@npm:^0.21.3": - version: 0.21.3 - resolution: "type-fest@npm:0.21.3" - checksum: 902bd57bfa30d51d4779b641c2bc403cdf1371fb9c91d3c058b0133694fcfdb817aef07a47f40faf79039eecbaa39ee9d3c532deff244f3a19ce68cea71a61e8 - languageName: node - linkType: hard - -"typescript@npm:^3.9.7": - version: 3.9.10 - resolution: "typescript@npm:3.9.10" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 863cc06070fa18a0f9c6a83265fb4922a8b51bf6f2c6760fb0b73865305ce617ea4bc6477381f9f4b7c3a8cb4a455b054f5469e6e41307733fe6a2bd9aae82f8 - languageName: node - linkType: hard - -"typescript@npm:^4.3.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 5f6cad2e728a8a063521328e612d7876e12f0d8a8390d3b3aaa452a6a65e24e9ac8ea22beb72a924fd96ea0a49ea63bb4e251fb922b12eedfb7f7a26475e5c56 - languageName: node - linkType: hard - -"typescript@patch:typescript@npm%3A^3.9.7#optional!builtin": - version: 3.9.10 - resolution: "typescript@patch:typescript@npm%3A3.9.10#optional!builtin::version=3.9.10&hash=3bd3d3" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 9041fb3886e7d6a560f985227b8c941d17a750f2edccb5f9b3a15a2480574654d9be803ad4a14aabcc2f2553c4d272a25fd698a7c42692f03f66b009fb46883c - languageName: node - linkType: hard - -"typescript@patch:typescript@npm%3A^4.3.5#optional!builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#optional!builtin::version=4.9.5&hash=289587" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: e3333f887c6829dfe0ab6c1dbe0dd1e3e2aeb56c66460cb85c5440c566f900c833d370ca34eb47558c0c69e78ced4bfe09b8f4f98b6de7afed9b84b8d1dd06a1 - languageName: node - linkType: hard - -"unique-filename@npm:^3.0.0": - version: 3.0.0 - resolution: "unique-filename@npm:3.0.0" - dependencies: - unique-slug: "npm:^4.0.0" - checksum: 6363e40b2fa758eb5ec5e21b3c7fb83e5da8dcfbd866cc0c199d5534c42f03b9ea9ab069769cc388e1d7ab93b4eeef28ef506ab5f18d910ef29617715101884f - languageName: node - linkType: hard - -"unique-slug@npm:^4.0.0": - version: 4.0.0 - resolution: "unique-slug@npm:4.0.0" - dependencies: - imurmurhash: "npm:^0.1.4" - checksum: cb811d9d54eb5821b81b18205750be84cb015c20a4a44280794e915f5a0a70223ce39066781a354e872df3572e8155c228f43ff0cce94c7cbf4da2cc7cbdd635 - languageName: node - linkType: hard - -"universalify@npm:^2.0.0": - version: 2.0.0 - resolution: "universalify@npm:2.0.0" - checksum: 07092b9f46df61b823d8ab5e57f0ee5120c178b39609a95e4a15a98c42f6b0b8e834e66fbb47ff92831786193be42f1fd36347169b88ce8639d0f9670af24a71 - languageName: node - linkType: hard - -"util-deprecate@npm:^1.0.1": - version: 1.0.2 - resolution: "util-deprecate@npm:1.0.2" - checksum: 41a5bdd214df2f6c3ecf8622745e4a366c4adced864bc3c833739791aeeeb1838119af7daed4ba36428114b5c67dcda034a79c882e97e43c03e66a4dd7389942 - languageName: node - linkType: hard - -"wcwidth@npm:^1.0.1": - version: 1.0.1 - resolution: "wcwidth@npm:1.0.1" - dependencies: - defaults: "npm:^1.0.3" - checksum: 5b61ca583a95e2dd85d7078400190efd452e05751a64accb8c06ce4db65d7e0b0cde9917d705e826a2e05cc2548f61efde115ffa374c3e436d04be45c889e5b4 - languageName: node - linkType: hard - -"which@npm:^1.2.9": - version: 1.3.1 - resolution: "which@npm:1.3.1" - dependencies: - isexe: "npm:^2.0.0" - bin: - which: ./bin/which - checksum: e945a8b6bbf6821aaaef7f6e0c309d4b615ef35699576d5489b4261da9539f70393c6b2ce700ee4321c18f914ebe5644bc4631b15466ffbaad37d83151f6af59 - languageName: node - linkType: hard - -"which@npm:^2.0.1, which@npm:^2.0.2": - version: 2.0.2 - resolution: "which@npm:2.0.2" - dependencies: - isexe: "npm:^2.0.0" - bin: - node-which: ./bin/node-which - checksum: 66522872a768b60c2a65a57e8ad184e5372f5b6a9ca6d5f033d4b0dc98aff63995655a7503b9c0a2598936f532120e81dd8cc155e2e92ed662a2b9377cc4374f - languageName: node - linkType: hard - -"which@npm:^4.0.0": - version: 4.0.0 - resolution: "which@npm:4.0.0" - dependencies: - isexe: "npm:^3.1.1" - bin: - node-which: bin/which.js - checksum: 449fa5c44ed120ccecfe18c433296a4978a7583bf2391c50abce13f76878d2476defde04d0f79db8165bdf432853c1f8389d0485ca6e8ebce3bbcded513d5e6a - languageName: node - linkType: hard - -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": - version: 7.0.0 - resolution: "wrap-ansi@npm:7.0.0" - dependencies: - ansi-styles: "npm:^4.0.0" - string-width: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - checksum: d15fc12c11e4cbc4044a552129ebc75ee3f57aa9c1958373a4db0292d72282f54373b536103987a4a7594db1ef6a4f10acf92978f79b98c49306a4b58c77d4da - languageName: node - linkType: hard - -"wrap-ansi@npm:^6.2.0": - version: 6.2.0 - resolution: "wrap-ansi@npm:6.2.0" - dependencies: - ansi-styles: "npm:^4.0.0" - string-width: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - checksum: baad244e6e33335ea24e86e51868fe6823626e3a3c88d9a6674642afff1d34d9a154c917e74af8d845fd25d170c4ea9cf69a47133c3f3656e1252b3d462d9f6c - languageName: node - linkType: hard - -"wrap-ansi@npm:^8.1.0": - version: 8.1.0 - resolution: "wrap-ansi@npm:8.1.0" - dependencies: - ansi-styles: "npm:^6.1.0" - string-width: "npm:^5.0.1" - strip-ansi: "npm:^7.0.1" - checksum: 138ff58a41d2f877eae87e3282c0630fc2789012fc1af4d6bd626eeb9a2f9a65ca92005e6e69a75c7b85a68479fe7443c7dbe1eb8fbaa681a4491364b7c55c60 - languageName: node - linkType: hard - -"wrappy@npm:1": - version: 1.0.2 - resolution: "wrappy@npm:1.0.2" - checksum: 56fece1a4018c6a6c8e28fbc88c87e0fbf4ea8fd64fc6c63b18f4acc4bd13e0ad2515189786dd2c30d3eec9663d70f4ecf699330002f8ccb547e4a18231fc9f0 - languageName: node - linkType: hard - -"ws@npm:^8.12.0": - version: 8.17.1 - resolution: "ws@npm:8.17.1" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: f4a49064afae4500be772abdc2211c8518f39e1c959640457dcee15d4488628620625c783902a52af2dd02f68558da2868fd06e6fd0e67ebcd09e6881b1b5bfe - languageName: node - linkType: hard - -"yallist@npm:^4.0.0": - version: 4.0.0 - resolution: "yallist@npm:4.0.0" - checksum: 2286b5e8dbfe22204ab66e2ef5cc9bbb1e55dfc873bbe0d568aa943eb255d131890dfd5bf243637273d31119b870f49c18fcde2c6ffbb7a7a092b870dc90625a - languageName: node - linkType: hard +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@sindresorhus/is@^4.0.0": + version "4.6.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" + integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== + +"@szmarczak/http-timer@^4.0.5": + version "4.0.6" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" + integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== + dependencies: + defer-to-connect "^2.0.0" + +"@types/cacheable-request@^6.0.1": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.3.tgz#a430b3260466ca7b5ca5bfd735693b36e7a9d183" + integrity sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw== + dependencies: + "@types/http-cache-semantics" "*" + "@types/keyv" "^3.1.4" + "@types/node" "*" + "@types/responselike" "^1.0.0" + +"@types/http-cache-semantics@*": + version "4.0.4" + resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4" + integrity sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA== + +"@types/jest@^27.0.3": + version "27.5.2" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.5.2.tgz#ec49d29d926500ffb9fd22b84262e862049c026c" + integrity sha512-mpT8LJJ4CMeeahobofYWIjFo0xonRS/HfxnVEPMPFSQdGUt1uHCnoPT7Zhb+sjDU2wz0oKV0OLUR0WzrHNgfeA== + dependencies: + jest-matcher-utils "^27.0.0" + pretty-format "^27.0.0" + +"@types/keyv@^3.1.4": + version "3.1.4" + resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6" + integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== + dependencies: + "@types/node" "*" + +"@types/node@*": + version "22.13.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.4.tgz#3fe454d77cd4a2d73c214008b3e331bfaaf5038a" + integrity sha512-ywP2X0DYtX3y08eFVx5fNIw7/uIv8hYUKgXoK8oayJlLnKcRfEYCxWMVE1XagUdVtCJlZT1AU4LXEABW+L1Peg== + dependencies: + undici-types "~6.20.0" + +"@types/responselike@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.3.tgz#cc29706f0a397cfe6df89debfe4bf5cea159db50" + integrity sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw== + dependencies: + "@types/node" "*" + +ansi-escapes@^4.2.1: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +binary-extensions@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== + +bl@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" + integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== + dependencies: + buffer "^5.5.0" + inherits "^2.0.4" + readable-stream "^3.4.0" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@~3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + +buffer@^5.5.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +cacheable-lookup@^5.0.3: + version "5.0.4" + resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" + integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== + +cacheable-request@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.4.tgz#7a33ebf08613178b403635be7b899d3e69bbe817" + integrity sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^4.0.0" + lowercase-keys "^2.0.0" + normalize-url "^6.0.1" + responselike "^2.0.0" + +chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chokidar@^3.5.1, chokidar@^3.5.2, chokidar@^3.5.3: + version "3.6.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cli-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== + dependencies: + restore-cursor "^3.1.0" + +cli-spinners@^2.5.0: + version "2.9.2" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" + integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== + +clone-response@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.3.tgz#af2032aa47816399cf5f0a1d0db902f517abb8c3" + integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== + dependencies: + mimic-response "^1.0.0" + +clone@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" + integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +commander@^6.0.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" + integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== + +commander@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" + integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +cross-spawn@6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +cross-spawn@^7.0.3, cross-spawn@^7.0.6: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +debug@^4.1.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + dependencies: + ms "^2.1.3" + +decompress-response@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" + integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== + dependencies: + mimic-response "^3.1.0" + +defaults@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" + integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== + dependencies: + clone "^1.0.2" + +defer-to-connect@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" + integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== + +diff-sequences@^27.5.1: + version "27.5.1" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" + integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== + +elm-codegen@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/elm-codegen/-/elm-codegen-0.5.3.tgz#28ab430fe6addd7e3938a346d4d0c3bfd8ca4917" + integrity sha512-LKscQHnDeNGQsvaoDXq1nxlm9XlsWaIQCUiqBgJjXk/gPU6PtcXVC0ji1ytmmSW+/N0zb+DWegSbPPYGeV4eew== + dependencies: + chalk "^4.1.1" + chokidar "^3.5.1" + commander "^8.3.0" + node-elm-compiler "^5.0.6" + +elm-optimize-level-2@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/elm-optimize-level-2/-/elm-optimize-level-2-0.3.5.tgz#a0ac9b825d9ff68be50ed1b819780f88693a872a" + integrity sha512-t1xl8zR9UBspdmEMuLBE/qTLP+Ew3L4PzKLhSY/PsO21HU3jZ1ULmKxDtZmJPVG4ciqsY1JSl/GFbaSdQ1sX9Q== + dependencies: + "@types/jest" "^27.0.3" + chalk "^4.1.0" + commander "^6.0.0" + node-elm-compiler "^5.0.4" + ts-union "^2.2.1" + typescript "^4.5.5" + +elm-review@^2.11.1: + version "2.13.1" + resolved "https://registry.yarnpkg.com/elm-review/-/elm-review-2.13.1.tgz#33064b3a2baf2af8d20fb7e9a382fd6240c585a2" + integrity sha512-okkw5Mfmjkjy2ZggFyWfz5bpcd81fsQXGyNIDgZRFBU2vXao+xdt5/AN6L1tt6KWgjSyBJD94RXeyd5e3AhPKw== + dependencies: + chalk "^4.0.0" + chokidar "^3.5.2" + cross-spawn "^7.0.3" + elm-solve-deps-wasm "^1.0.2 || ^2.0.0" + fastest-levenshtein "^1.0.16" + find-up "^4.1.0 || ^5.0.0" + folder-hash "^3.3.0" + got "^11.8.5" + graceful-fs "^4.2.11" + minimist "^1.2.6" + ora "^5.4.0" + path-key "^3.1.1" + prompts "^2.2.1" + strip-ansi "^6.0.0" + terminal-link "^2.1.1" + tinyglobby "^0.2.10" + which "^2.0.2" + wrap-ansi "^7.0.0" + +"elm-solve-deps-wasm@^1.0.2 || ^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/elm-solve-deps-wasm/-/elm-solve-deps-wasm-2.0.0.tgz#8214705876fbcd9789cf6ab2db45ec781b5c1234" + integrity sha512-11OV8FgB9qsth/F94q2SJjb1MoEgbworSyNM1L+YlxVoaxp7wtWPyA8cNcPEkSoIKG1B8Tqg68ED1P6dVamHSg== + +elm-watch@^2.0.0-beta.2: + version "2.0.0-beta.6" + resolved "https://registry.yarnpkg.com/elm-watch/-/elm-watch-2.0.0-beta.6.tgz#33b31856de19276690715c3f8a495f1e312630d2" + integrity sha512-pb3qZVfoBMEWsfrP4mN760z85n5XC0cXg1JRR4ojAVZVjFMeDczYojLaKDQgP+qNeMAK52xj7s31+bCevT+X2Q== + dependencies: + chokidar "^3.5.3" + cross-spawn "^7.0.6" + tiny-decoders "^23.0.0" + ws "^8.18.0" + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +end-of-stream@^1.1.0: + version "1.4.4" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== + dependencies: + once "^1.4.0" + +fastest-levenshtein@^1.0.16: + version "1.0.16" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" + integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== + +fdir@^6.4.3: + version "6.4.3" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.3.tgz#011cdacf837eca9b811c89dbb902df714273db72" + integrity sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw== + +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +find-elm-dependencies@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/find-elm-dependencies/-/find-elm-dependencies-2.0.4.tgz#0a327fc8c0c0297b54115efbf0a9d6de474cfc89" + integrity sha512-x/4w4fVmlD2X4PD9oQ+yh9EyaQef6OtEULdMGBTuWx0Nkppvo2Z/bAiQioW2n+GdRYKypME2b9OmYTw5tw5qDg== + dependencies: + firstline "^1.2.0" + lodash "^4.17.19" + +"find-up@^4.1.0 || ^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +firstline@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/firstline/-/firstline-1.3.1.tgz#59e84af0fd858fbc6dac0a0ff97fd22a47e58084" + integrity sha512-ycwgqtoxujz1dm0kjkBFOPQMESxB9uKc/PlD951dQDIG+tBXRpYZC2UmJb0gDxopQ1ZX6oyRQN3goRczYu7Deg== + +folder-hash@^3.3.0: + version "3.3.3" + resolved "https://registry.yarnpkg.com/folder-hash/-/folder-hash-3.3.3.tgz#883c8359d54f91b3f02c1a646c00c30e5831365b" + integrity sha512-SDgHBgV+RCjrYs8aUwCb9rTgbTVuSdzvFmLaChsLre1yf+D64khCW++VYciaByZ8Rm0uKF8R/XEpXuTRSGUM1A== + dependencies: + debug "^4.1.1" + graceful-fs "~4.2.0" + minimatch "~3.0.4" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +get-stream@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" + integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== + dependencies: + pump "^3.0.0" + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@^7.1.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +got@^11.8.5: + version "11.8.6" + resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" + integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== + dependencies: + "@sindresorhus/is" "^4.0.0" + "@szmarczak/http-timer" "^4.0.5" + "@types/cacheable-request" "^6.0.1" + "@types/responselike" "^1.0.0" + cacheable-lookup "^5.0.3" + cacheable-request "^7.0.2" + decompress-response "^6.0.0" + http2-wrapper "^1.0.0-beta.5.2" + lowercase-keys "^2.0.0" + p-cancelable "^2.0.0" + responselike "^2.0.0" + +graceful-fs@^4.2.11, graceful-fs@~4.2.0: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +http-cache-semantics@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" + integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== + +http2-wrapper@^1.0.0-beta.5.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d" + integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== + dependencies: + quick-lru "^5.1.1" + resolve-alpn "^1.0.0" + +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.3, inherits@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-interactive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" + integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w== + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +jest-diff@^27.5.1: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def" + integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw== + dependencies: + chalk "^4.0.0" + diff-sequences "^27.5.1" + jest-get-type "^27.5.1" + pretty-format "^27.5.1" + +jest-get-type@^27.5.1: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" + integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw== + +jest-matcher-utils@^27.0.0: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab" + integrity sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw== + dependencies: + chalk "^4.0.0" + jest-diff "^27.5.1" + jest-get-type "^27.5.1" + pretty-format "^27.5.1" + +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + +keyv@^4.0.0: + version "4.5.4" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" + integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== + dependencies: + json-buffer "3.0.1" + +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + +lie@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw== + dependencies: + immediate "~3.0.5" + +localforage@^1.9.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" + integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== + dependencies: + lie "3.1.1" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash@^4.17.19: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +lowercase-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +mimic-response@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + +mimic-response@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" + integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== + +minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@~3.0.4: + version "3.0.8" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" + integrity sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +node-elm-compiler@^5.0.4, node-elm-compiler@^5.0.6: + version "5.0.6" + resolved "https://registry.yarnpkg.com/node-elm-compiler/-/node-elm-compiler-5.0.6.tgz#d4a6e6c9d9a26dba4211ccd2aeae7d5e34057f0c" + integrity sha512-DWTRQR8b54rvschcZRREdsz7K84lnS8A6YJu8du3QLQ8f204SJbyTaA6NzYYbfUG97OTRKRv/0KZl82cTfpLhA== + dependencies: + cross-spawn "6.0.5" + find-elm-dependencies "^2.0.4" + lodash "^4.17.19" + temp "^0.9.0" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +normalize-url@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" + integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +ora@^5.4.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18" + integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ== + dependencies: + bl "^4.1.0" + chalk "^4.1.0" + cli-cursor "^3.1.0" + cli-spinners "^2.5.0" + is-interactive "^1.0.0" + is-unicode-supported "^0.1.0" + log-symbols "^4.1.0" + strip-ansi "^6.0.0" + wcwidth "^1.0.1" + +p-cancelable@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" + integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== + +path-key@^3.1.0, path-key@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +picomatch@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab" + integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== + +pretty-format@^27.0.0, pretty-format@^27.5.1: + version "27.5.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" + integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ== + dependencies: + ansi-regex "^5.0.1" + ansi-styles "^5.0.0" + react-is "^17.0.1" + +prompts@^2.2.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + +pump@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.2.tgz#836f3edd6bc2ee599256c924ffe0d88573ddcbf8" + integrity sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +quick-lru@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" + integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== + +react-is@^17.0.1: + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" + integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== + +readable-stream@^3.4.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +resolve-alpn@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" + integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== + +responselike@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.1.tgz#9a0bc8fdc252f3fb1cca68b016591059ba1422bc" + integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== + dependencies: + lowercase-keys "^2.0.0" + +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + +rimraf@~2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +semver@^5.5.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== + dependencies: + shebang-regex "^1.0.0" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +signal-exit@^3.0.2: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + +string-width@^4.1.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +supports-color@^7.0.0, supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-hyperlinks@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" + integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== + dependencies: + has-flag "^4.0.0" + supports-color "^7.0.0" + +temp@^0.9.0: + version "0.9.4" + resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.4.tgz#cd20a8580cb63635d0e4e9d4bd989d44286e7620" + integrity sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA== + dependencies: + mkdirp "^0.5.1" + rimraf "~2.6.2" + +terminal-link@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" + integrity sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ== + dependencies: + ansi-escapes "^4.2.1" + supports-hyperlinks "^2.0.0" + +tiny-decoders@^23.0.0: + version "23.0.0" + resolved "https://registry.yarnpkg.com/tiny-decoders/-/tiny-decoders-23.0.0.tgz#49acf51455612c7729b04be6147fcea6d2a20f8b" + integrity sha512-gQB+za3EW9JN1ASDmrVl1a1I6Q/jzg4M75YLI9ToHCdCW4/9KvBTTNH4u3kFbg8e+/8Zn68VRF+ayuiPNqYAmg== + +tinyglobby@^0.2.10: + version "0.2.12" + resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.12.tgz#ac941a42e0c5773bd0b5d08f32de82e74a1a61b5" + integrity sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww== + dependencies: + fdir "^6.4.3" + picomatch "^4.0.2" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-union@^2.2.1: + version "2.3.0" + resolved "https://registry.yarnpkg.com/ts-union/-/ts-union-2.3.0.tgz#2dc5240e0a1ceea2159bf06cacdc96a78475dd04" + integrity sha512-OP+W9WoYvGlOMjc90D6nYz60jU1zQlXAg3VBtuSoMDejY94PaORkya9HtHjaaqqwA4I5/hN38fmKK0nSWj7jPg== + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +typescript@^4.5.5: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== + +typescript@^5.4.4: + version "5.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e" + integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== + +undici-types@~6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433" + integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg== + +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +wcwidth@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" + integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== + dependencies: + defaults "^1.0.3" + +which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@^2.0.1, which@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +ws@^8.18.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" + integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From feafb9d22166ac224777b2b707940ea61d118b4c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 20 Apr 2024 20:56:47 +0200 Subject: [PATCH 108/139] Fix ElmLS not starting --- elm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elm.json b/elm.json index b44b86ad..a2373be6 100644 --- a/elm.json +++ b/elm.json @@ -46,4 +46,4 @@ "elm/random": "1.0.0" } } -} +} \ No newline at end of file From 88750879f7011eee06ed8fd4bc229239c8d60b84 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Sat, 20 Apr 2024 22:50:47 +0200 Subject: [PATCH 109/139] [WIP] Implementing new codegen --- .vscode/settings.json | 3 + Makefile | 1 + codegen/elm.json | 8 +- codegen/functions.frag | 93 +- codegen/helpers/Glsl.elm | 202 ++-- codegen/helpers/Glsl/Operations.elm | 11 +- codegen/helpers/Glsl/PrettyPrinter.elm | 79 +- codegen/src/Generate.elm | 95 +- codegen/src/Glsl/Parser.elm | 70 +- package.json | 1 + src/elm/Expression.elm | 681 +++++++----- src/elm/Expression/Derivative.elm | 28 +- src/elm/Expression/NumericRange.elm | 9 +- src/elm/Expression/Parser.elm | 4 +- src/elm/Expression/Simplify.elm | 14 +- src/elm/Expression/Utils.elm | 4 +- src/elm/Expression/Value.elm | 59 +- src/elm/UI.elm | 3 +- src/elm/UI/Glsl.elm | 122 +- src/elm/UI/Glsl/Code.elm | 1408 +++++++++++++++++++++--- src/elm/UI/Glsl/Generator.elm | 302 +++-- src/elm/UI/Glsl/Plane.elm | 45 +- src/elm/UI/Glsl/Polynomial.elm | 258 +++-- src/elm/UI/Glsl/Sphere.elm | 48 +- src/elm/UI/RowView.elm | 2 +- tests/GlslFuzzer.elm | 10 +- yarn.lock | 36 + 27 files changed, 2511 insertions(+), 1085 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..aa329955 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "elmLS.elmFormatPath": "elm-format-hack" +} diff --git a/Makefile b/Makefile index 826873fa..3274c4a2 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ src/optimized.js: $(ELM_FILES) Makefile generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/bindings/Gen/Glsl.elm Makefile rm -rf generated yarn elm-codegen run --flags-from $< codegen/src/Generate.elm + elm-format --yes $@ codegen/bindings/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile rm -rf codegen/bindings diff --git a/codegen/elm.json b/codegen/elm.json index 52be2eb4..02ccb1d8 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -1,10 +1,6 @@ { "type": "application", - "source-directories": [ - "src", - "helpers", - "bindings" - ], + "source-directories": ["src", "helpers", "bindings"], "elm-version": "0.19.1", "dependencies": { "direct": { @@ -36,4 +32,4 @@ "direct": {}, "indirect": {} } -} \ No newline at end of file +} diff --git a/codegen/functions.frag b/codegen/functions.frag index 8f08eb0a..4930d91b 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -23,6 +23,10 @@ uniform float u_theta; // Utils // /////////// +float log10(float x) { + return log(x) / log(10.0); +} + float sinh(float x) { return 0.5 * (exp(x) - exp(-x)); } float cosh(float x) { return 0.5 * (exp(x) + exp(-x)); } float tanh(float x) { @@ -67,6 +71,18 @@ float thetaDelta(float theta) { return abs(fract(thetaSix) - .5) / thetaNeigh; } +float axis(float coord, float otherCoord, float maxDelta) { + float across = 1.0 - abs(coord/maxDelta); + if(across < -12.0) + return 0.0; + float smallUnit = pow(10.0, ceil(log10(maxDelta))); + if(across < 0.0 && abs(otherCoord) < maxDelta * 2.0) + return 0.0; + float unit = across < -6.0 ? smallUnit * 100.0 : across < -0.1 ? smallUnit * 10.0 : smallUnit * 5.0; + float parallel = mod(abs(otherCoord), unit) < maxDelta ? 1.0 : 0.0; + return max(0.0, max(across, parallel)); +} + // Shifts for the recursive algorithm int left_shift(int i) { return i * 2; } int left_shift_increment(int i) { return i * 2 + 1; } @@ -311,8 +327,8 @@ vec2 iln(vec2 z) { return log(z); } vec2 iexp(vec2 z) { return exp(z); } vec2 ipow(vec2 b, float e) { - if (abs(e.x - round(e.x)) < .000001) - return ipow(b, int(e.x)); + if (abs(e - round(e)) < .000001) + return ipow(b, int(e)); return iexp(e * iln(b)); } @@ -509,3 +525,76 @@ vec4 gsign(vec4 v) { return gnum(sign(v.x)); } vec4 gceil(vec4 z) { return gnum(ceil(z.x)); } vec4 gfloor(vec4 z) { return gnum(floor(z.x)); } vec4 ground(vec4 z) { return gnum(round(z.x)); } + +////////////////////// +// Bisect, raytrace // +////////////////////// + +// bool bisect${suffix}(vec3 o, mat3 d, float max_distance, out vec3 found) { +// mat3 from = mat3(o, o, vec3(0)); +// mat3 to = from + max_distance * d; +// float ithreshold = ${threshold}; +// int depth = 0; +// int choices = 0; +// for(int it = 0; it < ${max_iterations}; it++) { +// mat3 midpoint = 0.5 * (from + to); +// vec2 front = interval${suffix}(from, midpoint); +// vec2 back = interval${suffix}(midpoint, to); +// if(depth >= ${max_depth} +// || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) +// || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) +// ) { +// found = mix(midpoint[0], midpoint[1], 0.5); +// return true; +// } +// if(front.x <= 0.0 && front.y >= 0.0) { +// to = midpoint; +// depth++; +// choices = left_shift(choices); +// } else if(back.x <= 0.0 && back.y >= 0.0) { +// from = midpoint; +// depth++; +// choices = left_shift_increment(choices); +// } else { +// // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch +// for(int j = ${max_depth} - 1; j > 0; j--) { +// if(j > depth) +// continue; +// depth--; +// choices = right_shift(choices); +// if(is_even(choices)) { +// midpoint = to; +// to = to + (to - from); +// vec2 back = interval${suffix}(midpoint, to); +// if(back.x <= 0.0 && back.y >= 0.0) { +// from = midpoint; +// depth++; +// choices = left_shift_increment(choices); +// break; +// } +// } else { +// from = from - (to - from); +// } +// } +// if(depth == 0) +// return false; +// } +// } +// return false; +// } + +// bool sphere_bisect${suffix}(vec3 o, mat3 d, float max_distance, out vec3 found) { +// vec3 center = vec3(${center.x},${center.y},${center.z}); + +// vec3 to_center = o - center; +// float b = dot(to_center, 0.5 * (d[0] + d[1])); +// float c = dot(to_center, to_center) - ${radius} * ${radius}; +// float delta = b*b - c; +// if(delta < 0.0) +// return false; +// float x = -b - sqrt(delta); +// if(x < ${threshold}) +// return false; +// found = o + x * 0.5 * (d[0] + d[1]); +// return true; +// } diff --git a/codegen/helpers/Glsl.elm b/codegen/helpers/Glsl.elm index 6ad71c3a..48dcc8ca 100644 --- a/codegen/helpers/Glsl.elm +++ b/codegen/helpers/Glsl.elm @@ -1,16 +1,17 @@ module Glsl exposing ( Function , Statement(..), Stat(..), ForDirection(..) - , Expression(..), Expr(..) + , Expression(..), ExprWithDeps, Expr(..) , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) , BisectSignature - , true, false, int, float, var + , true, false, var , unsafeDot, dot2X, dot2Y, dot3X, dot3Y, dot3Z , TypingFunction, TypedName(..), Type(..) , Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 , unsafeMap, unsafeMap2, unsafeMap3 - , buildStatement, statement, unsafeExprStat, unsafeStat1, withExpression, withStatement + , build, withExpression, withStatement, buildExpression, buildStatement + , Declaration(..), Uniform, WithDepsBuilder, dot4XY, float1, int1, unsafeTypecast ) {-| @@ -41,6 +42,12 @@ module Glsl exposing @docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 @docs unsafeMap, unsafeMap2, unsafeMap3 +@docs unsafeTypecase + + +# Building while tracking dependencies + +@docs build, withExpression, withStatement, buildExpression, buildStatement -} @@ -53,128 +60,142 @@ import SortedSet exposing (SortedSet) unsafeCall0 : String -> List String -> Expression r unsafeCall0 name deps = - unsafeCall name deps [] + build (Call name []) + |> withDependencies deps + |> buildExpression unsafeCall1 : String -> List String -> Expression t -> Expression r -unsafeCall1 name deps (Expression arg0) = - unsafeCall name deps [ arg0 ] +unsafeCall1 name deps arg0 = + build (\a0 -> Call name [ a0 ]) + |> withDependencies deps + |> withExpression arg0 + |> buildExpression unsafeCall2 : String -> List String -> Expression t -> Expression u -> Expression r -unsafeCall2 name deps (Expression arg0) (Expression arg1) = - unsafeCall name deps [ arg0, arg1 ] +unsafeCall2 name deps arg0 arg1 = + build (\a0 a1 -> Call name [ a0, a1 ]) + |> withDependencies deps + |> withExpression arg0 + |> withExpression arg1 + |> buildExpression unsafeCall3 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression r -unsafeCall3 name deps (Expression arg0) (Expression arg1) (Expression arg2) = - unsafeCall name deps [ arg0, arg1, arg2 ] +unsafeCall3 name deps arg0 arg1 arg2 = + build (\a0 a1 a2 -> Call name [ a0, a1, a2 ]) + |> withDependencies deps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> buildExpression unsafeCall4 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r -unsafeCall4 name deps (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) = - unsafeCall name deps [ arg0, arg1, arg2, arg3 ] +unsafeCall4 name deps arg0 arg1 arg2 arg3 = + build (\a0 a1 a2 a3 -> Call name [ a0, a1, a2, a3 ]) + |> withDependencies deps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> buildExpression unsafeCall5 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression x -> Expression r -unsafeCall5 name deps (Expression arg0) (Expression arg1) (Expression arg2) (Expression arg3) (Expression arg4) = - unsafeCall name deps [ arg0, arg1, arg2, arg3, arg4 ] - - -unsafeCall : String -> List String -> List ExprWithDeps -> Expression t -unsafeCall name deps args = - Expression - { expr = - args - |> List.map .expr - |> Call name - , deps = - args - |> List.map .deps - |> List.foldl SortedSet.insertAll (SortedSet.fromList deps) - } +unsafeCall5 name deps arg0 arg1 arg2 arg3 arg4 = + build (\a0 a1 a2 a3 a4 -> Call name [ a0, a1, a2, a3, a4 ]) + |> withDependencies deps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> buildExpression unsafeMap : (Expr -> Expr) -> Expression a -> Expression b -unsafeMap f (Expression l) = - Expression - { expr = f l.expr - , deps = l.deps - } +unsafeMap f l = + build f + |> withExpression l + |> buildExpression unsafeMap2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -unsafeMap2 f (Expression l) (Expression r) = - Expression - { expr = f l.expr r.expr - , deps = - l.deps - |> SortedSet.insertAll r.deps - } +unsafeMap2 f l r = + build f + |> withExpression l + |> withExpression r + |> buildExpression unsafeMap3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d -unsafeMap3 f (Expression l) (Expression m) (Expression r) = - Expression - { expr = f l.expr m.expr r.expr - , deps = - l.deps - |> SortedSet.insertAll m.deps - |> SortedSet.insertAll r.deps - } - - -unsafeStat1 : (Stat -> Stat) -> Statement r -> Statement r -unsafeStat1 f (Statement stat) = - Statement - { stat = f stat.stat - , deps = stat.deps - } +unsafeMap3 f l m r = + build f + |> withExpression l + |> withExpression m + |> withExpression r + |> buildExpression -unsafeExprStat : (Expr -> Stat -> Stat) -> Expression a -> Statement s -> Statement t -unsafeExprStat f (Expression l) (Statement r) = - Statement - { stat = f l.expr r.stat - , deps = - l.deps - |> SortedSet.insertAll r.deps - } +unsafeTypecast : Expression a -> Expression b +unsafeTypecast (Expression a) = + Expression a -type StatementBuilder k - = StatementBuilder k (SortedSet String) +type WithDepsBuilder k + = WithDepsBuilder k (SortedSet String) -statement : k -> StatementBuilder k -statement k = - StatementBuilder k SortedSet.empty +build : k -> WithDepsBuilder k +build k = + WithDepsBuilder k SortedSet.empty -withExpression : Expression e -> StatementBuilder (Expr -> k) -> StatementBuilder k -withExpression (Expression e) (StatementBuilder k deps) = - StatementBuilder (k e.expr) +withExpression : Expression e -> WithDepsBuilder (Expr -> k) -> WithDepsBuilder k +withExpression (Expression e) (WithDepsBuilder k deps) = + WithDepsBuilder (k e.expr) (deps |> SortedSet.insertAll e.deps) -withStatement : Statement r -> StatementBuilder (Stat -> k) -> StatementBuilder k -withStatement (Statement s) (StatementBuilder k deps) = - StatementBuilder (k s.stat) +withStatement : Statement r -> WithDepsBuilder (Stat -> k) -> WithDepsBuilder k +withStatement (Statement s) (WithDepsBuilder k deps) = + WithDepsBuilder (k s.stat) (deps |> SortedSet.insertAll s.deps) -buildStatement : StatementBuilder Stat -> Statement r -buildStatement (StatementBuilder stat deps) = +withDependencies : List String -> WithDepsBuilder k -> WithDepsBuilder k +withDependencies additionalDeps (WithDepsBuilder k deps) = + WithDepsBuilder k + (deps |> SortedSet.insertAll (SortedSet.fromList additionalDeps)) + + +buildStatement : WithDepsBuilder Stat -> Statement r +buildStatement (WithDepsBuilder stat deps) = Statement { stat = stat , deps = deps } +buildExpression : WithDepsBuilder Expr -> Expression t +buildExpression (WithDepsBuilder expr deps) = + Expression + { expr = expr + , deps = deps + } + + -- Typed expressions +type Declaration + = FunctionDeclaration Function + | UniformDeclaration Uniform + + type alias Function = { returnType : Type , name : String @@ -185,6 +206,12 @@ type alias Function = } +type alias Uniform = + { tipe : Type + , name : String + } + + type Expression t = Expression ExprWithDeps @@ -352,26 +379,26 @@ type Out t true : Expression Bool true = - bool True + bool1 True false : Expression Bool false = - bool False + bool1 False -bool : Bool -> Expression Bool -bool b = +bool1 : Bool -> Expression Bool +bool1 b = pure <| Bool b -int : Int -> Expression Int -int i = +int1 : Int -> Expression Int +int1 i = pure <| Int i -float : Float -> Expression Float -float i = +float1 : Float -> Expression Float +float1 i = pure <| Float i @@ -405,6 +432,11 @@ dot3Z e = unsafeDot e "z" +dot4XY : Expression Vec4 -> Expression Vec2 +dot4XY e = + unsafeDot e "xy" + + unsafeDot : Expression t -> String -> Expression a unsafeDot ex v = unsafeMap (\e -> Dot e v) ex diff --git a/codegen/helpers/Glsl/Operations.elm b/codegen/helpers/Glsl/Operations.elm index 43cd7766..ef8d6f63 100644 --- a/codegen/helpers/Glsl/Operations.elm +++ b/codegen/helpers/Glsl/Operations.elm @@ -7,7 +7,7 @@ module Glsl.Operations exposing , by31 , div11, div22, div33, div44 , array33 - , lt, gt + , lt, eq, gt ) {-| @@ -47,12 +47,12 @@ module Glsl.Operations exposing # Comparison -@docs lt, gt +@docs lt, eq, gt -} import Expression exposing (BinaryOperation(..)) -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Mat3, RelationOperation(..), UnaryOperation(..), Vec2, Vec3, Vec4) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression, Mat3, RelationOperation(..), UnaryOperation(..), Vec2, Vec3, Vec4) @@ -236,3 +236,8 @@ lt = gt : Expression Float -> Expression Float -> Expression Bool gt = Glsl.unsafeMap2 (Comparison GreaterThan) + + +eq : Expression t -> Expression t -> Expression Bool +eq = + Glsl.unsafeMap2 (Comparison Equals) diff --git a/codegen/helpers/Glsl/PrettyPrinter.elm b/codegen/helpers/Glsl/PrettyPrinter.elm index bd25f848..b1fdb617 100644 --- a/codegen/helpers/Glsl/PrettyPrinter.elm +++ b/codegen/helpers/Glsl/PrettyPrinter.elm @@ -1,7 +1,6 @@ -module Glsl.PrettyPrinter exposing (type_) +module Glsl.PrettyPrinter exposing (float, type_) -import Glsl exposing (BinaryOperation(..), Expression(..), ForDirection(..), RelationOperation(..), Statement(..), Type(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Step(..), Trailing(..)) +import Glsl exposing (Type(..)) @@ -54,7 +53,7 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- case stat of -- Expression e next -> -- "expr " --- ++ prettyPrintExpression e +-- ++ prettyToGlslExpression e -- ++ " <| \\_ ->\n" -- ++ statement next -- For { var, from, op, to, step, direction } next -> @@ -67,9 +66,9 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- ) -- ++ var -- ++ "\", " --- ++ prettyPrintExpression from +-- ++ prettyToGlslExpression from -- ++ ", " --- ++ prettyPrintExpression to +-- ++ prettyToGlslExpression to -- ++ ") (\\" -- ++ var -- ++ " ->\n" @@ -84,9 +83,9 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- ) -- ++ var -- ++ ", " --- ++ prettyPrintExpression from +-- ++ prettyToGlslExpression from -- ++ ", " --- ++ prettyPrintExpression to +-- ++ prettyToGlslExpression to -- ++ ") (\\" -- ++ var -- ++ " ->\n" @@ -101,9 +100,9 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- ) -- ++ var -- ++ "\", " --- ++ prettyPrintExpression from +-- ++ prettyToGlslExpression from -- ++ ", " --- ++ prettyPrintExpression to +-- ++ prettyToGlslExpression to -- ++ ") (\\" -- ++ var -- ++ " ->\n" @@ -118,9 +117,9 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- ) -- ++ var -- ++ ", " --- ++ prettyPrintExpression from +-- ++ prettyToGlslExpression from -- ++ ", " --- ++ prettyPrintExpression to +-- ++ prettyToGlslExpression to -- ++ ") (\\" -- ++ var -- ++ " ->\n" @@ -135,13 +134,13 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- "TODO branch 'Assign' not implemented" -- If cond ifTrue next -> -- "if_ " --- ++ prettyPrintExpression cond +-- ++ prettyToGlslExpression cond -- ++ "(\n" -- ++ statement ifTrue -- ++ ") <| \\_ ->\n" -- ++ statement next -- Return e -> --- "(return <| " ++ prettyPrintExpression e ++ ")\n" +-- "(return <| " ++ prettyToGlslExpression e ++ ")\n" -- Nop -> -- "nop\n" -- Def { type_, var, val } next -> @@ -150,7 +149,7 @@ import Parser exposing ((|.), (|=), Step(..), Trailing(..)) -- ++ "T \"" -- ++ var -- ++ "\" (" --- ++ prettyPrintExpression val +-- ++ prettyToGlslExpression val -- ++ ") <| \\" -- ++ var -- ++ " -> \n" @@ -203,8 +202,8 @@ type_ t = --- prettyPrintExpression : Expression -> String --- prettyPrintExpression e = +-- prettyToGlslExpression : Expression -> String +-- prettyToGlslExpression e = -- let -- parens args = -- "(" ++ String.join " " args ++ ")" @@ -228,7 +227,7 @@ type_ t = -- "False" -- ] -- Dot v sw -> --- prettyPrintExpression v ++ "." ++ sw +-- prettyToGlslExpression v ++ "." ++ sw -- Variable v -> -- v -- Constant c -> @@ -246,7 +245,7 @@ type_ t = -- in -- "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) -- Call "float" [ arg ] -> --- parens [ "floatCast", prettyPrintExpression arg ] +-- parens [ "floatCast", prettyToGlslExpression arg ] -- Call n args -> -- if String.startsWith "vec" n then -- if List.all ((==) (Int 0)) args then @@ -258,41 +257,41 @@ type_ t = -- (\c -> -- case c of -- Int i -> --- prettyPrintExpression (Float <| toFloat i) +-- prettyToGlslExpression (Float <| toFloat i) -- _ -> --- prettyPrintExpression c +-- prettyToGlslExpression c -- ) -- args -- else if n == "atan" then -- if List.length args == 2 then --- parens <| "atan2_" :: List.map prettyPrintExpression args +-- parens <| "atan2_" :: List.map prettyToGlslExpression args -- else --- parens <| "atan_" :: List.map prettyPrintExpression args +-- parens <| "atan_" :: List.map prettyToGlslExpression args -- else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then --- parens <| (n ++ "_") :: List.map prettyPrintExpression args +-- parens <| (n ++ "_") :: List.map prettyToGlslExpression args -- else --- parens <| n :: List.map prettyPrintExpression args +-- parens <| n :: List.map prettyToGlslExpression args -- Arr l r -> --- parens [ "arr", prettyPrintExpression l, prettyPrintExpression r ] +-- parens [ "arr", prettyToGlslExpression l, prettyToGlslExpression r ] -- Ternary c l r -> --- parens [ "ternary\n", prettyPrintExpression c, prettyPrintExpression l, prettyPrintExpression r ] +-- parens [ "ternary\n", prettyToGlslExpression c, prettyToGlslExpression l, prettyToGlslExpression r ] -- UnaryOperation Negate ex -> --- parens [ "negate_", prettyPrintExpression ex ] +-- parens [ "negate_", prettyToGlslExpression ex ] -- BinaryOperation op l r -> --- parens [ prettyPrintBinaryOperation op, prettyPrintExpression l, prettyPrintExpression r ] +-- parens [ prettyPrintBinaryOperation op, prettyToGlslExpression l, prettyToGlslExpression r ] -- BooleanOperation op es -> -- parens -- [ prettyPrintBooleanOperation op -- , "[" --- , String.join ", " <| List.map prettyPrintExpression es +-- , String.join ", " <| List.map prettyToGlslExpression es -- , "]" -- ] -- RelationOperation rop l r -> --- parens [ prettyPrintRelationOperation rop, prettyPrintExpression l, prettyPrintExpression r ] +-- parens [ prettyPrintRelationOperation rop, prettyToGlslExpression l, prettyToGlslExpression r ] -- PostfixIncrement c -> --- parens [ "postfixIncrement", prettyPrintExpression c ] +-- parens [ "postfixIncrement", prettyToGlslExpression c ] -- PostfixDecrement c -> --- parens [ "postfixDecrement", prettyPrintExpression c ] +-- parens [ "postfixDecrement", prettyToGlslExpression c ] -- prettyPrintRelationOperation : RelationOperation -> String -- prettyPrintRelationOperation op = -- case op of @@ -328,3 +327,17 @@ type_ t = -- "by" -- Div -> -- "div" + + +float : Float -> String +float f = + let + s : String + s = + String.fromFloat f + in + if String.contains "." s || String.contains "e" s then + s + + else + s ++ "." diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index 7404a390..00f971fd 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -6,7 +6,7 @@ import Elm.Annotation as Type import Gen.CodeGen.Generate as Generate import Gen.Debug import Gen.Glsl -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), Function, Stat(..), Statement(..), Type(..)) +import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), Function, Stat(..), Statement(..), Type(..), Uniform) import Glsl.Parser import Glsl.PrettyPrinter import List.Extra @@ -45,8 +45,32 @@ generate glsl = |> Elm.withDocumentation (errorToString e) |> List.singleton - Ok functions -> + Ok declarations -> let + functions = + List.filterMap + (\declaration -> + case declaration of + FunctionDeclaration function -> + Just function + + UniformDeclaration _ -> + Nothing + ) + declarations + + uniforms = + List.filterMap + (\declaration -> + case declaration of + UniformDeclaration uniform -> + Just uniform + + FunctionDeclaration _ -> + Nothing + ) + declarations + env : Env env = List.foldl @@ -65,7 +89,10 @@ generate glsl = builtinFunctions |> Dict.map (\_ { return } -> return) - , variablesEnv = builtinUniforms + , variablesEnv = + uniforms + |> List.map (\{ tipe, name } -> ( name, tipe )) + |> Dict.fromList } functions @@ -74,10 +101,14 @@ generate glsl = Result.Extra.combineMap (functionToDeclarations env) functions + + uniformDecls : List Elm.Declaration + uniformDecls = + List.map uniformToDeclaration uniforms in case maybeDecls of Ok decls -> - List.concat decls ++ builtinDecls + List.concat decls ++ builtinDecls ++ uniformDecls Err e -> "Error generating file" @@ -87,6 +118,14 @@ generate glsl = |> List.singleton +uniformToDeclaration : Uniform -> Elm.Declaration +uniformToDeclaration { name, tipe } = + Gen.Glsl.var name + |> Elm.withType (Gen.Glsl.annotation_.expression (typeToAnnotation tipe)) + |> Elm.declaration name + |> Elm.exposeWith { exposeConstructor = False, group = Just "uniforms" } + + functionHasType : String -> List Type -> Type -> Env -> Env functionHasType baseName argTypes returnType env = { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } @@ -605,21 +644,6 @@ typeToShort t = "o" ++ typeToShort tt -builtinUniforms : Dict String Type -builtinUniforms = - [ ( "u_whiteLines", TFloat ) - , ( "u_completelyReal", TFloat ) - , ( "u_drawAxes", TFloat ) - , ( "u_zoomCenter", TVec2 ) - , ( "u_viewportWidth", TFloat ) - , ( "u_canvasWidth", TFloat ) - , ( "u_canvasHeight", TFloat ) - , ( "u_phi", TFloat ) - , ( "u_theta", TFloat ) - ] - |> Dict.fromList - - builtinFunctions : Dict String { baseName : String, args : List Type, return : Type } builtinFunctions = let @@ -660,10 +684,31 @@ builtinFunctions = ([ TFloat, TInt ] |> List.repeat size |> List.Extra.cartesianProduct - |> (++) [ [ TInt ], [ TFloat ], [ TFloat, TVec3 ] ] + |> (++) + (if size == 4 then + [ [ TInt ] + , [ TFloat ] + , [ TFloat, TVec3 ] + , [ TVec3, TFloat ] + ] + + else + [ [ TInt ], [ TFloat ] ] + ) ) ) + mats : List ( String, List Type, Type ) + mats = + [ ( [ TVec3, TVec3, TVec3 ], 3, TMat3 ) ] + |> List.map + (\( inTypes, size, type_ ) -> + ( "mat" ++ String.fromInt size + , inTypes + , type_ + ) + ) + ivecs : List ( String, List Type, Type ) ivecs = [ ( 2, TVec2 ) @@ -688,7 +733,7 @@ builtinFunctions = builtTuple ( name, inTypes, resultType ) = ( fullName name inTypes, { baseName = name, args = inTypes, return = resultType } ) in - (regular ++ vecs ++ ivecs ++ others) + (regular ++ vecs ++ ivecs ++ mats ++ others) |> List.map builtTuple |> Dict.fromList @@ -708,8 +753,10 @@ builtin_v_s = builtin_v_v : ( List String, List ( List Type, Type ) ) builtin_v_v = - ( [ -- Rounding - "ceil" + ( [ "fwidth" + + -- Rounding + , "ceil" , "floor" , "fract" @@ -896,6 +943,6 @@ indexedVar i = String.fromChar <| Char.fromCode <| Char.toCode 'a' + i -parseFile : String -> Result (List Parser.DeadEnd) (List Function) +parseFile : String -> Result (List Parser.DeadEnd) (List Declaration) parseFile glsl = Parser.run Glsl.Parser.file glsl diff --git a/codegen/src/Glsl/Parser.elm b/codegen/src/Glsl/Parser.elm index b9bf28e7..bfd11990 100644 --- a/codegen/src/Glsl/Parser.elm +++ b/codegen/src/Glsl/Parser.elm @@ -1,11 +1,11 @@ module Glsl.Parser exposing (file, function, statement) -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, loop, oneOf, problem, sequence, spaces, succeed, symbol) +import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, keyword, loop, oneOf, problem, sequence, spaces, succeed, symbol) import Parser.Workaround -function : Parser Function +function : Parser Declaration function = succeed (\glsl begin returnType { name, hasSuffix } args stat end -> @@ -20,7 +20,7 @@ function = , body = String.slice begin end glsl } in - res + FunctionDeclaration res ) |= Parser.getSource |= Parser.getOffset @@ -41,6 +41,24 @@ function = |= Parser.getOffset +uniform : Parser Declaration +uniform = + succeed + (\tipe name -> + UniformDeclaration + { tipe = tipe + , name = name + } + ) + |. symbol "uniform" + |. spaces + |= typeParser + |. spaces + |= identifierParser + |. spaces + |. symbol ";" + + argParser : Parser ( Type, String ) argParser = succeed Tuple.pair @@ -70,18 +88,32 @@ identifierParser = typeParser : Parser Type typeParser = - [ ( "void", TVoid ) - , ( "bool", TBool ) - , ( "float", TFloat ) - , ( "int", TInt ) - , ( "vec2", TVec2 ) - , ( "ivec2", TIVec2 ) - , ( "vec3", TVec3 ) - , ( "vec4", TVec4 ) - , ( "mat3", TMat3 ) - ] - |> List.map (\( s, t ) -> succeed t |. symbol s) - |> oneOf + let + baseParser = + [ ( "void", TVoid ) + , ( "bool", TBool ) + , ( "float", TFloat ) + , ( "int", TInt ) + , ( "vec2", TVec2 ) + , ( "ivec2", TIVec2 ) + , ( "vec3", TVec3 ) + , ( "vec4", TVec4 ) + , ( "mat3", TMat3 ) + ] + |> List.map (\( s, t ) -> succeed t |. keyword s) + |> oneOf + in + oneOf + [ succeed TOut + |. keyword "out" + |. spaces + |= baseParser + , succeed TIn + |. keyword "in" + |. spaces + |= baseParser + , baseParser + ] statement : Parser Stat @@ -446,7 +478,7 @@ tryParseNumber n = problem "Expected a number" -file : Parser (List Function) +file : Parser (List Declaration) file = Parser.succeed (List.filterMap identity) |= Parser.sequence @@ -460,8 +492,8 @@ file = |. Parser.Workaround.lineCommentAfter "#define" , Parser.succeed Nothing |. Parser.Workaround.lineCommentAfter "precision highp" - , Parser.succeed Nothing - |. Parser.Workaround.lineCommentAfter "uniform" + , Parser.succeed Just + |= uniform , Parser.succeed Just |= function ] diff --git a/package.json b/package.json index 7854065d..03630b15 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "devDependencies": { "elm-codegen": "^0.5.3", + "elm-format": "^0.8.7", "elm-optimize-level-2": "^0.3.5", "elm-review": "^2.11.1", "elm-watch": "^2.0.0-beta.2", diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index ab22b923..ac1ea1a9 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -3,11 +3,16 @@ module Expression exposing , BinaryOperation(..) , Context , Expression(..) + , Function1(..) + , Function2(..) + , Function3(..) , FunctionName(..) , KnownFunction(..) - , PrintExpression(..) , RelationOperation(..) , SolutionTree(..) + , TGApply(..) + , ToGlslExpression(..) + , TypecheckError(..) , UnaryOperation(..) , VariableStatus(..) , asMatrix @@ -27,9 +32,9 @@ module Expression exposing , relationToString , solutionTreeToString , toDebugTree - , toPrintExpression , toString , toTeXString + , typecheck , variadicFunctions , visit ) @@ -39,6 +44,7 @@ import Dict exposing (Dict) import Element.WithContext as Element exposing (Element) import Element.WithContext.Border as Border import Element.WithContext.Font +import Result.Extra import Set exposing (Set) import Trie exposing (Trie) import UI.L10N exposing (L10N, invariant) @@ -69,7 +75,6 @@ type SolutionTree type FunctionName = KnownFunction KnownFunction - | UserFunction String type KnownFunction @@ -86,7 +91,8 @@ type KnownFunction | Tanh -- Power | Abs - | Root Int + | Sqrt + | Cbrt | Ln | Log10 | Exp @@ -107,9 +113,8 @@ type KnownFunction | Round | Floor | Ceil - | Pw + | Piecewise | Plot - | APlot | Simplify | StepSimplify | Solve @@ -206,7 +211,7 @@ visit f expr = List <| List.map (visit f) es -pvisit : (PrintExpression -> Maybe PrintExpression) -> PrintExpression -> PrintExpression +pvisit : (ToGlslExpression -> Maybe ToGlslExpression) -> ToGlslExpression -> ToGlslExpression pvisit f expr = case f expr of Just r -> @@ -214,44 +219,44 @@ pvisit f expr = Nothing -> case expr of - PVariable s -> - PVariable s + TGVariable s -> + TGVariable s - PInteger i -> - PInteger i + TGInteger i -> + TGInteger i - PFloat f_ -> - PFloat f_ + TGFloat f_ -> + TGFloat f_ - PNegate l -> - PNegate (pvisit f l) + TGNegate l -> + TGNegate (pvisit f l) - PLambda x e -> - PLambda x (pvisit f e) + TGAdd l r -> + TGAdd (pvisit f l) (pvisit f r) - PAdd l r -> - PAdd (pvisit f l) (pvisit f r) + TGBy l r -> + TGBy (pvisit f l) (pvisit f r) - PBy l r -> - PBy (pvisit f l) (pvisit f r) + TGDiv l r -> + TGDiv (pvisit f l) (pvisit f r) - PDiv l r -> - PDiv (pvisit f l) (pvisit f r) + TGPower l r -> + TGPower (pvisit f l) (pvisit f r) - PPower l r -> - PPower (pvisit f l) (pvisit f r) + TGRel o l r -> + TGRel o (pvisit f l) (pvisit f r) - PRel o l r -> - PRel o (pvisit f l) (pvisit f r) + TGApply (TGApply1 func l) -> + TGApply (TGApply1 func (pvisit f l)) - PApply func e -> - PApply func <| List.map (pvisit f) e + TGApply (TGApply2 func l m) -> + TGApply (TGApply2 func (pvisit f l) (pvisit f m)) - PReplace vars e -> - PReplace (Dict.map (\_ -> Maybe.map <| pvisit f) vars) (pvisit f e) + TGApply (TGApply3 func l m r) -> + TGApply (TGApply3 func (pvisit f l) (pvisit f m) (pvisit f r)) - PList es -> - PList <| List.map (pvisit f) es + TGList es -> + TGList <| List.map (pvisit f) es partialSubstitute : String -> Expression -> Expression -> Expression @@ -397,8 +402,9 @@ listEquals ls rs = toString : Expression -> String toString = - toPrintExpression - >> toStringPrec 0 + typecheck + >> Result.map (toStringPrec 0) + >> Result.withDefault "Typecheck error" solutionTreeToString : SolutionTree -> L10N String @@ -425,68 +431,236 @@ solutionTreeToString tree = UI.L10N.map (\ps -> "(" ++ String.join ") (" ps ++ ")") (UI.L10N.traverse solutionTreeToString ls) -type PrintExpression - = PInteger Int - | PFloat Float - | PVariable String - | PLambda String PrintExpression - | PAdd PrintExpression PrintExpression - | PNegate PrintExpression - | PBy PrintExpression PrintExpression - | PDiv PrintExpression PrintExpression - | PRel RelationOperation PrintExpression PrintExpression - | PPower PrintExpression PrintExpression - | PReplace (Dict String (Maybe PrintExpression)) PrintExpression - | PList (List PrintExpression) - | PApply FunctionName (List PrintExpression) - - -toPrintExpression : Expression -> PrintExpression -toPrintExpression e = +type ToGlslExpression + = TGInteger Int + | TGFloat Float + | TGVariable String + | TGAdd ToGlslExpression ToGlslExpression + | TGNegate ToGlslExpression + | TGBy ToGlslExpression ToGlslExpression + | TGDiv ToGlslExpression ToGlslExpression + | TGRel RelationOperation ToGlslExpression ToGlslExpression + | TGPower ToGlslExpression ToGlslExpression + | TGList (List ToGlslExpression) + | TGApply TGApply + + +type TGApply + = TGApply1 Function1 ToGlslExpression + | TGApply2 Function2 ToGlslExpression ToGlslExpression + | TGApply3 Function3 ToGlslExpression ToGlslExpression ToGlslExpression + + +type Function1 + = -- Trig + PSin + | PCos + | PTan + | PAsin + | PAcos + | PAtan + | PSinh + | PCosh + | PTanh + -- Power + | PAbs + | PSqrt + | PCbrt + | PLn + | PLog10 + | PExp + | PSign + -- Complex + | PRe + | PIm + | PArg + -- Matrix + | PGra + | PDet + -- Misc + | PRound + | PFloor + | PCeil + + +type Function2 + = -- Trig + PAtan2 + -- Misc + | PMin + | PMax + | PMod + | PMbrot + + +type Function3 + = -- Misc + PPiecewise + + +type TypecheckError + = InvalidArgCount KnownFunction Int + | FoundLambda + + +typecheck : Expression -> Result TypecheckError ToGlslExpression +typecheck e = case e of Variable v -> - PVariable v + Ok (TGVariable v) - Lambda x f -> - PLambda x <| toPrintExpression f + Lambda _ _ -> + Err FoundLambda Integer i -> - PInteger i + Ok (TGInteger i) Float f -> - PFloat f + Ok (TGFloat f) UnaryOperation Negate expression -> - PNegate <| toPrintExpression expression + Result.map TGNegate <| typecheck expression BinaryOperation Power l r -> - PPower (toPrintExpression l) (toPrintExpression r) + Result.map2 TGPower (typecheck l) (typecheck r) BinaryOperation Division l r -> - PDiv (toPrintExpression l) (toPrintExpression r) + Result.map2 TGDiv (typecheck l) (typecheck r) RelationOperation op l r -> - PRel op (toPrintExpression l) (toPrintExpression r) + Result.map2 (TGRel op) (typecheck l) (typecheck r) AssociativeOperation Addition l r o -> - List.foldl (\el a -> PAdd a el) - (PAdd (toPrintExpression l) (toPrintExpression r)) - (List.map toPrintExpression o) + List.foldl (\el a -> Result.map2 TGAdd a el) + (typecheck l) + (List.map typecheck (r :: o)) AssociativeOperation Multiplication l r o -> - List.foldl (\el a -> PBy a el) - (PBy (toPrintExpression l) (toPrintExpression r)) - (List.map toPrintExpression o) - - Replace vars expr -> - PReplace (Dict.map (\_ -> Maybe.map toPrintExpression) vars) <| - toPrintExpression expr + List.foldl (\el a -> Result.map2 TGBy a el) + (typecheck l) + (List.map typecheck (r :: o)) List es -> - PList <| List.map toPrintExpression es + es + |> Result.Extra.combineMap typecheck + |> Result.map TGList + + Apply (KnownFunction Sin) [ a0 ] -> + Result.map (TGApply << TGApply1 PSin) (typecheck a0) + + Apply (KnownFunction Sin) args -> + Err <| InvalidArgCount Sin (List.length args) + + Apply (KnownFunction Cos) _ -> + Debug.todo "branch 'Apply (KnownFunction Cos) _' not implemented" + + Apply (KnownFunction Tan) _ -> + Debug.todo "branch 'Apply (KnownFunction Tan) _' not implemented" + + Apply (KnownFunction Asin) _ -> + Debug.todo "branch 'Apply (KnownFunction Asin) _' not implemented" + + Apply (KnownFunction Acos) _ -> + Debug.todo "branch 'Apply (KnownFunction Acos) _' not implemented" + + Apply (KnownFunction Atan) _ -> + Debug.todo "branch 'Apply (KnownFunction Atan) _' not implemented" + + Apply (KnownFunction Atan2) _ -> + Debug.todo "branch 'Apply (KnownFunction Atan2) _' not implemented" + + Apply (KnownFunction Sinh) _ -> + Debug.todo "branch 'Apply (KnownFunction Sinh) _' not implemented" + + Apply (KnownFunction Cosh) _ -> + Debug.todo "branch 'Apply (KnownFunction Cosh) _' not implemented" + + Apply (KnownFunction Tanh) _ -> + Debug.todo "branch 'Apply (KnownFunction Tanh) _' not implemented" + + Apply (KnownFunction Abs) _ -> + Debug.todo "branch 'Apply (KnownFunction Abs) _' not implemented" + + Apply (KnownFunction Ln) _ -> + Debug.todo "branch 'Apply (KnownFunction Ln) _' not implemented" + + Apply (KnownFunction Log10) _ -> + Debug.todo "branch 'Apply (KnownFunction Log10) _' not implemented" + + Apply (KnownFunction Exp) _ -> + Debug.todo "branch 'Apply (KnownFunction Exp) _' not implemented" + + Apply (KnownFunction Sign) _ -> + Debug.todo "branch 'Apply (KnownFunction Sign) _' not implemented" + + Apply (KnownFunction Re) _ -> + Debug.todo "branch 'Apply (KnownFunction Re) _' not implemented" + + Apply (KnownFunction Im) _ -> + Debug.todo "branch 'Apply (KnownFunction Im) _' not implemented" + + Apply (KnownFunction Arg) _ -> + Debug.todo "branch 'Apply (KnownFunction Arg) _' not implemented" + + Apply (KnownFunction Gra) _ -> + Debug.todo "branch 'Apply (KnownFunction Gra) _' not implemented" + + Apply (KnownFunction Det) _ -> + Debug.todo "branch 'Apply (KnownFunction Det) _' not implemented" + + Apply (KnownFunction Dd) _ -> + Debug.todo "branch 'Apply (KnownFunction Dd) _' not implemented" + + Apply (KnownFunction Ii) _ -> + Debug.todo "branch 'Apply (KnownFunction Ii) _' not implemented" + + Apply (KnownFunction Min) _ -> + Debug.todo "branch 'Apply (KnownFunction Min) _' not implemented" + + Apply (KnownFunction Max) _ -> + Debug.todo "branch 'Apply (KnownFunction Max) _' not implemented" + + Apply (KnownFunction Round) _ -> + Debug.todo "branch 'Apply (KnownFunction Round) _' not implemented" + + Apply (KnownFunction Floor) _ -> + Debug.todo "branch 'Apply (KnownFunction Floor) _' not implemented" + + Apply (KnownFunction Ceil) _ -> + Debug.todo "branch 'Apply (KnownFunction Ceil) _' not implemented" + + Apply (KnownFunction Piecewise) _ -> + Debug.todo "branch 'Apply (KnownFunction Piecewise) _' not implemented" + + Apply (KnownFunction Plot) _ -> + Debug.todo "branch 'Apply (KnownFunction Plot) _' not implemented" + + Apply (KnownFunction Simplify) _ -> + Debug.todo "branch 'Apply (KnownFunction Simplify) _' not implemented" + + Apply (KnownFunction StepSimplify) _ -> + Debug.todo "branch 'Apply (KnownFunction StepSimplify) _' not implemented" + + Apply (KnownFunction Solve) _ -> + Debug.todo "branch 'Apply (KnownFunction Solve) _' not implemented" + + Apply (KnownFunction Mod) _ -> + Debug.todo "branch 'Apply (KnownFunction Mod) _' not implemented" + + Apply (KnownFunction Mbrot) _ -> + Debug.todo "branch 'Apply (KnownFunction Mbrot) _' not implemented" + + Apply (KnownFunction For) _ -> + Debug.todo "branch 'Apply (KnownFunction For) _' not implemented" + + Apply (KnownFunction Sqrt) _ -> + Debug.todo "branch 'Apply (KnownFunction Sqrt) _' not implemented" - Apply f es -> - PApply f <| List.map toPrintExpression es + Apply (KnownFunction Cbrt) _ -> + Debug.todo "branch 'Apply (KnownFunction Cbrt) _' not implemented" + + Replace _ _ -> + Debug.todo "branch 'Replace _ _' not implemented" @@ -495,7 +669,7 @@ toPrintExpression e = -- 7 * / -toStringPrec : Int -> PrintExpression -> String +toStringPrec : Int -> ToGlslExpression -> String toStringPrec p e = let paren b c = @@ -521,7 +695,7 @@ toStringPrec p e = |> List.filterMap (\el -> case el of - PList [ x ] -> + TGList [ x ] -> Just x _ -> @@ -535,87 +709,77 @@ toStringPrec p e = Nothing in case e of - PVariable v -> + TGVariable v -> v - PFloat f -> + TGFloat f -> String.fromFloat f - PInteger v -> + TGInteger v -> String.fromInt v - PNegate expression -> + TGNegate expression -> noninfix "-" expression - PAdd l (PNegate r) -> + TGAdd l (TGNegate r) -> infixl_ 6 " - " l r - PAdd l (PFloat pf) -> + TGAdd l (TGFloat pf) -> if pf < 0 then - infixl_ 6 " - " l (PFloat -pf) + infixl_ 6 " - " l (TGFloat -pf) else - infixl_ 6 " + " l (PFloat pf) + infixl_ 6 " + " l (TGFloat pf) - PAdd l (PInteger pi) -> + TGAdd l (TGInteger pi) -> if pi < 0 then - infixl_ 6 " - " l (PInteger -pi) + infixl_ 6 " - " l (TGInteger -pi) else - infixl_ 6 " + " l (PInteger pi) + infixl_ 6 " + " l (TGInteger pi) - PAdd l r -> + TGAdd l r -> infixl_ 6 " + " l r - PRel rel l r -> + TGRel rel l r -> infixl_ 5 (" " ++ relationToString rel ++ " ") l r - PBy ((PInteger _) as l) r -> + TGBy ((TGInteger _) as l) r -> case r of - PPower _ _ -> + TGPower _ _ -> infixl_ 7 "" l r - PVariable _ -> + TGVariable _ -> infixl_ 7 "" l r - PApply _ _ -> + TGApply _ -> infixl_ 7 "" l r _ -> infixl_ 7 "*" l r - PBy l r -> + TGBy l r -> infixl_ 7 "*" l r - PDiv l r -> + TGDiv l r -> infixl_ 7 "/" l r - PPower l (PInteger 2) -> + TGPower l (TGInteger 2) -> paren (p > 8) <| toStringPrec 9 l ++ "²" - PPower l (PInteger 3) -> + TGPower l (TGInteger 3) -> paren (p > 8) <| toStringPrec 9 l ++ "³" - PPower l r -> + TGPower l r -> infixr_ 8 "^" l r - PLambda x ((PApply fn [ PVariable v ]) as f) -> - if v == x then - functionNameToString fn - - else - paren (p > 0) <| x ++ " => " ++ toStringPrec 0 f - - PLambda x f -> - paren (p > 0) <| x ++ " => " ++ toStringPrec 0 f + TGApply (TGApply1 name ((TGList _) as ex)) -> + paren (p > 10) <| functionNameToString (toFunctionName1 name) ++ toStringPrec 0 ex - PApply name [ (PList _) as ex ] -> - paren (p > 10) <| functionNameToString name ++ toStringPrec 0 ex + TGApply (TGApply1 name ex) -> + paren (p > 10) <| functionNameToString (toFunctionName1 name) ++ "(" ++ toStringPrec 0 ex ++ ")" - PApply name ex -> - paren (p > 10) <| functionNameToString name ++ "(" ++ String.join ", " (List.map (toStringPrec 0) ex) ++ ")" - - PList es -> + TGList es -> case asVector es of Nothing -> "{" ++ String.join ", " (List.map (toStringPrec 0) es) ++ "}" @@ -623,34 +787,88 @@ toStringPrec p e = Just rs -> "(" ++ String.join ", " (List.map (toStringPrec 0) rs) ++ ")" - PReplace var expr -> - "[" - ++ String.join "; " - (List.map - (\( k, mv ) -> - case mv of - Nothing -> - "!" ++ k - - Just v -> - let - r = - toStringPrec 0 v - in - String.join - (if String.contains " " r then - " " - - else - "" - ) - [ k, "=", r ] - ) - <| - Dict.toList var - ) - ++ "] " - ++ toStringPrec 0 expr + TGApply (TGApply2 _ _ _) -> + Debug.todo "branch 'TGApply (TGApply2 _ _ _)' not implemented" + + TGApply (TGApply3 _ _ _ _) -> + Debug.todo "branch 'TGApply (TGApply3 _ _ _ _)' not implemented" + + +toFunctionName1 : Function1 -> FunctionName +toFunctionName1 pf = + KnownFunction <| + case pf of + PSin -> + Sin + + PCos -> + Cos + + PTan -> + Tan + + PAsin -> + Asin + + PAcos -> + Acos + + PAtan -> + Atan + + PSinh -> + Sinh + + PCosh -> + Cosh + + PTanh -> + Tanh + + PAbs -> + Abs + + PSqrt -> + Sqrt + + PCbrt -> + Cbrt + + PLn -> + Ln + + PLog10 -> + Log10 + + PExp -> + Exp + + PSign -> + Sign + + PRe -> + Re + + PIm -> + Im + + PArg -> + Arg + + PGra -> + Gra + + PDet -> + Det + + PRound -> + Round + + PFloor -> + Floor + + PCeil -> + Ceil greeks : Dict String String @@ -720,8 +938,8 @@ unaryFunctions = power = [ ( "abs", Abs ) , ( "sign", Sign ) - , ( "sqrt", Root 2 ) - , ( "cbrt", Root 3 ) + , ( "sqrt", Sqrt ) + , ( "cbrt", Cbrt ) , ( "ln", Ln ) , ( "log10", Log10 ) , ( "exp", Exp ) @@ -740,7 +958,6 @@ unaryFunctions = other = [ ( "plot", Plot ) - , ( "aplot", APlot ) , ( "simplify", Simplify ) , ( "stepsimplify", StepSimplify ) , ( "floor", Floor ) @@ -769,7 +986,7 @@ binaryFunctions = ternaryFunctions : List ( String, KnownFunction ) ternaryFunctions = - [ ( "pw", Pw ) ] + [ ( "pw", Piecewise ) ] quaternaryFunctions : List ( String, KnownFunction ) @@ -889,15 +1106,12 @@ functionNameToString name = KnownFunction Sign -> "sign" - KnownFunction (Root 2) -> + KnownFunction Sqrt -> "sqrt" - KnownFunction (Root 3) -> + KnownFunction Cbrt -> "cbrt" - KnownFunction (Root n) -> - "root" ++ String.fromInt n - KnownFunction Ln -> "ln" @@ -928,15 +1142,12 @@ functionNameToString name = KnownFunction Ii -> "ii" - KnownFunction Pw -> + KnownFunction Piecewise -> "pw" KnownFunction Plot -> "plot" - KnownFunction APlot -> - "aplot" - KnownFunction Simplify -> "simplify" @@ -970,29 +1181,13 @@ functionNameToString name = KnownFunction For -> "for" - UserFunction u -> - u - -pfullSubstitute : Dict String (Maybe PrintExpression) -> PrintExpression -> PrintExpression +pfullSubstitute : Dict String (Maybe ToGlslExpression) -> ToGlslExpression -> ToGlslExpression pfullSubstitute dict = pvisit <| \expr -> case expr of - PReplace vars e -> - Just <| - PReplace (Dict.map (\_ -> Maybe.map <| pfullSubstitute dict) vars) <| - let - reduced = - Dict.filter (\k _ -> not <| Dict.member k vars) dict - in - if Dict.isEmpty reduced then - e - - else - pfullSubstitute dict e - - PVariable string -> + TGVariable string -> Dict.get string dict |> Maybe.andThen identity |> Maybe.withDefault expr @@ -1004,7 +1199,8 @@ pfullSubstitute dict = toTeXString : Expression -> String toTeXString = - toPrintExpression + typecheck + >> Result.withDefault (TGInteger 0) >> toTeXStringPrec 0 @@ -1123,12 +1319,12 @@ toDebugTree todo e = goRec "list" ls -asMatrixPrint : PrintExpression -> Maybe (List (List PrintExpression)) +asMatrixPrint : ToGlslExpression -> Maybe (List (List ToGlslExpression)) asMatrixPrint = genericAsMatrix (\l -> case l of - PList u -> + TGList u -> Just u _ -> @@ -1333,7 +1529,7 @@ genericDeterminant { plus, negate, by } mat = Nothing -toTeXStringPrec : Int -> PrintExpression -> String +toTeXStringPrec : Int -> ToGlslExpression -> String toTeXStringPrec p e = let paren b c = @@ -1358,135 +1554,130 @@ toTeXStringPrec p e = in wrp <| case e of - PVariable v -> + TGVariable v -> if Dict.member v greeks then "\\" ++ v else v - PFloat f -> + TGFloat f -> String.fromFloat f - PInteger v -> + TGInteger v -> String.fromInt v - PNegate expression -> + TGNegate expression -> noninfix "-" expression - PAdd l (PNegate r) -> + TGAdd l (TGNegate r) -> infixl_ 6 " - " l r - PAdd l (PBy (PInteger m) r) -> + TGAdd l (TGBy (TGInteger m) r) -> if m < 0 then - infixl_ 6 " - " l (PBy (PInteger -m) r) + infixl_ 6 " - " l (TGBy (TGInteger -m) r) else - infixl_ 6 " + " l (PBy (PInteger m) r) + infixl_ 6 " + " l (TGBy (TGInteger m) r) - PAdd l (PFloat pf) -> + TGAdd l (TGFloat pf) -> if pf < 0 then - infixl_ 6 " - " l (PFloat -pf) + infixl_ 6 " - " l (TGFloat -pf) else - infixl_ 6 " + " l (PFloat pf) + infixl_ 6 " + " l (TGFloat pf) - PAdd l (PInteger pi) -> + TGAdd l (TGInteger pi) -> if pi < 0 then - infixl_ 6 " - " l (PInteger -pi) + infixl_ 6 " - " l (TGInteger -pi) else - infixl_ 6 " + " l (PInteger pi) + infixl_ 6 " + " l (TGInteger pi) - PAdd l r -> + TGAdd l r -> infixl_ 6 " + " l r - PRel rel l r -> + TGRel rel l r -> infixl_ 5 (" " ++ relationToString rel ++ " ") l r - PLambda x ((PApply fn [ PVariable v ]) as f) -> - if v == x then - functionNameToString fn - - else - paren (p > 0) <| x ++ " \\RightArrow " ++ toTeXStringPrec 0 f - - PLambda x f -> - paren (p > 0) <| x ++ " \\RightArrow " ++ toTeXStringPrec 0 f - - PBy ((PInteger _) as l) r -> + TGBy ((TGInteger _) as l) r -> case r of - PPower _ _ -> + TGPower _ _ -> infixl_ 7 "" l r - PVariable _ -> + TGVariable _ -> infixl_ 7 "" l r - PApply (KnownFunction Abs) _ -> + TGApply (TGApply1 PAbs _) -> infixl_ 7 "\\cdot" l r - PApply _ _ -> + TGApply (TGApply1 _ _) -> + infixl_ 7 "" l r + + TGApply (TGApply2 _ _ _) -> + infixl_ 7 "" l r + + TGApply (TGApply3 _ _ _ _) -> infixl_ 7 "" l r _ -> infixl_ 7 "\\cdot" l r - PBy l r -> + TGBy l r -> infixl_ 7 "\\cdot" l r - PDiv l r -> + TGDiv l r -> paren (p > 7) <| "\\frac" ++ toTeXStringPrec 7 l ++ toTeXStringPrec 8 r - PPower l (PDiv (PInteger 1) (PInteger 2)) -> + TGPower l (TGDiv (TGInteger 1) (TGInteger 2)) -> paren (p > 8) <| "\\sqrt{" ++ toTeXStringPrec 0 l ++ "}" - PPower l (PDiv (PInteger 1) s) -> + TGPower l (TGDiv (TGInteger 1) s) -> paren (p > 8) <| "\\sqrt[" ++ toTeXStringPrec 0 s ++ "]{" ++ toTeXStringPrec 0 l ++ "}" - PPower (PApply name args) (PFloat i) -> + TGPower (TGApply (TGApply1 name arg)) (TGFloat i) -> paren (p > 10) <| "\\mathrm{" - ++ functionNameToString name + ++ functionNameToString (toFunctionName1 name) ++ "}^{" ++ String.fromFloat i ++ "}\\left(" - ++ String.join ", " (List.map (toTeXStringPrec 0) args) + ++ toTeXStringPrec 0 arg ++ "\\right)" - PPower (PApply name args) (PInteger i) -> + TGPower (TGApply (TGApply1 name args)) (TGInteger i) -> paren (p > 10) <| "\\mathrm{" - ++ functionNameToString name + ++ functionNameToString (toFunctionName1 name) ++ "}^{" ++ String.fromInt i ++ "}\\left(" - ++ String.join ", " (List.map (toTeXStringPrec 0) args) + ++ toTeXStringPrec 0 args ++ "\\right)" - PPower l r -> + TGPower l r -> paren (p > 8) <| toTeXStringPrec 9 l ++ "^{" ++ toTeXStringPrec 0 r ++ "}" - PApply (KnownFunction Abs) [ ex ] -> + TGApply (TGApply1 PAbs ex) -> paren (p > 10) <| "\\left|" ++ toTeXStringPrec 0 ex ++ "\\right|" - PApply (KnownFunction (Root 2)) [ ex ] -> + TGApply (TGApply1 PSqrt ex) -> paren (p > 10) <| "\\sqrt{" ++ toTeXStringPrec 0 ex ++ "}" - PApply (KnownFunction (Root n)) [ ex ] -> - paren (p > 10) <| "\\sqrt[" ++ String.fromInt n ++ "]{" ++ toTeXStringPrec 0 ex ++ "}" + -- TGApply (KnownFunction (Root n)) [ ex ] -> + -- paren (p > 10) <| "\\sqrt[" ++ String.fromInt n ++ "]{" ++ toTeXStringPrec 0 ex ++ "}" + TGApply (TGApply1 name ((TGList _) as ex)) -> + paren (p > 10) <| "\\mathrm{" ++ functionNameToString (toFunctionName1 name) ++ "}" ++ toTeXStringPrec 0 ex - PApply name [ (PList _) as ex ] -> - paren (p > 10) <| "\\mathrm{" ++ functionNameToString name ++ "}" ++ toTeXStringPrec 0 ex - - PApply name ex -> + TGApply (TGApply1 name ex) -> paren (p > 10) <| "\\mathrm{" - ++ functionNameToString name + ++ functionNameToString (toFunctionName1 name) ++ "}\\left(" - ++ String.join ", " (List.map (toTeXStringPrec 0) ex) + ++ toTeXStringPrec 0 ex ++ "\\right)" - PList es -> + TGList es -> case asMatrixPrint e of Just childLists -> let @@ -1498,34 +1689,8 @@ toTeXStringPrec p e = Nothing -> "\\begin{Bmatrix}" ++ String.join ", & " (List.map (\cell -> "{" ++ toTeXStringPrec 0 cell ++ "}") es) ++ " \\end{Bmatrix}" - PReplace var expr -> - "\\begin{bmatrix}" - ++ String.join " \\\\ " - (List.map - (\( k, mv ) -> - case mv of - Nothing -> - "!" ++ k - - Just v -> - let - r = - toTeXStringPrec 0 v - in - String.join - (if String.contains " " r then - " " - - else - "" - ) - [ k, "=", r ] - ) - <| - Dict.toList var - ) - ++ "\\end{bmatrix} " - ++ toTeXStringPrec 0 expr + TGApply _ -> + Debug.todo "branch 'TGApply _' not implemented" filterContext : Dict comparable (Maybe v) -> Dict comparable v diff --git a/src/elm/Expression/Derivative.elm b/src/elm/Expression/Derivative.elm index 4e441d57..e1c11d3f 100644 --- a/src/elm/Expression/Derivative.elm +++ b/src/elm/Expression/Derivative.elm @@ -1,7 +1,7 @@ module Expression.Derivative exposing (derivative) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), FunctionName(..), KnownFunction(..), UnaryOperation(..), filterContext, fullSubstitute) -import Expression.Utils exposing (by, byShort, cos_, cosh_, div, e, exp, ipowShort, ln_, log10_, minus, negate_, one, plus, pow, sign, sin_, sinh_, sqrt_, square, tan_, zero) +import Expression.Utils exposing (by, byShort, cos_, cosh_, div, exp, ipowShort, ln_, log10_, minus, negate_, one, plus, pow, sign, sin_, sinh_, sqrt_, square, tan_, zero) derivative : String -> Expression -> Expression @@ -141,19 +141,15 @@ knownDerivative name x = Abs -> sign x - Root n -> - let - ni = - Integer n - in + Sqrt -> + div + (Integer 1) + (by [ Integer 2, Apply (KnownFunction Sqrt) [ x ] ]) + + Cbrt -> div - (pow x - (div - (Integer (1 - n)) - ni - ) - ) - ni + (Integer 1) + (by [ Integer 3, pow x (div (Integer 2) (Integer 3)) ]) Ln -> div one x @@ -212,7 +208,7 @@ knownDerivative name x = Ceil -> zero - Pw -> + Piecewise -> --TODO Variable "TODO" @@ -220,10 +216,6 @@ knownDerivative name x = --TODO Variable "TODO" - APlot -> - --TODO - Variable "TODO" - Simplify -> --TODO Variable "TODO" diff --git a/src/elm/Expression/NumericRange.elm b/src/elm/Expression/NumericRange.elm index 7915662d..d4abc58c 100644 --- a/src/elm/Expression/NumericRange.elm +++ b/src/elm/Expression/NumericRange.elm @@ -87,10 +87,10 @@ getRange ctx e = o -> o - Apply (KnownFunction (Root 2)) [ c ] -> + Apply (KnownFunction Sqrt) [ c ] -> sqrtRange <| getRange ctx c - Apply (KnownFunction (Root 3)) [ c ] -> + Apply (KnownFunction Cbrt) [ c ] -> getRange ctx c Apply (KnownFunction Re) [ _ ] -> @@ -106,7 +106,7 @@ getRange ctx e = else Complex - Apply (KnownFunction Pw) [ _, t, f ] -> + Apply (KnownFunction Piecewise) [ _, t, f ] -> union (getRange ctx t) (getRange ctx f) Apply (KnownFunction Mbrot) _ -> @@ -119,9 +119,6 @@ getRange ctx e = else Real - Apply _ _ -> - Complex - Replace variables c -> getRange (List.foldl (\( k, v ) -> Dict.insert k (getRange ctx v)) diff --git a/src/elm/Expression/Parser.elm b/src/elm/Expression/Parser.elm index 63a050ad..9785cf9f 100644 --- a/src/elm/Expression/Parser.elm +++ b/src/elm/Expression/Parser.elm @@ -120,9 +120,11 @@ problemGroupToString : -> L10N String problemGroupToString ( { col, contextStack, problem }, problems ) = let + allProblems : List Problem allProblems = problem :: List.map .problem problems + prefix : L10N String prefix = case contextStack of [] -> @@ -441,7 +443,7 @@ multidivisionParser context = ] in Parser.inContext MultiDivisionContext <| - Parser.succeed (\maybeNegate md -> maybeNegate md) + Parser.succeed identity |= Parser.loop False signLoopStep |. whitespace |= multiSequence diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index b54bcf1a..649c5603 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -8,7 +8,6 @@ import Expression , Expression(..) , FunctionName(..) , KnownFunction(..) - , RelationOperation(..) , UnaryOperation(..) , filterContext , fullSubstitute @@ -216,16 +215,13 @@ stepList context { andThen, ifChanged } args = stepSimplifyApply : FunctionName -> List Expression -> Expression stepSimplifyApply fname sargs = case fname of - UserFunction _ -> - Apply fname sargs - KnownFunction name -> case ( name, sargs ) of - ( Root 2, [ arg ] ) -> + ( Sqrt, [ arg ] ) -> stepSimplifySqrt arg |> Maybe.withDefault (sqrt_ arg) - ( Root 3, [ arg ] ) -> + ( Cbrt, [ arg ] ) -> stepSimplifyCbrt arg |> Maybe.withDefault (cbrt arg) @@ -551,6 +547,9 @@ stepSimplifyCos sarg = stepSimplifyCbrt : Expression -> Maybe Expression stepSimplifyCbrt sarg = case sarg of + UnaryOperation Negate c -> + Just <| negate_ <| cbrt c + Integer j -> cbrtInteger j @@ -1681,9 +1680,6 @@ innerHoistLabmda expr = ( KnownFunction Plot, _ ) -> Nothing - ( KnownFunction APlot, _ ) -> - Nothing - ( _, [ Lambda x f ] ) -> Just <| Lambda x <| hoistLambda <| Apply fn [ f ] diff --git a/src/elm/Expression/Utils.elm b/src/elm/Expression/Utils.elm index c7cefacd..5f8090d6 100644 --- a/src/elm/Expression/Utils.elm +++ b/src/elm/Expression/Utils.elm @@ -244,12 +244,12 @@ ipow base exponent = cbrt : Expression -> Expression cbrt = - unaryFunc (Root 3) + unaryFunc Cbrt sqrt_ : Expression -> Expression sqrt_ = - unaryFunc (Root 2) + unaryFunc Sqrt re : Expression -> Expression diff --git a/src/elm/Expression/Value.elm b/src/elm/Expression/Value.elm index 8b859c70..7d67df66 100644 --- a/src/elm/Expression/Value.elm +++ b/src/elm/Expression/Value.elm @@ -15,7 +15,7 @@ type Value | SolutionTreeValue SolutionTree | SymbolicValue Expression | ComplexValue Complex - | GraphValue { axes : Bool, graph : Graph } + | GraphValue Graph | LambdaValue String Value | ListValue (List Value) @@ -252,11 +252,11 @@ applyValue context name args = KnownFunction Atan2 -> binaryFunctionValue context args Atan2 Complex.atan2 - KnownFunction (Root 2) -> - unaryFunctionValue context args (Root 2) Complex.sqrt + KnownFunction Sqrt -> + unaryFunctionValue context args Sqrt Complex.sqrt - KnownFunction (Root n) -> - unaryFunctionValue context args (Root n) (\v -> Complex.power v (Complex.fromReal <| 1.0 / toFloat n)) + KnownFunction Cbrt -> + unaryFunctionValue context args Cbrt (\v -> Complex.power v (Complex.fromReal <| 1.0 / 3.0)) KnownFunction Ln -> unaryFunctionValue context args Ln Complex.ln @@ -293,7 +293,7 @@ applyValue context name args = KnownFunction Exp -> unaryFunctionValue context args Exp Complex.exp - KnownFunction Pw -> + KnownFunction Piecewise -> case args of [ c, t, f ] -> case innerValue context c of @@ -309,10 +309,10 @@ applyValue context name args = ErrorValue e SymbolicValue s -> - SymbolicValue <| Apply (KnownFunction Pw) [ s, t, f ] + SymbolicValue <| Apply (KnownFunction Piecewise) [ s, t, f ] _ -> - SymbolicValue <| Apply (KnownFunction Pw) args + SymbolicValue <| Apply (KnownFunction Piecewise) args _ -> unexpectedArgCount (Just "pw") [ 3 ] @@ -345,25 +345,11 @@ applyValue context name args = KnownFunction Plot -> case args of [ e ] -> - GraphValue - { axes = True - , graph = Expression.Graph.fromExpression <| toExpression <| value Dict.empty e - } + GraphValue <| Expression.Graph.fromExpression <| toExpression <| value Dict.empty e _ -> unexpectedArgCount (Just "plot") [ 1 ] - KnownFunction APlot -> - case args of - [ e ] -> - GraphValue - { axes = False - , graph = Expression.Graph.fromExpression <| toExpression <| value Dict.empty e - } - - _ -> - unexpectedArgCount (Just "aplot") [ 1 ] - KnownFunction For -> case Utils.runForLoop args of Just values -> @@ -388,10 +374,6 @@ applyValue context name args = --TODO SymbolicValue <| Apply name args - UserFunction _ -> - --TODO - SymbolicValue <| Apply name args - unexpectedArgCount : Maybe String -> List Int -> Value unexpectedArgCount maybeName count = @@ -602,17 +584,9 @@ toString v = GraphValue g -> { en = - if g.axes then - "Graph: " ++ Expression.Graph.toString g.graph - - else - "Graph without axes: " ++ Expression.Graph.toString g.graph + "Graph: " ++ Expression.Graph.toString g , it = - if g.axes then - "Grafico: " ++ Expression.Graph.toString g.graph - - else - "Grafico senza assi: " ++ Expression.Graph.toString g.graph + "Grafico: " ++ Expression.Graph.toString g } LambdaValue x f -> @@ -853,15 +827,8 @@ toExpression v = ListValue l -> List <| List.map toExpression l - GraphValue { graph, axes } -> - Apply - (KnownFunction <| - if axes then - Plot - - else - APlot - ) + GraphValue graph -> + Apply (KnownFunction Plot) [ Expression.Graph.toExpression graph ] ErrorValue _ -> diff --git a/src/elm/UI.elm b/src/elm/UI.elm index 2950e23c..ca5087c6 100644 --- a/src/elm/UI.elm +++ b/src/elm/UI.elm @@ -220,8 +220,7 @@ init ({ saved, hasClipboard, hasFullscreen, languages } as flags) url key = , isFullscreen = False , language = languages - |> List.map parseLanguage - |> List.filterMap identity + |> List.filterMap parseLanguage |> List.head |> Maybe.withDefault En , rayDifferentials = True diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 9f790212..1a38dad0 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -1,15 +1,14 @@ module UI.Glsl exposing (getGlsl) import Dict -import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), FunctionName(..), KnownFunction(..), RelationOperation(..)) +import Expression exposing (Expression(..), RelationOperation(..)) import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) -import Expression.Utils exposing (by, minus, plus, square) -import Glsl exposing (BisectSignature, Mat3, Out, Vec3) +import Expression.Utils exposing (by, minus, plus) +import Glsl exposing (BisectSignature, ExprWithDeps) import Maybe.Extra as Maybe -import SortedAnySet as Set -import UI.Glsl.Code exposing (constantToGlsl, intervalFunctionToGlsl, intervalOperationToGlsl, mainGlsl, straightFunctionToGlsl, straightOperationToGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (FunDecl, expr, fileToGlsl) +import UI.Glsl.Code exposing (mainGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Generator as Generator exposing (expr) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere @@ -21,86 +20,90 @@ getGlsl rayDifferentials graph = { expr, funDecls, usesThetaDelta, pixel2D, pixel3D } = extract "" graph + build2d : + (Expression.Expression -> ExprWithDeps) + -> Expression.Expression + -> + { expr : ExprWithDeps + , funDecls : a + , usesThetaDelta : Bool + , pixel2D : List { call : b, color : Bool } + , pixel3D : List c + } build2d toSrc e = - let - ( decl, call ) = - toSrc e - in - { expr = e - , funDecls = decl + { expr = toSrc e , usesThetaDelta = False , pixel2D = [ { call = call, color = True } ] , pixel3D = [] } - extract prefix g = + extract : String -> Graph -> { pixel2D : List { call : String, color : Bool }, pixel3D : List a } + extract suffix g = case g of Explicit2D c -> - build2d (toSrcImplicit prefix) <| - minus Expression.Utils.y c + -- build2d (toSrcImplicit suffix) <| + -- minus Expression.Utils.y c + Debug.todo "Explicit2D" Implicit2D l r -> - build2d (toSrcImplicit prefix) <| - minus l r + -- build2d (toSrcImplicit suffix) <| + -- minus l r + Debug.todo "Implicit2D" Polar2D e -> - build2d (toSrcPolar prefix) e + -- build2d (toSrcPolar suffix) e + Debug.todo "Polar2D" Parametric2D x y -> - { pixel2D = - [ { call = toSrcParametric prefix e - , color = True - } - ] - , pixel3D = [] - } + -- { pixel2D = + -- [ { call = toSrcParametric suffix e + -- , color = True + -- } + -- ] + -- , pixel3D = [] + -- } + Debug.todo "Parametric2D" Relation2D e -> - build2d (toSrcRelation prefix) e + -- build2d (toSrcRelation suffix) e + Debug.todo "Relation2D" Contour e -> - { pixel2D = [ { call = toSrcContour prefix e, color = False } ] - , pixel3D = [] - } + -- { pixel2D = [ { call = toSrcContour suffix e, color = False } ] + -- , pixel3D = [] + -- } + Debug.todo "Countour" Implicit3D e -> - let - f = - get3DSource prefix e - in - { expr = f.expr - , pixel2D = [] - , pixel3D = [ f.bisect ] - } + -- let + -- f = + -- get3DSource suffix e + -- in + -- { expr = f.expr + -- , pixel2D = [] + -- , pixel3D = [ f.bisect ] + -- } + Debug.todo "Implicit3D" GraphList children -> let - prefix_ i = - prefix ++ "_" ++ String.fromInt i + suffix_ i = + suffix ++ "_" ++ String.fromInt i extracted = - List.indexedMap (extract << prefix_) children + List.indexedMap (extract << suffix_) children in { pixel2D = List.concatMap .pixel2D extracted , pixel3D = List.concatMap .pixel3D extracted } VectorField2D x y -> - { pixel2D = [ { call = toSrcVectorField2D prefix x y, color = False } ] + { pixel2D = [ { call = toSrcVectorField2D suffix x y, color = False } ] , pixel3D = [] } reqs = - let - _ = - -- Can remove in the future - Debug.todo - in - expr - |> expressionToRequirements - |> List.sortWith requirementSort - |> List.map (requirementToGlsl interval) - |> String.join "\n" + expr.deps in reqs ++ "\n/* Expression */\n" @@ -109,23 +112,24 @@ getGlsl rayDifferentials graph = get3DSource : String -> Expression -> BisectSignature -get3DSource prefix e = - case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl prefix) of +get3DSource suffix e = + case Sphere.asSphere e |> Maybe.map (Sphere.toGlsl suffix) of Just bisect -> bisect Nothing -> - case Plane.asPlane e |> Maybe.map (Plane.toGlsl prefix) of + case Plane.asPlane e |> Maybe.map (Plane.toGlsl suffix) of Just bisect -> bisect Nothing -> - case tryGlslFromPolynomial prefix e of + case tryGlslFromPolynomial suffix e of Just o -> o Nothing -> - UI.Glsl.Code.suffixToBisect (toSrc3D prefix e) prefix + -- UI.Glsl.Code.suffixToBisect (toSrc3D suffix e) suffix + Debug.todo "" tryGlslFromPolynomial : String -> Expression -> Maybe BisectSignature @@ -176,8 +180,4 @@ tryGlslFromPolynomial suffix e = |> Maybe.map Dict.fromList |> Maybe.withDefault Dict.empty in - UI.Glsl.Polynomial.glslFromPolySolutions suffix (var "max_distance") poly - |> Maybe.map - (\{ bisect } -> - bisect - ) + UI.Glsl.Polynomial.glslFromPolySolutions suffix (Glsl.var "max_distance") poly diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 18a62c44..7a791e6e 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,235 +1,1317 @@ -module UI.Glsl.Code exposing (expressionToGlsl, threshold) +module UI.Glsl.Code exposing (expressionToGlsl, expressionToGlslComplex, mainGlsl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D, toThreshold) -import Dict -import Expression exposing (FunctionName(..), KnownFunction(..), PrintExpression(..), RelationOperation(..), toPrintExpression) -import Glsl exposing (Expr, Expression, Vec2, float) -import Glsl.Functions exposing (abs2, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cpow22, cpw222, cre2, cround2, csign2, csin2, csinh2, csquare2, ctan2, ctanh2, exp1, vec21, vec211) -import Glsl.Operations exposing (add22, by11, negate2, subtract22) -import UI.Glsl.Generator exposing (expr, one, vec2Zero, zero) +import Expression exposing (Function1(..), Function2(..), Function3(..), RelationOperation(..), TGApply(..), ToGlslExpression(..)) +import Glsl exposing (Expr, Expression, Vec2, Vec3, Vec4, dot2X, dot2Y, dot4XY, float1, unsafeCall0, unsafeTypecast, var) +import Glsl.Functions exposing (abs2, abs3, abs4, axis111, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, ccbrt2, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cos1, cpow22, cpw222, cre2, cross33, cround2, csign2, csin2, csinh2, csqrt2, ctan2, ctanh2, dup1, exp1, fwidth3, gby44, gdiv44, gneg4, gnum1, gpow41, gpow44, gsquare4, hl2rgb11, iabs2, iacos2, iarg2, iasin2, iatan2, iby22, icbrt2, iceil2, icos2, icosh2, idiv22, ieq22, iexp2, iexpand2, ifloor2, igeq22, igt22, iim2, ileq22, iln2, ilog102, ilt22, ineg2, ineq22, ipow21, ipow22, ire2, iround2, isign2, isin2, isinh2, isqrt2, isquare2, itan2, itanh2, mat3333, max11, max33, max44, normalize3, pow11, radians1, sin1, u_canvasHeight, u_canvasWidth, u_drawAxes, u_phi, u_theta, u_viewportWidth, u_zoomCenter, vec211, vec3111, vec41111, vec431) +import Glsl.Operations exposing (add11, add22, add33, add44, by11, by12, by13, by22, by31, by33, div11, div22, eq, lt, negate1, negate2, subtract11, subtract22, subtract33, subtract44) +import Glsl.PrettyPrinter +import UI.Glsl.Generator as Generator exposing (adds3, assign, decl, def, expr, float, floatT, fun0, gl_FragColor, gl_FragCoord, main_, mat3, nop, one, return, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) -expressionToGlsl : List ( String, Expression Float ) -> Expression.Expression -> Expression Vec2 -expressionToGlsl context = - let - ctx : Dict.Dict String (Expression Float) - ctx = - Dict.fromList context - - variadic : (Expression Vec2 -> Expression Vec2 -> Expression Vec2) -> List PrintExpression -> Expression Vec2 - variadic f es = - case List.map go es of - [] -> - vec2Zero +expressionToGlslComplex : ToGlslExpression -> Glsl.Expression Vec2 +expressionToGlslComplex = + visit + { expr = + \expr -> + case expr of + VVariable "i" -> + vec211 zero one - head :: tail -> - List.foldl (\e a -> f a e) head tail + VVariable "pi" -> + vec211 (float1 pi) zero - go : PrintExpression -> Expression Vec2 - go expr = - case expr of - PVariable "i" -> - vec211 zero one + VVariable "e" -> + vec211 (exp1 one) zero - PVariable "pi" -> - vec211 (float pi) zero + VVariable v -> + vec211 (var v) zero - PVariable "e" -> - vec211 (exp1 one) zero + VInteger v -> + vec211 (float1 <| toFloat v) zero - PVariable v -> - case Dict.get v ctx of - Just w -> - vec211 w zero + VFloat f -> + vec211 (float1 f) zero - Nothing -> - vec21 zero + VNegate expression -> + negate2 expression - PInteger v -> - vec211 (float <| toFloat v) zero + VAdd l r -> + add22 l r - PFloat f -> - vec211 (float f) zero + VRel op l r -> + case op of + LessThan -> + subtract22 r l - PNegate expression -> - negate2 <| go expression + LessThanOrEquals -> + subtract22 r l - PAdd l (PNegate r) -> - subtract22 (go l) (go r) + NotEquals -> + abs2 <| subtract22 r l - PAdd l r -> - add22 (go l) (go r) + Equals -> + abs2 <| subtract22 r l - PRel op l r -> - case op of - LessThan -> - subtract22 (go r) (go l) + GreaterThanOrEquals -> + subtract22 l r - LessThanOrEquals -> - subtract22 (go r) (go l) + GreaterThan -> + subtract22 l r - NotEquals -> - abs2 <| subtract22 (go r) (go l) + VBy l r -> + cby22 l r - Equals -> - abs2 <| subtract22 (go r) (go l) + VDiv l r -> + cdiv22 l r - GreaterThanOrEquals -> - subtract22 (go l) (go r) + VPower l r -> + cpow22 l r - GreaterThan -> - subtract22 (go l) (go r) + -- If this happens, it's too late + VList _ -> + vec2Zero - PBy l r -> - cby22 (go l) (go r) + VSubtract _ _ -> + Debug.todo "branch 'VSubtract _ _' not implemented" - PDiv l r -> - cdiv22 (go l) (go r) + VSquare _ -> + Debug.todo "branch 'VSquare _' not implemented" - PPower (PVariable v) (PInteger 2) -> - case Dict.get v ctx of - Just w -> - vec211 (by11 w w) zero + VPowerF _ _ -> + Debug.todo "branch 'VPowerF _ _' not implemented" + , function1 = function1ToComplex + , function2 = function2ToComplex + , function3 = + \f l m r -> + case f of + PPiecewise -> + cpw222 l m r + } - Nothing -> - vec2Zero - PPower l (PInteger 2) -> - csquare2 (go l) +function2ToComplex : Function2 -> Expression Vec2 -> Expression Vec2 -> Expression Vec2 +function2ToComplex f = + case f of + PAtan2 -> + catan222 - PPower l r -> - cpow22 (go l) (go r) + PMod -> + cmod22 - PApply (KnownFunction Simplify) [ e ] -> - go e + PMbrot -> + cmbrot22 - PApply (KnownFunction Sin) [ e ] -> - csin2 (go e) + PMin -> + cmin22 - PApply (KnownFunction Cos) [ e ] -> - ccos2 (go e) + PMax -> + cmax22 - PApply (KnownFunction Tan) [ e ] -> - ctan2 (go e) - PApply (KnownFunction Asin) [ e ] -> - casin2 (go e) +function1ToComplex : Function1 -> Expression Vec2 -> Expression Vec2 +function1ToComplex f = + case f of + PSin -> + csin2 - PApply (KnownFunction Acos) [ e ] -> - cacos2 (go e) + PCos -> + ccos2 - PApply (KnownFunction Atan) [ e ] -> - catan2 (go e) + PTan -> + ctan2 - PApply (KnownFunction Atan2) [ l, r ] -> - catan222 (go l) (go r) + PAsin -> + casin2 - PApply (KnownFunction Sinh) [ e ] -> - csinh2 (go e) + PAcos -> + cacos2 - PApply (KnownFunction Cosh) [ e ] -> - ccosh2 (go e) + PAtan -> + catan2 - PApply (KnownFunction Tanh) [ e ] -> - ctanh2 (go e) + PSinh -> + csinh2 - PApply (KnownFunction Abs) [ e ] -> - cabs2 (go e) + PCosh -> + ccosh2 - PApply (KnownFunction Ln) [ e ] -> - cln2 (go e) + PTanh -> + ctanh2 - PApply (KnownFunction Log10) [ e ] -> - clog102 (go e) + PAbs -> + cabs2 - PApply (KnownFunction Exp) [ e ] -> - cexp2 (go e) + PLn -> + cln2 - PApply (KnownFunction Sign) [ e ] -> - csign2 (go e) + PLog10 -> + clog102 - PApply (KnownFunction Re) [ e ] -> - cre2 (go e) + PExp -> + cexp2 - PApply (KnownFunction Im) [ e ] -> - cim2 (go e) + PSign -> + csign2 - PApply (KnownFunction Arg) [ e ] -> - carg2 (go e) + PRe -> + cre2 - PApply (KnownFunction Round) [ e ] -> - cround2 (go e) + PIm -> + cim2 - PApply (KnownFunction Floor) [ e ] -> - cfloor2 (go e) + PArg -> + carg2 - PApply (KnownFunction Ceil) [ e ] -> - cceil2 (go e) + PRound -> + cround2 - PApply (KnownFunction Pw) [ c, t, f ] -> - cpw222 (go c) (go t) (go f) + PFloor -> + cfloor2 - PApply (KnownFunction Mod) [ l, r ] -> - cmod22 (go l) (go r) + PCeil -> + cceil2 - PApply (KnownFunction Mbrot) [ x, y ] -> - cmbrot22 (go x) (go y) + PSqrt -> + csqrt2 - PApply (KnownFunction Min) es -> - variadic cmin22 es + PCbrt -> + ccbrt2 - PApply (KnownFunction Max) es -> - variadic cmax22 es + PGra -> + Debug.todo "branch 'PGra' not implemented" - PReplace var e -> - go (Expression.pfullSubstitute var e) + PDet -> + Debug.todo "branch 'PDet' not implemented" - -- If this happens, it's too late - PApply _ _ -> - vec2Zero - PList _ -> - vec2Zero +expressionToIntervalGlsl : Bool -> ToGlslExpression -> Expression Vec2 +expressionToIntervalGlsl expandIntervals = + let + expand : Expression Vec2 -> Expression Vec2 + expand e = + if expandIntervals then + iexpand2 e + + else + e + + visitExpr expr = + case expr of + VVariable "pi" -> + dup1 (radians1 (float1 180)) + + VVariable "e" -> + dup1 (float1 e) + + VVariable v -> + var v + + VInteger v -> + dup1 (float1 <| toFloat v) + + VFloat f -> + dup1 (float1 f) - PLambda _ _ -> + VNegate expression -> + ineg2 expression + + VAdd l r -> + expand <| add22 l r + + VRel op l r -> + comparisonToInterval op l r + + VBy l r -> + expand <| iby22 l r + + VDiv l r -> + expand <| idiv22 l r + + VSquare l -> + expand <| isquare2 l + + VPowerF l f -> + expand <| ipow21 l (float1 f) + + VPower l r -> + expand <| ipow22 l r + + VList [ x, y ] -> + vec211 x y + + VList _ -> + -- TODO: handle this vec2Zero + + VSubtract _ _ -> + Debug.todo "branch 'VSubtract _ _' not implemented" in - toPrintExpression >> go + visit + { expr = visitExpr + , function1 = + \f l -> + -- sin and cos should not be expanded + if f == PSin || f == PCos then + function1ToInterval f l + + else + expand <| function1ToInterval f l + , function2 = Debug.todo "function2" + , function3 = Debug.todo "function3" + } + + +function1ToInterval : Function1 -> Expression Vec2 -> Expression Vec2 +function1ToInterval f = + case f of + PSin -> + isin2 + + PCos -> + icos2 + + PTan -> + itan2 + + PAsin -> + iasin2 + + PAcos -> + iacos2 + + PAtan -> + iatan2 + + PSinh -> + isinh2 + + PCosh -> + icosh2 + + PTanh -> + itanh2 + + PAbs -> + iabs2 + + PSqrt -> + isqrt2 + + PCbrt -> + icbrt2 + + PLn -> + iln2 + + PLog10 -> + ilog102 + + PExp -> + iexp2 + + PSign -> + isign2 + + PRe -> + ire2 + + PIm -> + iim2 + + PArg -> + iarg2 + + PRound -> + iround2 + + PFloor -> + ifloor2 + + PCeil -> + iceil2 + + PGra -> + Debug.todo "branch 'PGra' not implemented" + + PDet -> + Debug.todo "branch 'PDet' not implemented" + + +comparisonToInterval : RelationOperation -> Expression Vec2 -> Expression Vec2 -> Expression Vec2 +comparisonToInterval op = + case op of + LessThan -> + ilt22 + + LessThanOrEquals -> + ileq22 + + Equals -> + ieq22 + + NotEquals -> + ineq22 + GreaterThanOrEquals -> + igeq22 -threshold : Expression Float -> Expression Float -threshold max_distance = - by11 (float 0.000001) max_distance + GreaterThan -> + igt22 + + +expressionToNormalGlsl : ToGlslExpression -> Expression Vec4 +expressionToNormalGlsl = + visit + { expr = + \expr -> + case expr of + VVariable "pi" -> + gnum1 (radians1 (float1 180)) + + VVariable "e" -> + gnum1 (exp1 one) + + VVariable "x" -> + vec41111 (var "x") one zero zero + + VVariable "y" -> + vec41111 (var "y") zero one zero + + VVariable "z" -> + vec41111 (var "z") zero zero one + + VVariable v -> + var v + + VInteger v -> + gnum1 (float1 (toFloat v)) + + VFloat f -> + gnum1 (float1 f) + + VNegate expression -> + gneg4 expression + + VAdd l r -> + add44 l r + + VRel op l r -> + case op of + LessThan -> + subtract44 r l + + LessThanOrEquals -> + subtract44 r l + + Equals -> + abs4 (subtract44 r l) + + NotEquals -> + abs4 (subtract44 r l) + + GreaterThanOrEquals -> + subtract44 l r + + GreaterThan -> + subtract44 l r + + VBy l r -> + gby44 l r + + VDiv l r -> + gdiv44 l r + + VPower l r -> + gpow44 l r + + VSquare l -> + gsquare4 l + + VPowerF l r -> + gpow41 l (float1 r) + + VList _ -> + Debug.todo "branch 'VList _' not implemented" + + VSubtract _ _ -> + Debug.todo "branch 'VSubtract _ _' not implemented" + , function1 = Debug.todo "function1" + , function2 = Debug.todo "function2" + , function3 = Debug.todo "function3" + } + + +epsilon : Float +epsilon = + 0.00001 + + +threshold : String +threshold = + String.fromFloat epsilon ++ " * max_distance" + + +toThreshold : Expression Float -> Expression Float +toThreshold maxDistance = + by11 (float1 epsilon) maxDistance + + +floatToGlsl : Float -> String +floatToGlsl f = + Glsl.PrettyPrinter.float f toSrcImplicit : String -> Expr -> String toSrcImplicit suffix e = + -- let + -- antialiasingSamples = + -- 7 + -- in + -- """ + -- float f""" ++ suffix ++ """(float x, float y) { + -- vec2 complex = """ ++ expressionToGlslComplex e ++ """; + -- if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { + -- return 0.0; + -- } + -- return complex.x > 0.0 ? 1.0 : -1.0; + -- } + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- float sum = 0.0; + -- float samples = """ ++ floatToGlsl antialiasingSamples ++ """ * 2.0 + 1.0; + -- samples *= samples; + -- float coeff = 0.0875; + -- for(int w = -""" ++ String.fromInt antialiasingSamples ++ """; w <= """ ++ String.fromInt antialiasingSamples ++ """; w++) + -- for(int h = -""" ++ String.fromInt antialiasingSamples ++ """; h <= """ ++ String.fromInt antialiasingSamples ++ """; h++) { + -- float piece = f""" ++ suffix ++ """(x + deltaX * coeff * float(w), y + deltaX * coeff * float(h)); + -- if(piece == 0.0) + -- return vec3(0); + -- sum += piece; + -- } + -- float perc = (samples - abs(sum)) / samples; + -- perc = pow(perc, 0.2); + -- return perc * vec3(1,1,1); + -- } + -- """ + let + _ = + Debug.todo + in + "" + + +toSrcPolar : String -> Expr -> String +toSrcPolar suffix e = + -- """ + -- float f""" ++ suffix ++ """(float x, float y, float deltaT, float ot) { + -- float r = sqrt(x*x + y*y); + -- float t = atanPlus(y, x) + deltaT; + -- // Avoid the branch cut at {x > 0, y = 0} + -- if(abs(t - ot) > radians(180.0)) { + -- if(t < ot) t += radians(360.0); + -- else t -= radians(360.0); + -- } + -- vec2 complex = """ ++ expressionToGlsl e ++ """; + -- if(abs(complex.y) > """ ++ floatToGlsl epsilon ++ """) { + -- return -1.0; + -- } + -- return complex.x > 0.0 ? 1.0 : 0.0; + -- } + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- float t = 0.0; + -- x += deltaX / 2.0; + -- y += deltaY / 2.0; + -- float ot = atanPlus(y, x); + -- for(int i = 0; i < MAX_ITERATIONS / 10; i++) { + -- float h = f""" ++ suffix ++ """(x, y, t, ot); + -- float l = f""" ++ suffix ++ """(x - deltaX, y, t, ot); + -- float u = f""" ++ suffix ++ """(x, y - deltaY, t, ot); + -- float ul = f""" ++ suffix ++ """(x - deltaX, y - deltaY, t, ot); + -- if(h < 0.0 || l < 0.0 || u < 0.0 || ul < 0.0) + -- break; + -- if(h != l || h != u || h != ul) + -- return vec3(1,1,1); + -- t += radians(360.0); + -- ot += radians(360.0); + -- } + -- return vec3(0,0,0); + -- } + -- """ let - antialiasingSamples = - 7 + _ = + Debug.todo in + "" + + +toSrcParametric : Bool -> String -> Expr -> String +toSrcParametric expandIntervals suffix e = + -- """ + -- vec2 interval""" ++ suffix ++ """(vec2 p, float from, float to) { + -- vec2 x = vec2(p.x,p.x); + -- vec2 y = vec2(p.y,p.y); + -- vec2 t = from < to ? vec2(from, to) : vec2(to, from); + -- return """ ++ expressionToIntervalGlsl expandIntervals e ++ """; + -- } + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- float max_distance = pow(2.0, 10.0); + -- float from = -max_distance / 2.0; + -- float to = max_distance / 2.0; + -- vec2 p = vec2(x, y); + -- int depth = 0; + -- int choices = 0; + -- float ithreshold = 10.0 * deltaX * deltaX; + -- for(int it = 0; it < MAX_ITERATIONS; it++) { + -- float midpoint = mix(from, to, 0.5); + -- vec2 front = interval""" ++ suffix ++ """(p, from, midpoint); + -- vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + -- if(depth >= MAX_DEPTH + -- || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) + -- || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) + -- ) + -- return vec3(1,1,1); + -- if(front.x <= 0.0 && front.y >= 0.0) { + -- to = midpoint; + -- depth++; + -- choices *= 2; + -- } else if(back.x <= 0.0 && back.y >= 0.0) { + -- from = midpoint; + -- depth++; + -- choices = choices * 2 + 1; + -- } else { + -- // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + -- for(int j = MAX_DEPTH - 1; j > 0; j--) { + -- if(j > depth) + -- continue; + -- depth--; + -- choices /= 2; + -- if(choices / 2 * 2 == choices) { + -- midpoint = to; + -- to = to + (to - from); + -- vec2 back = interval""" ++ suffix ++ """(p, midpoint, to); + -- if(back.x <= 0.0 && back.y >= 0.0) { + -- from = midpoint; + -- depth++; + -- choices = choices * 2 + 1; + -- break; + -- } + -- } else { + -- from = from - (to - from); + -- } + -- } + -- if(depth == 0) + -- return vec3(0,0,0); + -- } + -- } + -- return vec3(0,0,0); + -- } + -- """ + let + _ = + Debug.todo + in + "" + + +thetaDelta : String +thetaDelta = """ - float f_SUFFIX(float x, float y) { - vec2 complex = EXPRESSION; - if(abs(complex.y) > EPSILON) { - return 0.0; - } - return complex.x > 0.0 ? 1.0 : -1.0; + float thetaDelta(float theta) { + if(u_whiteLines < 1.0) + return 100.0; + float thetaSix = theta * u_whiteLines + 0.5; + float thetaNeigh = 0.05; + return abs(fract(thetaSix) - 0.5) / thetaNeigh; } + """ + + +toSrcVectorField2D : String -> Expression.Expression -> Expression.Expression -> String +toSrcVectorField2D suffix x y = + -- """ + -- vec2 vector""" ++ suffix ++ """(float x, float y) { + -- vec2 xv = """ ++ expressionToGlsl x ++ """; + -- vec2 yv = """ ++ expressionToGlsl y ++ """; + -- return abs(xv.y) + abs(yv.y) < """ ++ floatToGlsl epsilon ++ """ ? vec2(xv.x, yv.x) : vec2(0,0); + -- } + -- bool near(vec2 o, vec2 corner, vec2 vector, float deltaX, float mx) { + -- float angleCorner = arg(o - corner); + -- float angleVector = arg(vector); + -- float delta = mod(angleCorner - angleVector, radians(360.0)); + -- float l = length(vector) / mx; + -- float maxLength = deltaX * VECTOR_SPACING * (l < """ ++ floatToGlsl epsilon ++ """ ? 0.0 : l / 2.0 + 0.5); + -- float wantedLength = length(o - corner); + -- float angularDistance = mix(180.0, 0.0, pow(wantedLength / maxLength, 0.3)); + -- return (delta < radians(angularDistance) || delta > radians(360.0 - angularDistance)) && wantedLength < maxLength; + -- } + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- vec2 o = vec2(x, y); + -- float mx = 0.0; + -- for(int xi = -X_POINTS; xi <= X_POINTS; xi++) { + -- for(int yi = -Y_POINTS; yi <= Y_POINTS; yi++) { + -- vec2 p = u_zoomCenter + vec2(deltaX * VECTOR_SPACING * float(xi), deltaX * VECTOR_SPACING * float(yi)); + -- vec2 v = vector""" ++ suffix ++ """(p.x, p.y); + -- mx = max(mx, length(v)); + -- } + -- } + -- vec3 colorA = vec3(0.0, 1.0, 0.0); + -- vec3 colorB = vec3(0.0, 0.0, 1.0); + -- x = o.x - mod(o.x, deltaX * VECTOR_SPACING); + -- y = o.y - mod(o.y, deltaX * VECTOR_SPACING); + -- vec2 bl = vector""" ++ suffix ++ """(x, y); + -- vec2 br = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y); + -- vec2 ul = vector""" ++ suffix ++ """(x, y + deltaX * VECTOR_SPACING); + -- vec2 ur = vector""" ++ suffix ++ """(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + -- float angleO; + -- vec2 corner; + -- float l; + -- corner = vec2(x, y); + -- l = length(bl) / mx; + -- if(near(o, corner, bl, deltaX, mx)) + -- return mix(colorA, colorB, l); + -- corner = vec2(x + deltaX * VECTOR_SPACING, y); + -- l = length(br) / mx; + -- if(near(o, corner, br, deltaX, mx)) + -- return mix(colorA, colorB, l); + -- corner = vec2(x, y + deltaX * VECTOR_SPACING); + -- l = length(ul) / mx; + -- if(near(o, corner, ul, deltaX, mx)) + -- return mix(colorA, colorB, l); + -- corner = vec2(x + deltaX * VECTOR_SPACING, y + deltaX * VECTOR_SPACING); + -- l = length(ur) / mx; + -- if(near(o, corner, ur, deltaX, mx)) + -- return mix(colorA, colorB, l); + -- return vec3(0,0,0); + -- } + -- """ + let + _ = + Debug.todo + in + "" - vec3 pixel_SUFFIX(float deltaX, float deltaY, float x, float y) { - float sum = 0.0; - float samples = ANTIALIASING_SAMPLES * 2.0 + 1.0; - samples *= samples; - float coeff = 0.0875; - for(int w = -ANTIALIASING_SAMPLES; w <= ANTIALIASING_SAMPLES; w++) - for(int h = -ANTIALIASING_SAMPLES; h <= ANTIALIASING_SAMPLES; h++) { - float piece = f_SUFFIX(x + deltaX * coeff * float(w), y + deltaX * coeff * float(h)); - if(piece == 0.0) - return vec3(0); - sum += piece; + +toSrcContour : String -> ToGlslExpression -> String +toSrcContour suffix e = + -- """ + -- vec3 pixel""" ++ suffix ++ """_o(float deltaX, float deltaY, float x, float y) { + -- vec2 z = """ ++ expressionToGlslComplex e ++ """; + -- float theta = atan(z.y, z.x) / radians(360.0); + -- float logRadius = log2(length(z)); + -- float powerRemainder = fract(logRadius); + -- float squished = 0.7 - powerRemainder * 0.4; + -- if(u_completelyReal > 0.0) { + -- float haf = fract(logRadius) / 6.0; + -- if(z.x > 0.0) + -- return hl2rgb(haf + 0.3, squished); + -- else + -- return hl2rgb(haf - 0.1, 1.0 - squished); + -- } + -- float td = thetaDelta(theta); + -- float l = mix(1.0, squished, smoothstep(0.0, 1.0, td)); + -- return hl2rgb(theta, l); + -- } + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- // Antialiasing + -- float dist = 1.0 / 3.0; + -- vec3 a = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + dist * deltaX, y + dist * deltaY); + -- vec3 b = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - dist * deltaX, y - dist * deltaY); + -- vec3 c = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + dist * deltaX, y - dist * deltaY); + -- vec3 d = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - dist * deltaX, y + dist * deltaY); + -- vec3 diff = abs(max(a, max(b, max(c, d))) - min(a, min(b, min(c, d)))); + -- if (diff.x < dist && diff.y < dist && diff.z < dist) + -- return (a + b + c + d) / 4.0; + -- vec3 e = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x + 2.0 * dist * deltaX, y); + -- vec3 f = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x - 2.0 * dist * deltaX, y); + -- vec3 g = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x, y - 2.0 * dist * deltaY); + -- vec3 h = pixel""" ++ suffix ++ """_o(deltaX, deltaY, x, y + 2.0 * dist * deltaY); + -- return (a + b + c + d + e + f + g + h) / 8.0; + -- } + -- """ + let + _ = + Debug.todo + in + "" + + +toSrcRelation : String -> Expr -> String +toSrcRelation suffix e = + -- """ + -- vec3 pixel""" ++ suffix ++ """(float deltaX, float deltaY, float x, float y) { + -- vec2 complex = """ ++ expressionToGlsl e ++ """; + -- return complex.x > 0.0 && abs(complex.y) < """ ++ floatToGlsl epsilon ++ """ ? vec3(0.8,0.5,0.5) : vec3(0,0,0); + -- } + -- """ + let + _ = + Debug.todo + in + "" + + +mainGlsl : + Bool + -> + List + { call : + Expression Float + -> Expression Float + -> Expression Float + -> Expression Float + -> Expression Vec3 + , color : Bool } - float perc = (samples - abs(sum)) / samples; - perc = pow(perc, 0.2); - return perc * vec3(1,1,1); - } + -> List String + -> String +mainGlsl rayDifferentials pixel2 pixel3 = + (case ( pixel2, pixel3 ) of + ( [], [] ) -> + main_ vec4Zero + + ( _ :: _, [] ) -> + main_ (main2D pixel2) + + ( [], _ :: _ ) -> + main_ (main3D rayDifferentials pixel3) + + ( _ :: _, _ :: _ ) -> + main_ + (max44 + (main2D pixel2) + (main3D rayDifferentials pixel3) + ) + ) + |> Generator.fileToGlsl + + +main2D : + List + { call : + Expression Float + -> Expression Float + -> Expression Float + -> Expression Float + -> Expression Vec3 + , color : Bool + } + -> Expression Vec4 +main2D pixels = + let + maybeColor : Int -> Bool -> Expression Vec3 -> Expression Vec3 + maybeColor i color innerCall = + let + h : Expression Float + h = + (toFloat (i + 2) / pi) + |> float1 + in + if color then + by33 (hl2rgb11 h (float1 0.5)) innerCall + + else + innerCall + in + fun0 vec4T "pixel2" <| \_ -> + def vec2T "canvasSize" (vec211 u_canvasWidth u_canvasHeight) <| \canvasSize -> + def vec2T "uv_centered" (subtract22 (gl_FragCoord |> dot4XY) (by12 (float1 0.5) canvasSize)) <| \uv_centered -> + def vec2T "viewportSize" (by12 (div11 u_viewportWidth u_canvasWidth) canvasSize) <| \viewportSize -> + def vec2T "uv" (by22 (div22 uv_centered canvasSize) viewportSize) <| \uv -> + def vec2T "c" (add22 u_zoomCenter uv) <| \c -> + float "x" (c |> dot2X) <| \x -> + float "y" (c |> dot2Y) <| \y -> + float "deltaX" (div11 u_viewportWidth u_canvasWidth) <| \deltaX -> + float "deltaY" (div11 u_viewportWidth u_canvasHeight) <| \deltaY -> + vec3 "px" vec3Zero <| \px -> + decl vec3T "curr" <| \curr -> + let + addPixel : + Int + -> + { call : Expression Float -> Expression Float -> Expression Float -> Expression Float -> Expression Vec3 + , color : Bool + } + -> Glsl.Statement r + -> Glsl.Statement r + addPixel i { call, color } cont = + let + inColor = + maybeColor i color (call deltaX deltaY x y) + in + expr (assign curr inColor) <| \_ -> + expr (assign px (ternary3 (eq curr vec3Zero) px curr)) <| \_ -> + cont + + inner : Glsl.Statement r -> Glsl.Statement r + inner cont = + pixels + |> List.indexedMap addPixel + |> List.foldr identity cont + in + inner <| + float "maxDelta" (max11 deltaX deltaY) <| \maxDelta -> + vec3 + "yax" + (ternary3 (eq u_drawAxes one) + (by13 (axis111 x y maxDelta) (vec3111 zero one zero)) + vec3Zero + ) + <| \yax -> + vec3 + "xax" + (ternary3 (eq u_drawAxes one) + (by13 (axis111 y x maxDelta) (vec3111 one zero zero)) + vec3Zero + ) + <| \xax -> + return (vec431 (max33 px (max33 xax yax)) one) + + +toSrc3D : Bool -> String -> Expr -> String +toSrc3D expandIntervals suffix e = + -- """ + -- vec3 normal""" ++ suffix ++ """(vec3 p) { + -- float x = p.x; + -- float y = p.y; + -- float z = p.z; + -- vec4 gradient = """ ++ expressionToNormalGlsl e ++ """; + -- return normalize(gradient.yzw); + -- } + -- vec2 interval""" ++ suffix ++ """(mat3 f, mat3 t) { + -- vec3 mn = min(f[0], t[0]); + -- vec3 mx = max(f[1], t[1]); + -- vec2 x = vec2(mn.x, mx.x); + -- vec2 y = vec2(mn.y, mx.y); + -- vec2 z = vec2(mn.z, mx.z); + -- return """ ++ expressionToIntervalGlsl expandIntervals e ++ """; + -- } + -- """ + let + _ = + Debug.todo + in + "" + + +main3D : Bool -> List String -> Expression Vec4 +main3D rayDifferentials suffixes = + let + iif b t f = + if b then + t + + else + f + in + fun0 vec4T "pixel3" <| \_ -> + float "eye_dist" (by11 (float1 2) u_viewportWidth) <| \eye_dist -> + vec2 "canvasSize" (vec211 u_canvasWidth u_canvasHeight) <| \canvasSize -> + vec2 "uv_centered" (subtract22 (gl_FragCoord |> dot4XY) (by12 (float1 0.5) canvasSize)) <| \uv_centered -> + vec2 "uv_normalized" (by12 (div11 one u_canvasHeight) uv_centered) <| \uv_normalized -> + float "t" (add11 u_theta (float1 0.58)) <| \t -> + float "p" (by11 (float1 -2) u_phi) <| \p -> + vec3 + "eye" + (by13 eye_dist + (normalize3 + (vec3111 + (by11 (cos1 t) (sin1 p)) + (by11 (cos1 t) (negate1 (cos1 p))) + (sin1 t) + ) + ) + ) + <| \eye -> + vec3 "target" vec3Zero <| \target -> + vec3 "to_target" (normalize3 (subtract33 target eye)) <| \to_target -> + vec3 "across" (normalize3 (cross33 to_target (vec3111 zero zero one))) <| \across -> + vec3 "up" (normalize3 (cross33 across to_target)) <| \up -> + vec3 "canvas_center" (add33 eye to_target) <| \canvas_center -> + vec3 + "canvas_point" + (adds3 + [ canvas_center + , by13 (uv_normalized |> dot2X) across + , by13 (uv_normalized |> dot2Y) up + ] + ) + <| \canvas_point -> + vec3 "ray_direction" (normalize3 (subtract33 canvas_point eye)) <| \ray_direction -> + vec3 "diffs" (abs3 (fwidth3 ray_direction)) <| \diffs -> + float "k" (iif rayDifferentials (float1 0.001) zero) <| \k -> + mat3 "d" + (mat3333 + (subtract33 ray_direction (by13 k diffs)) + (add33 ray_direction (by13 k diffs)) + vec3Zero + ) + <| \d -> + float "max_distance" (by11 (float1 100) eye_dist) <| \max_distance -> + return (raytrace suffixes canvas_point d max_distance) + + +raytrace : List String -> a -> b -> c -> Expression Vec4 +raytrace suffixes _ _ _ = + let + colorCoeff = + floatToGlsl (1.19 - 0.2 * toFloat (List.length suffixes)) + + innerTrace = + String.join "\n" (List.indexedMap suffixToRay suffixes) + + innerLightTrace = + String.join "\n" (List.map suffixToRayLight suffixes) + + suffixToRay i suffix = + """ + if(bisect""" ++ suffix ++ """(o, d, max_distance, f) && length(f - o) < curr_distance) { + found_index = """ ++ String.fromInt i ++ """; + found = f; + curr_distance = length(found - o); + } + """ + + suffixToRayLight suffix = + """ + else if(bisect""" ++ suffix ++ """(offseted, light_direction, light_distance, f)) { + light_coeff = 0.2; + } + """ + in + """ + vec4 raytrace(vec3 o, mat3 d, float max_distance) { + vec3 found = vec3(0); + float curr_distance = max_distance; + int found_index = -1; + vec3 f = vec3(0); + vec3 n = vec3(0); + """ ++ innerTrace ++ """ + if(found_index >= 0) { + float hue_based_on_index = (float(found_index))*radians(360.0 / 1.1); + vec3 ld = normalize(vec3(-0.3, 0.0, 1.0)); + vec3 diffs = d[1] - d[0]; + mat3 light_direction = mat3(ld - 0.5 * diffs, ld + 0.5 * diffs, vec3(0)); + float light_distance = max_distance; + float light_coeff = 0.45; + vec3 offseted = found + 0.0001 * max_distance * normalize(o - found); + if(0 == 1) { } + """ ++ innerLightTrace ++ """ + vec3 px = mix( + hl2rgb(hue_based_on_index, light_coeff), + hl2rgb(found.z * 0.5, light_coeff), + max(0.2, """ ++ colorCoeff ++ """) + ); + return vec4(px, 1.0); + } else { + return vec4(0.0, 0.0, 0.0, 1.0); + } + } + """ + + +suffixToBisect : String -> String +suffixToBisect suffix = """ + bool bisect""" ++ suffix ++ """(vec3 o, mat3 d, float max_distance, out vec3 found) { + mat3 from = mat3(o, o, vec3(0)); + mat3 to = from + max_distance * d; + float ithreshold = """ ++ threshold ++ """; + int depth = 0; + int choices = 0; + for(int it = 0; it < MAX_ITERATIONS; it++) { + mat3 midpoint = 0.5 * (from + to); + vec2 front = interval""" ++ suffix ++ """(from, midpoint); + vec2 back = interval""" ++ suffix ++ """(midpoint, to); + if(depth >= MAX_DEPTH + || (front.y - front.x < ithreshold && front.x <= 0.0 && front.y >= 0.0) + || (back.y - back.x < ithreshold && back.x <= 0.0 && back.y >= 0.0) + ) { + found = mix(midpoint[0], midpoint[1], 0.5); + return true; + } + if(front.x <= 0.0 && front.y >= 0.0) { + to = midpoint; + depth++; + choices = left_shift(choices); + } else if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = left_shift_increment(choices); + } else { + // This could be possibly helped by https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch + for(int j = MAX_DEPTH - 1; j > 0; j--) { + if(j > depth) + continue; + depth--; + choices = right_shift(choices); + if(is_even(choices)) { + midpoint = to; + to = to + (to - from); + vec2 back = interval""" ++ suffix ++ """(midpoint, to); + if(back.x <= 0.0 && back.y >= 0.0) { + from = midpoint; + depth++; + choices = left_shift_increment(choices); + break; + } + } else { + from = from - (to - from); + } + } + if(depth == 0) + return false; + } + } + return false; + } +""" + + +type VisitExpression a + = VInteger Int + | VFloat Float + | VVariable String + | VAdd a a + | VSubtract a a + | VNegate a + | VBy a a + | VDiv a a + | VRel RelationOperation a a + | VPower a a + | VSquare a + | VPowerF a Float + | VList (List (Glsl.Expression Float)) + + +visit : + { expr : VisitExpression a -> a + , function1 : Function1 -> a -> a + , function2 : Function2 -> a -> a -> a + , function3 : Function3 -> a -> a -> a -> a + } + -> ToGlslExpression + -> a +visit ({ expr, function1, function2, function3 } as cfg) p = + let + expr1 f l = + expr (f (visit cfg l)) + + expr2 f l r = + expr (f (visit cfg l) (visit cfg r)) + in + case p of + TGInteger i -> + expr (VInteger i) + + TGFloat f -> + expr (VFloat f) + + TGVariable v -> + expr (VVariable v) + + TGNegate e -> + expr1 VNegate e + + TGAdd l (TGNegate r) -> + expr2 VSubtract l r + + TGAdd l r -> + expr2 VAdd l r + + TGBy l r -> + expr2 VBy l r + + TGDiv l r -> + expr2 VDiv l r + + TGRel op l r -> + expr2 (VRel op) l r + + TGPower l (TGInteger i) -> + if i == 2 then + expr1 VSquare l + + else + expr1 (\le -> VPowerF le (toFloat i)) l + + TGPower l (TGFloat f) -> + if f == 2 then + expr1 VSquare l + + else + expr1 (\le -> VPowerF le f) l + + TGPower l r -> + expr2 VPower l r + + TGList es -> + expr (VList (List.map expressionToGlsl es)) + + TGApply (TGApply1 f1 l) -> + function1 f1 (visit cfg l) + + TGApply (TGApply2 f2 l r) -> + function2 f2 (visit cfg l) (visit cfg r) + + TGApply (TGApply3 f3 l m r) -> + function3 f3 (visit cfg l) (visit cfg m) (visit cfg r) + + +expressionToGlsl : ToGlslExpression -> Expression Float +expressionToGlsl = + visit + { expr = + \expr -> + case expr of + VInteger i -> + float1 (toFloat i) + + VFloat f -> + float1 f + + VVariable v -> + var v + + VAdd l r -> + add11 l r + + VNegate l -> + negate1 l + + VSubtract l r -> + subtract11 l r + + VBy l r -> + by11 l r + + VDiv l r -> + div11 l r + + VRel op l r -> + unsafeTypecast <| + case op of + LessThan -> + lt l r + + LessThanOrEquals -> + Debug.todo "branch 'LessThanOrEquals' not implemented" + + Equals -> + Debug.todo "branch 'Equals' not implemented" + + NotEquals -> + Debug.todo "branch 'NotEquals' not implemented" + + GreaterThanOrEquals -> + Debug.todo "branch 'GreaterThanOrEquals' not implemented" + + GreaterThan -> + Debug.todo "branch 'GreaterThan' not implemented" + + VPower l r -> + pow11 l r + + VList _ -> + Debug.todo "branch 'VList _' not implemented" + + VSquare _ -> + Debug.todo "branch 'VSquare _' not implemented" + + VPowerF _ _ -> + Debug.todo "branch 'VPowerF _ _' not implemented" + , function1 = + \f -> + case f of + PSin -> + sin1 + + PCos -> + Debug.todo "branch 'PCos' not implemented" + + PTan -> + Debug.todo "branch 'PTan' not implemented" + + PAsin -> + Debug.todo "branch 'PAsin' not implemented" + + PAcos -> + Debug.todo "branch 'PAcos' not implemented" + + PAtan -> + Debug.todo "branch 'PAtan' not implemented" + + PSinh -> + Debug.todo "branch 'PSinh' not implemented" + + PCosh -> + Debug.todo "branch 'PCosh' not implemented" + + PTanh -> + Debug.todo "branch 'PTanh' not implemented" + + PAbs -> + Debug.todo "branch 'PAbs' not implemented" + + PSqrt -> + Debug.todo "branch 'PSqrt' not implemented" + + PCbrt -> + Debug.todo "branch 'PCbrt' not implemented" + + PLn -> + Debug.todo "branch 'PLn' not implemented" + + PLog10 -> + Debug.todo "branch 'PLog10' not implemented" + + PExp -> + Debug.todo "branch 'PExp' not implemented" + + PSign -> + Debug.todo "branch 'PSign' not implemented" + + PRe -> + Debug.todo "branch 'PRe' not implemented" + + PIm -> + Debug.todo "branch 'PIm' not implemented" + + PArg -> + Debug.todo "branch 'PArg' not implemented" + + PGra -> + Debug.todo "branch 'PGra' not implemented" + + PDet -> + Debug.todo "branch 'PDet' not implemented" + + PRound -> + Debug.todo "branch 'PRound' not implemented" + + PFloor -> + Debug.todo "branch 'PFloor' not implemented" + + PCeil -> + Debug.todo "branch 'PCeil' not implemented" + , function2 = + \f -> + case f of + PAtan2 -> + Debug.todo "branch 'PAtan2' not implemented" + + PMax -> + Debug.todo "branch 'PMax' not implemented" + + PMod -> + Debug.todo "branch 'PMod' not implemented" + + PMbrot -> + Debug.todo "branch 'PMbrot' not implemented" + + PMin -> + Debug.todo "branch 'PMin' not implemented" + , function3 = + \f -> + case f of + PPiecewise -> + Debug.todo "branch 'PPiecewise' not implemented" + } diff --git a/src/elm/UI/Glsl/Generator.elm b/src/elm/UI/Glsl/Generator.elm index caa14043..e4c77907 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/src/elm/UI/Glsl/Generator.elm @@ -1,9 +1,10 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, floatT, floatToGlsl, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, mat3T, minusOne, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2T, vec2Zero, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) +module UI.Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) import Dict exposing (Dict) -import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, buildStatement, false, float, statement, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeExprStat, unsafeMap2, unsafeMap3, unsafeStat1, var, withExpression, withStatement) +import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, false, float1, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var, withExpression, withStatement) import Glsl.Functions exposing (vec211, vec3111, vec41111) import Glsl.Operations exposing (add22, add33, add44) +import Glsl.PrettyPrinter import Set import SortedSet @@ -379,7 +380,7 @@ exprToGlsl tree = "false" Float f -> - floatToGlsl f + Glsl.PrettyPrinter.float f Int i -> String.fromInt i @@ -531,63 +532,17 @@ gl_FragCoord = zero : Expression Float zero = - float 0 + float1 0 one : Expression Float one = - float 1 + float1 1 minusOne : Expression Float minusOne = - float -1 - - -floatToGlsl : Float -> String -floatToGlsl f = - let - s = - String.fromFloat f - in - if String.contains "." s || String.contains "e" s then - s - - else - s ++ "." - - - --- Utils - - -unsafeExpr1 : (Expr -> Expr) -> Expression a -> Expression b -unsafeExpr1 f (Expression l) = - Expression - { expr = f l.expr - , deps = l.deps - } - - -unsafeExpr2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -unsafeExpr2 f (Expression l) (Expression r) = - Expression - { expr = f l.expr r.expr - , deps = - l.deps - |> SortedSet.insertAll r.deps - } - - -unsafeExpr3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d -unsafeExpr3 f (Expression l) (Expression m) (Expression r) = - Expression - { expr = f l.expr m.expr r.expr - , deps = - l.deps - |> SortedSet.insertAll m.deps - |> SortedSet.insertAll r.deps - } + float1 -1 @@ -646,16 +601,27 @@ funX call typeF name body args = ) +main_ : Expression Vec4 -> List FunDecl +main_ e = + let + _ = + fun0 voidT "main" <| \_ -> + expr (assign gl_FragColor e) <| \_ -> + nop + in + Debug.todo "Generator.main_" + + fun0 : TypingFunction t -> String - -> Statement t + -> (() -> Statement t) -> Expression t fun0 typeF name body = funX unsafeCall0 typeF name - body + (body ()) [] @@ -754,22 +720,22 @@ fun5 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (Typ [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ), ( t4, arg4 ) ] -if_ : Expression Bool -> Statement r -> Statement r -> Statement r +if_ : Expression Bool -> Statement r -> (() -> Statement r) -> Statement r if_ cond ifTrue next = - statement If + build If |> withExpression cond |> withStatement ifTrue - |> withStatement next + |> withStatement (next ()) |> buildStatement -ifElse : Expression Bool -> Statement s -> Statement s -> Statement s -> Statement s +ifElse : Expression Bool -> Statement s -> Statement s -> (() -> Statement s) -> Statement s ifElse cond ifTrue ifFalse next = - statement IfElse + build IfElse |> withExpression cond |> withStatement ifTrue |> withStatement ifFalse - |> withStatement next + |> withStatement (next ()) |> buildStatement @@ -779,15 +745,12 @@ for : -> Statement r -> Statement r for ( var, from, to ) loop next = - -- Statement <| - -- For var - -- (unwrapExpression from) - -- LessThan - -- (unwrapExpression to) - -- (PostfixIncrement (Variable var)) - -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) - -- (unwrapLazyStatement next) - Debug.todo "for" + build (\f t -> For var f LessThan t PlusPlus) + |> withExpression from + |> withExpression to + |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement next + |> buildStatement forLeq : @@ -796,15 +759,12 @@ forLeq : -> Statement r -> Statement r forLeq ( var, from, to ) loop next = - -- Statement <| - -- For var - -- (unwrapExpression from) - -- LessThanOrEquals - -- (unwrapExpression to) - -- (PostfixIncrement (Variable var)) - -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) - -- (unwrapLazyStatement next) - Debug.todo "forLeq" + build (\f t -> For var f LessThanOrEquals t PlusPlus) + |> withExpression from + |> withExpression to + |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement next + |> buildStatement forDown : @@ -813,33 +773,30 @@ forDown : -> Statement r -> Statement r forDown ( var, from, to ) loop next = - -- Statement <| - -- For var - -- (unwrapExpression from) - -- GreaterThan - -- (unwrapExpression to) - -- (PostfixDecrement (Variable var)) - -- (unwrapStatement <| loop (dottedVariable1 var) internalNop) - -- (unwrapLazyStatement next) - Debug.todo "forDown" + build (\f t -> For var f GreaterThan t MinusMinus) + |> withExpression from + |> withExpression to + |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement next + |> buildStatement return : Expression r -> Statement r return e = - statement Return + build Return |> withExpression e |> buildStatement break : Statement a break = - statement Break + build Break |> buildStatement continue : Statement a continue = - statement Continue + build Continue |> buildStatement @@ -849,7 +806,7 @@ decl typeF name k = (TypedName t n) = typeF name in - statement (Decl t n Nothing) + build (Decl t n Nothing) |> withStatement (k (var n)) |> buildStatement @@ -859,6 +816,31 @@ def typeF name val k = def1 ( typeF name, val ) k +float : String -> Expression Float -> (Expression Float -> Statement r) -> Statement r +float = + def floatT + + +vec2 : String -> Expression Vec2 -> (Expression Vec2 -> Statement r) -> Statement r +vec2 = + def vec2T + + +vec3 : String -> Expression Vec3 -> (Expression Vec3 -> Statement r) -> Statement r +vec3 = + def vec3T + + +vec4 : String -> Expression Vec4 -> (Expression Vec4 -> Statement r) -> Statement r +vec4 = + def vec4T + + +mat3 : String -> Expression Mat3 -> (Expression Mat3 -> Statement r) -> Statement r +mat3 = + def mat3T + + def1 : ( TypedName a, Expression a ) -> (Expression a -> Statement r) @@ -868,7 +850,7 @@ def1 ( tn0, val0 ) k = (TypedName t0 n0) = tn0 in - statement + build (\v0 k0 -> Decl t0 n0 (Just v0) k0) |> withExpression val0 |> withStatement (k (var n0)) @@ -915,21 +897,32 @@ assignOut name e = unsafeMap2 (Comparison Assign) name e -expr : Expression t -> Statement r -> Statement r -expr = - unsafeExprStat ExpressionStatement +expr : Expression t -> (() -> Statement r) -> Statement r +expr e s = + build ExpressionStatement + |> withExpression e + |> withStatement (s ()) + |> buildStatement + + +nop : Statement () +nop = + Statement { stat = Nop, deps = SortedSet.empty } + + +unsafeNop : Statement r +unsafeNop = + Statement { stat = Nop, deps = SortedSet.empty } -assignAdd : Expression t -> Expression t -> Statement q -> Statement q -assignAdd name e next = - -- Statement <| ExpressionStatement (AssignCombo ComboAdd (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) - Debug.todo "assignAdd" +assignAdd : Expression t -> Expression t -> (() -> Statement q) -> Statement q +assignAdd name val = + expr <| unsafeMap2 (AssignCombo ComboAdd) name val -assignBy : Expression t -> Expression t -> Statement q -> Statement q -assignBy name e next = - -- Statement <| ExpressionStatement (AssignCombo ComboBy (unwrapExpression name) (unwrapExpression e)) (unwrapLazyStatement next) - Debug.todo "assignBy" +assignBy : Expression t -> Expression t -> (() -> Statement q) -> Statement q +assignBy name val = + expr <| unsafeMap2 (AssignCombo ComboBy) name val @@ -1088,52 +1081,49 @@ innerValue ctx e = ) BinaryOperation And l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) BinaryOperation Or l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) Comparison k l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) Ternary _ _ _ -> Debug.todo "branch 'Ternary _ _ _' not implemented" @@ -1145,31 +1135,29 @@ innerValue ctx e = Debug.todo "branch 'Subtract _ _' not implemented" BinaryOperation By l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) BinaryOperation Div _ _ -> Debug.todo "branch 'Div _ _' not implemented" Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) Call "exp" [ l ] -> autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index 7440789c..e3a204bb 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -2,7 +2,7 @@ module UI.Glsl.Plane exposing (Plane, asPlane, toGlsl) import Dict import Expression exposing (Expression) -import Glsl exposing (BisectSignature, float, int) +import Glsl exposing (BisectSignature, float1, int) import Glsl.Functions exposing (dot33, mix331, vec3111) import Glsl.Operations exposing (add11, add33, array33, by13, div11, gt, negate1) import Maybe @@ -40,27 +40,22 @@ asPlane e = toGlsl : String -> Plane -> BisectSignature toGlsl suffix (Plane { x, y, z, known }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - -- a x + b y + c z + k = 0 - -- x = ox + t dx - -- y = oy + t dy - -- z = oz + t dz - -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 - -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) - -- t = - (k + dot abc o) / (dot abc d) - def2 - ( vec3T "coeffs", vec3111 (float x) (float y) (float z) ) - ( vec3T "dMix", mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5) ) - <| - \coeffs dMix -> - def floatT - "t" - (div11 - (negate1 <| add11 (float known) (dot33 coeffs o)) - (dot33 coeffs dMix) - ) - <| - \t -> - expr (assignOut found <| add33 o <| by13 t dMix) <| - return (gt t <| threshold maxDistance) + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + -- a x + b y + c z + k = 0 + -- x = ox + t dx + -- y = oy + t dy + -- z = oz + t dz + -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 + -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) + -- t = - (k + dot abc o) / (dot abc d) + vec3 "coeffs" (vec3111 (float1 x) (float1 y) (float1 z)) <| \coeffs -> + vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> + def floatT + "t" + (div11 + (negate1 <| add11 (float1 known) (dot33 coeffs o)) + (dot33 coeffs dMix) + ) + <| \t -> + expr (assignOut found <| add33 o <| by13 t dMix) <| \_ -> + return (gt t <| UI.Glsl.Code.toThreshold maxDistance) diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 194f057d..2e0370fe 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -1,10 +1,10 @@ -module UI.Glsl.Polynomial exposing (asPolynomial, getDegree, getSolutions, glslFromPolySolutions, glslFromSolutions) +module UI.Glsl.Polynomial exposing (asPolynomial, getDegree, glslFromPolySolutions, glslFromSolutions) import Dict exposing (Dict) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), RelationOperation(..), UnaryOperation(..)) import Expression.Polynomial exposing (Exponents) import Expression.Utils -import Glsl exposing (BisectSignature, Stat(..), Statement, Vec3, dot2X, dot2Y, dot3X, dot3Y, dot3Z, float, int) +import Glsl exposing (BisectSignature, Statement, Vec3, dot2X, dot2Y, dot3X, dot3Y, dot3Z, float1, int) import Glsl.Functions exposing (abs1, cby22, cdiv22, csqrt2, min11, mix331) import Glsl.Operations exposing (add22, add33, array33, by11, by12, by13, gt, lt, negate2, subtract22) import Maybe.Extra as Maybe @@ -67,123 +67,119 @@ toFloat e = Nothing -getSolutions : - Glsl.Expression Float - -> Dict Int Expression - -> - Maybe - ( Int - , { t : Glsl.Expression Float - , o : Glsl.Expression Vec3 - , dMix : Glsl.Expression Vec3 - } - -> Statement r - -> Statement r - ) -getSolutions maxDistance poly = - let - deg = - poly - |> Dict.keys - |> List.maximum - |> Maybe.withDefault 0 - - get { dMix, o } degree = - Dict.get degree poly - |> Maybe.withDefault Expression.Utils.zero - |> UI.Glsl.Code.expressionToGlsl - [ ( "dx", dot3X dMix ) - , ( "dy", dot3Y dMix ) - , ( "dz", dot3Z dMix ) - , ( "o.x", dot3X o ) - , ( "o.y", dot3Y o ) - , ( "o.z", dot3Z o ) - ] - - -- tFrom : Glsl.Expression Vec2 -> Glsl.Statement r -> Glsl.Statement r - tFrom { t } v = - expr - (assign t - (ternary - (or - (lt (dot2X v) (float 0)) - (gt (abs1 <| dot2Y v) (threshold maxDistance)) - ) - t - (min11 (dot2X v) t) - ) - ) - - sols = - case deg of - 1 -> - Just <| - \vars cont -> - -- ax + b = 0 - -- x = -b / a - def vec2T "a" (get vars 1) <| - \a -> - def vec2T "b" (get vars 0) <| - \b -> - def vec2T "x" (cdiv22 (negate2 b) a) <| - \x -> - tFrom vars x cont - - 2 -> - Just <| - \vars cont -> - -- ax² + bx + c = 0 - def3 - ( vec2T "a", get vars 2 ) - ( vec2T "b", get vars 1 ) - ( vec2T "c", get vars 1 ) - <| - \a b c -> - def vec2T "delta" (subtract22 (cby22 b b) (by12 (float 4.0) (cby22 a c))) <| - \delta -> - def2 - ( vec2T "sqdelta", csqrt2 delta ) - ( vec2T "den", by12 (float 2.0) a ) - <| - \sqdelta den -> - def vec2T "pos" (cdiv22 (add22 (negate2 b) sqdelta) den) <| - \pos -> - tFrom vars pos <| - def vec2T "neg" (cdiv22 (add22 (negate2 b) (negate2 sqdelta)) den) <| - \neg -> - tFrom vars neg cont - - {- 3 -> - [ ( "!dx", "mix(d[0].x, d[1].x, 0.5)" ) - , ( "!dy", "mix(d[0].y, d[1].y, 0.5)" ) - , ( "!dz", "mix(d[0].z, d[1].z, 0.5)" ) - , ( "a", get 3 ) - , ( "b", get 2 ) - , ( "c", get 1 ) - , ( "dd", get 0 ) - , ( "deltaZero", "cby(b,b) - 3.0 * cby(a,c)" ) - , ( "deltaOne", "2.0 * cby(b,b,b) - 9.0 * cby(a,b,c) + 27.0 * cby(a,a, dd)" ) - , ( "inner", "csqrt(cby(deltaOne,deltaOne) - 4.0 * cby(deltaZero,deltaZero,deltaZero))" ) - , ( "CargPlus", "deltaOne + inner" ) - , ( "CargMinus", "deltaOne - inner" ) - , ( "Carg", "length(CargMinus) > length(CargPlus) ? CargMinus : CargPlus" ) - , ( "C", "ccbrt(0.5 * Carg)" ) - , ( "coeff", "-cdiv(vec2(1,0), 3.0 * a)" ) - , ( "xi", "0.5 * vec2(-1,sqrt(3.0))" ) - , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) - , tFrom "x" - , ( "C", "cby(xi,C)" ) - , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) - , tFrom "x" - , ( "C", "cby(xi,C)" ) - , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) - , tFrom "x" - ] - -} - _ -> - Nothing - in - Maybe.map (Tuple.pair deg) sols + +-- getSolutions : +-- Glsl.Expression Float +-- -> Dict Int Expression +-- -> +-- Maybe +-- ( Int +-- , { t : Glsl.Expression Float +-- , o : Glsl.Expression Vec3 +-- , dMix : Glsl.Expression Vec3 +-- } +-- -> Statement r +-- -> Statement r +-- ) +-- getSolutions maxDistance poly = +-- let +-- deg = +-- poly +-- |> Dict.keys +-- |> List.maximum +-- |> Maybe.withDefault 0 +-- get { dMix, o } degree = +-- Dict.get degree poly +-- |> Maybe.withDefault Expression.Utils.zero +-- |> UI.Glsl.Code.expressionToGlsl +-- -- [ ( "dx", dot3X dMix ) +-- -- , ( "dy", dot3Y dMix ) +-- -- , ( "dz", dot3Z dMix ) +-- -- , ( "o.x", dot3X o ) +-- -- , ( "o.y", dot3Y o ) +-- -- , ( "o.z", dot3Z o ) +-- -- ] +-- -- tFrom : Glsl.Expression Vec2 -> Glsl.Statement r -> Glsl.Statement r +-- tFrom { t } v = +-- expr +-- (assign t +-- (ternary +-- (or +-- (lt (dot2X v) zero) +-- (gt (abs1 <| dot2Y v) (threshold maxDistance)) +-- ) +-- t +-- (min11 (dot2X v) t) +-- ) +-- ) +-- sols = +-- case deg of +-- 1 -> +-- Just <| +-- \vars cont -> +-- -- ax + b = 0 +-- -- x = -b / a +-- def vec2T "a" (get vars 1) <| +-- \a -> +-- def vec2T "b" (get vars 0) <| +-- \b -> +-- def vec2T "x" (cdiv22 (negate2 b) a) <| +-- \x -> +-- tFrom vars x cont +-- 2 -> +-- Just <| +-- \vars cont -> +-- -- ax² + bx + c = 0 +-- def3 +-- ( vec2T "a", get vars 2 ) +-- ( vec2T "b", get vars 1 ) +-- ( vec2T "c", get vars 1 ) +-- <| +-- \a b c -> +-- def vec2T "delta" (subtract22 (cby22 b b) (by12 (float 4.0) (cby22 a c))) <| +-- \delta -> +-- def2 +-- ( vec2T "sqdelta", csqrt2 delta ) +-- ( vec2T "den", by12 (float 2.0) a ) +-- <| +-- \sqdelta den -> +-- def vec2T "pos" (cdiv22 (add22 (negate2 b) sqdelta) den) <| +-- \pos -> +-- tFrom vars pos <| +-- def vec2T "neg" (cdiv22 (add22 (negate2 b) (negate2 sqdelta)) den) <| +-- \neg -> +-- tFrom vars neg cont +-- {- 3 -> +-- [ ( "!dx", "mix(d[0].x, d[1].x, 0.5)" ) +-- , ( "!dy", "mix(d[0].y, d[1].y, 0.5)" ) +-- , ( "!dz", "mix(d[0].z, d[1].z, 0.5)" ) +-- , ( "a", get 3 ) +-- , ( "b", get 2 ) +-- , ( "c", get 1 ) +-- , ( "dd", get 0 ) +-- , ( "deltaZero", "cby(b,b) - 3.0 * cby(a,c)" ) +-- , ( "deltaOne", "2.0 * cby(b,b,b) - 9.0 * cby(a,b,c) + 27.0 * cby(a,a, dd)" ) +-- , ( "inner", "csqrt(cby(deltaOne,deltaOne) - 4.0 * cby(deltaZero,deltaZero,deltaZero))" ) +-- , ( "CargPlus", "deltaOne + inner" ) +-- , ( "CargMinus", "deltaOne - inner" ) +-- , ( "Carg", "length(CargMinus) > length(CargPlus) ? CargMinus : CargPlus" ) +-- , ( "C", "ccbrt(0.5 * Carg)" ) +-- , ( "coeff", "-cdiv(vec2(1,0), 3.0 * a)" ) +-- , ( "xi", "0.5 * vec2(-1,sqrt(3.0))" ) +-- , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) +-- , tFrom "x" +-- , ( "C", "cby(xi,C)" ) +-- , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) +-- , tFrom "x" +-- , ( "C", "cby(xi,C)" ) +-- , ( "x", "cby(coeff, b + C + cdiv(deltaZero, C))" ) +-- , tFrom "x" +-- ] +-- -} +-- _ -> +-- Nothing +-- in +-- Maybe.map (Tuple.pair deg) sols glslFromSolutions : @@ -193,20 +189,17 @@ glslFromSolutions : , o : Glsl.Expression Vec3 , dMix : Glsl.Expression Vec3 } - -> Statement Bool + -> (() -> Statement Bool) -> Statement Bool ) -> BisectSignature glslFromSolutions suffix sols = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - def vec3T "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5)) <| - \dMix -> - def floatT "t" (by11 maxDistance <| float 2) <| - \t -> - sols { dMix = dMix, o = o, t = t } <| - expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5))))) <| - return (ands [ lt t maxDistance, gt t zero ]) + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> + def floatT "t" (by11 maxDistance <| float1 2) <| \t -> + sols { dMix = dMix, o = o, t = t } <| \_ -> + expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5))))) <| \_ -> + return (ands [ lt t maxDistance, gt t zero ]) glslFromPolySolutions : @@ -215,4 +208,9 @@ glslFromPolySolutions : -> Dict Int Expression -> Maybe BisectSignature glslFromPolySolutions suffix maxDistance poly = - getSolutions maxDistance poly |> Maybe.map (\( _, sols ) -> glslFromSolutions suffix sols) + -- getSolutions maxDistance poly |> Maybe.map (\( _, sols ) -> glslFromSolutions suffix sols) + let + _ = + Debug.todo + in + Nothing diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 15c8b7fc..8a434f37 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -3,11 +3,11 @@ module UI.Glsl.Sphere exposing (Sphere, asSphere, toGlsl) import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) -import Glsl exposing (BisectSignature, false, float, int, true) +import Glsl exposing (BisectSignature, false, float1, int, true) import Glsl.Functions exposing (dot33, mix331, sqrt1, vec3111) import Glsl.Operations exposing (add33, array33, by11, by13, lt, negate1, subtract11, subtract33) -import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (assignOut, boolT, def, def2, expr, floatT, fun4, if_, mat3T, out, return, vec3T, zero) +import UI.Glsl.Code +import UI.Glsl.Generator exposing (assignOut, boolT, def, expr, floatT, fun4, if_, mat3T, out, return, vec3T, zero) import UI.Glsl.Polynomial as Polynomial @@ -78,29 +78,19 @@ reduce poly = toGlsl : String -> Sphere -> BisectSignature toGlsl suffix (Sphere { center, radius }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| - \o d maxDistance found -> - def2 - ( vec3T "center", vec3111 (float center.x) (float center.y) (float center.z) ) - ( vec3T "dMix", mix331 (array33 d (int 0)) (array33 d (int 1)) (float 0.5) ) - <| - \centerVar dMix -> - def vec3T "to_center" (subtract33 o centerVar) <| - \to_center -> - def2 - ( floatT "b", dot33 to_center dMix ) - ( floatT "c", subtract11 (dot33 to_center to_center) (float <| radius * radius) ) - <| - \b c -> - def floatT "delta" (subtract11 (by11 b b) c) <| - \delta -> - if_ (lt delta zero) - (return false) - <| - def floatT "x" (subtract11 (negate1 b) (sqrt1 delta)) <| - \x -> - if_ (lt x <| threshold maxDistance) - (return false) - <| - expr (assignOut found (add33 o (by13 x dMix))) <| - return true + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> + vec3 "center" (vec3111 (float1 center.x) (float1 center.y) (float1 center.z)) <| \centerVar -> + vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> + vec3 "to_center" (subtract33 o centerVar) <| \to_center -> + def floatT "b" (dot33 to_center dMix) <| \b -> + def floatT "c" (subtract11 (dot33 to_center to_center) (float1 <| radius * radius)) <| \c -> + def floatT "delta" (subtract11 (by11 b b) c) <| \delta -> + if_ (lt delta zero) + (return false) + <| \_ -> + def floatT "x" (subtract11 (negate1 b) (sqrt1 delta)) <| \x -> + if_ (lt x <| UI.Glsl.Code.toThreshold maxDistance) + (return false) + <| \_ -> + expr (assignOut found (add33 o (by13 x dMix))) <| \_ -> + return true diff --git a/src/elm/UI/RowView.elm b/src/elm/UI/RowView.elm index 1839867f..29be1ceb 100644 --- a/src/elm/UI/RowView.elm +++ b/src/elm/UI/RowView.elm @@ -506,7 +506,7 @@ outputBlock blockId size output = ) GraphValue g -> - ( draw size (CanvasId id) coeffs g, True ) + ( draw size (CanvasId id) coeffs { axes = True, graph = g }, True ) ComplexValue c -> ( text <| invariant <| Complex.toString c, False ) diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm index f8692544..6ab71af8 100644 --- a/tests/GlslFuzzer.elm +++ b/tests/GlslFuzzer.elm @@ -4,7 +4,6 @@ import Complex exposing (Complex(..)) import Dict import Expect exposing (Expectation) import Test exposing (Test) -import UI.Glsl.Code exposing (cexpFunction) import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2, GlslValue, Statement, Vec2, float, one, vec2, zero) @@ -53,10 +52,11 @@ test1 name function cases = cases |> List.map (\( input, output ) -> - Test.test (Debug.toString input) <| \_ -> - check - (Generator.interpret Dict.empty <| function input) - (Generator.value Dict.empty output.base) + Test.test (Debug.toString input) <| + \_ -> + check + (Generator.interpret Dict.empty <| function input) + (Generator.value Dict.empty output.base) ) |> Test.describe name diff --git a/yarn.lock b/yarn.lock index dca608b4..37fb1c4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,31 @@ # yarn lockfile v1 +"@avh4/elm-format-darwin-arm64@0.8.7-2": + version "0.8.7-2" + resolved "https://registry.yarnpkg.com/@avh4/elm-format-darwin-arm64/-/elm-format-darwin-arm64-0.8.7-2.tgz#7ef272e77ed22804c3d18e99cffdf8952b88cf6a" + integrity sha512-F5JD44mJ3KX960J5GkXMfh1/dtkXuPcQpX2EToHQKjLTZUfnhZ++ytQQt0gAvrJ0bzoOvhNzjNjUHDA1ruTVbg== + +"@avh4/elm-format-darwin-x64@0.8.7-2": + version "0.8.7-2" + resolved "https://registry.yarnpkg.com/@avh4/elm-format-darwin-x64/-/elm-format-darwin-x64-0.8.7-2.tgz#c43eb3af88edec45aae405fda7d703e343614965" + integrity sha512-4pfF1cl0KyTion+7Mg4XKM3yi4Yc7vP76Kt/DotLVGJOSag4ISGic1og2mt8RZZ7XArybBmHNyYkiUbe/cEiCw== + +"@avh4/elm-format-linux-arm64@0.8.7-2": + version "0.8.7-2" + resolved "https://registry.yarnpkg.com/@avh4/elm-format-linux-arm64/-/elm-format-linux-arm64-0.8.7-2.tgz#e01a088c051aa5734453f83e9f63aa572ffb7439" + integrity sha512-WkVmuce2zU6s9dupHhqPc886Vaqpea8dZlxv2fpZ4wSzPUbiiKHoHZzoVndMIMTUL0TZukP3Ps0n/lWO5R5+FA== + +"@avh4/elm-format-linux-x64@0.8.7-2": + version "0.8.7-2" + resolved "https://registry.yarnpkg.com/@avh4/elm-format-linux-x64/-/elm-format-linux-x64-0.8.7-2.tgz#50f60f3bfb11223d9e72a34a0cc28640726f5bae" + integrity sha512-kmncfJrTBjVT94JtQvMf4M5Pn2Yl0sZt3wo7AzgFiDnB/CiZ+KjJyXuWM64NeGiv4MQqzPq65tsFXUH1CIJeiQ== + +"@avh4/elm-format-win32-x64@0.8.7-2": + version "0.8.7-2" + resolved "https://registry.yarnpkg.com/@avh4/elm-format-win32-x64/-/elm-format-win32-x64-0.8.7-2.tgz#4a4e7489a7b519a810a8a89798c4aab3805626ab" + integrity sha512-sBdMBGq/8mD8Y5C+fIr5vlb3N50yB7S1MfgeAq2QEbvkr/sKrCZI540i43lZDH9gWsfA1w2W8wCe0penFYzsGw== + "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" @@ -290,6 +315,17 @@ elm-codegen@^0.5.3: commander "^8.3.0" node-elm-compiler "^5.0.6" +elm-format@^0.8.7: + version "0.8.7" + resolved "https://registry.yarnpkg.com/elm-format/-/elm-format-0.8.7.tgz#23d8a320ef896400b01b26609f99f579b2ed2d84" + integrity sha512-sVzFXfWnb+6rzXK+q3e3Ccgr6/uS5mFbFk1VSmigC+x2XZ28QycAa7lS8owl009ALPhRQk+pZ95Eq5ANjpEZsQ== + optionalDependencies: + "@avh4/elm-format-darwin-arm64" "0.8.7-2" + "@avh4/elm-format-darwin-x64" "0.8.7-2" + "@avh4/elm-format-linux-arm64" "0.8.7-2" + "@avh4/elm-format-linux-x64" "0.8.7-2" + "@avh4/elm-format-win32-x64" "0.8.7-2" + elm-optimize-level-2@^0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/elm-optimize-level-2/-/elm-optimize-level-2-0.3.5.tgz#a0ac9b825d9ff68be50ed1b819780f88693a872a" From ee3c034fd461a90b2d0c9ef9bfc16eeb8638de7a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 29 Apr 2024 14:49:57 +0200 Subject: [PATCH 110/139] Moving glsl to vendored folder --- elm.json | 3 +- src/elm/UI/Glsl/Code.elm | 33 ++++++------------- .../miniBill/elm-glsl-dsl/1.0.0/src}/Glsl.elm | 0 .../1.0.0/src}/Glsl/Generator.elm | 14 +++----- 4 files changed, 16 insertions(+), 34 deletions(-) rename {codegen/helpers => vendored/miniBill/elm-glsl-dsl/1.0.0/src}/Glsl.elm (100%) rename {src/elm/UI => vendored/miniBill/elm-glsl-dsl/1.0.0/src}/Glsl/Generator.elm (97%) diff --git a/elm.json b/elm.json index a2373be6..7b772d3c 100644 --- a/elm.json +++ b/elm.json @@ -4,7 +4,8 @@ "src/elm", "src/elm-extra", "generated", - "codegen/helpers" + "codegen/helpers", + "vendored/miniBill/elm-glsl-dsl/1.0.0/src" ], "elm-version": "0.19.1", "dependencies": { diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 7a791e6e..a099466d 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -3,9 +3,9 @@ module UI.Glsl.Code exposing (expressionToGlsl, expressionToGlslComplex, mainGls import Expression exposing (Function1(..), Function2(..), Function3(..), RelationOperation(..), TGApply(..), ToGlslExpression(..)) import Glsl exposing (Expr, Expression, Vec2, Vec3, Vec4, dot2X, dot2Y, dot4XY, float1, unsafeCall0, unsafeTypecast, var) import Glsl.Functions exposing (abs2, abs3, abs4, axis111, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, ccbrt2, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cos1, cpow22, cpw222, cre2, cross33, cround2, csign2, csin2, csinh2, csqrt2, ctan2, ctanh2, dup1, exp1, fwidth3, gby44, gdiv44, gneg4, gnum1, gpow41, gpow44, gsquare4, hl2rgb11, iabs2, iacos2, iarg2, iasin2, iatan2, iby22, icbrt2, iceil2, icos2, icosh2, idiv22, ieq22, iexp2, iexpand2, ifloor2, igeq22, igt22, iim2, ileq22, iln2, ilog102, ilt22, ineg2, ineq22, ipow21, ipow22, ire2, iround2, isign2, isin2, isinh2, isqrt2, isquare2, itan2, itanh2, mat3333, max11, max33, max44, normalize3, pow11, radians1, sin1, u_canvasHeight, u_canvasWidth, u_drawAxes, u_phi, u_theta, u_viewportWidth, u_zoomCenter, vec211, vec3111, vec41111, vec431) +import Glsl.Generator as Generator exposing (adds3, assign, decl, def, expr, float, fun0, gl_FragColor, gl_FragCoord, main_, mat3, one, return, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4T, vec4Zero, zero) import Glsl.Operations exposing (add11, add22, add33, add44, by11, by12, by13, by22, by31, by33, div11, div22, eq, lt, negate1, negate2, subtract11, subtract22, subtract33, subtract44) import Glsl.PrettyPrinter -import UI.Glsl.Generator as Generator exposing (adds3, assign, decl, def, expr, float, floatT, fun0, gl_FragColor, gl_FragCoord, main_, mat3, nop, one, return, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4T, vec4Zero, voidT, zero) expressionToGlslComplex : ToGlslExpression -> Glsl.Expression Vec2 @@ -612,19 +612,6 @@ toSrcParametric expandIntervals suffix e = "" -thetaDelta : String -thetaDelta = - """ - float thetaDelta(float theta) { - if(u_whiteLines < 1.0) - return 100.0; - float thetaSix = theta * u_whiteLines + 0.5; - float thetaNeigh = 0.05; - return abs(fract(thetaSix) - 0.5) / thetaNeigh; - } - """ - - toSrcVectorField2D : String -> Expression.Expression -> Expression.Expression -> String toSrcVectorField2D suffix x y = -- """ @@ -766,22 +753,22 @@ mainGlsl : mainGlsl rayDifferentials pixel2 pixel3 = (case ( pixel2, pixel3 ) of ( [], [] ) -> - main_ vec4Zero + vec4Zero ( _ :: _, [] ) -> - main_ (main2D pixel2) + main2D pixel2 ( [], _ :: _ ) -> - main_ (main3D rayDifferentials pixel3) + main3D rayDifferentials pixel3 ( _ :: _, _ :: _ ) -> - main_ - (max44 - (main2D pixel2) - (main3D rayDifferentials pixel3) - ) + max44 + (main2D pixel2) + (main3D rayDifferentials pixel3) ) - |> Generator.fileToGlsl + |> assign gl_FragColor + |> main_ + |> Generator.toGlsl main2D : diff --git a/codegen/helpers/Glsl.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm similarity index 100% rename from codegen/helpers/Glsl.elm rename to vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm diff --git a/src/elm/UI/Glsl/Generator.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm similarity index 97% rename from src/elm/UI/Glsl/Generator.elm rename to vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm index e4c77907..4b16d6f3 100644 --- a/src/elm/UI/Glsl/Generator.elm +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm @@ -1,4 +1,4 @@ -module UI.Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) +module Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) import Dict exposing (Dict) import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, false, float1, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var, withExpression, withStatement) @@ -601,15 +601,9 @@ funX call typeF name body args = ) -main_ : Expression Vec4 -> List FunDecl -main_ e = - let - _ = - fun0 voidT "main" <| \_ -> - expr (assign gl_FragColor e) <| \_ -> - nop - in - Debug.todo "Generator.main_" +main_ : (Statement () -> Statement ()) -> Expression () +main_ stat = + fun0 voidT "main" <| \_ -> stat nop fun0 : From 4d6958a13083c123a48698027c74294aeb7b0d39 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Feb 2025 23:13:17 +0100 Subject: [PATCH 111/139] Add web worker lib --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 94fc39d7..f5933879 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,6 @@ "sourceMap": true, "allowSyntheticDefaultImports": true, "moduleResolution": "node", - "lib": ["ES2017","DOM"] + "lib": ["ES2017", "DOM", "WebWorker"] } -} \ No newline at end of file +} From 9365901478b80cab28a649eaa16c1e47c4fba293 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Feb 2025 23:14:21 +0100 Subject: [PATCH 112/139] Updated dependencies --- package.json | 8 ++++---- yarn.lock | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 03630b15..90ad4b0a 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,12 @@ ] }, "devDependencies": { - "elm-codegen": "^0.5.3", + "elm-codegen": "^0.6.1", "elm-format": "^0.8.7", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.11.1", - "elm-watch": "^2.0.0-beta.2", - "typescript": "^5.4.4" + "elm-review": "^2.13.1", + "elm-watch": "^2.0.0-beta.6", + "typescript": "^5.7.3" }, "scripts": { "build": "make build", diff --git a/yarn.lock b/yarn.lock index 37fb1c4e..20bbbf05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -305,10 +305,10 @@ diff-sequences@^27.5.1: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== -elm-codegen@^0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/elm-codegen/-/elm-codegen-0.5.3.tgz#28ab430fe6addd7e3938a346d4d0c3bfd8ca4917" - integrity sha512-LKscQHnDeNGQsvaoDXq1nxlm9XlsWaIQCUiqBgJjXk/gPU6PtcXVC0ji1ytmmSW+/N0zb+DWegSbPPYGeV4eew== +elm-codegen@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/elm-codegen/-/elm-codegen-0.6.1.tgz#396bb401e05a0ea911ea289d688f247daa43b60a" + integrity sha512-mbVmK4fqW+wtYzTZhJSuT42KrQZMRTueYerCvo09sO5v7QdDGw3qeG/rL1vLH0q2GJF44lXhyBo4lv6azSBOQQ== dependencies: chalk "^4.1.1" chokidar "^3.5.1" @@ -338,7 +338,7 @@ elm-optimize-level-2@^0.3.5: ts-union "^2.2.1" typescript "^4.5.5" -elm-review@^2.11.1: +elm-review@^2.13.1: version "2.13.1" resolved "https://registry.yarnpkg.com/elm-review/-/elm-review-2.13.1.tgz#33064b3a2baf2af8d20fb7e9a382fd6240c585a2" integrity sha512-okkw5Mfmjkjy2ZggFyWfz5bpcd81fsQXGyNIDgZRFBU2vXao+xdt5/AN6L1tt6KWgjSyBJD94RXeyd5e3AhPKw== @@ -367,7 +367,7 @@ elm-review@^2.11.1: resolved "https://registry.yarnpkg.com/elm-solve-deps-wasm/-/elm-solve-deps-wasm-2.0.0.tgz#8214705876fbcd9789cf6ab2db45ec781b5c1234" integrity sha512-11OV8FgB9qsth/F94q2SJjb1MoEgbworSyNM1L+YlxVoaxp7wtWPyA8cNcPEkSoIKG1B8Tqg68ED1P6dVamHSg== -elm-watch@^2.0.0-beta.2: +elm-watch@^2.0.0-beta.6: version "2.0.0-beta.6" resolved "https://registry.yarnpkg.com/elm-watch/-/elm-watch-2.0.0-beta.6.tgz#33b31856de19276690715c3f8a495f1e312630d2" integrity sha512-pb3qZVfoBMEWsfrP4mN760z85n5XC0cXg1JRR4ojAVZVjFMeDczYojLaKDQgP+qNeMAK52xj7s31+bCevT+X2Q== @@ -1020,7 +1020,7 @@ typescript@^4.5.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== -typescript@^5.4.4: +typescript@^5.7.3: version "5.7.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e" integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== From 367fea423cbba862cebeacd4d65c60db73b6546f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Thu, 20 Feb 2025 23:28:36 +0100 Subject: [PATCH 113/139] Cleanup Sphere --- src/elm/UI/Glsl/Sphere.elm | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index 8a434f37..f7b8f853 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -3,11 +3,12 @@ module UI.Glsl.Sphere exposing (Sphere, asSphere, toGlsl) import Dict exposing (Dict) import Expression exposing (Expression) import Expression.Polynomial exposing (Exponents) -import Glsl exposing (BisectSignature, false, float1, int, true) +import Glsl exposing (BisectSignature, false, float1, int1, true) import Glsl.Functions exposing (dot33, mix331, sqrt1, vec3111) +import Glsl.Generator exposing (assignOut, boolT, expr, float, floatT, fun4, if_, mat3T, out, return, vec3, vec3T, zero) import Glsl.Operations exposing (add33, array33, by11, by13, lt, negate1, subtract11, subtract33) +import Maybe.Extra import UI.Glsl.Code -import UI.Glsl.Generator exposing (assignOut, boolT, def, expr, floatT, fun4, if_, mat3T, out, return, vec3T, zero) import UI.Glsl.Polynomial as Polynomial @@ -34,6 +35,7 @@ asSphere e = -- k = a² + b² + c² - r² -- r² = a²+b²+c²-k let + getCenter : String -> Maybe Float getCenter v = case ( Dict.get [ ( v, 2 ) ] poly, Maybe.withDefault 0 <| Dict.get [ ( v, 1 ) ] poly ) of ( Just s, l ) -> @@ -46,21 +48,33 @@ asSphere e = _ -> Nothing in - Maybe.map3 + Maybe.Extra.andThen3 (\x y z -> - Sphere + let + rSquared : Float + rSquared = + x * x + y * y + z * z - Maybe.withDefault 0 (Dict.get [] poly) + in + if rSquared >= 0 then { center = { x = x , y = y , z = z } - , radius = sqrt <| max 0 <| x * x + y * y + z * z - Maybe.withDefault 0 (Dict.get [] poly) + , radius = sqrt rSquared } + |> Sphere + |> Just + + else + Nothing ) (getCenter "x") (getCenter "y") (getCenter "z") ) + -- TODO: fix + |> always Nothing reduce : Dict Exponents Float -> Maybe (Dict Exponents Float) @@ -80,15 +94,15 @@ toGlsl : String -> Sphere -> BisectSignature toGlsl suffix (Sphere { center, radius }) = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> vec3 "center" (vec3111 (float1 center.x) (float1 center.y) (float1 center.z)) <| \centerVar -> - vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> + vec3 "dMix" (mix331 (array33 d (int1 0)) (array33 d (int1 1)) (float1 0.5)) <| \dMix -> vec3 "to_center" (subtract33 o centerVar) <| \to_center -> - def floatT "b" (dot33 to_center dMix) <| \b -> - def floatT "c" (subtract11 (dot33 to_center to_center) (float1 <| radius * radius)) <| \c -> - def floatT "delta" (subtract11 (by11 b b) c) <| \delta -> + float "b" (dot33 to_center dMix) <| \b -> + float "c" (subtract11 (dot33 to_center to_center) (float1 <| radius * radius)) <| \c -> + float "delta" (subtract11 (by11 b b) c) <| \delta -> if_ (lt delta zero) (return false) <| \_ -> - def floatT "x" (subtract11 (negate1 b) (sqrt1 delta)) <| \x -> + float "x" (subtract11 (negate1 b) (sqrt1 delta)) <| \x -> if_ (lt x <| UI.Glsl.Code.toThreshold maxDistance) (return false) <| \_ -> From 93e3b485ea4e8c1571b1d2611fd66ac85a804fa5 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 11:29:32 +0200 Subject: [PATCH 114/139] Update packages --- package.json | 5 +-- yarn.lock | 96 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 90ad4b0a..ff2d5e03 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,10 @@ "elm-codegen": "^0.6.1", "elm-format": "^0.8.7", "elm-optimize-level-2": "^0.3.5", - "elm-review": "^2.13.1", + "elm-review": "^2.13.2", + "elm-test-rs": "^3.0.0-5", "elm-watch": "^2.0.0-beta.6", - "typescript": "^5.7.3" + "typescript": "^5.8.3" }, "scripts": { "build": "make build", diff --git a/yarn.lock b/yarn.lock index 20bbbf05..8405ea62 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,6 +27,36 @@ resolved "https://registry.yarnpkg.com/@avh4/elm-format-win32-x64/-/elm-format-win32-x64-0.8.7-2.tgz#4a4e7489a7b519a810a8a89798c4aab3805626ab" integrity sha512-sBdMBGq/8mD8Y5C+fIr5vlb3N50yB7S1MfgeAq2QEbvkr/sKrCZI540i43lZDH9gWsfA1w2W8wCe0penFYzsGw== +"@mattpiz/elm-test-rs-darwin-arm64@3.0.0-1": + version "3.0.0-1" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-darwin-arm64/-/elm-test-rs-darwin-arm64-3.0.0-1.tgz#fe2abeb2b472b76242b0e8b69b5d5a18e97f20d1" + integrity sha512-+8pzcj2CK8NUElWvI4NUwCtn1doLk05NjFRXS9nUluGzgoImy9wwQPLtla5DWgdYOL70UufkwfxJN+0qaQMEpg== + +"@mattpiz/elm-test-rs-darwin-x64@3.0.0-0": + version "3.0.0-0" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-darwin-x64/-/elm-test-rs-darwin-x64-3.0.0-0.tgz#26b0cc9c9543b58a7f03bac958ba2652e8f540a3" + integrity sha512-PfUELK7y9UpeZnvKeJBSPbuCbb1I3T0ptZUOnjVIWvAQmg3iov6I79PD2OEP9NtP0iepj+2v2BtgbmZlVrXIZg== + +"@mattpiz/elm-test-rs-linux-arm64@3.0.0-0": + version "3.0.0-0" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-linux-arm64/-/elm-test-rs-linux-arm64-3.0.0-0.tgz#f3e95983a4cb405d3b09c29ae8b668dc02413864" + integrity sha512-BdfQDWtVUFM1NMPa5U5lBKT3gtDSP7KpypdK+R0jRBx51382t5VA5Byb+2Nzc7aXgS6LA1/nvNRtq/jO7Aj2uw== + +"@mattpiz/elm-test-rs-linux-arm@3.0.0-0": + version "3.0.0-0" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-linux-arm/-/elm-test-rs-linux-arm-3.0.0-0.tgz#9ed4ee3eebb280cd90761738d06bfb4017e23d66" + integrity sha512-VVFq5horhAldLLmz/P2ljLArJkZuuzpjIUVo9KIPA15euesAxM0lzUnj5Bag9kbjZz4T6/YKToXnaxdDdwcitg== + +"@mattpiz/elm-test-rs-linux-x64@3.0.0-0": + version "3.0.0-0" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-linux-x64/-/elm-test-rs-linux-x64-3.0.0-0.tgz#ccaee2191358fe9b5daad6ffcf0d58c3e01092dd" + integrity sha512-RfOs3KEyPn0yEHjMjka3R99SdR/TtjgnjSsYahLL1mVUaWOHEcdr86iU6CpWScVtY2jMNQLaeudXOcBm6lXIsQ== + +"@mattpiz/elm-test-rs-win32-x64@3.0.0-0": + version "3.0.0-0" + resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-win32-x64/-/elm-test-rs-win32-x64-3.0.0-0.tgz#77f5d2adfe9a0dc864d6adfc229b44b2eb613c2a" + integrity sha512-7Vr74820XFPwUNrpZVybStPlCTyAjthgnUel23j3fJB2yDm9ydbBSPvLCmngqzkZBAnpX8eruUqDphTx+mR28Q== + "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" @@ -70,11 +100,11 @@ "@types/node" "*" "@types/node@*": - version "22.13.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.4.tgz#3fe454d77cd4a2d73c214008b3e331bfaaf5038a" - integrity sha512-ywP2X0DYtX3y08eFVx5fNIw7/uIv8hYUKgXoK8oayJlLnKcRfEYCxWMVE1XagUdVtCJlZT1AU4LXEABW+L1Peg== + version "22.14.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.14.1.tgz#53b54585cec81c21eee3697521e31312d6ca1e6f" + integrity sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw== dependencies: - undici-types "~6.20.0" + undici-types "~6.21.0" "@types/responselike@^1.0.0": version "1.0.3" @@ -338,10 +368,10 @@ elm-optimize-level-2@^0.3.5: ts-union "^2.2.1" typescript "^4.5.5" -elm-review@^2.13.1: - version "2.13.1" - resolved "https://registry.yarnpkg.com/elm-review/-/elm-review-2.13.1.tgz#33064b3a2baf2af8d20fb7e9a382fd6240c585a2" - integrity sha512-okkw5Mfmjkjy2ZggFyWfz5bpcd81fsQXGyNIDgZRFBU2vXao+xdt5/AN6L1tt6KWgjSyBJD94RXeyd5e3AhPKw== +elm-review@^2.13.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/elm-review/-/elm-review-2.13.2.tgz#e303bb976f6a6de70f1a3bd1f392f21eb9f34e49" + integrity sha512-kI34BQ/EN1NC4KUcdZWAGNbaxWmR80kqJQRjT1ZmC0AyZRiJqdylhANucyzhPKEz60VGAkqau5axpySWXbdPLg== dependencies: chalk "^4.0.0" chokidar "^3.5.2" @@ -367,6 +397,18 @@ elm-review@^2.13.1: resolved "https://registry.yarnpkg.com/elm-solve-deps-wasm/-/elm-solve-deps-wasm-2.0.0.tgz#8214705876fbcd9789cf6ab2db45ec781b5c1234" integrity sha512-11OV8FgB9qsth/F94q2SJjb1MoEgbworSyNM1L+YlxVoaxp7wtWPyA8cNcPEkSoIKG1B8Tqg68ED1P6dVamHSg== +elm-test-rs@^3.0.0-5: + version "3.0.0-5" + resolved "https://registry.yarnpkg.com/elm-test-rs/-/elm-test-rs-3.0.0-5.tgz#b5d300b6585cff60fcae29157d52081281b728e8" + integrity sha512-efTPM54Ly7gm6zfECCYxfueP4TOVrMudae2eturtMBAvp5rlFOkWUL+7VHAsd4AjCvMNw5h7qD+c/RqQDhAH9Q== + optionalDependencies: + "@mattpiz/elm-test-rs-darwin-arm64" "3.0.0-1" + "@mattpiz/elm-test-rs-darwin-x64" "3.0.0-0" + "@mattpiz/elm-test-rs-linux-arm" "3.0.0-0" + "@mattpiz/elm-test-rs-linux-arm64" "3.0.0-0" + "@mattpiz/elm-test-rs-linux-x64" "3.0.0-0" + "@mattpiz/elm-test-rs-win32-x64" "3.0.0-0" + elm-watch@^2.0.0-beta.6: version "2.0.0-beta.6" resolved "https://registry.yarnpkg.com/elm-watch/-/elm-watch-2.0.0-beta.6.tgz#33b31856de19276690715c3f8a495f1e312630d2" @@ -394,10 +436,10 @@ fastest-levenshtein@^1.0.16: resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== -fdir@^6.4.3: - version "6.4.3" - resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.3.tgz#011cdacf837eca9b811c89dbb902df714273db72" - integrity sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw== +fdir@^6.4.4: + version "6.4.4" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.4.tgz#1cfcf86f875a883e19a8fab53622cfe992e8d2f9" + integrity sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg== fill-range@^7.1.1: version "7.1.1" @@ -991,11 +1033,11 @@ tiny-decoders@^23.0.0: integrity sha512-gQB+za3EW9JN1ASDmrVl1a1I6Q/jzg4M75YLI9ToHCdCW4/9KvBTTNH4u3kFbg8e+/8Zn68VRF+ayuiPNqYAmg== tinyglobby@^0.2.10: - version "0.2.12" - resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.12.tgz#ac941a42e0c5773bd0b5d08f32de82e74a1a61b5" - integrity sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww== + version "0.2.13" + resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.13.tgz#a0e46515ce6cbcd65331537e57484af5a7b2ff7e" + integrity sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw== dependencies: - fdir "^6.4.3" + fdir "^6.4.4" picomatch "^4.0.2" to-regex-range@^5.0.1: @@ -1020,15 +1062,15 @@ typescript@^4.5.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== -typescript@^5.7.3: - version "5.7.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e" - integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== +typescript@^5.8.3: + version "5.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e" + integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ== -undici-types@~6.20.0: - version "6.20.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433" - integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg== +undici-types@~6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" + integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== util-deprecate@^1.0.1: version "1.0.2" @@ -1071,9 +1113,9 @@ wrappy@1: integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== ws@^8.18.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" - integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== + version "8.18.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.1.tgz#ea131d3784e1dfdff91adb0a4a116b127515e3cb" + integrity sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w== yocto-queue@^0.1.0: version "0.1.0" From 357f347dba32f295d8813159625d45f864de646c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 11:29:52 +0200 Subject: [PATCH 115/139] Format --- src/dev.html | 81 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/src/dev.html b/src/dev.html index 169d0ee8..c4e5c272 100644 --- a/src/dev.html +++ b/src/dev.html @@ -1,36 +1,49 @@ - - - - - nuPlot - - - - - - - - - - - - - - - - - -
- - - - - - - \ No newline at end of file + + + + nuPlot + + + + + + + + + + + + + + + + +
+ + + + + + From db11225fe294eb3c7cd6d174df2f884ea2d2fc2b Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 11:42:38 +0200 Subject: [PATCH 116/139] Cleaning up GLSL --- .vscode/settings.json | 3 +- src/elm/Expression.elm | 75 +++-- src/elm/UI/Glsl.elm | 2 +- src/elm/UI/Glsl/Code.elm | 3 +- tests/GlslFuzzer.elm | 54 ++-- .../elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm | 299 +++++++++++++++++ .../elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm | 304 +----------------- 7 files changed, 368 insertions(+), 372 deletions(-) create mode 100644 vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm diff --git a/.vscode/settings.json b/.vscode/settings.json index aa329955..33d4340e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "elmLS.elmFormatPath": "elm-format-hack" + "elmLS.elmFormatPath": "elm-format-hack", + "cSpell.words": ["Glsl"] } diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index ac1ea1a9..6da577dc 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -266,29 +266,28 @@ partialSubstitute var val = fullSubstitute : Dict String Expression -> Expression -> Expression fullSubstitute dict = - visit <| - \expr -> - case expr of - Replace vars e -> - Just <| - Replace (Dict.map (\_ -> Maybe.map <| fullSubstitute dict) vars) <| - let - reduced = - Dict.filter (\k _ -> not <| Dict.member k vars) dict - in - if Dict.isEmpty reduced then - e - - else - fullSubstitute dict e - - Variable string -> - Dict.get string dict - |> Maybe.withDefault expr - |> Just + visit <| \expr -> + case expr of + Replace vars e -> + Just <| + Replace (Dict.map (\_ -> Maybe.map <| fullSubstitute dict) vars) <| + let + reduced = + Dict.filter (\k _ -> not <| Dict.member k vars) dict + in + if Dict.isEmpty reduced then + e - _ -> - Nothing + else + fullSubstitute dict e + + Variable string -> + Dict.get string dict + |> Maybe.withDefault expr + |> Just + + _ -> + Nothing equals : Expression -> Expression -> Bool @@ -1184,17 +1183,16 @@ functionNameToString name = pfullSubstitute : Dict String (Maybe ToGlslExpression) -> ToGlslExpression -> ToGlslExpression pfullSubstitute dict = - pvisit <| - \expr -> - case expr of - TGVariable string -> - Dict.get string dict - |> Maybe.andThen identity - |> Maybe.withDefault expr - |> Just + pvisit <| \expr -> + case expr of + TGVariable string -> + Dict.get string dict + |> Maybe.andThen identity + |> Maybe.withDefault expr + |> Just - _ -> - Nothing + _ -> + Nothing toTeXString : Expression -> String @@ -1334,14 +1332,13 @@ asMatrixPrint = asMatrix : Expression -> Maybe (List (List Expression)) asMatrix = - genericAsMatrix <| - \e -> - case e of - List es -> - Just es + genericAsMatrix <| \e -> + case e of + List es -> + Just es - _ -> - Nothing + _ -> + Nothing genericAsMatrix : (a -> Maybe (List a)) -> a -> Maybe (List (List a)) diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index 1a38dad0..a12c43c7 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -6,9 +6,9 @@ import Expression.Graph exposing (Graph(..)) import Expression.Polynomial exposing (asPolynomial) import Expression.Utils exposing (by, minus, plus) import Glsl exposing (BisectSignature, ExprWithDeps) +import Glsl.Generator as Generator import Maybe.Extra as Maybe import UI.Glsl.Code exposing (mainGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) -import UI.Glsl.Generator as Generator exposing (expr) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index a099466d..043148bc 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -767,8 +767,9 @@ mainGlsl rayDifferentials pixel2 pixel3 = (main3D rayDifferentials pixel3) ) |> assign gl_FragColor + |> expr |> main_ - |> Generator.toGlsl + |> Generator.fileToGlsl main2D : diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm index 6ab71af8..3303097f 100644 --- a/tests/GlslFuzzer.elm +++ b/tests/GlslFuzzer.elm @@ -3,64 +3,64 @@ module GlslFuzzer exposing (suite) import Complex exposing (Complex(..)) import Dict import Expect exposing (Expectation) +import Glsl exposing (Expression, Vec2, float1) +import Glsl.Eval exposing (Context, Error, Value) +import Glsl.Functions exposing (cexp2, vec211) +import Glsl.Generator exposing (one, zero) import Test exposing (Test) -import UI.Glsl.Generator as Generator exposing (Context, ErrorValue, Expression2, GlslValue, Statement, Vec2, float, one, vec2, zero) suite : Test suite = Test.describe "Glsl" - [ Test.test "NOP" <| \_ -> Expect.true "True" True - - -- test1 "cexp" - -- cexpFunction - -- [ ( zeroC, oneC ) - -- , ( oneC, real e ) - -- , ( real 2, real <| e * e ) - -- , ( real -1, real <| 1 / e ) - -- , ( complex Complex.i, complex <| Complex.exp Complex.i ) - -- ] + [ test1 "cexp" + cexp2 + [ ( zeroC, oneC ) + , ( oneC, real e ) + , ( real 2, real <| e * e ) + , ( real -1, real <| 1 / e ) + , ( complex Complex.i, complex <| Complex.exp Complex.i ) + ] ] -complex : Complex -> Expression2 +complex : Complex -> Expression Vec2 complex (Complex r i) = - vec2 (float r) (float i) + vec211 (float1 r) (float1 i) -real : Float -> Expression2 +real : Float -> Expression Vec2 real r = - vec2 (float r) zero + vec211 (float1 r) zero -oneC : Expression2 +oneC : Expression Vec2 oneC = - vec2 one zero + vec211 one zero -zeroC : Expression2 +zeroC : Expression Vec2 zeroC = - vec2 zero zero + vec211 zero zero test1 : String - -> (Expression2 -> Statement Vec2) - -> List ( Expression2, Expression2 ) + -> (Expression Vec2 -> Expression Vec2) + -> List ( Expression Vec2, Expression Vec2 ) -> Test test1 name function cases = cases |> List.map (\( input, output ) -> - Test.test (Debug.toString input) <| - \_ -> - check - (Generator.interpret Dict.empty <| function input) - (Generator.value Dict.empty output.base) + Test.test (Debug.toString input) <| \_ -> + check + (Glsl.Eval.value Dict.empty <| function input) + (Glsl.Eval.value Dict.empty output) ) |> Test.describe name -check : Result ErrorValue ( Context, GlslValue ) -> Result ErrorValue ( Context, GlslValue ) -> Expectation +check : Result Error ( Context, Value ) -> Result Error ( Context, Value ) -> Expectation check actual expected = Expect.equal expected actual diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm new file mode 100644 index 00000000..6e74d554 --- /dev/null +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm @@ -0,0 +1,299 @@ +module Glsl.Eval exposing (Context, Error(..), Value(..), innerInterpret, innerValue, innerValue2, interpret, value) + +import Dict exposing (Dict) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), RelationOperation(..), Stat(..), Statement(..), UnaryOperation(..)) + + +type Value + = VFloat Float + | VBool Bool + | VInt Int + | VVec2 Float Float + | VVec3 Float Float Float + | VMat3 ( Float, Float, Float ) ( Float, Float, Float ) ( Float, Float, Float ) + | VVoid -- Used for void return + + +type alias Context = + Dict String Value + + +type Error + = MissingVariable String + | InvalidTypes String + + +value : Context -> Expression t -> Result Error ( Context, Value ) +value initialContext (Expression input) = + innerValue initialContext input.expr + + +innerValue : Context -> Expr -> Result Error ( Context, Value ) +innerValue ctx e = + case e of + Float f -> + Ok ( ctx, VFloat f ) + + Bool b -> + Ok ( ctx, VBool b ) + + Int i -> + Ok ( ctx, VInt i ) + + Variable v -> + case Dict.get v ctx of + Just f -> + Ok ( ctx, f ) + + Nothing -> + Err <| MissingVariable v + + UnaryOperation Negate c -> + innerValue ctx c + |> Result.andThen + (\( ctx2, vc ) -> + case vc of + VFloat fc -> + Ok ( ctx2, VFloat <| negate fc ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `-` for " ++ valueToString vc) + ) + + BinaryOperation And l r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + BinaryOperation Or l r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Comparison k l r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) + + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) + + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) + + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) + + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) + + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + + Ternary _ _ _ -> + Debug.todo "branch 'Ternary _ _ _' not implemented" + + BinaryOperation Add _ _ -> + Debug.todo "branch 'Add _ _' not implemented" + + BinaryOperation Subtract _ _ -> + Debug.todo "branch 'Subtract _ _' not implemented" + + BinaryOperation By l r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + BinaryOperation Div _ _ -> + Debug.todo "branch 'Div _ _' not implemented" + + Call "vec2" [ l, r ] -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Call "exp" [ l ] -> + autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l + + Call "cos" [ l ] -> + autovectorizingFloatOp ctx "cos" Basics.cos l + + Call "sin" [ l ] -> + autovectorizingFloatOp ctx "sin" Basics.sin l + + Call name args -> + Debug.todo <| "branch 'Call \"" ++ name ++ "\" [" ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) ++ " ]' not implemented" + + Dot _ _ -> + Debug.todo "branch 'Dot _ _' not implemented" + + Array _ _ -> + Debug.todo "branch 'Array _ _' not implemented" + + AssignCombo _ _ _ -> + Debug.todo "branch 'AssignCombo _ _' not implemented" + + PostfixIncrement _ -> + Debug.todo "branch 'PostfixIncrement _' not implemented" + + PostfixDecrement _ -> + Debug.todo "branch 'PostfixDecrement _' not implemented" + + +innerValue2 : + Context + -> Expr + -> Expr + -> (Context -> Value -> Value -> Result Error ( Context, Value )) + -> Result Error ( Context, Value ) +innerValue2 ctx l r k = + innerValue ctx l + |> Result.andThen + (\( ctx2, vl ) -> + innerValue ctx2 r + |> Result.andThen + (\( ctx3, vr ) -> + k ctx3 vl vr + ) + ) + + +autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result Error ( Dict String Value, Value ) +autovectorizingFloatOp ctx name inner e = + innerValue ctx e + |> Result.andThen + (\( ctx2, v ) -> + case v of + VFloat fv -> + Ok ( ctx2, VFloat <| inner fv ) + + VVec2 x y -> + Ok ( ctx2, VVec2 (inner x) (inner y) ) + + VVec3 x y z -> + Ok ( ctx2, VVec3 (inner x) (inner y) (inner z) ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `" ++ name ++ "` for " ++ valueToString v) + ) + + +interpret : Context -> Statement a -> Result Error ( Context, Value ) +interpret ctx (Statement s) = + innerInterpret ctx s.stat + + +innerInterpret : Context -> Stat -> Result Error ( Context, Value ) +innerInterpret ctx stat = + case stat of + Return e -> + e + |> innerValue ctx + |> Result.map (\( ctx2, val ) -> ( ctx2, val )) + + If c t n -> + c + |> innerValue ctx + |> Result.andThen + (\( ctx2, cval ) -> + case cval of + VBool True -> + innerInterpret ctx2 t + |> Result.andThen + (\( ctx3, res ) -> + case res of + -- TODO: Fix this + VVoid -> + innerInterpret ctx3 n + + _ -> + Ok ( ctx3, res ) + ) + + VBool False -> + innerInterpret ctx2 n + + _ -> + Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval + ) + + IfElse _ _ _ _ -> + Debug.todo "branch 'IfElse _' not implemented" + + Nop -> + Ok ( ctx, VVoid ) + + ExpressionStatement _ _ -> + Debug.todo "branch 'ExpressionStatement _' not implemented" + + Decl _ _ _ _ -> + Debug.todo "branch 'Decl _ _ _' not implemented" + + For _ _ _ _ _ _ _ -> + Debug.todo "branch 'For _ _ _ _ _ _ _' not implemented" + + Break -> + Debug.todo "branch 'Break' not implemented" + + Continue -> + Debug.todo "branch 'Continue' not implemented" + + +valueToString : Value -> String +valueToString v = + case v of + VFloat f -> + String.fromFloat f + + VBool b -> + if b then + "true" + + else + "false" + + VInt i -> + String.fromInt i + + VVoid -> + "void" + + VVec2 x y -> + "vec2(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ ")" + + VVec3 x y z -> + "vec3(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ "," ++ String.fromFloat z ++ ")" + + VMat3 _ _ _ -> + Debug.todo "branch 'VMat3 _ _ _' not implemented" diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm index 4b16d6f3..7d663201 100644 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm @@ -1,6 +1,5 @@ -module Glsl.Generator exposing (Context, ErrorValue(..), File, FunDecl, GlslValue(..), adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, interpret, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, value, valueToString, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) +module Glsl.Generator exposing (File, FunDecl, adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) -import Dict exposing (Dict) import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, false, float1, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var, withExpression, withStatement) import Glsl.Functions exposing (vec211, vec3111, vec41111) import Glsl.Operations exposing (add22, add33, add44) @@ -979,304 +978,3 @@ in_ inner n = inner n in TypedName (TIn t) name - - - --------------------- --- TESTING HELPER -- --------------------- - - -type GlslValue - = VFloat Float - | VBool Bool - | VInt Int - | VVec2 Float Float - | VVec3 Float Float Float - | VMat3 ( Float, Float, Float ) ( Float, Float, Float ) ( Float, Float, Float ) - | VVoid -- Used for void return - - -type ErrorValue - = MissingVariable String - | InvalidTypes String - - -type alias Context = - Dict String GlslValue - - -valueToString : GlslValue -> String -valueToString v = - case v of - VFloat f -> - String.fromFloat f - - VBool b -> - if b then - "true" - - else - "false" - - VInt i -> - String.fromInt i - - VVoid -> - "void" - - VVec2 x y -> - "vec2(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ ")" - - VVec3 x y z -> - "vec3(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ "," ++ String.fromFloat z ++ ")" - - VMat3 _ _ _ -> - Debug.todo "branch 'VMat3 _ _ _' not implemented" - - -value : Context -> Expression t -> Result ErrorValue ( Context, GlslValue ) -value initialContext (Expression input) = - innerValue initialContext input.expr - - -innerValue : Context -> Expr -> Result ErrorValue ( Context, GlslValue ) -innerValue ctx e = - case e of - Float f -> - Ok ( ctx, VFloat f ) - - Bool b -> - Ok ( ctx, VBool b ) - - Int i -> - Ok ( ctx, VInt i ) - - Variable v -> - case Dict.get v ctx of - Just f -> - Ok ( ctx, f ) - - Nothing -> - Err <| MissingVariable v - - UnaryOperation Negate c -> - innerValue ctx c - |> Result.andThen - (\( ctx2, vc ) -> - case vc of - VFloat fc -> - Ok ( ctx2, VFloat <| negate fc ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `-` for " ++ valueToString vc) - ) - - BinaryOperation And l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - BinaryOperation Or l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - Comparison k l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) - - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) - - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) - - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) - - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) - - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) - - Ternary _ _ _ -> - Debug.todo "branch 'Ternary _ _ _' not implemented" - - BinaryOperation Add _ _ -> - Debug.todo "branch 'Add _ _' not implemented" - - BinaryOperation Subtract _ _ -> - Debug.todo "branch 'Subtract _ _' not implemented" - - BinaryOperation By l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - BinaryOperation Div _ _ -> - Debug.todo "branch 'Div _ _' not implemented" - - Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - Call "exp" [ l ] -> - autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l - - Call "cos" [ l ] -> - autovectorizingFloatOp ctx "cos" Basics.cos l - - Call "sin" [ l ] -> - autovectorizingFloatOp ctx "sin" Basics.sin l - - Call name args -> - Debug.todo <| "branch 'Call \"" ++ name ++ "\" [" ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) ++ " ]' not implemented" - - Dot _ _ -> - Debug.todo "branch 'Dot _ _' not implemented" - - Array _ _ -> - Debug.todo "branch 'Array _ _' not implemented" - - AssignCombo _ _ _ -> - Debug.todo "branch 'AssignCombo _ _' not implemented" - - PostfixIncrement _ -> - Debug.todo "branch 'PostfixIncrement _' not implemented" - - PostfixDecrement _ -> - Debug.todo "branch 'PostfixDecrement _' not implemented" - - -innerValue2 : - Context - -> Expr - -> Expr - -> (Context -> GlslValue -> GlslValue -> Result ErrorValue ( Context, GlslValue )) - -> Result ErrorValue ( Context, GlslValue ) -innerValue2 ctx l r k = - innerValue ctx l - |> Result.andThen - (\( ctx2, vl ) -> - innerValue ctx2 r - |> Result.andThen - (\( ctx3, vr ) -> - k ctx3 vl vr - ) - ) - - -autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result ErrorValue ( Dict String GlslValue, GlslValue ) -autovectorizingFloatOp ctx name inner e = - innerValue ctx e - |> Result.andThen - (\( ctx2, v ) -> - case v of - VFloat fv -> - Ok ( ctx2, VFloat <| inner fv ) - - VVec2 x y -> - Ok ( ctx2, VVec2 (inner x) (inner y) ) - - VVec3 x y z -> - Ok ( ctx2, VVec3 (inner x) (inner y) (inner z) ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `" ++ name ++ "` for " ++ valueToString v) - ) - - -interpret : Context -> Statement a -> Result ErrorValue ( Context, GlslValue ) -interpret ctx (Statement s) = - innerInterpret ctx s.stat - - -innerInterpret : Context -> Stat -> Result ErrorValue ( Context, GlslValue ) -innerInterpret ctx stat = - case stat of - Return e -> - e - |> innerValue ctx - |> Result.map (\( ctx2, val ) -> ( ctx2, val )) - - If c t n -> - c - |> innerValue ctx - |> Result.andThen - (\( ctx2, cval ) -> - case cval of - VBool True -> - innerInterpret ctx2 t - |> Result.andThen - (\( ctx3, res ) -> - case res of - -- TODO: Fix this - VVoid -> - innerInterpret ctx3 n - - _ -> - Ok ( ctx3, res ) - ) - - VBool False -> - innerInterpret ctx2 n - - _ -> - Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval - ) - - IfElse _ _ _ _ -> - Debug.todo "branch 'IfElse _' not implemented" - - Nop -> - Ok ( ctx, VVoid ) - - ExpressionStatement _ _ -> - Debug.todo "branch 'ExpressionStatement _' not implemented" - - Decl _ _ _ _ -> - Debug.todo "branch 'Decl _ _ _' not implemented" - - For _ _ _ _ _ _ _ -> - Debug.todo "branch 'For _ _ _ _ _ _ _' not implemented" - - Break -> - Debug.todo "branch 'Break' not implemented" - - Continue -> - Debug.todo "branch 'Continue' not implemented" From 284e88b966ae29c684f0e8a8862b6d95c72b8f81 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 12:00:15 +0200 Subject: [PATCH 117/139] Cleanup --- .vscode/settings.json | 2 +- review/elm.json | 27 +-- review/src/ReviewConfig.elm | 16 +- src/elm/API/Google.elm | 58 +++-- src/elm/Expression.elm | 15 +- src/elm/Expression/Graph.elm | 4 +- src/elm/Expression/NumericRange.elm | 154 +++++++------ src/elm/Expression/Parser.elm | 11 +- src/elm/Expression/Polynomial.elm | 100 +++++---- src/elm/Expression/Simplify.elm | 202 +++++++++--------- src/elm/UI/Glsl/Code.elm | 20 +- src/elm/UI/Glsl/Polynomial.elm | 13 +- tests/SolverTest.elm | 2 +- .../elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm | 18 +- 14 files changed, 317 insertions(+), 325 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 33d4340e..6756131f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { "elmLS.elmFormatPath": "elm-format-hack", - "cSpell.words": ["Glsl"] + "cSpell.words": ["Glsl", "sqrts"] } diff --git a/review/elm.json b/review/elm.json index dfd4ee41..35c80c33 100644 --- a/review/elm.json +++ b/review/elm.json @@ -6,22 +6,23 @@ "elm-version": "0.19.1", "dependencies": { "direct": { + "SiriusStarr/elm-review-pipeline-styles": "1.3.9", "elm/core": "1.0.5", "elm/json": "1.1.3", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.13.0", - "jfmengels/elm-review-code-style": "1.1.4", - "jfmengels/elm-review-common": "1.3.2", + "jfmengels/elm-review": "2.15.1", + "jfmengels/elm-review-code-style": "1.2.0", + "jfmengels/elm-review-common": "1.3.3", "jfmengels/elm-review-debug": "1.0.8", - "jfmengels/elm-review-documentation": "2.0.3", - "jfmengels/elm-review-simplify": "2.0.29", - "jfmengels/elm-review-unused": "1.1.29", + "jfmengels/elm-review-documentation": "2.0.4", + "jfmengels/elm-review-simplify": "2.1.6", + "jfmengels/elm-review-unused": "1.2.4", "jsuder-xx/elm-review-reducible-lambdas": "2.0.1", "lue-bird/elm-review-record-alias-constructor": "1.1.3", "sparksp/elm-review-always": "1.0.6", "sparksp/elm-review-imports": "1.0.2", "sparksp/elm-review-ports": "1.3.1", - "stil4m/elm-syntax": "7.2.9", + "stil4m/elm-syntax": "7.3.8", "truqu/elm-review-nobooleancase": "1.0.1" }, "indirect": { @@ -36,20 +37,20 @@ "elm-community/basics-extra": "4.1.0", "elm-community/list-extra": "8.7.0", "elm-community/maybe-extra": "5.3.0", - "elm-explorations/test": "2.1.1", + "elm-explorations/test": "2.2.0", "jsuder-xx/elm-ra": "1.1.1", - "miniBill/elm-fast-dict": "1.0.0", - "miniBill/elm-unicode": "1.0.3", + "miniBill/elm-fast-dict": "1.2.1", + "miniBill/elm-unicode": "1.1.1", "pzp1997/assoc-list": "1.0.0", "rtfeldman/elm-hex": "1.0.0", "stil4m/structured-writer": "1.0.3", - "the-sett/elm-pretty-printer": "3.0.0", - "the-sett/elm-syntax-dsl": "6.0.2" + "the-sett/elm-pretty-printer": "3.1.1", + "the-sett/elm-syntax-dsl": "6.0.3" } }, "test-dependencies": { "direct": { - "elm-explorations/test": "2.1.1" + "elm-explorations/test": "2.2.0" }, "indirect": {} } diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 5f3ee920..1696a6c9 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -28,6 +28,7 @@ import NoUnused.Patterns import NoUnused.Variables import NoUnusedPorts import Review.Rule as Rule exposing (Rule) +import ReviewPipelineStyles import Simplify @@ -41,10 +42,11 @@ config = , NoDebug.TodoOrToString.rule |> Rule.ignoreErrorsForDirectories [ "tests/" ] , NoDuplicatePorts.rule - , NoEtaReducibleLambdas.rule - { lambdaReduceStrategy = NoEtaReducibleLambdas.AlwaysRemoveLambdaWhenPossible - , argumentNamePredicate = always True - } + + -- , NoEtaReducibleLambdas.rule + -- { lambdaReduceStrategy = NoEtaReducibleLambdas.AlwaysRemoveLambdaWhenPossible + -- , argumentNamePredicate = always True + -- } , NoExposingEverything.rule , NoImportingEverything.rule [] , NoMissingTypeAnnotation.rule @@ -65,4 +67,10 @@ config = , NoUnused.Variables.rule , NoUnusedPorts.rule , Simplify.rule Simplify.defaults + , ReviewPipelineStyles.rule + [ ReviewPipelineStyles.forbid ReviewPipelineStyles.leftCompositionPipelines + |> ReviewPipelineStyles.andCallThem "forbidden << composition" + , ReviewPipelineStyles.forbid ReviewPipelineStyles.rightCompositionPipelines + |> ReviewPipelineStyles.andCallThem "forbidden >> composition" + ] ] diff --git a/src/elm/API/Google.elm b/src/elm/API/Google.elm index 2cd48d14..ce3e30a5 100644 --- a/src/elm/API/Google.elm +++ b/src/elm/API/Google.elm @@ -98,9 +98,6 @@ uploadFile params = updateUrl = B.crossOrigin "https://www.googleapis.com" [ "upload", "drive", "v3", "files", id ] [ B.string "uploadType" "multipart" ] - insertUrl = - B.crossOrigin "https://www.googleapis.com" [ "upload", "drive", "v3", "files" ] [ B.string "uploadType" "multipart" ] - (FileId id) = params.id @@ -112,18 +109,6 @@ uploadFile params = , ( "name", JE.string params.name ) ] - insertMetadataEncoder = - BE.string <| - JE.encode 0 <| - JE.object - [ ( "id", JE.string id ) - , ( "mimeType", JE.string "text/markdown" ) - , ( "name", JE.string params.name ) - - -- TODO: parents are a list of FileIDs, so it's Very Annoying and will be implemented later - --, ( "parents", JE.list JE.string [ "nuPlot" ] ) - ] - updateTask = Http.task { method = "PATCH" @@ -137,26 +122,39 @@ uploadFile params = ] , timeout = Nothing } - - insertTask = - Http.task - { method = "POST" - , url = insertUrl - , headers = [ Http.header "Authorization" <| "Bearer " ++ params.accessToken ] - , resolver = jsonResolver <| JD.succeed () - , body = - Http.multipartBody - [ Http.bytesPart "metadata" "application/json; charset=UTF-8" <| BE.encode insertMetadataEncoder - , Http.stringPart "content" params.content - ] - , timeout = Nothing - } in updateTask |> Task.onError (\e -> if e == FileNotFound then - insertTask + let + insertUrl = + B.crossOrigin "https://www.googleapis.com" [ "upload", "drive", "v3", "files" ] [ B.string "uploadType" "multipart" ] + + insertMetadataEncoder = + BE.string <| + JE.encode 0 <| + JE.object + [ ( "id", JE.string id ) + , ( "mimeType", JE.string "text/markdown" ) + , ( "name", JE.string params.name ) + + -- TODO: parents are a list of FileIDs, so it's Very Annoying and will be implemented later + --, ( "parents", JE.list JE.string [ "nuPlot" ] ) + ] + in + Http.task + { method = "POST" + , url = insertUrl + , headers = [ Http.header "Authorization" <| "Bearer " ++ params.accessToken ] + , resolver = jsonResolver <| JD.succeed () + , body = + Http.multipartBody + [ Http.bytesPart "metadata" "application/json; charset=UTF-8" <| BE.encode insertMetadataEncoder + , Http.stringPart "content" params.content + ] + , timeout = Nothing + } else Task.fail e diff --git a/src/elm/Expression.elm b/src/elm/Expression.elm index 6da577dc..8f242388 100644 --- a/src/elm/Expression.elm +++ b/src/elm/Expression.elm @@ -383,11 +383,8 @@ equals l r = -- Yes, this is enough for now goat = Variable "GOATFINDER" - - res = - equals (partialSubstitute x goat f) (partialSubstitute y goat g) in - res + equals (partialSubstitute x goat f) (partialSubstitute y goat g) ( Lambda _ _, _ ) -> False @@ -545,7 +542,7 @@ typecheck e = |> Result.map TGList Apply (KnownFunction Sin) [ a0 ] -> - Result.map (TGApply << TGApply1 PSin) (typecheck a0) + Result.map (\t0 -> TGApply (TGApply1 PSin t0)) (typecheck a0) Apply (KnownFunction Sin) args -> Err <| InvalidArgCount Sin (List.length args) @@ -1027,8 +1024,9 @@ defaultContext = getFreeVariables : Expression -> Set String getFreeVariables expr = let + concatMap : List Expression -> Set String concatMap = - List.foldl (Set.union << getFreeVariables) Set.empty + List.foldl (\e -> Set.union (getFreeVariables e)) Set.empty in case expr of Variable v -> @@ -1678,8 +1676,9 @@ toTeXStringPrec p e = case asMatrixPrint e of Just childLists -> let - viewRow = - String.join " & " << List.map (\cell -> "{" ++ toTeXStringPrec 0 cell ++ "}") + viewRow : List ToGlslExpression -> String + viewRow elements = + String.join " & " (List.map (\cell -> "{" ++ toTeXStringPrec 0 cell ++ "}") elements) in "\\begin{pmatrix}" ++ String.join " \\\\ " (List.map viewRow childLists) ++ "\\end{pmatrix}" diff --git a/src/elm/Expression/Graph.elm b/src/elm/Expression/Graph.elm index 63581670..8338eef6 100644 --- a/src/elm/Expression/Graph.elm +++ b/src/elm/Expression/Graph.elm @@ -19,7 +19,7 @@ type Graph fromExpression : Expression -> Graph -fromExpression = +fromExpression input = let go expr = let @@ -87,7 +87,7 @@ fromExpression = else Explicit2D expr in - go << Expression.Simplify.hoistLambda + go (Expression.Simplify.hoistLambda input) toString : Graph -> String diff --git a/src/elm/Expression/NumericRange.elm b/src/elm/Expression/NumericRange.elm index d4abc58c..a0467c7e 100644 --- a/src/elm/Expression/NumericRange.elm +++ b/src/elm/Expression/NumericRange.elm @@ -26,111 +26,107 @@ get = getRange : Dict String NumericRange -> Expression -> NumericRange getRange ctx e = - let - result = - case e of - Variable v -> - Dict.get v ctx |> Maybe.withDefault Real + case e of + Variable v -> + Dict.get v ctx |> Maybe.withDefault Real - Integer j -> - sign j + Integer j -> + sign j - Float j -> - sign j + Float j -> + sign j - UnaryOperation Negate c -> - negateRange <| getRange ctx c + UnaryOperation Negate c -> + negateRange <| getRange ctx c - BinaryOperation Power b ex -> - powerRange ctx (getRange ctx b) ex + BinaryOperation Power b ex -> + powerRange ctx (getRange ctx b) ex - BinaryOperation Division n d -> - multiplyRange (getRange ctx n) (getRange ctx d) + BinaryOperation Division n d -> + multiplyRange (getRange ctx n) (getRange ctx d) - RelationOperation _ _ _ -> - Nonnegative + RelationOperation _ _ _ -> + Nonnegative - AssociativeOperation Addition l m o -> - List.foldl addRange (getRange ctx l) <| List.map (getRange ctx) (m :: o) + AssociativeOperation Addition l m o -> + List.foldl addRange (getRange ctx l) <| List.map (getRange ctx) (m :: o) - AssociativeOperation Multiplication l m o -> - List.foldl multiplyRange (getRange ctx l) <| List.map (getRange ctx) (m :: o) + AssociativeOperation Multiplication l m o -> + List.foldl multiplyRange (getRange ctx l) <| List.map (getRange ctx) (m :: o) - List es -> - case es of - [] -> - Zero + List es -> + case es of + [] -> + Zero - h :: t -> - List.foldl union (getRange ctx h) <| List.map (getRange ctx) t + h :: t -> + List.foldl union (getRange ctx h) <| List.map (getRange ctx) t - Apply (KnownFunction Abs) [ c ] -> - case getRange ctx c of - Positive -> - Positive + Apply (KnownFunction Abs) [ c ] -> + case getRange ctx c of + Positive -> + Positive - Negative -> - Positive + Negative -> + Positive - Zero -> - Zero + Zero -> + Zero - _ -> - Nonnegative + _ -> + Nonnegative - Apply (KnownFunction Arg) [ c ] -> - case getRange ctx c of - Complex -> - Real + Apply (KnownFunction Arg) [ c ] -> + case getRange ctx c of + Complex -> + Real - -- monotone with arg(0) = 0 - o -> - o + -- monotone with arg(0) = 0 + o -> + o - Apply (KnownFunction Sqrt) [ c ] -> - sqrtRange <| getRange ctx c + Apply (KnownFunction Sqrt) [ c ] -> + sqrtRange <| getRange ctx c - Apply (KnownFunction Cbrt) [ c ] -> - getRange ctx c + Apply (KnownFunction Cbrt) [ c ] -> + getRange ctx c - Apply (KnownFunction Re) [ _ ] -> - Real + Apply (KnownFunction Re) [ _ ] -> + Real - Apply (KnownFunction Im) [ _ ] -> - Real + Apply (KnownFunction Im) [ _ ] -> + Real - Apply (KnownFunction Atan2) [ y, x ] -> - if getRange ctx y /= Complex && getRange ctx x /= Complex then - Real + Apply (KnownFunction Atan2) [ y, x ] -> + if getRange ctx y /= Complex && getRange ctx x /= Complex then + Real - else - Complex + else + Complex - Apply (KnownFunction Piecewise) [ _, t, f ] -> - union (getRange ctx t) (getRange ctx f) + Apply (KnownFunction Piecewise) [ _, t, f ] -> + union (getRange ctx t) (getRange ctx f) - Apply (KnownFunction Mbrot) _ -> - Complex + Apply (KnownFunction Mbrot) _ -> + Complex - Apply (KnownFunction _) args -> - if List.any (\c -> getRange ctx c == Complex) args then - Complex + Apply (KnownFunction _) args -> + if List.any (\c -> getRange ctx c == Complex) args then + Complex - else - Real - - Replace variables c -> - getRange - (List.foldl (\( k, v ) -> Dict.insert k (getRange ctx v)) - ctx - (Dict.toList <| filterContext variables) - ) - c - - Lambda x f -> - getRange (Dict.remove x ctx) f - in - result + else + Real + + Replace variables c -> + getRange + (List.foldl (\( k, v ) -> Dict.insert k (getRange ctx v)) + ctx + (Dict.toList <| filterContext variables) + ) + c + + Lambda x f -> + getRange (Dict.remove x ctx) f powerRange : Dict String NumericRange -> NumericRange -> Expression -> NumericRange diff --git a/src/elm/Expression/Parser.elm b/src/elm/Expression/Parser.elm index 9785cf9f..71080545 100644 --- a/src/elm/Expression/Parser.elm +++ b/src/elm/Expression/Parser.elm @@ -150,7 +150,7 @@ problemGroupToString ( { col, contextStack, problem }, problems ) = in UI.L10N.concat [ prefix - , if List.any ((==) Unexpected) allProblems then + , if List.member Unexpected allProblems then if List.all ((==) Unexpected) allProblems then { en = "Unexpected" , it = "Inatteso" @@ -672,8 +672,9 @@ variableParser context = getFirstFree : Trie VariableStatus -> String getFirstFree trie = let - alphabeth = - List.map (String.fromChar << Char.fromCode) <| List.range (Char.toCode 'a') (Char.toCode 'z') + alphabet : List String + alphabet = + List.map (\c -> String.fromChar (Char.fromCode c)) <| List.range (Char.toCode 'a') (Char.toCode 'z') go : List String -> String go lst = @@ -682,9 +683,9 @@ getFirstFree trie = p Nothing -> - go (List.concatMap (\l -> List.map (\r -> l ++ r) alphabeth) lst) + go (List.concatMap (\l -> List.map (\r -> l ++ r) alphabet) lst) in - go alphabeth + go alphabet parseArgs : Maybe Int -> Bool -> ExpressionParser (List Expression) diff --git a/src/elm/Expression/Polynomial.elm b/src/elm/Expression/Polynomial.elm index 3e03c3ff..ca8b0742 100644 --- a/src/elm/Expression/Polynomial.elm +++ b/src/elm/Expression/Polynomial.elm @@ -18,61 +18,57 @@ type alias Polynomial = asPolynomial : List String -> Expression -> Maybe Polynomial asPolynomial vars e = - let - res = - case e of - Integer _ -> - Just <| Dict.singleton [] e - - Float _ -> - Just <| Dict.singleton [] e - - Variable v -> - if List.member v vars then - Just <| Dict.singleton [ ( v, 1 ) ] one - - else - Just <| Dict.singleton [] e - - UnaryOperation Negate c -> - asPolynomial vars c - |> Maybe.map negate_ - - AssociativeOperation Addition l m r -> - (l :: m :: r) - |> Maybe.traverse (asPolynomial vars) - |> Maybe.map (List.foldr sum Dict.empty) - - AssociativeOperation Multiplication l m r -> - (l :: m :: r) - |> Maybe.traverse (asPolynomial vars) - |> Maybe.map (List.foldr by (Dict.singleton [] (Integer 1))) - - BinaryOperation Power b (Integer i) -> - Maybe.andThen (pow i) (asPolynomial vars b) - - BinaryOperation Division n d -> - let - polyD = - Maybe.map Dict.toList <| asPolynomial vars d - in - case polyD of - Just [ ( [], z ) ] -> - asPolynomial vars n - |> Maybe.map - (Dict.map - (\_ k -> - div k z - ) - ) - - _ -> - Nothing + case e of + Integer _ -> + Just <| Dict.singleton [] e + + Float _ -> + Just <| Dict.singleton [] e + + Variable v -> + if List.member v vars then + Just <| Dict.singleton [ ( v, 1 ) ] one + + else + Just <| Dict.singleton [] e + + UnaryOperation Negate c -> + asPolynomial vars c + |> Maybe.map negate_ + + AssociativeOperation Addition l m r -> + (l :: m :: r) + |> Maybe.traverse (asPolynomial vars) + |> Maybe.map (List.foldr sum Dict.empty) + + AssociativeOperation Multiplication l m r -> + (l :: m :: r) + |> Maybe.traverse (asPolynomial vars) + |> Maybe.map (List.foldr by (Dict.singleton [] (Integer 1))) + + BinaryOperation Power b (Integer i) -> + Maybe.andThen (pow i) (asPolynomial vars b) + + BinaryOperation Division n d -> + let + polyD = + Maybe.map Dict.toList <| asPolynomial vars d + in + case polyD of + Just [ ( [], z ) ] -> + asPolynomial vars n + |> Maybe.map + (Dict.map + (\_ k -> + div k z + ) + ) _ -> Nothing - in - res + + _ -> + Nothing negate_ : Polynomial -> Polynomial diff --git a/src/elm/Expression/Simplify.elm b/src/elm/Expression/Simplify.elm index 649c5603..417e1a9f 100644 --- a/src/elm/Expression/Simplify.elm +++ b/src/elm/Expression/Simplify.elm @@ -173,14 +173,14 @@ stepSimplifyNegate context expr = step1 : Dict String Expression -> { andThen : Expression -> Expression, ifChanged : Expression -> Expression } -> Expression -> Expression step1 context { andThen, ifChanged } arg = let - sarg = + simplifiedArg = stepSimplify context arg in - if Expression.equals arg sarg then - andThen sarg + if Expression.equals arg simplifiedArg then + andThen simplifiedArg else - ifChanged sarg + ifChanged simplifiedArg step2 : Dict String Expression -> { andThen : Expression -> Expression -> Expression, ifChanged : Expression -> Expression -> Expression } -> Expression -> Expression -> Expression @@ -202,21 +202,22 @@ step2 context { andThen, ifChanged } arg1 arg2 = stepList : Dict String Expression -> { andThen : List Expression -> Expression, ifChanged : List Expression -> Expression } -> List Expression -> Expression stepList context { andThen, ifChanged } args = let - sargs = + simplifiedArgs : List Expression + simplifiedArgs = List.map (stepSimplify context) args in - if List.map2 Expression.equals args sargs |> List.all identity then - andThen sargs + if List.map2 Expression.equals args simplifiedArgs |> List.all identity then + andThen simplifiedArgs else - ifChanged sargs + ifChanged simplifiedArgs stepSimplifyApply : FunctionName -> List Expression -> Expression -stepSimplifyApply fname sargs = - case fname of +stepSimplifyApply functionName args = + case functionName of KnownFunction name -> - case ( name, sargs ) of + case ( name, args ) of ( Sqrt, [ arg ] ) -> stepSimplifySqrt arg |> Maybe.withDefault (sqrt_ arg) @@ -243,7 +244,7 @@ stepSimplifyApply fname sargs = by [ i, sin_ <| by rest ] Nothing -> - Apply fname sargs + Apply functionName args ( Cosh, [ AssociativeOperation Multiplication l r o ] ) -> case extract (findSpecificVariable "i") (l :: r :: o) of @@ -251,7 +252,7 @@ stepSimplifyApply fname sargs = cos_ <| by rest Nothing -> - Apply fname sargs + Apply functionName args ( Dd, [ expr, Variable var ] ) -> Expression.Derivative.derivative var expr @@ -260,16 +261,16 @@ stepSimplifyApply fname sargs = Expression.Utils.determinant expr ( Re, _ ) -> - stepSimplifyRe sargs + stepSimplifyRe args ( Im, _ ) -> - stepSimplifyIm sargs + stepSimplifyIm args ( Ii, [ expr, Variable var, from, to ] ) -> stepSimplifyIntegral expr var from to _ -> - Apply fname sargs + Apply functionName args stepSimplifyIntegral : Expression -> String -> Expression -> Expression -> Expression @@ -309,8 +310,8 @@ stepSimplifyIntegral expr var from to = stepSimplifyAbs : Expression -> Maybe Expression -stepSimplifyAbs sarg = - case sarg of +stepSimplifyAbs arg = + case arg of Integer i -> Just <| Integer <| abs i @@ -320,24 +321,24 @@ stepSimplifyAbs sarg = Variable v -> case v of "e" -> - Just sarg + Just arg "pi" -> - Just sarg + Just arg _ -> Nothing Apply (KnownFunction Abs) _ -> - Just sarg + Just arg _ -> Nothing stepSimplifySqrt : Expression -> Maybe Expression -stepSimplifySqrt sarg = - case sarg of +stepSimplifySqrt arg = + case arg of Integer j -> sqrtInteger j @@ -350,7 +351,7 @@ stepSimplifySqrt sarg = (l :: m :: r) |> List.map stepSimplifySqrt in if List.any ((/=) Nothing) sqrts then - Just <| by <| List.map2 (Maybe.withDefault << sqrt_) (l :: m :: r) sqrts + Just <| by <| List.map2 (\le re -> Maybe.withDefault (sqrt_ le) re) (l :: m :: r) sqrts else Nothing @@ -1437,49 +1438,6 @@ asList l = stepSimplifyMultiplication : Expression -> Expression -> Maybe Expression stepSimplifyMultiplication left right = let - go = - case ( left, right ) of - ( Integer 1, l ) -> - Just l - - ( c, Integer 1 ) -> - Just c - - ( _, Integer 0 ) -> - Just <| Integer 0 - - ( Integer 0, _ ) -> - Just <| Integer 0 - - ( Integer il, Integer ir ) -> - Just <| Integer <| il * ir - - ( Integer il, Float fr ) -> - Just <| Float <| toFloat il * fr - - ( Float fl, Integer ir ) -> - Just <| Float <| fl * toFloat ir - - ( Float fl, Float fr ) -> - Just <| Float <| fl * fr - - ( Integer j, _ ) -> - if j == -1 then - Just <| negate_ right - - else - go1 () - - ( _, Integer k ) -> - if k == -1 then - Just <| negate_ left - - else - go1 () - - _ -> - go1 () - go1 () = case ( left, right ) of ( AssociativeOperation Addition l m r, _ ) -> @@ -1556,7 +1514,47 @@ stepSimplifyMultiplication left right = else Nothing in - go + case ( left, right ) of + ( Integer 1, l ) -> + Just l + + ( c, Integer 1 ) -> + Just c + + ( _, Integer 0 ) -> + Just <| Integer 0 + + ( Integer 0, _ ) -> + Just <| Integer 0 + + ( Integer il, Integer ir ) -> + Just <| Integer <| il * ir + + ( Integer il, Float fr ) -> + Just <| Float <| toFloat il * fr + + ( Float fl, Integer ir ) -> + Just <| Float <| fl * toFloat ir + + ( Float fl, Float fr ) -> + Just <| Float <| fl * fr + + ( Integer j, _ ) -> + if j == -1 then + Just <| negate_ right + + else + go1 () + + ( _, Integer k ) -> + if k == -1 then + Just <| negate_ left + + else + go1 () + + _ -> + go1 () addMatrices : Expression -> Expression -> Maybe Expression @@ -1580,56 +1578,52 @@ multiplyMatrices = polyDegree : String -> Expression -> Maybe Int polyDegree var expr = - let - res = - case expr of - Integer _ -> - Just 0 + case expr of + Integer _ -> + Just 0 - UnaryOperation Negate e -> - polyDegree var e + UnaryOperation Negate e -> + polyDegree var e - BinaryOperation Division l r -> - Maybe.map2 (-) (polyDegree var l) (polyDegree var r) + BinaryOperation Division l r -> + Maybe.map2 (-) (polyDegree var l) (polyDegree var r) - BinaryOperation Power base (Integer i) -> - Maybe.map ((*) i) <| polyDegree var base + BinaryOperation Power base (Integer i) -> + Maybe.map ((*) i) <| polyDegree var base - BinaryOperation Power _ _ -> - Nothing + BinaryOperation Power _ _ -> + Nothing - RelationOperation _ _ _ -> - Nothing + RelationOperation _ _ _ -> + Nothing - AssociativeOperation Addition l r o -> - Maybe.andThen List.maximum <| Maybe.traverse (polyDegree var) (l :: r :: o) + AssociativeOperation Addition l r o -> + Maybe.andThen List.maximum <| Maybe.traverse (polyDegree var) (l :: r :: o) - AssociativeOperation Multiplication l r o -> - Maybe.map List.sum <| Maybe.traverse (polyDegree var) (l :: r :: o) + AssociativeOperation Multiplication l r o -> + Maybe.map List.sum <| Maybe.traverse (polyDegree var) (l :: r :: o) - Variable v -> - if v == var then - Just 1 + Variable v -> + if v == var then + Just 1 - else - Just 0 + else + Just 0 - Float _ -> - Just 0 + Float _ -> + Just 0 - Apply _ _ -> - Nothing + Apply _ _ -> + Nothing - Replace _ _ -> - Nothing + Replace _ _ -> + Nothing - List _ -> - Nothing + List _ -> + Nothing - Lambda _ _ -> - Nothing - in - res + Lambda _ _ -> + Nothing hoistLambda : Expression -> Expression diff --git a/src/elm/UI/Glsl/Code.elm b/src/elm/UI/Glsl/Code.elm index 043148bc..1535977b 100644 --- a/src/elm/UI/Glsl/Code.elm +++ b/src/elm/UI/Glsl/Code.elm @@ -1,14 +1,14 @@ module UI.Glsl.Code exposing (expressionToGlsl, expressionToGlslComplex, mainGlsl, threshold, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D, toThreshold) import Expression exposing (Function1(..), Function2(..), Function3(..), RelationOperation(..), TGApply(..), ToGlslExpression(..)) -import Glsl exposing (Expr, Expression, Vec2, Vec3, Vec4, dot2X, dot2Y, dot4XY, float1, unsafeCall0, unsafeTypecast, var) +import Glsl exposing (Expr, Expression, Vec2, Vec3, Vec4, dot2X, dot2Y, dot4XY, float1, unsafeTypecast, var) import Glsl.Functions exposing (abs2, abs3, abs4, axis111, cabs2, cacos2, carg2, casin2, catan2, catan222, cby22, ccbrt2, cceil2, ccos2, ccosh2, cdiv22, cexp2, cfloor2, cim2, cln2, clog102, cmax22, cmbrot22, cmin22, cmod22, cos1, cpow22, cpw222, cre2, cross33, cround2, csign2, csin2, csinh2, csqrt2, ctan2, ctanh2, dup1, exp1, fwidth3, gby44, gdiv44, gneg4, gnum1, gpow41, gpow44, gsquare4, hl2rgb11, iabs2, iacos2, iarg2, iasin2, iatan2, iby22, icbrt2, iceil2, icos2, icosh2, idiv22, ieq22, iexp2, iexpand2, ifloor2, igeq22, igt22, iim2, ileq22, iln2, ilog102, ilt22, ineg2, ineq22, ipow21, ipow22, ire2, iround2, isign2, isin2, isinh2, isqrt2, isquare2, itan2, itanh2, mat3333, max11, max33, max44, normalize3, pow11, radians1, sin1, u_canvasHeight, u_canvasWidth, u_drawAxes, u_phi, u_theta, u_viewportWidth, u_zoomCenter, vec211, vec3111, vec41111, vec431) import Glsl.Generator as Generator exposing (adds3, assign, decl, def, expr, float, fun0, gl_FragColor, gl_FragCoord, main_, mat3, one, return, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4T, vec4Zero, zero) -import Glsl.Operations exposing (add11, add22, add33, add44, by11, by12, by13, by22, by31, by33, div11, div22, eq, lt, negate1, negate2, subtract11, subtract22, subtract33, subtract44) +import Glsl.Operations exposing (add11, add22, add33, add44, by11, by12, by13, by22, by33, div11, div22, eq, lt, negate1, negate2, subtract11, subtract22, subtract33, subtract44) import Glsl.PrettyPrinter -expressionToGlslComplex : ToGlslExpression -> Glsl.Expression Vec2 +expressionToGlslComplex : ToGlslExpression -> Expression Vec2 expressionToGlslComplex = visit { expr = @@ -787,13 +787,13 @@ main2D pixels = let maybeColor : Int -> Bool -> Expression Vec3 -> Expression Vec3 maybeColor i color innerCall = - let - h : Expression Float - h = - (toFloat (i + 2) / pi) - |> float1 - in if color then + let + h : Expression Float + h = + (toFloat (i + 2) / pi) + |> float1 + in by33 (hl2rgb11 h (float1 0.5)) innerCall else @@ -1067,7 +1067,7 @@ type VisitExpression a | VPower a a | VSquare a | VPowerF a Float - | VList (List (Glsl.Expression Float)) + | VList (List (Expression Float)) visit : diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 2e0370fe..18c4747e 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -4,12 +4,11 @@ import Dict exposing (Dict) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), RelationOperation(..), UnaryOperation(..)) import Expression.Polynomial exposing (Exponents) import Expression.Utils -import Glsl exposing (BisectSignature, Statement, Vec3, dot2X, dot2Y, dot3X, dot3Y, dot3Z, float1, int) -import Glsl.Functions exposing (abs1, cby22, cdiv22, csqrt2, min11, mix331) -import Glsl.Operations exposing (add22, add33, array33, by11, by12, by13, gt, lt, negate2, subtract22) +import Glsl exposing (BisectSignature, Statement, Vec3, float1, int1) +import Glsl.Functions exposing (mix331) +import Glsl.Generator exposing (ands, assignOut, boolT, def, expr, floatT, fun4, mat3T, out, return, vec3, vec3T, zero) +import Glsl.Operations exposing (add33, array33, by11, by13, gt, lt) import Maybe.Extra as Maybe -import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (ands, assign, assignOut, boolT, def, def2, def3, expr, floatT, fun4, mat3T, or, out, return, ternary, vec2T, vec3T, zero) getDegree : Dict (List ( a, number )) b -> number @@ -195,10 +194,10 @@ glslFromSolutions : -> BisectSignature glslFromSolutions suffix sols = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> + vec3 "dMix" (mix331 (array33 d (int1 0)) (array33 d (int1 1)) (float1 0.5)) <| \dMix -> def floatT "t" (by11 maxDistance <| float1 2) <| \t -> sols { dMix = dMix, o = o, t = t } <| \_ -> - expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5))))) <| \_ -> + expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int1 0)) (array33 d (int1 1)) (float1 0.5))))) <| \_ -> return (ands [ lt t maxDistance, gt t zero ]) diff --git a/tests/SolverTest.elm b/tests/SolverTest.elm index c0b75cba..1f5e0791 100644 --- a/tests/SolverTest.elm +++ b/tests/SolverTest.elm @@ -4,7 +4,7 @@ import Expect import Expression exposing (Expression(..), RelationOperation(..), SolutionTree(..)) import Expression.Simplify exposing (simplify) import Expression.Solver -import Expression.Utils exposing (by, c, div, i, minus, minusOne, negate_, one, plus, square, two, x, zero) +import Expression.Utils exposing (by, div, i, minus, minusOne, negate_, one, plus, square, two, x, zero) import List import Test exposing (Test, describe, test) diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm index 7d663201..5d3dadf9 100644 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm @@ -737,11 +737,11 @@ for : -> (Expression Int -> Statement r -> Statement r) -> Statement r -> Statement r -for ( var, from, to ) loop next = - build (\f t -> For var f LessThan t PlusPlus) +for ( varName, from, to ) loop next = + build (\f t -> For varName f LessThan t PlusPlus) |> withExpression from |> withExpression to - |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement (loop (var varName) unsafeNop) |> withStatement next |> buildStatement @@ -751,11 +751,11 @@ forLeq : -> (Expression Int -> Statement r -> Statement r) -> Statement r -> Statement r -forLeq ( var, from, to ) loop next = - build (\f t -> For var f LessThanOrEquals t PlusPlus) +forLeq ( varName, from, to ) loop next = + build (\f t -> For varName f LessThanOrEquals t PlusPlus) |> withExpression from |> withExpression to - |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement (loop (var varName) unsafeNop) |> withStatement next |> buildStatement @@ -765,11 +765,11 @@ forDown : -> (Expression Int -> Statement r -> Statement r) -> Statement r -> Statement r -forDown ( var, from, to ) loop next = - build (\f t -> For var f GreaterThan t MinusMinus) +forDown ( varName, from, to ) loop next = + build (\f t -> For varName f GreaterThan t MinusMinus) |> withExpression from |> withExpression to - |> withStatement (loop (Glsl.var var) unsafeNop) + |> withStatement (loop (var varName) unsafeNop) |> withStatement next |> buildStatement From b8e9dbab66387c8e61edd9cbad334dff3de1da61 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 12:08:30 +0200 Subject: [PATCH 118/139] More cleanup --- review/src/ReviewConfig.elm | 8 +- src/elm/UI/Glsl.elm | 6 +- src/elm/UI/Glsl/Plane.elm | 47 ++++---- src/elm/UI/Glsl/Sphere.elm | 9 +- .../miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm | 19 +--- .../elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm | 105 +++++++++--------- 6 files changed, 98 insertions(+), 96 deletions(-) diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 1696a6c9..578b51fe 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -40,7 +40,7 @@ config = , NoConfusingPrefixOperator.rule , NoDebug.Log.rule , NoDebug.TodoOrToString.rule - |> Rule.ignoreErrorsForDirectories [ "tests/" ] + |> Rule.ignoreErrorsForDirectories [ "tests" ] , NoDuplicatePorts.rule -- , NoEtaReducibleLambdas.rule @@ -57,10 +57,12 @@ config = , NoRecordAliasConstructor.rule , NoSimpleLetBody.rule , NoUnsafePorts.rule NoUnsafePorts.any - , NoUnused.CustomTypeConstructorArgs.rule - , NoUnused.CustomTypeConstructors.rule [] + + -- , NoUnused.CustomTypeConstructorArgs.rule + -- , NoUnused.CustomTypeConstructors.rule [] , NoUnused.Dependencies.rule , NoUnused.Exports.rule + |> Rule.ignoreErrorsForDirectories [ "generated" ] , NoUnused.Modules.rule , NoUnused.Parameters.rule , NoUnused.Patterns.rule diff --git a/src/elm/UI/Glsl.elm b/src/elm/UI/Glsl.elm index a12c43c7..7938171f 100644 --- a/src/elm/UI/Glsl.elm +++ b/src/elm/UI/Glsl.elm @@ -8,7 +8,7 @@ import Expression.Utils exposing (by, minus, plus) import Glsl exposing (BisectSignature, ExprWithDeps) import Glsl.Generator as Generator import Maybe.Extra as Maybe -import UI.Glsl.Code exposing (mainGlsl, toSrc3D, toSrcContour, toSrcImplicit, toSrcParametric, toSrcPolar, toSrcRelation, toSrcVectorField2D) +import UI.Glsl.Code exposing (mainGlsl, toSrcVectorField2D) import UI.Glsl.Plane as Plane import UI.Glsl.Polynomial import UI.Glsl.Sphere as Sphere @@ -21,8 +21,8 @@ getGlsl rayDifferentials graph = extract "" graph build2d : - (Expression.Expression -> ExprWithDeps) - -> Expression.Expression + (Expression -> ExprWithDeps) + -> Expression -> { expr : ExprWithDeps , funDecls : a diff --git a/src/elm/UI/Glsl/Plane.elm b/src/elm/UI/Glsl/Plane.elm index e3a204bb..05a56321 100644 --- a/src/elm/UI/Glsl/Plane.elm +++ b/src/elm/UI/Glsl/Plane.elm @@ -6,8 +6,8 @@ import Glsl exposing (BisectSignature, float1, int) import Glsl.Functions exposing (dot33, mix331, vec3111) import Glsl.Operations exposing (add11, add33, array33, by13, div11, gt, negate1) import Maybe -import UI.Glsl.Code exposing (threshold) -import UI.Glsl.Generator exposing (assignOut, boolT, def, def2, expr, floatT, fun4, mat3T, out, return, vec3T) +import UI.Glsl.Code +import UI.Glsl.Generator exposing (assignOut, boolT, def, expr, floatT, fun4, mat3T, out, return, vec3T) import UI.Glsl.Polynomial as Polynomial @@ -40,22 +40,27 @@ asPlane e = toGlsl : String -> Plane -> BisectSignature toGlsl suffix (Plane { x, y, z, known }) = - fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> - -- a x + b y + c z + k = 0 - -- x = ox + t dx - -- y = oy + t dy - -- z = oz + t dz - -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 - -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) - -- t = - (k + dot abc o) / (dot abc d) - vec3 "coeffs" (vec3111 (float1 x) (float1 y) (float1 z)) <| \coeffs -> - vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| \dMix -> - def floatT - "t" - (div11 - (negate1 <| add11 (float1 known) (dot33 coeffs o)) - (dot33 coeffs dMix) - ) - <| \t -> - expr (assignOut found <| add33 o <| by13 t dMix) <| \_ -> - return (gt t <| UI.Glsl.Code.toThreshold maxDistance) + fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| + \o d maxDistance found -> + -- a x + b y + c z + k = 0 + -- x = ox + t dx + -- y = oy + t dy + -- z = oz + t dz + -- a ox + a t dx + b oy + b t dy + c oz + c t dz + k = 0 + -- t (a dx + b dy + c dy) = - k - (a ox + b oy + c oz) + -- t = - (k + dot abc o) / (dot abc d) + vec3 "coeffs" (vec3111 (float1 x) (float1 y) (float1 z)) <| + \coeffs -> + vec3 "dMix" (mix331 (array33 d (int 0)) (array33 d (int 1)) (float1 0.5)) <| + \dMix -> + def floatT + "t" + (div11 + (negate1 <| add11 (float1 known) (dot33 coeffs o)) + (dot33 coeffs dMix) + ) + <| + \t -> + expr (assignOut found <| add33 o <| by13 t dMix) <| + \_ -> + return (gt t <| UI.Glsl.Code.toThreshold maxDistance) diff --git a/src/elm/UI/Glsl/Sphere.elm b/src/elm/UI/Glsl/Sphere.elm index f7b8f853..7a6da98a 100644 --- a/src/elm/UI/Glsl/Sphere.elm +++ b/src/elm/UI/Glsl/Sphere.elm @@ -37,12 +37,17 @@ asSphere e = let getCenter : String -> Maybe Float getCenter v = - case ( Dict.get [ ( v, 2 ) ] poly, Maybe.withDefault 0 <| Dict.get [ ( v, 1 ) ] poly ) of - ( Just s, l ) -> + case Dict.get [ ( v, 2 ) ] poly of + Just s -> if s /= 1 then Nothing else + let + l : Float + l = + Maybe.withDefault 0 <| Dict.get [ ( v, 1 ) ] poly + in Just <| -l / 2 _ -> diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm index 48dcc8ca..46ba059d 100644 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm @@ -5,7 +5,7 @@ module Glsl exposing , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) , BisectSignature , true, false, var - , unsafeDot, dot2X, dot2Y, dot3X, dot3Y, dot3Z + , dot2X, dot2Y , TypingFunction, TypedName(..), Type(..) , Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 @@ -29,7 +29,7 @@ module Glsl exposing # Utils @docs true, false, int, float, var -@docs unsafeDot, dot2X, dot2Y, dot3X, dot3Y, dot3Z +@docs dot2X, dot2Y # Typelevel types @@ -417,21 +417,6 @@ dot2Y e = unsafeDot e "y" -dot3X : Expression Vec3 -> Expression Float -dot3X e = - unsafeDot e "x" - - -dot3Y : Expression Vec3 -> Expression Float -dot3Y e = - unsafeDot e "y" - - -dot3Z : Expression Vec3 -> Expression Float -dot3Z e = - unsafeDot e "z" - - dot4XY : Expression Vec4 -> Expression Vec2 dot4XY e = unsafeDot e "xy" diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm index 6e74d554..c8c05475 100644 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm +++ b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm @@ -1,4 +1,4 @@ -module Glsl.Eval exposing (Context, Error(..), Value(..), innerInterpret, innerValue, innerValue2, interpret, value) +module Glsl.Eval exposing (Context, Error(..), Value(..), interpret, value) import Dict exposing (Dict) import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), RelationOperation(..), Stat(..), Statement(..), UnaryOperation(..)) @@ -63,49 +63,52 @@ innerValue ctx e = ) BinaryOperation And l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) BinaryOperation Or l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) Comparison k l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) Ternary _ _ _ -> Debug.todo "branch 'Ternary _ _ _' not implemented" @@ -117,29 +120,31 @@ innerValue ctx e = Debug.todo "branch 'Subtract _ _' not implemented" BinaryOperation By l r -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) BinaryOperation Div _ _ -> Debug.todo "branch 'Div _ _' not implemented" Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + innerValue2 ctx l r <| + \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) Call "exp" [ l ] -> autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l From 233911fc7e1a612f36c6048f3015ad4cdb3ba793 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 18:55:40 +0200 Subject: [PATCH 119/139] Re-vendoring elm-glsl --- Makefile | 14 +- codegen/.gitignore | 2 +- codegen/.vscode/settings.json | 3 + codegen/{src => }/Generate.elm | 489 +- codegen/elm.codegen.json | 8 +- codegen/elm.json | 16 +- codegen/helpers/Glsl/Operations.elm | 243 - codegen/helpers/Glsl/PrettyPrinter.elm | 343 - codegen/src/Glsl/Parser.elm | 504 - elm.json | 9 +- package.json | 1 + tests/GlslFuzzer.elm | 3 +- .../miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm | 435 - .../elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm | 304 - .../elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm | 980 - vendored/miniBill/elm-glsl/1.0.0/LICENSE | 1 + vendored/miniBill/elm-glsl/1.0.0/README.md | 1 + vendored/miniBill/elm-glsl/1.0.0/elm.json | 19 + vendored/miniBill/elm-glsl/1.0.0/src/Glsl.elm | 812 + .../elm-glsl/1.0.0/src/Glsl/Constants.elm | 45 + .../miniBill/elm-glsl/1.0.0/src/Glsl/Dot.elm | 176 + .../miniBill/elm-glsl/1.0.0/src/Glsl/Eval.elm | 370 + .../elm-glsl/1.0.0/src/Glsl/Functions.elm | 21191 ++++++++++++++++ .../elm-glsl/1.0.0/src/Glsl/Helpers.elm | 591 + .../elm-glsl/1.0.0/src/Glsl/Operations.elm | 320 + .../elm-glsl/1.0.0/src/Glsl/Parser.elm | 801 + .../elm-glsl/1.0.0/src/Glsl/PrettyPrinter.elm | 582 + .../elm-glsl/1.0.0/src/Glsl/Simplify.elm | 151 + .../elm-glsl/1.0.0/src}/SortedSet.elm | 0 yarn.lock | 2233 +- 30 files changed, 27662 insertions(+), 2985 deletions(-) create mode 100644 codegen/.vscode/settings.json rename codegen/{src => }/Generate.elm (72%) delete mode 100644 codegen/helpers/Glsl/Operations.elm delete mode 100644 codegen/helpers/Glsl/PrettyPrinter.elm delete mode 100644 codegen/src/Glsl/Parser.elm delete mode 100644 vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm delete mode 100644 vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm delete mode 100644 vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/LICENSE create mode 100644 vendored/miniBill/elm-glsl/1.0.0/README.md create mode 100644 vendored/miniBill/elm-glsl/1.0.0/elm.json create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Constants.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Dot.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Eval.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Operations.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/PrettyPrinter.elm create mode 100644 vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Simplify.elm rename {codegen/helpers => vendored/miniBill/elm-glsl/1.0.0/src}/SortedSet.elm (100%) diff --git a/Makefile b/Makefile index 3274c4a2..7310be55 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,21 @@ ELM_FILES = $(wildcard src/**/*.elm) -CODEGEN_FILES = $(wildcard codegen/src/*.elm) $(wildcard codegen/src/Glsl/*.elm) $(wildcard codegen/helpers/*.elm) $(wildcard codegen/helpers/*/*.elm) +CODEGEN_FILES = $(wildcard codegen/*.elm) .PHONY: build -build: generated/Glsl/Functions.elm src/optimized.js Makefile +build: generated/Glsl/Functions/NuPlot.elm src/optimized.js Makefile parcel build src/index.html --public-url . src/optimized.js: $(ELM_FILES) Makefile yarn elm-optimize-level-2 src/elm/UI.elm --output $@ -generated/Glsl/Functions.elm: codegen/functions.frag $(CODEGEN_FILES) codegen/bindings/Gen/Glsl.elm Makefile +generated/Glsl/Functions/NuPlot.elm: codegen/functions.frag codegen/Generate.elm codegen/Gen/Glsl.elm Makefile rm -rf generated - yarn elm-codegen run --flags-from $< codegen/src/Generate.elm + yarn elm-codegen run --flags-from $< codegen/Generate.elm elm-format --yes $@ -codegen/bindings/Gen/Glsl.elm: $(CODEGEN_FILES) codegen/elm.codegen.json Makefile - rm -rf codegen/bindings +codegen/Gen/Glsl.elm: codegen/Generate.elm codegen/elm.codegen.json Makefile + rm -rf codegen/Gen yarn elm-codegen install - mkdir -p codegen/bindings - mv codegen/Gen codegen/bindings/ .PHONY: clean diff --git a/codegen/.gitignore b/codegen/.gitignore index 4109df9c..1f0e079e 100644 --- a/codegen/.gitignore +++ b/codegen/.gitignore @@ -1 +1 @@ -/bindings +/Gen diff --git a/codegen/.vscode/settings.json b/codegen/.vscode/settings.json new file mode 100644 index 00000000..0c8d6f19 --- /dev/null +++ b/codegen/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.words": ["Glsl"] +} diff --git a/codegen/src/Generate.elm b/codegen/Generate.elm similarity index 72% rename from codegen/src/Generate.elm rename to codegen/Generate.elm index 00f971fd..f1082974 100644 --- a/codegen/src/Generate.elm +++ b/codegen/Generate.elm @@ -20,32 +20,40 @@ main = let file : String -> Elm.File file glsl = - Elm.fileWith [ "Glsl", "Functions" ] - { docs = - List.map - (\{ group, members } -> - Elm.docs - { group = group - , members = List.sort members - } - ) - , aliases = [] - } - (generate glsl) + generate glsl + |> List.Extra.gatherEqualsBy Tuple.first + |> List.map + (\( head, tail ) -> + let + group : List Elm.Declaration + group = + List.map Tuple.second (head :: tail) + in + case Tuple.first head of + Just groupName -> + Elm.group (Elm.docs ("#" ++ groupName) :: group) + + Nothing -> + Elm.group group + ) + |> Elm.file + [ "Glsl", "Functions", "NuPlot" ] in Generate.fromText (\glsl -> [ file glsl ]) -generate : String -> List Elm.Declaration +generate : String -> List ( Maybe String, Elm.Declaration ) generate glsl = - case parseFile glsl of + case Parser.run Glsl.Parser.file glsl of Err e -> - Gen.Debug.todo "Error parsing file" - |> Elm.declaration "err" - |> Elm.withDocumentation (errorToString e) - |> List.singleton + [ ( Nothing + , Gen.Debug.todo "Error parsing file" + |> Elm.declaration "err" + |> Elm.withDocumentation (errorToString e) + ) + ] - Ok declarations -> + Ok ( _, declarations ) -> let functions = List.filterMap @@ -56,6 +64,9 @@ generate glsl = UniformDeclaration _ -> Nothing + + ConstDeclaration _ -> + Nothing ) declarations @@ -68,6 +79,24 @@ generate glsl = FunctionDeclaration _ -> Nothing + + ConstDeclaration _ -> + Nothing + ) + declarations + + constants = + List.filterMap + (\declaration -> + case declaration of + ConstDeclaration const -> + Just const + + FunctionDeclaration _ -> + Nothing + + UniformDeclaration _ -> + Nothing ) declarations @@ -81,10 +110,11 @@ generate glsl = returnType ) { constantsEnv = - Dict.fromList - [ ( "P32M1", TInt ) - , ( "P31", TInt ) - ] + constants + |> List.map (\{ tipe, name } -> ( name, tipe )) + |> Dict.fromList + |> Dict.insert "P32M1" TInt + |> Dict.insert "P31" TInt , functionsEnv = builtinFunctions |> Dict.map @@ -96,34 +126,39 @@ generate glsl = } functions - maybeDecls : Result String (List (List Elm.Declaration)) + maybeDecls : Result String (List ( Maybe String, Elm.Declaration )) maybeDecls = Result.Extra.combineMap (functionToDeclarations env) functions + |> Result.map List.concat - uniformDecls : List Elm.Declaration + uniformDecls : List ( Maybe String, Elm.Declaration ) uniformDecls = List.map uniformToDeclaration uniforms in case maybeDecls of Ok decls -> - List.concat decls ++ builtinDecls ++ uniformDecls + decls ++ builtinDecls ++ uniformDecls Err e -> - "Error generating file" - |> Gen.Debug.todo - |> Elm.declaration "err" - |> Elm.withDocumentation e - |> List.singleton + [ ( Nothing + , "Error generating file" + |> Gen.Debug.todo + |> Elm.declaration "err" + |> Elm.withDocumentation e + ) + ] -uniformToDeclaration : Uniform -> Elm.Declaration +uniformToDeclaration : Uniform -> ( Maybe String, Elm.Declaration ) uniformToDeclaration { name, tipe } = - Gen.Glsl.var name + ( Just "uniforms" + , Gen.Glsl.unsafeVar name |> Elm.withType (Gen.Glsl.annotation_.expression (typeToAnnotation tipe)) |> Elm.declaration name - |> Elm.exposeWith { exposeConstructor = False, group = Just "uniforms" } + |> Elm.expose + ) functionHasType : String -> List Type -> Type -> Env -> Env @@ -196,7 +231,7 @@ type alias Env = } -functionToDeclarations : Env -> Function -> Result String (List Elm.Declaration) +functionToDeclarations : Env -> Function -> Result String (List ( Maybe String, Elm.Declaration )) functionToDeclarations env function = let fname = @@ -213,15 +248,19 @@ functionToDeclarations env function = in Result.map (\deps -> - [ Elm.string function.body - |> Elm.declaration (fname ++ "Body") + [ ( Nothing + , function.stat + |> Glsl.PrettyPrinter.stat 0 + |> Elm.string + |> Elm.declaration (fname ++ "Body") + ) , wrapFunction function.name (SortedSet.insert fname deps) function.args function.returnType ] ) maybeDeps -wrapFunction : String -> SortedSet String -> List ( Type, String ) -> Type -> Elm.Declaration +wrapFunction : String -> SortedSet String -> List ( Type, String ) -> Type -> ( Maybe String, Elm.Declaration ) wrapFunction name deps args returnType = let fname = @@ -270,21 +309,18 @@ wrapFunction name deps args returnType = argValues |> Elm.withType (Gen.Glsl.annotation_.expression (typeToAnnotation returnType)) in - Elm.function argDecls expr + ( if + List.member (String.left 1 name) [ "g", "i", "c" ] + && not (List.member name [ "cbrt", "increment", "cosh", "is_even", "is_odd" ]) + then + Just (String.dropLeft 1 name) + + else + Just name + , Elm.function argDecls expr |> Elm.declaration fname - |> Elm.exposeWith - { exposeConstructor = False - , group = - Just <| - if - List.member (String.left 1 name) [ "g", "i", "c" ] - && not (List.member name [ "cbrt", "increment", "cosh", "is_even", "is_odd" ]) - then - String.dropLeft 1 name - - else - name - } + |> Elm.expose + ) typeToAnnotation : Type -> Type.Annotation @@ -305,18 +341,27 @@ typeToAnnotation type_ = TIVec2 -> Gen.Glsl.annotation_.iVec2 + TBVec2 -> + Gen.Glsl.annotation_.bVec2 + TVec3 -> Gen.Glsl.annotation_.vec3 TIVec3 -> Gen.Glsl.annotation_.iVec3 + TBVec3 -> + Gen.Glsl.annotation_.bVec3 + TVec4 -> Gen.Glsl.annotation_.vec4 TIVec4 -> Gen.Glsl.annotation_.iVec4 + TBVec4 -> + Gen.Glsl.annotation_.bVec4 + TMat3 -> Gen.Glsl.annotation_.mat3 @@ -329,6 +374,81 @@ typeToAnnotation type_ = TOut tt -> Gen.Glsl.annotation_.out (typeToAnnotation tt) + TUint -> + Debug.todo "branch 'TUint' not implemented" + + TUVec2 -> + Debug.todo "branch 'TUVec2' not implemented" + + TUVec3 -> + Debug.todo "branch 'TUVec3' not implemented" + + TUVec4 -> + Debug.todo "branch 'TUVec4' not implemented" + + TDouble -> + Debug.todo "branch 'TDouble' not implemented" + + TDVec2 -> + Debug.todo "branch 'TDVec2' not implemented" + + TDVec3 -> + Debug.todo "branch 'TDVec3' not implemented" + + TDVec4 -> + Debug.todo "branch 'TDVec4' not implemented" + + TMat2 -> + Debug.todo "branch 'TMat2' not implemented" + + TMat4 -> + Debug.todo "branch 'TMat4' not implemented" + + TMat23 -> + Debug.todo "branch 'TMat23' not implemented" + + TMat24 -> + Debug.todo "branch 'TMat24' not implemented" + + TMat32 -> + Debug.todo "branch 'TMat32' not implemented" + + TMat34 -> + Debug.todo "branch 'TMat34' not implemented" + + TMat42 -> + Debug.todo "branch 'TMat42' not implemented" + + TMat43 -> + Debug.todo "branch 'TMat43' not implemented" + + TDMat2 -> + Debug.todo "branch 'TDMat2' not implemented" + + TDMat3 -> + Debug.todo "branch 'TDMat3' not implemented" + + TDMat4 -> + Debug.todo "branch 'TDMat4' not implemented" + + TDMat23 -> + Debug.todo "branch 'TDMat23' not implemented" + + TDMat24 -> + Debug.todo "branch 'TDMat24' not implemented" + + TDMat32 -> + Debug.todo "branch 'TDMat32' not implemented" + + TDMat34 -> + Debug.todo "branch 'TDMat34' not implemented" + + TDMat42 -> + Debug.todo "branch 'TDMat42' not implemented" + + TDMat43 -> + Debug.todo "branch 'TDMat43' not implemented" + variableHasType : String -> Type -> Env -> Env variableHasType var type_ env = @@ -343,55 +463,47 @@ union = findDepsStatement : Env -> Stat -> Result String (SortedSet String) findDepsStatement env statement = case statement of - If cond true cont -> + If cond true -> union [ findDepsExpression env cond , findDepsStatement env true - , findDepsStatement env cont ] - IfElse cond true false cont -> + IfElse cond true false -> union [ findDepsExpression env cond , findDepsStatement env true , findDepsStatement env false - , findDepsStatement env cont ] - ExpressionStatement e cont -> - union - [ findDepsExpression env e - , findDepsStatement env cont - ] + ExpressionStatement e -> + findDepsExpression env e - For var from _ to _ step cont -> - let - newEnv : Env - newEnv = - variableHasType var TInt env - in + For from cond step loop -> union - [ findDepsExpression env from - , findDepsExpression env to - , findDepsStatement newEnv step - , findDepsStatement env cont + [ case from of + Just f -> + findDepsStatement env f + + Nothing -> + Ok SortedSet.empty + , findDepsExpression env cond + , findDepsExpression env step + , findDepsStatement env loop ] Return e -> findDepsExpression env e - Decl type_ var maybeVal cont -> + Decl type_ var maybeVal -> let newEnv : Env newEnv = variableHasType var type_ env in - union - [ maybeVal - |> Maybe.map (findDepsExpression env) - |> Maybe.withDefault (Ok SortedSet.empty) - , findDepsStatement newEnv cont - ] + maybeVal + |> Maybe.map (findDepsExpression newEnv) + |> Maybe.withDefault (Ok SortedSet.empty) Nop -> Ok SortedSet.empty @@ -402,6 +514,9 @@ findDepsStatement env statement = Continue -> Ok SortedSet.empty + Block l m r -> + union (List.map (findDepsStatement env) (l :: m :: r)) + findDepsExpression : Env -> Expr -> Result String (SortedSet String) findDepsExpression env = @@ -415,6 +530,12 @@ findDepsExpression env = Int _ -> Ok ( TInt, SortedSet.empty ) + Uint _ -> + Ok ( TInt, SortedSet.empty ) + + Double _ -> + Ok ( TInt, SortedSet.empty ) + Bool _ -> Ok ( TBool, SortedSet.empty ) @@ -460,7 +581,7 @@ findDepsExpression env = Just t -> Ok ( t, SortedSet.empty ) - Call f args -> + Call (Variable f) args -> args |> Result.Extra.combineMap go |> Result.map List.unzip @@ -485,23 +606,8 @@ findDepsExpression env = Ok ( to, deps ) ) - Array l r -> - Result.andThen - (\( ( lt, ld ), ( rt, rd ) ) -> - Result.map - (\t -> ( t, SortedSet.insertAll ld rd )) - (case ( lt, rt ) of - ( TVec3, TInt ) -> - Ok TFloat - - _ -> - Err <| "Don't know what the result of " ++ Glsl.PrettyPrinter.type_ lt ++ "[" ++ Glsl.PrettyPrinter.type_ rt ++ "] is" - ) - ) - (Result.map2 Tuple.pair - (go l) - (go r) - ) + Call _ _ -> + Err "Complex calls are not supported yet" Ternary c t f -> Result.map3 @@ -518,7 +624,7 @@ findDepsExpression env = UnaryOperation _ e -> go e - BinaryOperation bop l r -> + BinaryOperation l bop r -> Result.andThen (\( ( lt, ld ), ( rt, rd ) ) -> Result.map @@ -548,28 +654,6 @@ findDepsExpression env = (go l) (go r) ) - - Comparison _ l r -> - Result.map2 - (\( _, ld ) ( _, rd ) -> - ( TBool, SortedSet.insertAll ld rd ) - ) - (go l) - (go r) - - PostfixIncrement e -> - go e - - PostfixDecrement e -> - go e - - AssignCombo _ l r -> - Result.map2 - (\( lt, ld ) ( _, rd ) -> - ( lt, SortedSet.insertAll ld rd ) - ) - (go l) - (go r) in go >> Result.map Tuple.second @@ -595,6 +679,69 @@ binaryOperationToString bop = Or -> "||" + ArraySubscript -> + "[]" + + Mod -> + "%" + + ShiftLeft -> + "<<" + + ShiftRight -> + ">>" + + RelationOperation _ -> + Debug.todo "branch 'RelationOperation _' not implemented" + + BitwiseAnd -> + "&" + + BitwiseOr -> + "|" + + BitwiseXor -> + "^" + + Xor -> + "^^" + + Assign -> + "=" + + ComboAdd -> + "+=" + + ComboSubtract -> + "-=" + + ComboBy -> + "*=" + + ComboDiv -> + "/=" + + ComboMod -> + "%=" + + ComboLeftShift -> + "<<=" + + ComboRightShift -> + ">>=" + + ComboBitwiseAnd -> + "&=" + + ComboBitwiseXor -> + "^=" + + ComboBitwiseOr -> + "|=" + + Comma -> + "," + fullName : String -> List Type -> String fullName baseName argTypes = @@ -610,33 +757,117 @@ typeToShort t = TInt -> "i1" + TBool -> + "b1" + + TUint -> + "u1" + + TDouble -> + "d1" + TVec2 -> "2" TIVec2 -> "i2" + TBVec2 -> + "b2" + + TUVec2 -> + "u2" + + TDVec2 -> + "d2" + TVec3 -> "3" TIVec3 -> "i3" + TBVec3 -> + "b3" + + TUVec3 -> + "u3" + + TDVec3 -> + "d3" + TVec4 -> "4" TIVec4 -> "i4" + TBVec4 -> + "b4" + + TUVec4 -> + "u4" + + TDVec4 -> + "d4" + + TMat2 -> + "m2" + + TDMat2 -> + "dm2" + + TMat23 -> + "m23" + + TDMat23 -> + "dm23" + + TMat24 -> + "m24" + + TDMat24 -> + "dm24" + + TMat32 -> + "m32" + + TDMat32 -> + "dm32" + + TMat42 -> + "m42" + + TDMat42 -> + "dm42" + TMat3 -> "m3" + TDMat3 -> + "dm3" + + TMat34 -> + "m34" + + TDMat34 -> + "dm34" + + TMat43 -> + "m43" + + TDMat43 -> + "dm43" + + TMat4 -> + "m4" + + TDMat4 -> + "dm4" + TVoid -> "v" - TBool -> - "b1" - TIn tt -> "n" ++ typeToShort tt @@ -920,13 +1151,14 @@ builtin_vvv_v = ) -builtinDecls : List Elm.Declaration +builtinDecls : List ( Maybe String, Elm.Declaration ) builtinDecls = builtinFunctions |> Dict.toList |> List.map (\( _, { baseName, args, return } ) -> - wrapFunction + ( Just baseName + , wrapFunction baseName SortedSet.empty (List.indexedMap @@ -934,15 +1166,12 @@ builtinDecls = args ) return - |> Elm.exposeWith { exposeConstructor = False, group = Just baseName } + |> Tuple.second + |> Elm.expose + ) ) indexedVar : Int -> String indexedVar i = String.fromChar <| Char.fromCode <| Char.toCode 'a' + i - - -parseFile : String -> Result (List Parser.DeadEnd) (List Declaration) -parseFile glsl = - Parser.run Glsl.Parser.file glsl diff --git a/codegen/elm.codegen.json b/codegen/elm.codegen.json index 40850565..c473e5bb 100644 --- a/codegen/elm.codegen.json +++ b/codegen/elm.codegen.json @@ -1,11 +1,9 @@ { - "elm-codegen-version": "0.2.0", + "elm-codegen-version": "0.6.1", "codegen-helpers": { "packages": { "elm/core": "1.0.5" }, - "local": [ - "codegen/helpers/" - ] + "local": ["vendored/miniBill/elm-glsl/1.0.0/src"] } -} \ No newline at end of file +} diff --git a/codegen/elm.json b/codegen/elm.json index 02ccb1d8..d5eb426a 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -1,6 +1,9 @@ { "type": "application", - "source-directories": ["src", "helpers", "bindings"], + "source-directories": [ + ".", + "../vendored/miniBill/elm-glsl/1.0.0/src" + ], "elm-version": "0.19.1", "dependencies": { "direct": { @@ -9,23 +12,22 @@ "elm/html": "1.0.0", "elm/json": "1.1.3", "elm/parser": "1.1.0", - "elm-community/list-extra": "8.6.0", + "elm-community/list-extra": "8.7.0", "elm-community/result-extra": "2.4.0", - "mdgriffith/elm-codegen": "2.0.0", + "mdgriffith/elm-codegen": "5.2.0", "mdgriffith/elm-ui": "1.1.8", "pithub/elm-parser-bug-workaround": "1.0.0" }, "indirect": { "elm/time": "1.0.0", "elm/url": "1.0.0", - "elm/virtual-dom": "1.0.2", + "elm/virtual-dom": "1.0.3", "elm-community/basics-extra": "4.1.0", - "miniBill/elm-unicode": "1.0.2", "pithub/elm-parser-extra": "1.0.0", "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.9", + "stil4m/elm-syntax": "7.3.8", "stil4m/structured-writer": "1.0.3", - "the-sett/elm-pretty-printer": "3.0.0" + "the-sett/elm-pretty-printer": "3.1.1" } }, "test-dependencies": { diff --git a/codegen/helpers/Glsl/Operations.elm b/codegen/helpers/Glsl/Operations.elm deleted file mode 100644 index ef8d6f63..00000000 --- a/codegen/helpers/Glsl/Operations.elm +++ /dev/null @@ -1,243 +0,0 @@ -module Glsl.Operations exposing - ( add11, add22, add33, add44 - , subtract11, subtract22, subtract33, subtract44 - , negate1, negate2, negate3, negate4 - , by11, by22, by33, by44 - , by12, by13 - , by31 - , div11, div22, div33, div44 - , array33 - , lt, eq, gt - ) - -{-| - - -# Addition - -@docs add11, add22, add33, add44 - - -# Subtraction - -@docs subtract11, subtract22, subtract33, subtract44 - - -# Negate - -@docs negate1, negate2, negate3, negate4 - - -# Multiplication - -@docs by11, by22, by33, by44 -@docs by12, by13 -@docs by31 - - -# Division - -@docs div11, div22, div33, div44 - - -# Array access - -@docs array33 - - -# Comparison - -@docs lt, eq, gt - --} - -import Expression exposing (BinaryOperation(..)) -import Glsl exposing (BinaryOperation(..), Expr(..), Expression, Mat3, RelationOperation(..), UnaryOperation(..), Vec2, Vec3, Vec4) - - - --- Addition - - -add11 : Expression Float -> Expression Float -> Expression Float -add11 = - add - - -add22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -add22 = - add - - -add33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -add33 = - add - - -add44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -add44 = - add - - -add : Expression a -> Expression a -> Expression a -add l r = - Glsl.unsafeMap2 (BinaryOperation Add) l r - - - --- Subtraction - - -subtract11 : Expression Float -> Expression Float -> Expression Float -subtract11 = - subtract - - -subtract22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -subtract22 = - subtract - - -subtract33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -subtract33 = - subtract - - -subtract44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -subtract44 = - subtract - - -subtract : Expression a -> Expression a -> Expression a -subtract l r = - Glsl.unsafeMap2 (BinaryOperation Subtract) l r - - - --- Negation - - -negate1 : Expression Float -> Expression Float -negate1 = - negate - - -negate2 : Expression Vec2 -> Expression Vec2 -negate2 = - negate - - -negate3 : Expression Vec3 -> Expression Vec3 -negate3 = - negate - - -negate4 : Expression Vec4 -> Expression Vec4 -negate4 = - negate - - -negate : Expression a -> Expression a -negate l = - Glsl.unsafeMap (UnaryOperation Negate) l - - - --- Multiplication - - -by11 : Expression Float -> Expression Float -> Expression Float -by11 = - by - - -by22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -by22 = - by - - -by33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -by33 = - by - - -by44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -by44 = - by - - -by12 : Expression Float -> Expression Vec2 -> Expression Vec2 -by12 l r = - Glsl.unsafeMap2 (BinaryOperation By) l r - - -by13 : Expression Float -> Expression Vec3 -> Expression Vec3 -by13 l r = - Glsl.unsafeMap2 (BinaryOperation By) l r - - -by31 : Expression Vec3 -> Expression Float -> Expression Vec3 -by31 l r = - Glsl.unsafeMap2 (BinaryOperation By) l r - - -by : Expression a -> Expression a -> Expression a -by l r = - Glsl.unsafeMap2 (BinaryOperation By) l r - - - --- Division - - -div11 : Expression Float -> Expression Float -> Expression Float -div11 = - div - - -div22 : Expression Vec2 -> Expression Vec2 -> Expression Vec2 -div22 = - div - - -div33 : Expression Vec3 -> Expression Vec3 -> Expression Vec3 -div33 = - div - - -div44 : Expression Vec4 -> Expression Vec4 -> Expression Vec4 -div44 = - div - - -div : Expression a -> Expression a -> Expression a -div l r = - Glsl.unsafeMap2 (BinaryOperation Div) l r - - - --- Array access - - -array33 : Expression Mat3 -> Expression Int -> Expression Vec3 -array33 = - Glsl.unsafeMap2 Array - - - --- Comparisons - - -lt : Expression Float -> Expression Float -> Expression Bool -lt = - Glsl.unsafeMap2 (Comparison LessThan) - - -gt : Expression Float -> Expression Float -> Expression Bool -gt = - Glsl.unsafeMap2 (Comparison GreaterThan) - - -eq : Expression t -> Expression t -> Expression Bool -eq = - Glsl.unsafeMap2 (Comparison Equals) diff --git a/codegen/helpers/Glsl/PrettyPrinter.elm b/codegen/helpers/Glsl/PrettyPrinter.elm deleted file mode 100644 index b1fdb617..00000000 --- a/codegen/helpers/Glsl/PrettyPrinter.elm +++ /dev/null @@ -1,343 +0,0 @@ -module Glsl.PrettyPrinter exposing (float, type_) - -import Glsl exposing (Type(..)) - - - --- function : Function -> String --- function fun = --- if fun.hasSuffix then --- "(" --- ++ fun.name --- ++ "Decl, " --- ++ fun.name --- ++ ") = fun" --- ++ String.fromInt (List.length fun.args) --- ++ " " --- ++ type_ fun.returnType --- ++ "T " --- ++ "(\"" --- ++ fun.name --- ++ "\" ++ suffix)" --- ++ " " --- ++ String.join " " (List.map (\( t, n ) -> "(" ++ type_ t ++ "T \"" ++ n ++ "\")") fun.args) --- ++ " <| \\" --- ++ String.join " " (List.map Tuple.second fun.args) --- ++ " -> " --- ++ (statement fun.stat |> String.split "\n" |> String.join " ") --- else --- fun.name --- ++ "Couple = fun" --- ++ String.fromInt (List.length fun.args) --- ++ " " --- ++ type_ fun.returnType --- ++ "T \"" --- ++ fun.name --- ++ "\" " --- ++ String.join " " (List.map (\( t, n ) -> "(" ++ type_ t ++ "T \"" ++ n ++ "\")") fun.args) --- ++ " <| \\" --- ++ String.join " " (List.map Tuple.second fun.args) --- ++ " ->\n " --- ++ (statement fun.stat |> String.split "\n" |> String.join "\n ") --- ++ "\n\n" --- ++ fun.name --- ++ "Decl = Tuple.first " --- ++ fun.name --- ++ "Couple\n" --- ++ fun.name --- ++ " = Tuple.second " --- ++ fun.name --- ++ "Couple" --- statement : Statement -> String --- statement stat = --- case stat of --- Expression e next -> --- "expr " --- ++ prettyToGlslExpression e --- ++ " <| \\_ ->\n" --- ++ statement next --- For { var, from, op, to, step, direction } next -> --- case op of --- LessThan -> --- (if direction == PlusPlus then --- "for (\"" --- else --- "forDown (\"" --- ) --- ++ var --- ++ "\", " --- ++ prettyToGlslExpression from --- ++ ", " --- ++ prettyToGlslExpression to --- ++ ") (\\" --- ++ var --- ++ " ->\n" --- ++ statement step --- ++ ") <| \\_ ->\n" --- ++ statement next --- LessThanOrEquals -> --- (if direction == PlusPlus then --- "forLeq (\"" --- else --- "forLeqDown (\"" --- ) --- ++ var --- ++ ", " --- ++ prettyToGlslExpression from --- ++ ", " --- ++ prettyToGlslExpression to --- ++ ") (\\" --- ++ var --- ++ " ->\n" --- ++ statement step --- ++ ") <| \\_ ->\n" --- ++ statement next --- GreaterThan -> --- (if direction == PlusPlus then --- "for (\"" --- else --- "forDown (\"" --- ) --- ++ var --- ++ "\", " --- ++ prettyToGlslExpression from --- ++ ", " --- ++ prettyToGlslExpression to --- ++ ") (\\" --- ++ var --- ++ " ->\n" --- ++ statement step --- ++ ") <| \\_ ->\n" --- ++ statement next --- GreaterThanOrEquals -> --- (if direction == PlusPlus then --- "forLeq (\"" --- else --- "forLeqDown (\"" --- ) --- ++ var --- ++ ", " --- ++ prettyToGlslExpression from --- ++ ", " --- ++ prettyToGlslExpression to --- ++ ") (\\" --- ++ var --- ++ " ->\n" --- ++ statement step --- ++ ") <| \\_ ->\n" --- ++ statement next --- Equals -> --- "TODO branch 'Equals' not implemented" --- NotEquals -> --- "TODO branch 'NotEquals' not implemented" --- Assign -> --- "TODO branch 'Assign' not implemented" --- If cond ifTrue next -> --- "if_ " --- ++ prettyToGlslExpression cond --- ++ "(\n" --- ++ statement ifTrue --- ++ ") <| \\_ ->\n" --- ++ statement next --- Return e -> --- "(return <| " ++ prettyToGlslExpression e ++ ")\n" --- Nop -> --- "nop\n" --- Def { type_, var, val } next -> --- "def " --- ++ type_ type_ --- ++ "T \"" --- ++ var --- ++ "\" (" --- ++ prettyToGlslExpression val --- ++ ") <| \\" --- ++ var --- ++ " -> \n" --- ++ statement next --- Decl _ _ -> --- "TODO branch 'Decl _ _ _' not implemented" - - -type_ : Type -> String -type_ t = - case t of - TFloat -> - "float" - - TInt -> - "int" - - TVec2 -> - "vec2" - - TIVec2 -> - "ivec2" - - TVec3 -> - "vec3" - - TIVec3 -> - "ivec3" - - TVec4 -> - "vec4" - - TIVec4 -> - "ivec4" - - TMat3 -> - "mat3" - - TVoid -> - "void" - - TBool -> - "bool" - - TIn tt -> - "in " ++ type_ tt - - TOut tt -> - "out " ++ type_ tt - - - --- prettyToGlslExpression : Expression -> String --- prettyToGlslExpression e = --- let --- parens args = --- "(" ++ String.join " " args ++ ")" --- in --- case e of --- Float f -> --- if f == 0 then --- "zero" --- else if f == 1 then --- "one" --- else --- parens [ "float", String.fromFloat f ] --- Int i -> --- parens [ "int", String.fromInt i ] --- Bool b -> --- parens --- [ "bool" --- , if b then --- "True" --- else --- "False" --- ] --- Dot v sw -> --- prettyToGlslExpression v ++ "." ++ sw --- Variable v -> --- v --- Constant c -> --- case String.split "_" c of --- [] -> --- "constants.???" --- h :: t -> --- let --- toTitle s = --- case String.uncons s of --- Nothing -> --- "" --- Just ( sh, st ) -> --- String.cons (Char.toUpper sh) (String.toLower st) --- in --- "constants." ++ String.toLower h ++ String.concat (List.map toTitle t) --- Call "float" [ arg ] -> --- parens [ "floatCast", prettyToGlslExpression arg ] --- Call n args -> --- if String.startsWith "vec" n then --- if List.all ((==) (Int 0)) args then --- n ++ "Zero" --- else --- parens <| --- n --- :: List.map --- (\c -> --- case c of --- Int i -> --- prettyToGlslExpression (Float <| toFloat i) --- _ -> --- prettyToGlslExpression c --- ) --- args --- else if n == "atan" then --- if List.length args == 2 then --- parens <| "atan2_" :: List.map prettyToGlslExpression args --- else --- parens <| "atan_" :: List.map prettyToGlslExpression args --- else if List.member n [ "sin", "cos", "radians", "round", "floor", "ceil", "sqrt" ] then --- parens <| (n ++ "_") :: List.map prettyToGlslExpression args --- else --- parens <| n :: List.map prettyToGlslExpression args --- Arr l r -> --- parens [ "arr", prettyToGlslExpression l, prettyToGlslExpression r ] --- Ternary c l r -> --- parens [ "ternary\n", prettyToGlslExpression c, prettyToGlslExpression l, prettyToGlslExpression r ] --- UnaryOperation Negate ex -> --- parens [ "negate_", prettyToGlslExpression ex ] --- BinaryOperation op l r -> --- parens [ prettyPrintBinaryOperation op, prettyToGlslExpression l, prettyToGlslExpression r ] --- BooleanOperation op es -> --- parens --- [ prettyPrintBooleanOperation op --- , "[" --- , String.join ", " <| List.map prettyToGlslExpression es --- , "]" --- ] --- RelationOperation rop l r -> --- parens [ prettyPrintRelationOperation rop, prettyToGlslExpression l, prettyToGlslExpression r ] --- PostfixIncrement c -> --- parens [ "postfixIncrement", prettyToGlslExpression c ] --- PostfixDecrement c -> --- parens [ "postfixDecrement", prettyToGlslExpression c ] --- prettyPrintRelationOperation : RelationOperation -> String --- prettyPrintRelationOperation op = --- case op of --- LessThan -> --- "lt" --- LessThanOrEquals -> --- "leq" --- Equals -> --- "eq" --- Assign -> --- "assign" --- NotEquals -> --- "neq" --- GreaterThanOrEquals -> --- "geq" --- GreaterThan -> --- "gt" --- prettyPrintBooleanOperation : BooleanOperation -> String --- prettyPrintBooleanOperation op = --- case op of --- And -> --- "ands" --- Or -> --- "ors" --- prettyPrintBinaryOperation : BinaryOperation -> String --- prettyPrintBinaryOperation op = --- case op of --- Add -> --- "add" --- Subtract -> --- "subtract" --- By -> --- "by" --- Div -> --- "div" - - -float : Float -> String -float f = - let - s : String - s = - String.fromFloat f - in - if String.contains "." s || String.contains "e" s then - s - - else - s ++ "." diff --git a/codegen/src/Glsl/Parser.elm b/codegen/src/Glsl/Parser.elm deleted file mode 100644 index bfd11990..00000000 --- a/codegen/src/Glsl/Parser.elm +++ /dev/null @@ -1,504 +0,0 @@ -module Glsl.Parser exposing (file, function, statement) - -import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), ForDirection(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, keyword, loop, oneOf, problem, sequence, spaces, succeed, symbol) -import Parser.Workaround - - -function : Parser Declaration -function = - succeed - (\glsl begin returnType { name, hasSuffix } args stat end -> - let - res : Function - res = - { returnType = returnType - , name = name - , hasSuffix = hasSuffix - , args = args - , stat = stat - , body = String.slice begin end glsl - } - in - FunctionDeclaration res - ) - |= Parser.getSource - |= Parser.getOffset - |= typeParser - |. spaces - |= identifierWithSuffixParser - |. spaces - |= sequence - { start = "(" - , end = ")" - , spaces = spaces - , separator = "," - , item = argParser - , trailing = Forbidden - } - |. spaces - |= statement - |= Parser.getOffset - - -uniform : Parser Declaration -uniform = - succeed - (\tipe name -> - UniformDeclaration - { tipe = tipe - , name = name - } - ) - |. symbol "uniform" - |. spaces - |= typeParser - |. spaces - |= identifierParser - |. spaces - |. symbol ";" - - -argParser : Parser ( Type, String ) -argParser = - succeed Tuple.pair - |= typeParser - |. spaces - |= identifierParser - - -identifierWithSuffixParser : Parser { name : String, hasSuffix : Bool } -identifierWithSuffixParser = - succeed (\name hasSuffix -> { name = name, hasSuffix = hasSuffix }) - |= identifierParser - |= oneOf - [ succeed True |. symbol "\"\"\" ++ suffix ++ \"\"\"" - , succeed False - ] - - -identifierParser : Parser String -identifierParser = - getChompedString - (succeed () - |. chompIf (\c -> Char.isAlpha c || c == '_') - |. chompWhile (\c -> Char.isAlphaNum c || c == '_') - ) - - -typeParser : Parser Type -typeParser = - let - baseParser = - [ ( "void", TVoid ) - , ( "bool", TBool ) - , ( "float", TFloat ) - , ( "int", TInt ) - , ( "vec2", TVec2 ) - , ( "ivec2", TIVec2 ) - , ( "vec3", TVec3 ) - , ( "vec4", TVec4 ) - , ( "mat3", TMat3 ) - ] - |> List.map (\( s, t ) -> succeed t |. keyword s) - |> oneOf - in - oneOf - [ succeed TOut - |. keyword "out" - |. spaces - |= baseParser - , succeed TIn - |. keyword "in" - |. spaces - |= baseParser - , baseParser - ] - - -statement : Parser Stat -statement = - Parser.lazy <| - \_ -> - oneOf - [ commentParser - , blockParser - , returnParser - , ifParser - , forParser - , defParser - , expressionStatementParser - ] - - -expressionStatementParser : Parser Stat -expressionStatementParser = - Parser.succeed ExpressionStatement - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |= maybeStatementParser - - -ifParser : Parser Stat -ifParser = - Parser.succeed If - |. symbol "if" - |. spaces - |. symbol "(" - |. spaces - |= expressionParser - |. spaces - |. symbol ")" - |. spaces - |= statement - |. spaces - |= maybeStatementParser - - -maybeStatementParser : Parser Stat -maybeStatementParser = - oneOf [ statement, succeed Nop ] - - -forParser : Parser Stat -forParser = - Parser.succeed For - |. symbol "for" - |. spaces - |. symbol "(" - |. spaces - |. symbol "int" - |. spaces - |= identifierParser - |. spaces - |. symbol "=" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |. identifierParser - |. spaces - |= relationOperationParser - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |. identifierParser - |. spaces - |= oneOf - [ succeed PlusPlus |. symbol "++" - , succeed MinusMinus |. symbol "--" - ] - |. spaces - |. symbol ")" - |. spaces - |= statement - |. spaces - |= maybeStatementParser - - -returnParser : Parser Stat -returnParser = - Parser.succeed Return - |. symbol "return" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - - -commentParser : Parser Stat -commentParser = - Parser.succeed identity - |. Parser.Workaround.lineCommentAfter "//" - |. spaces - |= maybeStatementParser - - -blockParser : Parser Stat -blockParser = - Parser.succeed identity - |. symbol "{" - |. spaces - |= maybeStatementParser - |. spaces - |. symbol "}" - - -defParser : Parser Stat -defParser = - succeed - (\type_ var val -> - Decl type_ var (Just val) - ) - |= typeParser - |. spaces - |= identifierParser - |. spaces - |. symbol "=" - |. spaces - |= expressionParser - |. spaces - |. symbol ";" - |. spaces - |= maybeStatementParser - - -expressionParser : Parser Expr -expressionParser = - ternaryParser - - -ternaryParser : Parser Expr -ternaryParser = - Parser.succeed (\k f -> f k) - |= booleanParser - |. spaces - |= oneOf - [ succeed (\t f c -> Ternary c t f) - -- c is passed in last in the lambda because it's passed - -- from above - |. symbol "?" - |. spaces - |= booleanParser - |. spaces - |. symbol ":" - |. spaces - |= Parser.lazy (\_ -> ternaryParser) - , succeed identity - ] - - -booleanParser : Parser Expr -booleanParser = - multiSequence - { separators = - [ ( BinaryOperation Or, symbol "||" ) - , ( BinaryOperation And, symbol "&&" ) - ] - , item = relationParser - , allowNegation = False - } - - -relationParser : Parser Expr -relationParser = - let - inner = - succeed (\a f -> f a) - |= addsubtractionParser - |. spaces - |= oneOf - [ succeed (\o r l -> succeed <| Comparison o l r) - |= relationOperationParser - |. spaces - |= addsubtractionParser - , succeed succeed - ] - in - Parser.andThen identity inner - - -relationOperationParser : Parser RelationOperation -relationOperationParser = - oneOf - [ succeed LessThanOrEquals |. symbol "<=" - , succeed GreaterThanOrEquals |. symbol ">=" - , succeed LessThan |. symbol "<" - , succeed GreaterThan |. symbol ">" - , succeed Equals |. symbol "==" - , succeed NotEquals |. symbol "!=" - , succeed Assign |. symbol "=" - ] - - -addsubtractionParser : Parser Expr -addsubtractionParser = - multiSequence - { separators = - [ ( BinaryOperation Add, symbol "+" ) - , ( BinaryOperation Subtract, symbol "-" ) - ] - , item = multidivisionParser - , allowNegation = False - } - - -type alias SequenceData = - { separators : List ( Expr -> Expr -> Expr, Parser () ) - , item : Parser Expr - , allowNegation : Bool - } - - -multiSequence : SequenceData -> Parser Expr -multiSequence data = - succeed identity - |= data.item - |. spaces - |> Parser.andThen - (\first -> - loop first (\expr -> multiSequenceHelp data expr) - ) - - -multiSequenceHelp : - SequenceData - -> Expr - -> Parser (Step Expr Expr) -multiSequenceHelp { allowNegation, separators, item } acc = - let - separated = - separators - |> List.map - (\( f, parser ) -> - Parser.succeed (\mn e -> Loop <| f acc <| mn e) - |= (if allowNegation then - Parser.oneOf - [ Parser.succeed (UnaryOperation Negate) - |. Parser.symbol "-" - , Parser.succeed identity - ] - - else - Parser.succeed identity - ) - |. parser - |. spaces - |= item - |. spaces - ) - |> Parser.oneOf - in - Parser.oneOf - [ separated - , Parser.succeed (Done acc) - ] - - -multidivisionParser : Parser Expr -multidivisionParser = - multiSequence - { separators = - [ ( BinaryOperation By, symbol "*" ) - , ( BinaryOperation Div, symbol "/" ) - ] - , item = unaryParser - , allowNegation = False - } - - -unaryParser : Parser Expr -unaryParser = - Parser.oneOf - [ succeed (UnaryOperation Negate) - |. symbol "-" - |= atomParser - , atomParser - ] - - -atomParser : Parser Expr -atomParser = - succeed (\a f -> f a) - |= oneOf - [ succeed (\a f -> f a) - |. symbol "(" - |. spaces - |= Parser.lazy (\_ -> expressionParser) - |. spaces - |. symbol ")" - |= maybeDot - , succeed (Bool True) |. symbol "true" - , succeed (Bool False) |. symbol "false" - , succeed (\a f md -> md <| f a) - |= Parser.map .name identifierWithSuffixParser - |. spaces - |= oneOf - [ succeed (\args v -> Call v args) - |= sequence - { start = "(" - , separator = "," - , item = Parser.lazy <| \_ -> expressionParser - , end = ")" - , trailing = Forbidden - , spaces = spaces - } - , succeed (\arg v -> Array (Variable v) arg) - |. symbol "[" - |. spaces - |= Parser.lazy (\_ -> expressionParser) - |. spaces - |. symbol "]" - , succeed Variable - ] - |= maybeDot - , Parser.andThen tryParseNumber <| - getChompedString <| - succeed () - |. chompIf (\c -> c == '.' || Char.isDigit c) - |. chompWhile (\c -> c == '.' || Char.isDigit c) - ] - |. spaces - |= oneOf - [ succeed PostfixIncrement - |. symbol "++" - , succeed PostfixDecrement - |. symbol "--" - , succeed identity - ] - - -maybeDot : Parser (Expr -> Expr) -maybeDot = - oneOf - [ succeed (\p v -> Dot v p) - |. symbol "." - |= identifierParser - , succeed identity - ] - - -tryParseNumber : String -> Parser Expr -tryParseNumber n = - case String.toInt n of - Just i -> - succeed <| Int i - - Nothing -> - case String.toFloat n of - Just f -> - succeed <| Float f - - Nothing -> - problem "Expected a number" - - -file : Parser (List Declaration) -file = - Parser.succeed (List.filterMap identity) - |= Parser.sequence - { start = "" - , separator = "" - , item = - Parser.oneOf - [ Parser.succeed Nothing - |. Parser.Workaround.lineCommentAfter "//" - , Parser.succeed Nothing - |. Parser.Workaround.lineCommentAfter "#define" - , Parser.succeed Nothing - |. Parser.Workaround.lineCommentAfter "precision highp" - , Parser.succeed Just - |= uniform - , Parser.succeed Just - |= function - ] - , end = "" - , trailing = Parser.Optional - , spaces = Parser.spaces - } - |. Parser.end diff --git a/elm.json b/elm.json index 7b772d3c..ac8245ba 100644 --- a/elm.json +++ b/elm.json @@ -4,14 +4,16 @@ "src/elm", "src/elm-extra", "generated", - "codegen/helpers", - "vendored/miniBill/elm-glsl-dsl/1.0.0/src" + "vendored/miniBill/elm-glsl/1.0.0/src" ], "elm-version": "0.19.1", "dependencies": { "direct": { "avh4/elm-color": "1.0.0", "dillonkearns/elm-markdown": "7.0.1", + "elm-community/list-extra": "8.7.0", + "elm-community/maybe-extra": "5.3.0", + "elm-community/result-extra": "2.4.0", "elm/browser": "1.0.2", "elm/bytes": "1.0.8", "elm/core": "1.0.5", @@ -21,9 +23,6 @@ "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/url": "1.0.0", - "elm-community/list-extra": "8.7.0", - "elm-community/maybe-extra": "5.3.0", - "elm-community/result-extra": "2.4.0", "lemol/ant-design-icons-elm-ui": "1.0.0", "miniBill/elm-codec": "2.0.0", "miniBill/elm-ui-with-context": "2.0.0", diff --git a/package.json b/package.json index ff2d5e03..b4b77e78 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "elm-codegen": "^0.6.1", "elm-format": "^0.8.7", "elm-optimize-level-2": "^0.3.5", + "elm-pages": "3.0.22", "elm-review": "^2.13.2", "elm-test-rs": "^3.0.0-5", "elm-watch": "^2.0.0-beta.6", diff --git a/tests/GlslFuzzer.elm b/tests/GlslFuzzer.elm index 3303097f..fad9a41c 100644 --- a/tests/GlslFuzzer.elm +++ b/tests/GlslFuzzer.elm @@ -5,8 +5,7 @@ import Dict import Expect exposing (Expectation) import Glsl exposing (Expression, Vec2, float1) import Glsl.Eval exposing (Context, Error, Value) -import Glsl.Functions exposing (cexp2, vec211) -import Glsl.Generator exposing (one, zero) +import Glsl.Functions exposing (vec211) import Test exposing (Test) diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm deleted file mode 100644 index 46ba059d..00000000 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl.elm +++ /dev/null @@ -1,435 +0,0 @@ -module Glsl exposing - ( Function - , Statement(..), Stat(..), ForDirection(..) - , Expression(..), ExprWithDeps, Expr(..) - , BinaryOperation(..), UnaryOperation(..), RelationOperation(..), ComboOperation(..) - , BisectSignature - , true, false, var - , dot2X, dot2Y - , TypingFunction, TypedName(..), Type(..) - , Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out - , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 - , unsafeMap, unsafeMap2, unsafeMap3 - , build, withExpression, withStatement, buildExpression, buildStatement - , Declaration(..), Uniform, WithDepsBuilder, dot4XY, float1, int1, unsafeTypecast - ) - -{-| - - -# Types - -@docs Function -@docs Statement, Stat, ForDirection -@docs Expression, ExprWithDeps, Expr -@docs BinaryOperation, UnaryOperation, RelationOperation, ComboOperation -@docs BisectSignature - - -# Utils - -@docs true, false, int, float, var -@docs dot2X, dot2Y - - -# Typelevel types - -@docs TypingFunction, TypedName, Type -@docs Vec2, Vec3, Vec4, IVec2, IVec3, IVec4, Mat3, Void, In, Out - - -# Escape hatches - -@docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5 -@docs unsafeMap, unsafeMap2, unsafeMap3 -@docs unsafeTypecase - - -# Building while tracking dependencies - -@docs build, withExpression, withStatement, buildExpression, buildStatement - --} - -import SortedSet exposing (SortedSet) - - - --- UNSAFE -- - - -unsafeCall0 : String -> List String -> Expression r -unsafeCall0 name deps = - build (Call name []) - |> withDependencies deps - |> buildExpression - - -unsafeCall1 : String -> List String -> Expression t -> Expression r -unsafeCall1 name deps arg0 = - build (\a0 -> Call name [ a0 ]) - |> withDependencies deps - |> withExpression arg0 - |> buildExpression - - -unsafeCall2 : String -> List String -> Expression t -> Expression u -> Expression r -unsafeCall2 name deps arg0 arg1 = - build (\a0 a1 -> Call name [ a0, a1 ]) - |> withDependencies deps - |> withExpression arg0 - |> withExpression arg1 - |> buildExpression - - -unsafeCall3 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression r -unsafeCall3 name deps arg0 arg1 arg2 = - build (\a0 a1 a2 -> Call name [ a0, a1, a2 ]) - |> withDependencies deps - |> withExpression arg0 - |> withExpression arg1 - |> withExpression arg2 - |> buildExpression - - -unsafeCall4 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r -unsafeCall4 name deps arg0 arg1 arg2 arg3 = - build (\a0 a1 a2 a3 -> Call name [ a0, a1, a2, a3 ]) - |> withDependencies deps - |> withExpression arg0 - |> withExpression arg1 - |> withExpression arg2 - |> withExpression arg3 - |> buildExpression - - -unsafeCall5 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression x -> Expression r -unsafeCall5 name deps arg0 arg1 arg2 arg3 arg4 = - build (\a0 a1 a2 a3 a4 -> Call name [ a0, a1, a2, a3, a4 ]) - |> withDependencies deps - |> withExpression arg0 - |> withExpression arg1 - |> withExpression arg2 - |> withExpression arg3 - |> withExpression arg4 - |> buildExpression - - -unsafeMap : (Expr -> Expr) -> Expression a -> Expression b -unsafeMap f l = - build f - |> withExpression l - |> buildExpression - - -unsafeMap2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -unsafeMap2 f l r = - build f - |> withExpression l - |> withExpression r - |> buildExpression - - -unsafeMap3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d -unsafeMap3 f l m r = - build f - |> withExpression l - |> withExpression m - |> withExpression r - |> buildExpression - - -unsafeTypecast : Expression a -> Expression b -unsafeTypecast (Expression a) = - Expression a - - -type WithDepsBuilder k - = WithDepsBuilder k (SortedSet String) - - -build : k -> WithDepsBuilder k -build k = - WithDepsBuilder k SortedSet.empty - - -withExpression : Expression e -> WithDepsBuilder (Expr -> k) -> WithDepsBuilder k -withExpression (Expression e) (WithDepsBuilder k deps) = - WithDepsBuilder (k e.expr) - (deps |> SortedSet.insertAll e.deps) - - -withStatement : Statement r -> WithDepsBuilder (Stat -> k) -> WithDepsBuilder k -withStatement (Statement s) (WithDepsBuilder k deps) = - WithDepsBuilder (k s.stat) - (deps |> SortedSet.insertAll s.deps) - - -withDependencies : List String -> WithDepsBuilder k -> WithDepsBuilder k -withDependencies additionalDeps (WithDepsBuilder k deps) = - WithDepsBuilder k - (deps |> SortedSet.insertAll (SortedSet.fromList additionalDeps)) - - -buildStatement : WithDepsBuilder Stat -> Statement r -buildStatement (WithDepsBuilder stat deps) = - Statement - { stat = stat - , deps = deps - } - - -buildExpression : WithDepsBuilder Expr -> Expression t -buildExpression (WithDepsBuilder expr deps) = - Expression - { expr = expr - , deps = deps - } - - - --- Typed expressions - - -type Declaration - = FunctionDeclaration Function - | UniformDeclaration Uniform - - -type alias Function = - { returnType : Type - , name : String - , args : List ( Type, String ) - , stat : Stat - , body : String - , hasSuffix : Bool - } - - -type alias Uniform = - { tipe : Type - , name : String - } - - -type Expression t - = Expression ExprWithDeps - - -type alias ExprWithDeps = - { expr : Expr - , deps : SortedSet String - } - - -type Expr - = Bool Bool - | Int Int - | Float Float - | Variable String - | Comparison RelationOperation Expr Expr - | Ternary Expr Expr Expr - | UnaryOperation UnaryOperation Expr - | BinaryOperation BinaryOperation Expr Expr - | Call String (List Expr) - | PostfixIncrement Expr - | PostfixDecrement Expr - | Dot Expr String - | Array Expr Expr - | AssignCombo ComboOperation Expr Expr - - -type BinaryOperation - = Add - | Subtract - | By - | Div - | And - | Or - - -type UnaryOperation - = Negate - - -type RelationOperation - = LessThan - | LessThanOrEquals - | Equals - | NotEquals - | GreaterThanOrEquals - | GreaterThan - | Assign - - -type ComboOperation - = ComboAdd - | ComboSubtract - | ComboBy - | ComboDiv - - -type alias BisectSignature = - Expression Vec3 - -> Expression Mat3 - -> Expression Float - -> Expression (Out Vec3) - -> Expression Bool - - - --- Typed statements - - -type Statement r - = Statement - { stat : Stat - , deps : SortedSet String - } - - -type Stat - = If Expr Stat Stat - | IfElse Expr Stat Stat Stat - | For String Expr RelationOperation Expr ForDirection Stat Stat - | Return Expr - | Break - | Continue - | ExpressionStatement Expr Stat - | Decl Type String (Maybe Expr) Stat - | Nop - - -type ForDirection - = PlusPlus - | MinusMinus - - -type alias TypingFunction t = - String -> TypedName t - - -type TypedName t - = TypedName Type String - - -type Type - = TVoid - | TFloat - | TInt - | TBool - | TVec2 - | TVec3 - | TVec4 - | TIVec2 - | TIVec3 - | TIVec4 - | TMat3 - | TIn Type - | TOut Type - - - --- Typelevel types. Eh. - - -type Vec2 - = Vec2 Vec2 - - -type Vec3 - = Vec3 Vec3 - - -type Vec4 - = Vec4 Vec4 - - -type IVec2 - = IVec2 IVec2 - - -type IVec3 - = IVec3 IVec3 - - -type IVec4 - = IVec4 IVec4 - - -type Mat3 - = Mat3 Mat3 - - -type Void - = Void Void - - -type In t - = In (In t) - - -type Out t - = Out (Out t) - - - --- Utils - - -true : Expression Bool -true = - bool1 True - - -false : Expression Bool -false = - bool1 False - - -bool1 : Bool -> Expression Bool -bool1 b = - pure <| Bool b - - -int1 : Int -> Expression Int -int1 i = - pure <| Int i - - -float1 : Float -> Expression Float -float1 i = - pure <| Float i - - -var : String -> Expression t -var v = - pure <| Variable v - - -dot2X : Expression Vec2 -> Expression Float -dot2X e = - unsafeDot e "x" - - -dot2Y : Expression Vec2 -> Expression Float -dot2Y e = - unsafeDot e "y" - - -dot4XY : Expression Vec4 -> Expression Vec2 -dot4XY e = - unsafeDot e "xy" - - -unsafeDot : Expression t -> String -> Expression a -unsafeDot ex v = - unsafeMap (\e -> Dot e v) ex - - -pure : Expr -> Expression t -pure e = - Expression - { expr = e - , deps = SortedSet.empty - } diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm deleted file mode 100644 index c8c05475..00000000 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Eval.elm +++ /dev/null @@ -1,304 +0,0 @@ -module Glsl.Eval exposing (Context, Error(..), Value(..), interpret, value) - -import Dict exposing (Dict) -import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), RelationOperation(..), Stat(..), Statement(..), UnaryOperation(..)) - - -type Value - = VFloat Float - | VBool Bool - | VInt Int - | VVec2 Float Float - | VVec3 Float Float Float - | VMat3 ( Float, Float, Float ) ( Float, Float, Float ) ( Float, Float, Float ) - | VVoid -- Used for void return - - -type alias Context = - Dict String Value - - -type Error - = MissingVariable String - | InvalidTypes String - - -value : Context -> Expression t -> Result Error ( Context, Value ) -value initialContext (Expression input) = - innerValue initialContext input.expr - - -innerValue : Context -> Expr -> Result Error ( Context, Value ) -innerValue ctx e = - case e of - Float f -> - Ok ( ctx, VFloat f ) - - Bool b -> - Ok ( ctx, VBool b ) - - Int i -> - Ok ( ctx, VInt i ) - - Variable v -> - case Dict.get v ctx of - Just f -> - Ok ( ctx, f ) - - Nothing -> - Err <| MissingVariable v - - UnaryOperation Negate c -> - innerValue ctx c - |> Result.andThen - (\( ctx2, vc ) -> - case vc of - VFloat fc -> - Ok ( ctx2, VFloat <| negate fc ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `-` for " ++ valueToString vc) - ) - - BinaryOperation And l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl && br ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - BinaryOperation Or l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VBool bl, VBool br ) -> - Ok ( ctx2, VBool <| bl || br ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - Comparison k l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr, k ) of - ( VFloat fl, VFloat fr, LessThan ) -> - Ok ( ctx2, VBool (fl < fr) ) - - ( VFloat fl, VFloat fr, LessThanOrEquals ) -> - Ok ( ctx2, VBool (fl <= fr) ) - - ( VFloat fl, VFloat fr, Equals ) -> - Ok ( ctx2, VBool (fl == fr) ) - - ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> - Ok ( ctx2, VBool (fl >= fr) ) - - ( VFloat fl, VFloat fr, GreaterThan ) -> - Ok ( ctx2, VBool (fl > fr) ) - - _ -> - Err <| - InvalidTypes - ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) - - Ternary _ _ _ -> - Debug.todo "branch 'Ternary _ _ _' not implemented" - - BinaryOperation Add _ _ -> - Debug.todo "branch 'Add _ _' not implemented" - - BinaryOperation Subtract _ _ -> - Debug.todo "branch 'Subtract _ _' not implemented" - - BinaryOperation By l r -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VFloat <| fl * fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - BinaryOperation Div _ _ -> - Debug.todo "branch 'Div _ _' not implemented" - - Call "vec2" [ l, r ] -> - innerValue2 ctx l r <| - \ctx2 vl vr -> - case ( vl, vr ) of - ( VFloat fl, VFloat fr ) -> - Ok ( ctx2, VVec2 fl fr ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) - - Call "exp" [ l ] -> - autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l - - Call "cos" [ l ] -> - autovectorizingFloatOp ctx "cos" Basics.cos l - - Call "sin" [ l ] -> - autovectorizingFloatOp ctx "sin" Basics.sin l - - Call name args -> - Debug.todo <| "branch 'Call \"" ++ name ++ "\" [" ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) ++ " ]' not implemented" - - Dot _ _ -> - Debug.todo "branch 'Dot _ _' not implemented" - - Array _ _ -> - Debug.todo "branch 'Array _ _' not implemented" - - AssignCombo _ _ _ -> - Debug.todo "branch 'AssignCombo _ _' not implemented" - - PostfixIncrement _ -> - Debug.todo "branch 'PostfixIncrement _' not implemented" - - PostfixDecrement _ -> - Debug.todo "branch 'PostfixDecrement _' not implemented" - - -innerValue2 : - Context - -> Expr - -> Expr - -> (Context -> Value -> Value -> Result Error ( Context, Value )) - -> Result Error ( Context, Value ) -innerValue2 ctx l r k = - innerValue ctx l - |> Result.andThen - (\( ctx2, vl ) -> - innerValue ctx2 r - |> Result.andThen - (\( ctx3, vr ) -> - k ctx3 vl vr - ) - ) - - -autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result Error ( Dict String Value, Value ) -autovectorizingFloatOp ctx name inner e = - innerValue ctx e - |> Result.andThen - (\( ctx2, v ) -> - case v of - VFloat fv -> - Ok ( ctx2, VFloat <| inner fv ) - - VVec2 x y -> - Ok ( ctx2, VVec2 (inner x) (inner y) ) - - VVec3 x y z -> - Ok ( ctx2, VVec3 (inner x) (inner y) (inner z) ) - - _ -> - Err <| - InvalidTypes - ("Cannot calculate `" ++ name ++ "` for " ++ valueToString v) - ) - - -interpret : Context -> Statement a -> Result Error ( Context, Value ) -interpret ctx (Statement s) = - innerInterpret ctx s.stat - - -innerInterpret : Context -> Stat -> Result Error ( Context, Value ) -innerInterpret ctx stat = - case stat of - Return e -> - e - |> innerValue ctx - |> Result.map (\( ctx2, val ) -> ( ctx2, val )) - - If c t n -> - c - |> innerValue ctx - |> Result.andThen - (\( ctx2, cval ) -> - case cval of - VBool True -> - innerInterpret ctx2 t - |> Result.andThen - (\( ctx3, res ) -> - case res of - -- TODO: Fix this - VVoid -> - innerInterpret ctx3 n - - _ -> - Ok ( ctx3, res ) - ) - - VBool False -> - innerInterpret ctx2 n - - _ -> - Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval - ) - - IfElse _ _ _ _ -> - Debug.todo "branch 'IfElse _' not implemented" - - Nop -> - Ok ( ctx, VVoid ) - - ExpressionStatement _ _ -> - Debug.todo "branch 'ExpressionStatement _' not implemented" - - Decl _ _ _ _ -> - Debug.todo "branch 'Decl _ _ _' not implemented" - - For _ _ _ _ _ _ _ -> - Debug.todo "branch 'For _ _ _ _ _ _ _' not implemented" - - Break -> - Debug.todo "branch 'Break' not implemented" - - Continue -> - Debug.todo "branch 'Continue' not implemented" - - -valueToString : Value -> String -valueToString v = - case v of - VFloat f -> - String.fromFloat f - - VBool b -> - if b then - "true" - - else - "false" - - VInt i -> - String.fromInt i - - VVoid -> - "void" - - VVec2 x y -> - "vec2(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ ")" - - VVec3 x y z -> - "vec3(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ "," ++ String.fromFloat z ++ ")" - - VMat3 _ _ _ -> - Debug.todo "branch 'VMat3 _ _ _' not implemented" diff --git a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm b/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm deleted file mode 100644 index 5d3dadf9..00000000 --- a/vendored/miniBill/elm-glsl-dsl/1.0.0/src/Glsl/Generator.elm +++ /dev/null @@ -1,980 +0,0 @@ -module Glsl.Generator exposing (File, FunDecl, adds2, adds3, adds4, and, ands, assign, assignAdd, assignBy, assignOut, boolT, break, continue, decl, def, def1, def2, def3, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun2, fun3, fun4, fun5, funDeclToGlsl, gl_FragColor, gl_FragCoord, ifElse, if_, in_, intT, main_, mat3, mat3T, minusOne, nop, one, or, ors, out, return, statementToGlsl, ternary, ternary3, vec2, vec2T, vec2Zero, vec3, vec3T, vec3Zero, vec4, vec4T, vec4Zero, voidT, zero) - -import Glsl exposing (BinaryOperation(..), ComboOperation(..), Expr(..), Expression(..), ForDirection(..), In, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, false, float1, true, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeMap3, var, withExpression, withStatement) -import Glsl.Functions exposing (vec211, vec3111, vec41111) -import Glsl.Operations exposing (add22, add33, add44) -import Glsl.PrettyPrinter -import Set -import SortedSet - - -type alias File = - List FunDecl - - -type FunDecl - = FunDecl { name : String, type_ : String, body : String } - - - --- UTILS - - -fileToGlsl : File -> String -fileToGlsl decls = - decls - |> List.foldl - (\(FunDecl { name, type_, body }) ( found, output ) -> - if Set.member ( name, type_ ) found then - ( found, output ) - - else - ( Set.insert ( name, type_ ) found, body :: output ) - ) - ( Set.empty, [] ) - |> Tuple.second - |> List.reverse - |> String.join "\n\n" - - -funDeclToGlsl : FunDecl -> String -funDeclToGlsl (FunDecl { body }) = - body - - -statementToGlsl : Statement s -> String -statementToGlsl (Statement r) = - statToGlsl 1 r.stat - - -statToGlsl : Int -> Stat -> String -statToGlsl i c = - case c of - If cond t n -> - [ indent i ("if (" ++ exprToGlsl cond ++ ") {") - , statToGlsl (i + 1) t - , indent i "}" - , "" - , statToGlsl i n - ] - |> String.join "\n" - - IfElse cond t ((If _ _ _) as f) n -> - [ indent i ("if (" ++ exprToGlsl cond ++ ") {") - , statToGlsl (i + 1) t - , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) - , statToGlsl i n - ] - |> String.join "\n" - - IfElse cond t ((IfElse _ _ _ _) as f) n -> - [ indent i ("if (" ++ exprToGlsl cond ++ ") {") - , statToGlsl (i + 1) t - , indent i <| "} else " ++ String.trimLeft (statToGlsl i f) - , statToGlsl i n - ] - |> String.join "\n" - - IfElse cond t f n -> - [ indent i ("if (" ++ exprToGlsl cond ++ ") {") - , statToGlsl (i + 1) t - , indent i "} else {" - , statToGlsl (i + 1) f - , indent i "}" - , "" - , statToGlsl i n - ] - |> String.join "\n" - - For var from rel to direction loop next -> - [ indent i ("for (int " ++ var ++ " = " ++ exprToGlsl from ++ "; " ++ var ++ " " ++ relationToString rel ++ " " ++ exprToGlsl to ++ "; " ++ var ++ directionToGlsl direction ++ ") {") - , statToGlsl (i + 1) loop - , indent i "}" - , "" - , statToGlsl i next - ] - |> String.join "\n" - - Return e -> - indent i <| "return " ++ exprToGlsl e ++ ";" - - Break -> - indent i "break;" - - Continue -> - indent i "continue;" - - ExpressionStatement e Nop -> - indent i (exprToGlsl e ++ ";") - - Decl t n (Just e) Nop -> - indent i (typeToGlsl t ++ " " ++ n ++ " = " ++ exprToGlsl e ++ ";") - - Decl t n Nothing Nop -> - indent i (typeToGlsl t ++ " " ++ n ++ ";") - - ExpressionStatement e next -> - indent i (exprToGlsl e ++ ";\n") ++ statToGlsl i next - - Decl t n (Just e) next -> - indent i (typeToGlsl t ++ " " ++ n ++ " = " ++ exprToGlsl e ++ ";\n") ++ statToGlsl i next - - Decl t n Nothing next -> - indent i (typeToGlsl t ++ " " ++ n ++ ";\n") ++ statToGlsl i next - - Nop -> - "" - - -directionToGlsl : ForDirection -> String -directionToGlsl direction = - case direction of - PlusPlus -> - "++" - - MinusMinus -> - "--" - - -typeToGlsl : Type -> String -typeToGlsl type_ = - case type_ of - TVoid -> - "void" - - TFloat -> - "float" - - TInt -> - "int" - - TBool -> - "bool" - - TVec2 -> - "vec2" - - TVec3 -> - "vec3" - - TVec4 -> - "vec4" - - TIVec2 -> - "ivec2" - - TIVec3 -> - "ivec3" - - TIVec4 -> - "ivec4" - - TMat3 -> - "mat3" - - TIn t -> - "in " ++ typeToGlsl t - - TOut t -> - "out " ++ typeToGlsl t - - -relationToString : RelationOperation -> String -relationToString rel = - case rel of - LessThan -> - "<" - - LessThanOrEquals -> - "<=" - - Equals -> - "==" - - NotEquals -> - "!=" - - GreaterThanOrEquals -> - ">=" - - GreaterThan -> - ">" - - Assign -> - "=" - - -expressionToGlsl : Expression t -> String -expressionToGlsl (Expression tree) = - exprToGlsl tree.expr - - -exprToGlsl : Expr -> String -exprToGlsl tree = - let - -- The numbers are precedence numbers from the GLSL spec - go : Bool -> Expr -> String - go rec e = - -- case e of - -- Unknown u -> - -- u - -- _ -> - go17 rec e - - go17 : Bool -> Expr -> String - go17 rec e = - go16 rec e - - go16 : Bool -> Expr -> String - go16 rec e = - case e of - Comparison Assign l r -> - go15 False l ++ " = " ++ go15 False r - - AssignCombo k l r -> - go15 False l ++ " " ++ comboOperationToString k ++ "= " ++ go15 False r - - _ -> - go15 rec e - - go15 : Bool -> Expr -> String - go15 rec e = - case e of - Ternary c t f -> - go14 False c ++ " ? " ++ go14 False t ++ " : " ++ go15 False f - - _ -> - go14 rec e - - go14 : Bool -> Expr -> String - go14 rec e = - case e of - BinaryOperation Or l r -> - go14 False l ++ " || " ++ go13 False r - - _ -> - go13 rec e - - go13 : Bool -> Expr -> String - go13 rec e = - go12 rec e - - go12 : Bool -> Expr -> String - go12 rec e = - case e of - BinaryOperation And l r -> - go12 False l ++ " && " ++ go11 False r - - _ -> - go11 rec e - - go11 : Bool -> Expr -> String - go11 rec e = - go10 rec e - - go10 : Bool -> Expr -> String - go10 rec e = - go9 rec e - - go9 : Bool -> Expr -> String - go9 rec e = - go8 rec e - - go8 : Bool -> Expr -> String - go8 rec e = - case e of - Comparison Equals l r -> - go7 False l ++ " == " ++ go7 False r - - Comparison NotEquals l r -> - go7 False l ++ " != " ++ go7 False r - - _ -> - go7 rec e - - go7 : Bool -> Expr -> String - go7 rec e = - case e of - Comparison LessThan l r -> - go6 False l ++ " < " ++ go6 False r - - Comparison LessThanOrEquals l r -> - go6 False l ++ " <= " ++ go6 False r - - Comparison GreaterThan l r -> - go6 False l ++ " > " ++ go6 False r - - Comparison GreaterThanOrEquals l r -> - go6 False l ++ " >= " ++ go6 False r - - _ -> - go6 rec e - - go6 : Bool -> Expr -> String - go6 rec e = - go5 rec e - - go5 : Bool -> Expr -> String - go5 rec e = - case e of - BinaryOperation Add l r -> - go5 False l ++ " + " ++ go4 False r - - BinaryOperation Subtract l r -> - go5 False l ++ " - " ++ go4 False r - - _ -> - go4 rec e - - go4 : Bool -> Expr -> String - go4 rec e = - case e of - BinaryOperation By l r -> - go4 False l ++ " * " ++ go3 False r - - BinaryOperation Div l r -> - go4 False l ++ " / " ++ go3 False r - - _ -> - go3 rec e - - go3 : Bool -> Expr -> String - go3 rec e = - case e of - UnaryOperation Negate c -> - "-" ++ go2 False c - - PostfixIncrement c -> - go2 False c ++ "++" - - PostfixDecrement c -> - go2 False c ++ "--" - - _ -> - go2 rec e - - go2 : Bool -> Expr -> String - go2 rec e = - case e of - Call name args -> - name ++ "(" ++ String.join ", " (List.map (go False) args) ++ ")" - - Dot l r -> - go2 False l ++ "." ++ r - - Array l r -> - go2 False l ++ "[" ++ go False r ++ "]" - - _ -> - go1 rec e - - go1 : Bool -> Expr -> String - go1 rec e = - case e of - Bool b -> - if b then - "true" - - else - "false" - - Float f -> - Glsl.PrettyPrinter.float f - - Int i -> - String.fromInt i - - Variable v -> - v - - _ -> - if rec then - "!!!Internal error in toString for Glsl!!!" - - else - "(" ++ go True e ++ ")" - in - go False tree - - -comboOperationToString : ComboOperation -> String -comboOperationToString op = - case op of - ComboAdd -> - "+" - - ComboSubtract -> - "-" - - ComboBy -> - "*" - - ComboDiv -> - "/" - - -indent : Int -> String -> String -indent i line = - String.repeat (4 * i) " " ++ line - - - ---EXPRESSIONS - - -ternary : Expression Bool -> Expression t -> Expression t -> Expression t -ternary = - unsafeMap3 Ternary - - -ternary3 : Expression Bool -> Expression Vec3 -> Expression Vec3 -> Expression Vec3 -ternary3 = - unsafeMap3 Ternary - - -and : Expression Bool -> Expression Bool -> Expression Bool -and = - unsafeMap2 (BinaryOperation And) - - -ands : List (Expression Bool) -> Expression Bool -ands es = - case es of - [] -> - true - - h :: t -> - List.foldl (\e a -> and a e) h t - - -or : Expression Bool -> Expression Bool -> Expression Bool -or = - unsafeMap2 (BinaryOperation Or) - - -ors : List (Expression Bool) -> Expression Bool -ors es = - case es of - [] -> - false - - h :: t -> - List.foldl (\e a -> or a e) h t - - -adds2 : List (Expression Vec2) -> Expression Vec2 -adds2 es = - case es of - [] -> - vec2Zero - - h :: t -> - List.foldl (\e a -> add22 a e) h t - - -adds3 : List (Expression Vec3) -> Expression Vec3 -adds3 es = - case es of - [] -> - vec3Zero - - h :: t -> - List.foldl (\e a -> add33 a e) h t - - -adds4 : List (Expression Vec4) -> Expression Vec4 -adds4 es = - case es of - [] -> - vec4Zero - - h :: t -> - List.foldl (\e a -> add44 a e) h t - - - ---------------- --- CONSTANTS -- ---------------- - - -vec2Zero : Expression Vec2 -vec2Zero = - vec211 zero zero - - -vec3Zero : Expression Vec3 -vec3Zero = - vec3111 zero zero zero - - -vec4Zero : Expression Vec4 -vec4Zero = - vec41111 zero zero zero zero - - -gl_FragColor : Expression Vec4 -gl_FragColor = - var "gl_FragColor" - - -gl_FragCoord : Expression Vec4 -gl_FragCoord = - var "gl_FragCoord" - - - ----------------- --- CALL UTILS -- ----------------- - - -zero : Expression Float -zero = - float1 0 - - -one : Expression Float -one = - float1 1 - - -minusOne : Expression Float -minusOne = - float1 -1 - - - --- STATEMENTS - - -functionToGlsl : TypedName t -> List ( Type, String ) -> Statement t -> String -functionToGlsl (TypedName rt name) args body = - let - argsList = - String.join ", " (List.map (\( t, n ) -> typeToGlsl t ++ " " ++ n) args) - in - String.join "\n" <| - [ typeToGlsl rt ++ " " ++ name ++ "(" ++ argsList ++ ") {" - , statementToGlsl body - , "}" - ] - - -argToString : TypedName t -> ( String, String ) -argToString (TypedName t n) = - ( typeToGlsl t, n ) - - -toVar : TypedName t -> Expression t -toVar (TypedName _ n) = - --pure <| Variable n - Debug.todo "toVar" - - -funX : - (String - -> List String - -> a - ) - -> TypingFunction t - -> String - -> Statement t - -> List ( Type, String ) - -> a -funX call typeF name body args = - let - typed = - typeF name - - (Statement s) = - body - - funGlsl = - functionToGlsl typed args body - in - call name - (s.deps - |> SortedSet.insert funGlsl - |> SortedSet.toList - ) - - -main_ : (Statement () -> Statement ()) -> Expression () -main_ stat = - fun0 voidT "main" <| \_ -> stat nop - - -fun0 : - TypingFunction t - -> String - -> (() -> Statement t) - -> Expression t -fun0 typeF name body = - funX unsafeCall0 - typeF - name - (body ()) - [] - - -fun1 : - TypingFunction t - -> String - -> TypedName a - -> (Expression a -> Statement t) - -> Expression a - -> Expression r -fun1 typeF name (TypedName t0 arg0) body = - funX unsafeCall1 - typeF - name - (body (var arg0)) - [ ( t0, arg0 ) ] - - -fun2 : - TypingFunction t - -> String - -> TypedName a - -> TypedName b - -> (Expression a -> Expression b -> Statement t) - -> Expression a - -> Expression b - -> Expression t -fun2 typeF name (TypedName t0 arg0) (TypedName t1 arg1) body = - funX unsafeCall2 - typeF - name - (body (var arg0) (var arg1)) - [ ( t0, arg0 ), ( t1, arg1 ) ] - - -fun3 : - TypingFunction t - -> String - -> TypedName a - -> TypedName b - -> TypedName c - -> (Expression a -> Expression b -> Expression c -> Statement t) - -> Expression a - -> Expression b - -> Expression c - -> Expression t -fun3 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) body = - funX unsafeCall3 - typeF - name - (body (var arg0) (var arg1) (var arg2)) - [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ) ] - - -fun4 : - TypingFunction t - -> String - -> TypedName a - -> TypedName b - -> TypedName c - -> TypedName d - -> (Expression a -> Expression b -> Expression c -> Expression d -> Statement t) - -> Expression a - -> Expression b - -> Expression c - -> Expression d - -> Expression t -fun4 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) body = - funX unsafeCall4 - typeF - name - (body (var arg0) (var arg1) (var arg2) (var arg3)) - [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ) ] - - -fun5 : - TypingFunction t - -> String - -> TypedName a - -> TypedName b - -> TypedName c - -> TypedName d - -> TypedName e - -> (Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Statement t) - -> Expression a - -> Expression b - -> Expression c - -> Expression d - -> Expression e - -> Expression t -fun5 typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) (TypedName t4 arg4) body = - funX unsafeCall5 - typeF - name - (body (var arg0) (var arg1) (var arg2) (var arg3) (var arg4)) - [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ), ( t4, arg4 ) ] - - -if_ : Expression Bool -> Statement r -> (() -> Statement r) -> Statement r -if_ cond ifTrue next = - build If - |> withExpression cond - |> withStatement ifTrue - |> withStatement (next ()) - |> buildStatement - - -ifElse : Expression Bool -> Statement s -> Statement s -> (() -> Statement s) -> Statement s -ifElse cond ifTrue ifFalse next = - build IfElse - |> withExpression cond - |> withStatement ifTrue - |> withStatement ifFalse - |> withStatement (next ()) - |> buildStatement - - -for : - ( String, Expression Int, Expression Int ) - -> (Expression Int -> Statement r -> Statement r) - -> Statement r - -> Statement r -for ( varName, from, to ) loop next = - build (\f t -> For varName f LessThan t PlusPlus) - |> withExpression from - |> withExpression to - |> withStatement (loop (var varName) unsafeNop) - |> withStatement next - |> buildStatement - - -forLeq : - ( String, Expression Int, Expression Int ) - -> (Expression Int -> Statement r -> Statement r) - -> Statement r - -> Statement r -forLeq ( varName, from, to ) loop next = - build (\f t -> For varName f LessThanOrEquals t PlusPlus) - |> withExpression from - |> withExpression to - |> withStatement (loop (var varName) unsafeNop) - |> withStatement next - |> buildStatement - - -forDown : - ( String, Expression Int, Expression Int ) - -> (Expression Int -> Statement r -> Statement r) - -> Statement r - -> Statement r -forDown ( varName, from, to ) loop next = - build (\f t -> For varName f GreaterThan t MinusMinus) - |> withExpression from - |> withExpression to - |> withStatement (loop (var varName) unsafeNop) - |> withStatement next - |> buildStatement - - -return : Expression r -> Statement r -return e = - build Return - |> withExpression e - |> buildStatement - - -break : Statement a -break = - build Break - |> buildStatement - - -continue : Statement a -continue = - build Continue - |> buildStatement - - -decl : TypingFunction t -> String -> (Expression t -> Statement r) -> Statement r -decl typeF name k = - let - (TypedName t n) = - typeF name - in - build (Decl t n Nothing) - |> withStatement (k (var n)) - |> buildStatement - - -def : TypingFunction t -> String -> Expression t -> (Expression t -> Statement r) -> Statement r -def typeF name val k = - def1 ( typeF name, val ) k - - -float : String -> Expression Float -> (Expression Float -> Statement r) -> Statement r -float = - def floatT - - -vec2 : String -> Expression Vec2 -> (Expression Vec2 -> Statement r) -> Statement r -vec2 = - def vec2T - - -vec3 : String -> Expression Vec3 -> (Expression Vec3 -> Statement r) -> Statement r -vec3 = - def vec3T - - -vec4 : String -> Expression Vec4 -> (Expression Vec4 -> Statement r) -> Statement r -vec4 = - def vec4T - - -mat3 : String -> Expression Mat3 -> (Expression Mat3 -> Statement r) -> Statement r -mat3 = - def mat3T - - -def1 : - ( TypedName a, Expression a ) - -> (Expression a -> Statement r) - -> Statement r -def1 ( tn0, val0 ) k = - let - (TypedName t0 n0) = - tn0 - in - build - (\v0 k0 -> Decl t0 n0 (Just v0) k0) - |> withExpression val0 - |> withStatement (k (var n0)) - |> buildStatement - - -def2 : - ( TypedName a, Expression a ) - -> ( TypedName b, Expression b ) - -> (Expression a -> Expression b -> Statement r) - -> Statement r -def2 ( tn0, val0 ) ( tn1, val1 ) k = - def1 ( tn0, val0 ) - (\v0 -> - def1 ( tn1, val1 ) - (\v1 -> k v0 v1) - ) - - -def3 : - ( TypedName a, Expression a ) - -> ( TypedName b, Expression b ) - -> ( TypedName c, Expression c ) - -> (Expression a -> Expression b -> Expression c -> Statement r) - -> Statement r -def3 ( tn0, val0 ) ( tn1, val1 ) ( tn2, val2 ) k = - def1 ( tn0, val0 ) - (\v0 -> - def1 ( tn1, val1 ) - (\v1 -> - def1 ( tn2, val2 ) - (\v2 -> k v0 v1 v2) - ) - ) - - -assign : Expression t -> Expression t -> Expression t -assign name e = - unsafeMap2 (Comparison Assign) name e - - -assignOut : Expression (Out t) -> Expression t -> Expression t -assignOut name e = - unsafeMap2 (Comparison Assign) name e - - -expr : Expression t -> (() -> Statement r) -> Statement r -expr e s = - build ExpressionStatement - |> withExpression e - |> withStatement (s ()) - |> buildStatement - - -nop : Statement () -nop = - Statement { stat = Nop, deps = SortedSet.empty } - - -unsafeNop : Statement r -unsafeNop = - Statement { stat = Nop, deps = SortedSet.empty } - - -assignAdd : Expression t -> Expression t -> (() -> Statement q) -> Statement q -assignAdd name val = - expr <| unsafeMap2 (AssignCombo ComboAdd) name val - - -assignBy : Expression t -> Expression t -> (() -> Statement q) -> Statement q -assignBy name val = - expr <| unsafeMap2 (AssignCombo ComboBy) name val - - - --- TYPES - - -voidT : TypingFunction () -voidT n = - TypedName TVoid n - - -boolT : TypingFunction Bool -boolT n = - TypedName TBool n - - -intT : TypingFunction Int -intT n = - TypedName TInt n - - -floatT : TypingFunction Float -floatT n = - TypedName TFloat n - - -vec2T : TypingFunction Vec2 -vec2T n = - TypedName TVec2 n - - -vec3T : TypingFunction Vec3 -vec3T n = - TypedName TVec3 n - - -vec4T : TypingFunction Vec4 -vec4T n = - TypedName TVec4 n - - -mat3T : TypingFunction Mat3 -mat3T n = - TypedName TMat3 n - - -out : TypingFunction t -> TypingFunction (Out t) -out inner n = - let - (TypedName t name) = - inner n - in - TypedName (TOut t) name - - -in_ : TypingFunction t -> TypingFunction (In t) -in_ inner n = - let - (TypedName t name) = - inner n - in - TypedName (TIn t) name diff --git a/vendored/miniBill/elm-glsl/1.0.0/LICENSE b/vendored/miniBill/elm-glsl/1.0.0/LICENSE new file mode 100644 index 00000000..a1773b4d --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/LICENSE @@ -0,0 +1 @@ +BSD-3 diff --git a/vendored/miniBill/elm-glsl/1.0.0/README.md b/vendored/miniBill/elm-glsl/1.0.0/README.md new file mode 100644 index 00000000..6ff91132 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/README.md @@ -0,0 +1 @@ +A library to produce glsl shaders as strings. diff --git a/vendored/miniBill/elm-glsl/1.0.0/elm.json b/vendored/miniBill/elm-glsl/1.0.0/elm.json new file mode 100644 index 00000000..ebcc14cb --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/elm.json @@ -0,0 +1,19 @@ +{ + "type": "package", + "name": "miniBill/elm-glsl", + "summary": "Generate GLSL shaders in a typesafe way", + "license": "BSD-3-Clause", + "version": "1.0.0", + "exposed-modules": [], + "elm-version": "0.19.0 <= v < 0.20.0", + "dependencies": { + "elm/core": "1.0.0 <= v < 2.0.0", + "elm/parser": "1.1.0 <= v < 2.0.0" + }, + "test-dependencies": { + "elm/json": "1.1.3 <= v < 2.0.0", + "elm-explorations/test": "2.0.0 <= v < 3.0.0", + "elmcraft/core-extra": "2.0.0 <= v < 3.0.0", + "rtfeldman/console-print": "1.0.1 <= v < 2.0.0" + } +} diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl.elm new file mode 100644 index 00000000..2920101e --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl.elm @@ -0,0 +1,812 @@ +module Glsl exposing + ( Declaration(..), Uniform, Function + , Statement(..), Stat(..) + , Expression(..), ExprWithDeps, Expr(..) + , BinaryOperation(..), UnaryOperation(..), RelationOperation(..) + , true, false, int1, float1, bool1, double1, uint1 + , TypingFunction, TypedName(..), Type(..) + , Vec, Mat, D1, D2, D3, D4 + , Float_, Vec2, Vec3, Vec4 + , Int_, IVec2, IVec3, IVec4 + , Bool_, BVec2, BVec3, BVec4 + , Uint, Uint_, UVec2, UVec3, UVec4 + , Double, Double_, DVec2, DVec3, DVec4 + , Mat2, Mat3, Mat4, Mat23, Mat24, Mat32, Mat34, Mat42, Mat43 + , DMat2, DMat3, DMat4, DMat23, DMat24, DMat32, DMat34, DMat42, DMat43 + , Void, In, Out, Const + , unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeCall6, unsafeCall7, unsafeCall8, unsafeCall9 + , unsafeMap, unsafeMap2, unsafeMap3 + , unsafeTypecast + , unsafeVar + , unsafeDot + , build, withExpression, withStatement, withContinuation, buildExpression, buildStatement, WithDepsBuilder + , block, deps + ) + +{-| + + +# Types + +@docs Declaration, Uniform, Function +@docs Statement, Stat +@docs Expression, ExprWithDeps, Expr +@docs BinaryOperation, UnaryOperation, RelationOperation + + +# Utils + +@docs true, false, int1, float1, bool1, double1, uint1 + + +# Typelevel types + +@docs TypingFunction, TypedName, Type +@docs Vec, Mat, D1, D2, D3, D4 +@docs Float_, Vec2, Vec3, Vec4 +@docs Int_, IVec2, IVec3, IVec4 +@docs Bool_, BVec2, BVec3, BVec4 +@docs Uint, Uint_, UVec2, UVec3, UVec4 +@docs Double, Double_, DVec2, DVec3, DVec4 +@docs Mat2, Mat3, Mat4, Mat23, Mat24, Mat32, Mat34, Mat42, Mat43 +@docs DMat2, DMat3, DMat4, DMat23, DMat24, DMat32, DMat34, DMat42, DMat43 +@docs Void, In, Out, Const + + +# Escape hatches + +@docs unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeCall6, unsafeCall7, unsafeCall8, unsafeCall9 +@docs unsafeMap, unsafeMap2, unsafeMap3 +@docs unsafeTypecast +@docs unsafeVar +@docs unsafeDot + + +# Building while tracking dependencies + +@docs build, withExpression, withStatement, withContinuation, buildExpression, buildStatement, WithDepsBuilder + +-} + +import SortedSet exposing (SortedSet) + + +block : List Stat -> Stat +block stats = + let + list : List Stat + list = + List.concatMap + (\stat -> + case stat of + Block a b children -> + a :: b :: children + + Nop -> + [] + + _ -> + [ stat ] + ) + stats + in + case list of + [] -> + Nop + + [ child ] -> + child + + a :: b :: c -> + Block a b c + + + +-- UNSAFE -- + + +unsafeCall0 : String -> List String -> Expression r +unsafeCall0 name dps = + build (Call (Variable name) []) + |> withDependencies dps + |> buildExpression + + +unsafeCall1 : String -> List String -> Expression t -> Expression r +unsafeCall1 name dps arg0 = + build (\a0 -> Call (Variable name) [ a0 ]) + |> withDependencies dps + |> withExpression arg0 + |> buildExpression + + +unsafeCall2 : String -> List String -> Expression t -> Expression u -> Expression r +unsafeCall2 name dps arg0 arg1 = + build (\a0 a1 -> Call (Variable name) [ a0, a1 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> buildExpression + + +unsafeCall3 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression r +unsafeCall3 name dps arg0 arg1 arg2 = + build (\a0 a1 a2 -> Call (Variable name) [ a0, a1, a2 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> buildExpression + + +unsafeCall4 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression r +unsafeCall4 name dps arg0 arg1 arg2 arg3 = + build (\a0 a1 a2 a3 -> Call (Variable name) [ a0, a1, a2, a3 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> buildExpression + + +unsafeCall5 : String -> List String -> Expression t -> Expression u -> Expression v -> Expression w -> Expression x -> Expression r +unsafeCall5 name dps arg0 arg1 arg2 arg3 arg4 = + build (\a0 a1 a2 a3 a4 -> Call (Variable name) [ a0, a1, a2, a3, a4 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> buildExpression + + +unsafeCall6 : String -> List String -> Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Expression f -> Expression r +unsafeCall6 name dps arg0 arg1 arg2 arg3 arg4 arg5 = + build (\a0 a1 a2 a3 a4 a5 -> Call (Variable name) [ a0, a1, a2, a3, a4, a5 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> withExpression arg5 + |> buildExpression + + +unsafeCall7 : String -> List String -> Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Expression f -> Expression g -> Expression r +unsafeCall7 name dps arg0 arg1 arg2 arg3 arg4 arg5 arg6 = + build (\a0 a1 a2 a3 a4 a5 a6 -> Call (Variable name) [ a0, a1, a2, a3, a4, a5, a6 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> withExpression arg5 + |> withExpression arg6 + |> buildExpression + + +unsafeCall8 : String -> List String -> Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Expression f -> Expression g -> Expression h -> Expression r +unsafeCall8 name dps arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 = + build (\a0 a1 a2 a3 a4 a5 a6 a7 -> Call (Variable name) [ a0, a1, a2, a3, a4, a5, a6, a7 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> withExpression arg5 + |> withExpression arg6 + |> withExpression arg7 + |> buildExpression + + +unsafeCall9 : String -> List String -> Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Expression f -> Expression g -> Expression h -> Expression i -> Expression r +unsafeCall9 name dps arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 = + build (\a0 a1 a2 a3 a4 a5 a6 a7 a8 -> Call (Variable name) [ a0, a1, a2, a3, a4, a5, a6, a7, a8 ]) + |> withDependencies dps + |> withExpression arg0 + |> withExpression arg1 + |> withExpression arg2 + |> withExpression arg3 + |> withExpression arg4 + |> withExpression arg5 + |> withExpression arg6 + |> withExpression arg7 + |> withExpression arg8 + |> buildExpression + + +unsafeMap : (Expr -> Expr) -> Expression a -> Expression b +unsafeMap f l = + build f + |> withExpression l + |> buildExpression + + +unsafeMap2 : (Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c +unsafeMap2 f l r = + build f + |> withExpression l + |> withExpression r + |> buildExpression + + +unsafeMap3 : (Expr -> Expr -> Expr -> Expr) -> Expression a -> Expression b -> Expression c -> Expression d +unsafeMap3 f l m r = + build f + |> withExpression l + |> withExpression m + |> withExpression r + |> buildExpression + + +unsafeTypecast : Expression a -> Expression b +unsafeTypecast (Expression a) = + Expression a + + +type WithDepsBuilder k + = WithDepsBuilder k (SortedSet String) + + +build : k -> WithDepsBuilder k +build k = + WithDepsBuilder k SortedSet.empty + + +withExpression : Expression e -> WithDepsBuilder (Expr -> k) -> WithDepsBuilder k +withExpression (Expression e) (WithDepsBuilder k dps) = + WithDepsBuilder (k e.expr) + (dps |> SortedSet.insertAll e.deps) + + +withStatement : Statement r -> WithDepsBuilder (Stat -> k) -> WithDepsBuilder k +withStatement (Statement s) (WithDepsBuilder k dps) = + WithDepsBuilder + (k s.stat) + (dps |> SortedSet.insertAll s.deps) + + +withContinuation : (() -> Statement r) -> WithDepsBuilder Stat -> Statement r +withContinuation next (WithDepsBuilder k dps) = + let + (Statement s) = + next () + in + Statement + { stat = block [ k, s.stat ] + , deps = dps |> SortedSet.insertAll s.deps + } + + +withDependencies : List String -> WithDepsBuilder k -> WithDepsBuilder k +withDependencies additionalDeps (WithDepsBuilder k dps) = + WithDepsBuilder k + (dps |> SortedSet.insertAll (SortedSet.fromList additionalDeps)) + + +buildStatement : WithDepsBuilder Stat -> Statement r +buildStatement (WithDepsBuilder stat dps) = + Statement + { stat = block [ stat ] + , deps = dps + } + + +buildExpression : WithDepsBuilder Expr -> Expression t +buildExpression (WithDepsBuilder expr dps) = + Expression + { expr = expr + , deps = dps + } + + + +-- Typed expressions + + +type Declaration + = FunctionDeclaration Function + | UniformDeclaration Uniform + | ConstDeclaration Const + + +type alias Function = + { returnType : Type + , name : String + , args : List ( Type, String ) + , stat : Stat + } + + +type alias Uniform = + { tipe : Type + , name : String + } + + +type alias Const = + { tipe : Type + , name : String + , value : Expr + } + + +type Expression t + = Expression ExprWithDeps + + +type alias ExprWithDeps = + { expr : Expr + , deps : SortedSet String + } + + +type Expr + = Bool Bool + | Int Int + | Float Float + | Uint Int + | Double Float + | Variable String + | Ternary Expr Expr Expr + | UnaryOperation UnaryOperation Expr + | BinaryOperation Expr BinaryOperation Expr + | Call Expr (List Expr) + | Dot Expr String + + +type BinaryOperation + = -- 2 + ArraySubscript + -- 4 + | By + | Div + | Mod + | -- 5 + Add + | Subtract + -- 6 + | ShiftLeft + | ShiftRight + -- 7 and 8 + | RelationOperation RelationOperation + -- 9 + | BitwiseAnd + -- 10 + | BitwiseOr + -- 11 + | BitwiseXor + -- 12 + | And + -- 13 + | Xor + -- 14 + | Or + -- 16 + | Assign + | ComboAdd + | ComboSubtract + | ComboBy + | ComboDiv + | ComboMod + | ComboLeftShift + | ComboRightShift + | ComboBitwiseAnd + | ComboBitwiseXor + | ComboBitwiseOr + -- 17 + | Comma + + +type RelationOperation + = -- 7 + LessThan + | GreaterThan + | LessThanOrEquals + | GreaterThanOrEquals + -- 8 + | Equals + | NotEquals + + +type UnaryOperation + = -- 2 + PostfixIncrement + | PostfixDecrement + -- 3 + | PrefixIncrement + | PrefixDecrement + | Plus + | Negate + | Invert + | Not + + + +-- Typed statements + + +type Statement r + = Statement + { stat : Stat + , deps : SortedSet String + } + + +type Stat + = If Expr Stat + | IfElse Expr Stat Stat + | For (Maybe Stat) Expr Expr Stat + | Return Expr + | Break + | Continue + | ExpressionStatement Expr + | Decl Type String (Maybe Expr) + | Nop + | Block Stat Stat (List Stat) + + +type alias TypingFunction t = + String -> TypedName t + + +type TypedName t + = TypedName Type String + + +type Type + = TVoid + -- bool + | TBool + | TBVec2 + | TBVec3 + | TBVec4 + -- int + | TInt + | TIVec2 + | TIVec3 + | TIVec4 + -- uint + | TUint + | TUVec2 + | TUVec3 + | TUVec4 + -- float + | TFloat + | TVec2 + | TVec3 + | TVec4 + -- double + | TDouble + | TDVec2 + | TDVec3 + | TDVec4 + -- mat + | TMat2 + | TMat3 + | TMat4 + | TMat23 + | TMat24 + | TMat32 + | TMat34 + | TMat42 + | TMat43 + | TDMat2 + | TDMat3 + | TDMat4 + | TDMat23 + | TDMat24 + | TDMat32 + | TDMat34 + | TDMat42 + | TDMat43 + -- Sampler/image + -- | TSampler1D + -- | TImage1D + -- | TSampler2D + -- | TImage2D + -- | TSampler3D + -- | TImage3D + -- | TSamplerCube + -- | TImageCube + -- | TSampler2DRect + -- | TImage2DRect + -- | TSampler1DArray + -- | TImage1DArray + -- | TSampler2DArray + -- | TImage2DArray + -- | TSamplerBuffer + -- | TImageBuffer + -- | TSampler2DMS + -- | TImage2DMS + -- | TSampler2DMSArray + -- | TImage2DMSArray + -- | TSamplerCubeArray + -- | TImageCubeArray + -- | TSampler1DShadow + -- | TSampler2DShadow + -- | TSampler2DRectShadow + -- | TSampler1DArrayShadow + -- | TSampler2DArrayShadow + -- | TSamplerCubeShadow + -- | TSamplerCubeArrayShadow + -- in/on + | TIn Type + | TOut Type + + + +-- Typelevel types. Eh. + + +type Vec t d + = Vec + + +type alias Float_ = + Vec Float D1 + + +type alias Vec2 = + Vec Float D2 + + +type alias Vec3 = + Vec Float D3 + + +type alias Vec4 = + Vec Float D4 + + +type alias D1 = + {} + + +type alias D2 = + { x : () + , y : () + } + + +type alias D3 = + { x : () + , y : () + , z : () + } + + +type alias D4 = + { x : () + , y : () + , z : () + , w : () + } + + +type alias Int_ = + Vec Int D1 + + +type alias IVec2 = + Vec Int D2 + + +type alias IVec3 = + Vec Int D3 + + +type alias IVec4 = + Vec Int D4 + + +type alias Bool_ = + Vec Bool D1 + + +type alias BVec2 = + Vec Bool D2 + + +type alias BVec3 = + Vec Bool D3 + + +type alias BVec4 = + Vec Bool D4 + + +type Uint + = UintType + + +type alias Uint_ = + Vec Uint D1 + + +type alias UVec2 = + Vec Uint D2 + + +type alias UVec3 = + Vec Uint D3 + + +type alias UVec4 = + Vec Uint D4 + + +type Double + = DoubleType + + +type alias Double_ = + Vec Double D1 + + +type alias DVec2 = + Vec Double D2 + + +type alias DVec3 = + Vec Double D3 + + +type alias DVec4 = + Vec Double D4 + + +type Mat t r c + = Mat + + +type alias Mat2 = + Mat Float D2 D2 + + +type alias Mat3 = + Mat Float D3 D3 + + +type alias Mat4 = + Mat Float D4 D4 + + +type alias Mat23 = + Mat Float D2 D3 + + +type alias Mat24 = + Mat Float D2 D4 + + +type alias Mat32 = + Mat Float D3 D2 + + +type alias Mat34 = + Mat Float D3 D4 + + +type alias Mat42 = + Mat Float D4 D2 + + +type alias Mat43 = + Mat Float D4 D3 + + +type alias DMat2 = + Mat Double D2 D2 + + +type alias DMat3 = + Mat Double D3 D3 + + +type alias DMat4 = + Mat Double D4 D4 + + +type alias DMat23 = + Mat Double D2 D3 + + +type alias DMat24 = + Mat Double D2 D4 + + +type alias DMat32 = + Mat Double D3 D2 + + +type alias DMat34 = + Mat Double D3 D4 + + +type alias DMat42 = + Mat Double D4 D2 + + +type alias DMat43 = + Mat Double D4 D3 + + +type Void + = Void + + +type In t + = In + + +type Out t + = Out + + + +-- Utils + + +true : Expression Bool_ +true = + bool1 True + + +false : Expression Bool_ +false = + bool1 False + + +bool1 : Bool -> Expression Bool_ +bool1 b = + pure <| Bool b + + +int1 : Int -> Expression Int_ +int1 i = + pure <| Int i + + +float1 : Float -> Expression Float_ +float1 i = + pure <| Float i + + +uint1 : Int -> Expression Uint +uint1 i = + pure <| Uint i + + +double1 : Float -> Expression Double_ +double1 i = + pure <| Double i + + +unsafeVar : String -> Expression t +unsafeVar v = + pure <| Variable v + + +unsafeDot : Expression t -> String -> Expression a +unsafeDot ex v = + unsafeMap (\e -> Dot e v) ex + + +pure : Expr -> Expression t +pure e = + Expression + { expr = e + , deps = SortedSet.empty + } + + +deps : Expression a -> List String +deps (Expression e) = + e.deps + |> SortedSet.toList diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Constants.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Constants.elm new file mode 100644 index 00000000..c5feeebc --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Constants.elm @@ -0,0 +1,45 @@ +module Glsl.Constants exposing + ( gl_FragColor, gl_FragCoord + , zero, one, minusOne + ) + +{-| + + +# Variables + +@docs gl_FragColor, gl_FragCoord + + +# Numbers + +@docs zero, one, minusOne + +-} + +import Glsl exposing (Expression, Float_, Vec4, float1, unsafeVar) + + +gl_FragColor : Expression Vec4 +gl_FragColor = + unsafeVar "gl_FragColor" + + +gl_FragCoord : Expression Vec4 +gl_FragCoord = + unsafeVar "gl_FragCoord" + + +zero : Expression Float_ +zero = + float1 0 + + +one : Expression Float_ +one = + float1 1 + + +minusOne : Expression Float_ +minusOne = + float1 -1 diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Dot.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Dot.elm new file mode 100644 index 00000000..fcbaf138 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Dot.elm @@ -0,0 +1,176 @@ +module Glsl.Dot exposing + ( x, y, z, w + , xx, xy, xz, xw + , yx, yy, yz, yw + , zx, zy, zz, zw + , wx, wy, wz, ww + , Dot(..) + , dot1, dot2, dot3, dot4 + , dx, dy, dz, dw + ) + +{-| + + +# Simple swizzles + +@docs x, y, z, w +@docs xx, xy, xz, xw +@docs yx, yy, yz, yw +@docs zx, zy, zz, zw +@docs wx, wy, wz, ww + + +# Arbitrary swizzles + +@docs Dot +@docs dot1, dot2, dot3, dot4 +@docs dx, dy, dz, dw + +-} + +import Glsl exposing (D1, D2, D3, D4, Expression, Vec, unsafeDot) + + +type Dot q + = Dotter Char + + +dx : Dot { a | x : x } +dx = + Dotter 'x' + + +dy : Dot { a | y : y } +dy = + Dotter 'y' + + +dz : Dot { a | z : z } +dz = + Dotter 'z' + + +dw : Dot { a | w : w } +dw = + Dotter 'w' + + +dot1 : Dot q -> Expression (Vec t q) -> Expression (Vec t D1) +dot1 (Dotter d1) e = + unsafeDot e (String.fromChar d1) + + +dot2 : Dot q -> Dot q -> Expression (Vec t q) -> Expression (Vec t D2) +dot2 (Dotter d1) (Dotter d2) e = + unsafeDot e (String.fromList [ d1, d2 ]) + + +xx : Expression (Vec t { a | x : x }) -> Expression (Vec t D2) +xx = + dot2 dx dx + + +xy : Expression (Vec t { a | x : x, y : y }) -> Expression (Vec t D2) +xy = + dot2 dx dy + + +xz : Expression (Vec t { a | x : x, z : z }) -> Expression (Vec t D2) +xz = + dot2 dx dz + + +xw : Expression (Vec t { a | x : x, w : w }) -> Expression (Vec t D2) +xw = + dot2 dx dw + + +yx : Expression (Vec t { a | y : y, x : x }) -> Expression (Vec t D2) +yx = + dot2 dy dx + + +yy : Expression (Vec t { a | y : y }) -> Expression (Vec t D2) +yy = + dot2 dy dy + + +yz : Expression (Vec t { a | y : y, z : z }) -> Expression (Vec t D2) +yz = + dot2 dy dz + + +yw : Expression (Vec t { a | y : y, w : w }) -> Expression (Vec t D2) +yw = + dot2 dy dw + + +zx : Expression (Vec t { a | z : z, x : x }) -> Expression (Vec t D2) +zx = + dot2 dz dx + + +zy : Expression (Vec t { a | z : z, y : y }) -> Expression (Vec t D2) +zy = + dot2 dz dy + + +zz : Expression (Vec t { a | z : z }) -> Expression (Vec t D2) +zz = + dot2 dz dz + + +zw : Expression (Vec t { a | z : z, w : w }) -> Expression (Vec t D2) +zw = + dot2 dz dw + + +wx : Expression (Vec t { a | w : w, x : x }) -> Expression (Vec t D2) +wx = + dot2 dw dx + + +wy : Expression (Vec t { a | w : w, y : y }) -> Expression (Vec t D2) +wy = + dot2 dw dy + + +wz : Expression (Vec t { a | w : w, z : z }) -> Expression (Vec t D2) +wz = + dot2 dw dz + + +ww : Expression (Vec t { a | w : w }) -> Expression (Vec t D2) +ww = + dot2 dw dw + + +dot3 : Dot q -> Dot q -> Dot q -> Expression (Vec t q) -> Expression (Vec t D3) +dot3 (Dotter d1) (Dotter d2) (Dotter d3) e = + unsafeDot e (String.fromList [ d1, d2, d3 ]) + + +dot4 : Dot q -> Dot q -> Dot q -> Dot q -> Expression (Vec t q) -> Expression (Vec t D4) +dot4 (Dotter d1) (Dotter d2) (Dotter d3) (Dotter d4) e = + unsafeDot e (String.fromList [ d1, d2, d3, d4 ]) + + +x : Expression (Vec t { a | x : x }) -> Expression (Vec t D1) +x e = + dot1 dx e + + +y : Expression (Vec t { a | y : y }) -> Expression (Vec t D1) +y e = + dot1 dy e + + +z : Expression (Vec t { a | z : z }) -> Expression (Vec t D1) +z e = + dot1 dz e + + +w : Expression (Vec t { a | w : w }) -> Expression (Vec t D1) +w e = + dot1 dw e diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Eval.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Eval.elm new file mode 100644 index 00000000..18642d76 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Eval.elm @@ -0,0 +1,370 @@ +module Glsl.Eval exposing (Context, Error(..), Value(..), interpret, value) + +import Dict exposing (Dict) +import Glsl exposing (BinaryOperation(..), Expr(..), Expression(..), RelationOperation(..), Stat(..), Statement(..), UnaryOperation(..)) + + +type Value + = VFloat Float + | VBool Bool + | VInt Int + | VVec2 Float Float + | VVec3 Float Float Float + | VMat3 ( Float, Float, Float ) ( Float, Float, Float ) ( Float, Float, Float ) + | VVoid -- Used for void return + + +type alias Context = + Dict String Value + + +type Error + = MissingVariable String + | InvalidTypes String + + +value : Context -> Expression t -> Result Error ( Context, Value ) +value initialContext (Expression input) = + innerValue initialContext input.expr + + +innerValue : Context -> Expr -> Result Error ( Context, Value ) +innerValue ctx e = + case e of + Float f -> + Ok ( ctx, VFloat f ) + + Bool b -> + Ok ( ctx, VBool b ) + + Int i -> + Ok ( ctx, VInt i ) + + Variable v -> + case Dict.get v ctx of + Just f -> + Ok ( ctx, f ) + + Nothing -> + Err <| MissingVariable v + + UnaryOperation Negate c -> + innerValue ctx c + |> Result.andThen + (\( ctx2, vc ) -> + case vc of + VFloat fc -> + Ok ( ctx2, VFloat <| negate fc ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `-` for " ++ valueToString vc) + ) + + BinaryOperation l And r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl && br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `and` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + BinaryOperation l Or r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VBool bl, VBool br ) -> + Ok ( ctx2, VBool <| bl || br ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `or` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + BinaryOperation l (RelationOperation k) r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr, k ) of + ( VFloat fl, VFloat fr, LessThan ) -> + Ok ( ctx2, VBool (fl < fr) ) + + ( VFloat fl, VFloat fr, LessThanOrEquals ) -> + Ok ( ctx2, VBool (fl <= fr) ) + + ( VFloat fl, VFloat fr, Equals ) -> + Ok ( ctx2, VBool (fl == fr) ) + + ( VFloat fl, VFloat fr, GreaterThanOrEquals ) -> + Ok ( ctx2, VBool (fl >= fr) ) + + ( VFloat fl, VFloat fr, GreaterThan ) -> + Ok ( ctx2, VBool (fl > fr) ) + + _ -> + Err <| + InvalidTypes + ("Cannot compare " ++ valueToString vl ++ " and " ++ valueToString vr) + + BinaryOperation l By r -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VFloat <| fl * fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `*` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Call (Variable "vec2") [ l, r ] -> + innerValue2 ctx l r <| \ctx2 vl vr -> + case ( vl, vr ) of + ( VFloat fl, VFloat fr ) -> + Ok ( ctx2, VVec2 fl fr ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `vec2` for " ++ valueToString vl ++ " and " ++ valueToString vr) + + Call (Variable "exp") [ l ] -> + autovectorizingFloatOp ctx "exp" (\fv -> Basics.e ^ fv) l + + Call (Variable "cos") [ l ] -> + autovectorizingFloatOp ctx "cos" Basics.cos l + + Call (Variable "sin") [ l ] -> + autovectorizingFloatOp ctx "sin" Basics.sin l + + Call name args -> + Debug.todo <| + "branch 'Call \"" + ++ Debug.toString name + ++ "\" [" + ++ String.join ", " (List.map (Debug.toString >> (++) " ") args) + ++ " ]' not implemented" + + Dot _ _ -> + Debug.todo "branch 'Dot _ _' not implemented" + + Uint _ -> + Debug.todo "branch 'Uint _' not implemented" + + Double _ -> + Debug.todo "branch 'Double _' not implemented" + + UnaryOperation PostfixIncrement _ -> + Debug.todo "branch 'UnaryOperation PostfixIncrement _' not implemented" + + UnaryOperation PostfixDecrement _ -> + Debug.todo "branch 'UnaryOperation PostfixDecrement _' not implemented" + + UnaryOperation PrefixIncrement _ -> + Debug.todo "branch 'UnaryOperation PrefixIncrement _' not implemented" + + UnaryOperation PrefixDecrement _ -> + Debug.todo "branch 'UnaryOperation PrefixDecrement _' not implemented" + + UnaryOperation Plus _ -> + Debug.todo "branch 'UnaryOperation Plus _' not implemented" + + UnaryOperation Invert _ -> + Debug.todo "branch 'UnaryOperation Invert _' not implemented" + + UnaryOperation Not _ -> + Debug.todo "branch 'UnaryOperation Not _' not implemented" + + BinaryOperation _ ArraySubscript _ -> + Debug.todo "branch 'BinaryOperation _ ArraySubscript _' not implemented" + + BinaryOperation _ Mod _ -> + Debug.todo "branch 'BinaryOperation _ Mod _' not implemented" + + BinaryOperation _ ShiftLeft _ -> + Debug.todo "branch 'BinaryOperation _ ShiftLeft _' not implemented" + + BinaryOperation _ ShiftRight _ -> + Debug.todo "branch 'BinaryOperation _ ShiftRight _' not implemented" + + BinaryOperation _ BitwiseAnd _ -> + Debug.todo "branch 'BinaryOperation _ BitwiseAnd _' not implemented" + + BinaryOperation _ BitwiseOr _ -> + Debug.todo "branch 'BinaryOperation _ BitwiseOr _' not implemented" + + BinaryOperation _ BitwiseXor _ -> + Debug.todo "branch 'BinaryOperation _ BitwiseXor _' not implemented" + + BinaryOperation _ Xor _ -> + Debug.todo "branch 'BinaryOperation _ Xor _' not implemented" + + BinaryOperation _ Assign _ -> + Debug.todo "branch 'BinaryOperation _ Assign _' not implemented" + + BinaryOperation _ ComboAdd _ -> + Debug.todo "branch 'BinaryOperation _ ComboAdd _' not implemented" + + BinaryOperation _ ComboSubtract _ -> + Debug.todo "branch 'BinaryOperation _ ComboSubtract _' not implemented" + + BinaryOperation _ ComboBy _ -> + Debug.todo "branch 'BinaryOperation _ ComboBy _' not implemented" + + BinaryOperation _ ComboDiv _ -> + Debug.todo "branch 'BinaryOperation _ ComboDiv _' not implemented" + + BinaryOperation _ ComboMod _ -> + Debug.todo "branch 'BinaryOperation _ ComboMod _' not implemented" + + BinaryOperation _ ComboLeftShift _ -> + Debug.todo "branch 'BinaryOperation _ ComboLeftShift _' not implemented" + + BinaryOperation _ ComboRightShift _ -> + Debug.todo "branch 'BinaryOperation _ ComboRightShift _' not implemented" + + BinaryOperation _ ComboBitwiseAnd _ -> + Debug.todo "branch 'BinaryOperation _ ComboBitwiseAnd _' not implemented" + + BinaryOperation _ ComboBitwiseXor _ -> + Debug.todo "branch 'BinaryOperation _ ComboBitwiseXor _' not implemented" + + BinaryOperation _ ComboBitwiseOr _ -> + Debug.todo "branch 'BinaryOperation _ ComboBitwiseOr _' not implemented" + + BinaryOperation _ Comma _ -> + Debug.todo "branch 'BinaryOperation _ Comma _' not implemented" + + Ternary _ _ _ -> + Debug.todo "branch 'Ternary _ _ _' not implemented" + + BinaryOperation _ Div _ -> + Debug.todo "branch 'BinaryOperation _ Div _' not implemented" + + BinaryOperation _ Add _ -> + Debug.todo "branch 'BinaryOperation _ Add _' not implemented" + + BinaryOperation _ Subtract _ -> + Debug.todo "branch 'BinaryOperation _ Subtract _' not implemented" + + +innerValue2 : + Context + -> Expr + -> Expr + -> (Context -> Value -> Value -> Result Error ( Context, Value )) + -> Result Error ( Context, Value ) +innerValue2 ctx l r k = + innerValue ctx l + |> Result.andThen + (\( ctx2, vl ) -> + innerValue ctx2 r + |> Result.andThen + (\( ctx3, vr ) -> + k ctx3 vl vr + ) + ) + + +autovectorizingFloatOp : Context -> String -> (Float -> Float) -> Expr -> Result Error ( Dict String Value, Value ) +autovectorizingFloatOp ctx name inner e = + innerValue ctx e + |> Result.andThen + (\( ctx2, v ) -> + case v of + VFloat fv -> + Ok ( ctx2, VFloat <| inner fv ) + + VVec2 x y -> + Ok ( ctx2, VVec2 (inner x) (inner y) ) + + VVec3 x y z -> + Ok ( ctx2, VVec3 (inner x) (inner y) (inner z) ) + + _ -> + Err <| + InvalidTypes + ("Cannot calculate `" ++ name ++ "` for " ++ valueToString v) + ) + + +interpret : Context -> Statement a -> Result Error ( Context, Value ) +interpret ctx (Statement s) = + innerInterpret ctx s.stat + + +innerInterpret : Context -> Stat -> Result Error ( Context, Value ) +innerInterpret ctx stat = + case stat of + Return e -> + innerValue ctx e + + If c t -> + c + |> innerValue ctx + |> Result.andThen + (\( ctx2, cval ) -> + case cval of + VBool True -> + innerInterpret ctx2 t + + VBool False -> + Ok ( ctx2, VVoid ) + + _ -> + Err <| InvalidTypes <| "Condition of if evaluated to " ++ Debug.toString cval + ) + + IfElse _ _ _ -> + Debug.todo "branch 'IfElse _' not implemented" + + Nop -> + Ok ( ctx, VVoid ) + + ExpressionStatement _ -> + Debug.todo "branch 'ExpressionStatement _' not implemented" + + Decl _ _ _ -> + Debug.todo "branch 'Decl _ _ _' not implemented" + + For _ _ _ _ -> + Debug.todo "branch 'For _ _ _ _' not implemented" + + Break -> + Debug.todo "branch 'Break' not implemented" + + Continue -> + Debug.todo "branch 'Continue' not implemented" + + Block _ _ _ -> + Debug.todo "branch 'Block _ _ _' not implemented" + + +valueToString : Value -> String +valueToString v = + case v of + VFloat f -> + String.fromFloat f + + VBool b -> + if b then + "true" + + else + "false" + + VInt i -> + String.fromInt i + + VVoid -> + "void" + + VVec2 x y -> + "vec2(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ ")" + + VVec3 x y z -> + "vec3(" ++ String.fromFloat x ++ "," ++ String.fromFloat y ++ "," ++ String.fromFloat z ++ ")" + + VMat3 _ _ _ -> + Debug.todo "branch 'VMat3 _ _ _' not implemented" diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm new file mode 100644 index 00000000..92944cb9 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm @@ -0,0 +1,21191 @@ +module Glsl.Functions exposing (abs1, abs2, abs3, abs4, abs_, absd1, absd2, absd3, absd4, absf, absi1, absi2, absi3, absi4, abswd1, abswi1, acos_, acosh, asin_, asinh, atan2_, atan_, atanh, ceil, ceil1, ceil2, ceil3, ceil4, ceild1, ceild2, ceild3, ceild4, ceilf, ceilwd1, clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f, clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333, clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1, clamp4ff, clamp_, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1, clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1, clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4, clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff, clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1, clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3, clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1, clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1, clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1, clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4, clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1, clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1, clampwu1wu1u1, clampwu1wu1wu1, cos_, cosh, cross33, crossd3d3, dFdx, dFdxCoarse, dFdxFine, dFdy, dFdyCoarse, dFdyFine, degrees_, distance, distance11, distance1f, distance22, distance33, distance44, distanced1d1, distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff, distancewd1d1, distancewd1wd1, dot, dot11, dot1f, dot22, dot33, dot44, dotd1d1, dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff, dotwd1d1, dotwd1wd1, exp, exp2, faceforward, faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333, faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2, faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff, faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf, floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf, floati1, floatwi1, floor1, floor2, floor3, floor4, floor_, floord1, floord2, floord3, floord4, floorf, floorwd1, fma, fma111, fma11f, fma1f1, fma1ff, fma222, fma333, fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2, fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff, fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fract, fract1, fract2, fract3, fract4, fractd1, fractd2, fractd3, fractd4, fractf, fractwd1, frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1, frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1, frexpwd1oi1, frexpwd1owi1, fwidth, fwidthCoarse, fwidthFine, int1, intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1, intf, inversesqrt, inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2, inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2, isinfd3, isinfd4, isinff, isinfwd1, isnan1, isnan2, isnan3, isnan4, isnand1, isnand2, isnand3, isnand4, isnanf, isnanwd1, ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1, ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1, ivec3wi1wi1i1, ivec3wi1wi1wi1, ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1, ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1, ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1, ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1, ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1, ldexpwd1i1, ldexpwd1wi1, length, length1, length2, length3, length4, lengthd1, lengthd2, lengthd3, lengthd4, lengthf, lengthwd1, log, log2, mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f, mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1, mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff, mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f, mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff, mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f, mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff, mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f, mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff, mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f, mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff, mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f, mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff, mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f, mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff, mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f, mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff, mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f, mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff, mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f, mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff, mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f, mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff, mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f, mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff, mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f, mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff, mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f, mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff, mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f, mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff, mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f, mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff, mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f, mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff, mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f, mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff, mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f, mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff, mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f, mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff, mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f, mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff, mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f, mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff, mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111, mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1, mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11, mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1, mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111, mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1, mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11, mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1, mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111, mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1, mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11, mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1, mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111, mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1, mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11, mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1, mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111, mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1, mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11, mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1, mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111, mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1, mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11, mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1, mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111, mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1, mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11, mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1, mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111, mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1, mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11, mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1, mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111, mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1, mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11, mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1, mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111, mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1, mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11, mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1, mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111, mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1, mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11, mat3fffffff1f, mat3ffffffff1, mat3fffffffff, mat44444, max11, max1f, max21, max22, max2f, max31, max33, max3f, max41, max44, max4f, max_, maxd1d1, maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3, maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff, maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1, maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1, maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3, maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1, maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1, min11, min1f, min21, min22, min2f, min31, min33, min3f, min41, min44, min4f, min_, mind1d1, mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3, mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff, mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1, mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1, minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3, minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1, minwi1i1, minwi1wi1, minwu1u1, minwu1wu1, mix, mix111, mix11f, mix1f1, mix1ff, mix221, mix222, mix22f, mix331, mix333, mix33f, mix441, mix444, mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1, mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1, mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff, mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mod, mod11, mod1f, mod21, mod22, mod2f, mod31, mod33, mod3f, mod41, mod44, mod4f, modd1d1, modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3, modd3wd1, modd4d1, modd4d4, modd4wd1, modf, modf1, modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1, modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modff, modffo1, modffof, modfwd1od1, modfwd1owd1, modwd1d1, modwd1wd1, normalize, normalize1, normalize2, normalize3, normalize4, normalized1, normalized2, normalized3, normalized4, normalizef, normalizewd1, pow, radians_, reflect, reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1, reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff, reflectwd1d1, reflectwd1wd1, refract, refract111, refract11f, refract1f1, refract1ff, refract221, refract22f, refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f, refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f, refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff, refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, round1, round2, round3, round4, roundEven, roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2, roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, round_, roundd1, roundd2, roundd3, roundd4, roundf, roundwd1, sign, sign1, sign2, sign3, sign4, signd1, signd2, signd3, signd4, signf, signi1, signi2, signi3, signi4, signwd1, signwi1, sin_, sinh, smoothstep, smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1, smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333, smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1, smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2, smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14, smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff, smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1, smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, sqrt1, sqrt2, sqrt3, sqrt4, sqrt_, sqrtd1, sqrtd2, sqrtd3, sqrtd4, sqrtf, sqrtwd1, step, step11, step12, step13, step14, step1f, step22, step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4, stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2, stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3, stepwd1d4, stepwd1wd1, tan_, tanh, trunc, trunc1, trunc2, trunc3, trunc4, truncd1, truncd2, truncd3, truncd4, truncf, truncwd1, uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1, vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f, vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11, vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f, vec2wi1i1, vec2wi1wi1, vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312, vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f, vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1, vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1, vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1, vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f, vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1, vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11, vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1, vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1, vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f, vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1, vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1, vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1, vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413, vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff, vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1, vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f, vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1, vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f, vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1, vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f, vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1, vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f, vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1, vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f, vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1, vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11, vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1, vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1, vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1, vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111, vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1, vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11, vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f, vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1, vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f, vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1, vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f, vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1, vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff, vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1, vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f, vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1, vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f, vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1, vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11, vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1, vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1, vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1, vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111, vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1, vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11, vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1, vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11, vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1, vec4wi1wi1wi1wi1) + +{-| + +@docs abs1, abs2, abs3, abs4, abs_, absd1, absd2, absd3, absd4, absf, absi1, absi2, absi3, absi4, abswd1, abswi1, acos_, acosh, asin_, asinh, atan2_, atan_, atanh, ceil, ceil1, ceil2, ceil3, ceil4, ceild1, ceild2, ceild3, ceild4, ceilf, ceilwd1, clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f, clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333, clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1, clamp4ff, clamp_, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1, clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1, clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4, clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff, clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1, clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3, clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1, clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1, clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1, clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4, clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1, clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1, clampwu1wu1u1, clampwu1wu1wu1, cos_, cosh, cross33, crossd3d3, dFdx, dFdxCoarse, dFdxFine, dFdy, dFdyCoarse, dFdyFine, degrees_, distance, distance11, distance1f, distance22, distance33, distance44, distanced1d1, distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff, distancewd1d1, distancewd1wd1, dot, dot11, dot1f, dot22, dot33, dot44, dotd1d1, dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff, dotwd1d1, dotwd1wd1, exp, exp2, faceforward, faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333, faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2, faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff, faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf, floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf, floati1, floatwi1, floor1, floor2, floor3, floor4, floor_, floord1, floord2, floord3, floord4, floorf, floorwd1, fma, fma111, fma11f, fma1f1, fma1ff, fma222, fma333, fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2, fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff, fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fract, fract1, fract2, fract3, fract4, fractd1, fractd2, fractd3, fractd4, fractf, fractwd1, frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1, frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1, frexpwd1oi1, frexpwd1owi1, fwidth, fwidthCoarse, fwidthFine, int1, intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1, intf, inversesqrt, inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2, inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2, isinfd3, isinfd4, isinff, isinfwd1, isnan1, isnan2, isnan3, isnan4, isnand1, isnand2, isnand3, isnand4, isnanf, isnanwd1, ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1, ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1, ivec3wi1wi1i1, ivec3wi1wi1wi1, ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1, ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1, ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1, ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1, ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1, ldexpwd1i1, ldexpwd1wi1, length, length1, length2, length3, length4, lengthd1, lengthd2, lengthd3, lengthd4, lengthf, lengthwd1, log, log2, mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f, mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1, mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff, mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f, mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff, mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f, mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff, mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f, mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff, mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f, mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff, mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f, mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff, mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f, mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff, mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f, mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff, mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f, mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff, mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f, mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff, mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f, mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff, mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f, mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff, mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f, mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff, mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f, mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff, mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f, mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff, mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f, mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff, mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f, mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff, mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f, mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff, mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f, mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff, mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f, mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff, mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f, mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff, mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f, mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff, mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111, mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1, mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11, mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1, mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111, mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1, mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11, mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1, mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111, mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1, mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11, mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1, mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111, mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1, mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11, mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1, mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111, mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1, mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11, mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1, mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111, mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1, mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11, mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1, mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111, mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1, mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11, mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1, mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111, mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1, mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11, mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1, mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111, mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1, mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11, mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1, mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111, mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1, mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11, mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1, mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111, mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1, mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11, mat3fffffff1f, mat3ffffffff1, mat3fffffffff, mat44444, max11, max1f, max21, max22, max2f, max31, max33, max3f, max41, max44, max4f, max_, maxd1d1, maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3, maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff, maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1, maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1, maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3, maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1, maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1, min11, min1f, min21, min22, min2f, min31, min33, min3f, min41, min44, min4f, min_, mind1d1, mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3, mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff, mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1, mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1, minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3, minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1, minwi1i1, minwi1wi1, minwu1u1, minwu1wu1, mix, mix111, mix11f, mix1f1, mix1ff, mix221, mix222, mix22f, mix331, mix333, mix33f, mix441, mix444, mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1, mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1, mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff, mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mod, mod11, mod1f, mod21, mod22, mod2f, mod31, mod33, mod3f, mod41, mod44, mod4f, modd1d1, modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3, modd3wd1, modd4d1, modd4d4, modd4wd1, modf, modf1, modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1, modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modff, modffo1, modffof, modfwd1od1, modfwd1owd1, modwd1d1, modwd1wd1, normalize, normalize1, normalize2, normalize3, normalize4, normalized1, normalized2, normalized3, normalized4, normalizef, normalizewd1, pow, radians_, reflect, reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1, reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff, reflectwd1d1, reflectwd1wd1, refract, refract111, refract11f, refract1f1, refract1ff, refract221, refract22f, refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f, refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f, refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff, refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, round1, round2, round3, round4, roundEven, roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2, roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, round_, roundd1, roundd2, roundd3, roundd4, roundf, roundwd1, sign, sign1, sign2, sign3, sign4, signd1, signd2, signd3, signd4, signf, signi1, signi2, signi3, signi4, signwd1, signwi1, sin_, sinh, smoothstep, smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1, smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333, smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1, smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2, smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14, smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff, smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1, smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, sqrt1, sqrt2, sqrt3, sqrt4, sqrt_, sqrtd1, sqrtd2, sqrtd3, sqrtd4, sqrtf, sqrtwd1, step, step11, step12, step13, step14, step1f, step22, step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4, stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2, stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3, stepwd1d4, stepwd1wd1, tan_, tanh, trunc, trunc1, trunc2, trunc3, trunc4, truncd1, truncd2, truncd3, truncd4, truncf, truncwd1, uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1, vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f, vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11, vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f, vec2wi1i1, vec2wi1wi1, vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312, vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f, vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1, vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1, vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1, vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f, vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1, vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11, vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1, vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1, vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f, vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1, vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1, vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1, vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413, vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff, vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1, vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f, vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1, vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f, vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1, vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f, vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1, vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f, vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1, vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f, vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1, vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11, vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1, vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1, vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1, vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111, vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1, vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11, vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f, vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1, vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f, vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1, vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f, vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1, vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff, vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1, vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f, vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1, vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f, vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1, vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11, vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1, vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1, vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1, vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111, vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1, vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11, vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1, vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11, vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1, vec4wi1wi1wi1wi1 + +-} + +import Glsl + + +abs1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +abs1 a = + Glsl.unsafeCall1 "abs" [] a + + +abs2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +abs2 a = + Glsl.unsafeCall1 "abs" [] a + + +abs3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +abs3 a = + Glsl.unsafeCall1 "abs" [] a + + +abs4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +abs4 a = + Glsl.unsafeCall1 "abs" [] a + + +absd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +absd1 a = + Glsl.unsafeCall1 "abs" [] a + + +absd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +absd2 a = + Glsl.unsafeCall1 "abs" [] a + + +absd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +absd3 a = + Glsl.unsafeCall1 "abs" [] a + + +absd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +absd4 a = + Glsl.unsafeCall1 "abs" [] a + + +absf : Float -> Glsl.Expression Glsl.Float_ +absf a = + Glsl.unsafeCall1 "abs" [] (Glsl.float1 a) + + +absi1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Int_ +absi1 a = + Glsl.unsafeCall1 "abs" [] a + + +absi2 : Glsl.Expression Glsl.IVec2 -> Glsl.Expression Glsl.IVec2 +absi2 a = + Glsl.unsafeCall1 "abs" [] a + + +absi3 : Glsl.Expression Glsl.IVec3 -> Glsl.Expression Glsl.IVec3 +absi3 a = + Glsl.unsafeCall1 "abs" [] a + + +absi4 : Glsl.Expression Glsl.IVec4 -> Glsl.Expression Glsl.IVec4 +absi4 a = + Glsl.unsafeCall1 "abs" [] a + + +abswd1 : Float -> Glsl.Expression Glsl.Double +abswd1 a = + Glsl.unsafeCall1 "abs" [] (Glsl.double1 a) + + +abswi1 : Int -> Glsl.Expression Glsl.Int_ +abswi1 a = + Glsl.unsafeCall1 "abs" [] (Glsl.int1 a) + + +ceil1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +ceil1 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceil2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +ceil2 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceil3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +ceil3 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceil4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +ceil4 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceild1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +ceild1 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceild2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +ceild2 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceild3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +ceild3 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceild4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +ceild4 a = + Glsl.unsafeCall1 "ceil" [] a + + +ceilf : Float -> Glsl.Expression Glsl.Float_ +ceilf a = + Glsl.unsafeCall1 "ceil" [] (Glsl.float1 a) + + +ceilwd1 : Float -> Glsl.Expression Glsl.Double +ceilwd1 a = + Glsl.unsafeCall1 "ceil" [] (Glsl.double1 a) + + +ceil : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +ceil a = + Glsl.unsafeCall1 "ceil" [] a + + +clamp111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +clamp111 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +clamp11f a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.float1 c) + + +clamp1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +clamp1f1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) c + + +clamp1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +clamp1ff a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) (Glsl.float1 c) + + +clamp211 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +clamp211 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp21f : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec2 +clamp21f a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.float1 c) + + +clamp222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +clamp222 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp2f1 : + Glsl.Expression Glsl.Vec2 + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +clamp2f1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) c + + +clamp2ff : Glsl.Expression Glsl.Vec2 -> Float -> Float -> Glsl.Expression Glsl.Vec2 +clamp2ff a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) (Glsl.float1 c) + + +clamp311 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +clamp311 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp31f : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec3 +clamp31f a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.float1 c) + + +clamp333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +clamp333 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp3f1 : + Glsl.Expression Glsl.Vec3 + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +clamp3f1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) c + + +clamp3ff : Glsl.Expression Glsl.Vec3 -> Float -> Float -> Glsl.Expression Glsl.Vec3 +clamp3ff a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) (Glsl.float1 c) + + +clamp411 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +clamp411 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp41f : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +clamp41f a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.float1 c) + + +clamp444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +clamp444 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clamp4f1 : + Glsl.Expression Glsl.Vec4 + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +clamp4f1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) c + + +clamp4ff : Glsl.Expression Glsl.Vec4 -> Float -> Float -> Glsl.Expression Glsl.Vec4 +clamp4ff a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.float1 b) (Glsl.float1 c) + + +clampd1d1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +clampd1d1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd1d1wd1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +clampd1d1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.double1 c) + + +clampd1wd1d1 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +clampd1wd1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) c + + +clampd1wd1wd1 : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +clampd1wd1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) (Glsl.double1 c) + + +clampd2d1d1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +clampd2d1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd2d1wd1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec2 +clampd2d1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.double1 c) + + +clampd2d2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +clampd2d2d2 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd2wd1d1 : + Glsl.Expression Glsl.DVec2 + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +clampd2wd1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) c + + +clampd2wd1wd1 : Glsl.Expression Glsl.DVec2 -> Float -> Float -> Glsl.Expression Glsl.DVec2 +clampd2wd1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) (Glsl.double1 c) + + +clampd3d1d1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +clampd3d1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd3d1wd1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec3 +clampd3d1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.double1 c) + + +clampd3d3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +clampd3d3d3 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd3wd1d1 : + Glsl.Expression Glsl.DVec3 + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +clampd3wd1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) c + + +clampd3wd1wd1 : Glsl.Expression Glsl.DVec3 -> Float -> Float -> Glsl.Expression Glsl.DVec3 +clampd3wd1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) (Glsl.double1 c) + + +clampd4d1d1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +clampd4d1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd4d1wd1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec4 +clampd4d1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.double1 c) + + +clampd4d4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +clampd4d4d4 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampd4wd1d1 : + Glsl.Expression Glsl.DVec4 + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +clampd4wd1d1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) c + + +clampd4wd1wd1 : Glsl.Expression Glsl.DVec4 -> Float -> Float -> Glsl.Expression Glsl.DVec4 +clampd4wd1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.double1 b) (Glsl.double1 c) + + +clampf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +clampf11 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.float1 a) b c + + +clampf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +clampf1f a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.float1 a) b (Glsl.float1 c) + + +clampff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +clampff1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.float1 a) (Glsl.float1 b) c + + +clampfff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +clampfff a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) + + +clampi1i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ +clampi1i1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ +clampi1i1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.int1 c) + + +clampi1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ +clampi1wi1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) c + + +clampi1wi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Int -> Glsl.Expression Glsl.Int_ +clampi1wi1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) (Glsl.int1 c) + + +clampi2i1i1 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec2 +clampi2i1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi2i1wi1 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.IVec2 +clampi2i1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.int1 c) + + +clampi2i2i2 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 +clampi2i2i2 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi2wi1i1 : + Glsl.Expression Glsl.IVec2 + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec2 +clampi2wi1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) c + + +clampi2wi1wi1 : Glsl.Expression Glsl.IVec2 -> Int -> Int -> Glsl.Expression Glsl.IVec2 +clampi2wi1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) (Glsl.int1 c) + + +clampi3i1i1 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec3 +clampi3i1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi3i1wi1 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.IVec3 +clampi3i1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.int1 c) + + +clampi3i3i3 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 +clampi3i3i3 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi3wi1i1 : + Glsl.Expression Glsl.IVec3 + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec3 +clampi3wi1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) c + + +clampi3wi1wi1 : Glsl.Expression Glsl.IVec3 -> Int -> Int -> Glsl.Expression Glsl.IVec3 +clampi3wi1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) (Glsl.int1 c) + + +clampi4i1i1 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec4 +clampi4i1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi4i1wi1 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.IVec4 +clampi4i1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.int1 c) + + +clampi4i4i4 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 +clampi4i4i4 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampi4wi1i1 : + Glsl.Expression Glsl.IVec4 + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec4 +clampi4wi1i1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) c + + +clampi4wi1wi1 : Glsl.Expression Glsl.IVec4 -> Int -> Int -> Glsl.Expression Glsl.IVec4 +clampi4wi1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.int1 b) (Glsl.int1 c) + + +clampu1u1u1 : + Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint +clampu1u1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu1u1wu1 : + Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Int + -> Glsl.Expression Glsl.Uint +clampu1u1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.uint1 c) + + +clampu1wu1u1 : + Glsl.Expression Glsl.Uint + -> Int + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint +clampu1wu1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) c + + +clampu1wu1wu1 : Glsl.Expression Glsl.Uint -> Int -> Int -> Glsl.Expression Glsl.Uint +clampu1wu1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) (Glsl.uint1 c) + + +clampu2u1u1 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec2 +clampu2u1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu2u1wu1 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.Uint + -> Int + -> Glsl.Expression Glsl.UVec2 +clampu2u1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.uint1 c) + + +clampu2u2u2 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 +clampu2u2u2 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu2wu1u1 : + Glsl.Expression Glsl.UVec2 + -> Int + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec2 +clampu2wu1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) c + + +clampu2wu1wu1 : Glsl.Expression Glsl.UVec2 -> Int -> Int -> Glsl.Expression Glsl.UVec2 +clampu2wu1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) (Glsl.uint1 c) + + +clampu3u1u1 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec3 +clampu3u1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu3u1wu1 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.Uint + -> Int + -> Glsl.Expression Glsl.UVec3 +clampu3u1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.uint1 c) + + +clampu3u3u3 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 +clampu3u3u3 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu3wu1u1 : + Glsl.Expression Glsl.UVec3 + -> Int + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec3 +clampu3wu1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) c + + +clampu3wu1wu1 : Glsl.Expression Glsl.UVec3 -> Int -> Int -> Glsl.Expression Glsl.UVec3 +clampu3wu1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) (Glsl.uint1 c) + + +clampu4u1u1 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec4 +clampu4u1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu4u1wu1 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.Uint + -> Int + -> Glsl.Expression Glsl.UVec4 +clampu4u1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a b (Glsl.uint1 c) + + +clampu4u4u4 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 +clampu4u4u4 a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +clampu4wu1u1 : + Glsl.Expression Glsl.UVec4 + -> Int + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec4 +clampu4wu1u1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) c + + +clampu4wu1wu1 : Glsl.Expression Glsl.UVec4 -> Int -> Int -> Glsl.Expression Glsl.UVec4 +clampu4wu1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] a (Glsl.uint1 b) (Glsl.uint1 c) + + +clampwd1d1d1 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +clampwd1d1d1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.double1 a) b c + + +clampwd1d1wd1 : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +clampwd1d1wd1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.double1 a) b (Glsl.double1 c) + + +clampwd1wd1d1 : Float -> Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +clampwd1wd1d1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.double1 a) (Glsl.double1 b) c + + +clampwd1wd1wd1 : Float -> Float -> Float -> Glsl.Expression Glsl.Double +clampwd1wd1wd1 a b c = + Glsl.unsafeCall3 + "clamp" + [] + (Glsl.double1 a) + (Glsl.double1 b) + (Glsl.double1 c) + + +clampwi1i1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ +clampwi1i1i1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.int1 a) b c + + +clampwi1i1wi1 : Int -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Int_ +clampwi1i1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.int1 a) b (Glsl.int1 c) + + +clampwi1wi1i1 : Int -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Int_ +clampwi1wi1i1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.int1 a) (Glsl.int1 b) c + + +clampwi1wi1wi1 : Int -> Int -> Int -> Glsl.Expression Glsl.Int_ +clampwi1wi1wi1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) + + +clampwu1u1u1 : + Int + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint +clampwu1u1u1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.uint1 a) b c + + +clampwu1u1wu1 : Int -> Glsl.Expression Glsl.Uint -> Int -> Glsl.Expression Glsl.Uint +clampwu1u1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.uint1 a) b (Glsl.uint1 c) + + +clampwu1wu1u1 : Int -> Int -> Glsl.Expression Glsl.Uint -> Glsl.Expression Glsl.Uint +clampwu1wu1u1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.uint1 a) (Glsl.uint1 b) c + + +clampwu1wu1wu1 : Int -> Int -> Int -> Glsl.Expression Glsl.Uint +clampwu1wu1wu1 a b c = + Glsl.unsafeCall3 "clamp" [] (Glsl.uint1 a) (Glsl.uint1 b) (Glsl.uint1 c) + + +cross33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +cross33 a b = + Glsl.unsafeCall2 "cross" [] a b + + +crossd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +crossd3d3 a b = + Glsl.unsafeCall2 "cross" [] a b + + +distance11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +distance11 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distance1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +distance1f a b = + Glsl.unsafeCall2 "distance" [] a (Glsl.float1 b) + + +distance22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ +distance22 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distance33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ +distance33 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distance44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ +distance44 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distanced1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +distanced1d1 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distanced1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +distanced1wd1 a b = + Glsl.unsafeCall2 "distance" [] a (Glsl.double1 b) + + +distanced2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double +distanced2d2 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distanced3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double +distanced3d3 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distanced4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double +distanced4d4 a b = + Glsl.unsafeCall2 "distance" [] a b + + +distancef1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +distancef1 a b = + Glsl.unsafeCall2 "distance" [] (Glsl.float1 a) b + + +distanceff : Float -> Float -> Glsl.Expression Glsl.Float_ +distanceff a b = + Glsl.unsafeCall2 "distance" [] (Glsl.float1 a) (Glsl.float1 b) + + +distancewd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +distancewd1d1 a b = + Glsl.unsafeCall2 "distance" [] (Glsl.double1 a) b + + +distancewd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +distancewd1wd1 a b = + Glsl.unsafeCall2 "distance" [] (Glsl.double1 a) (Glsl.double1 b) + + +distance : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t Glsl.D1) +distance a b = + Glsl.unsafeCall2 "distance" [] a b + + +dot11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +dot11 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dot1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +dot1f a b = + Glsl.unsafeCall2 "dot" [] a (Glsl.float1 b) + + +dot22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ +dot22 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dot33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ +dot33 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dot44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ +dot44 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dotd1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +dotd1d1 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dotd1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +dotd1wd1 a b = + Glsl.unsafeCall2 "dot" [] a (Glsl.double1 b) + + +dotd2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double +dotd2d2 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dotd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double +dotd3d3 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dotd4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double +dotd4d4 a b = + Glsl.unsafeCall2 "dot" [] a b + + +dotf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +dotf1 a b = + Glsl.unsafeCall2 "dot" [] (Glsl.float1 a) b + + +dotff : Float -> Float -> Glsl.Expression Glsl.Float_ +dotff a b = + Glsl.unsafeCall2 "dot" [] (Glsl.float1 a) (Glsl.float1 b) + + +dotwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +dotwd1d1 a b = + Glsl.unsafeCall2 "dot" [] (Glsl.double1 a) b + + +dotwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +dotwd1wd1 a b = + Glsl.unsafeCall2 "dot" [] (Glsl.double1 a) (Glsl.double1 b) + + +dot : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t Glsl.D1) +dot a b = + Glsl.unsafeCall2 "dot" [] a b + + +faceforward111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +faceforward111 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforward11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +faceforward11f a b c = + Glsl.unsafeCall3 "faceforward" [] a b (Glsl.float1 c) + + +faceforward1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +faceforward1f1 a b c = + Glsl.unsafeCall3 "faceforward" [] a (Glsl.float1 b) c + + +faceforward1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +faceforward1ff a b c = + Glsl.unsafeCall3 "faceforward" [] a (Glsl.float1 b) (Glsl.float1 c) + + +faceforward222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +faceforward222 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforward333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +faceforward333 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforward444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +faceforward444 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforwardd1d1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +faceforwardd1d1d1 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforwardd1d1wd1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +faceforwardd1d1wd1 a b c = + Glsl.unsafeCall3 "faceforward" [] a b (Glsl.double1 c) + + +faceforwardd1wd1d1 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +faceforwardd1wd1d1 a b c = + Glsl.unsafeCall3 "faceforward" [] a (Glsl.double1 b) c + + +faceforwardd1wd1wd1 : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +faceforwardd1wd1wd1 a b c = + Glsl.unsafeCall3 "faceforward" [] a (Glsl.double1 b) (Glsl.double1 c) + + +faceforwardd2d2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +faceforwardd2d2d2 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforwardd3d3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +faceforwardd3d3d3 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforwardd4d4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +faceforwardd4d4d4 a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +faceforwardf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +faceforwardf11 a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.float1 a) b c + + +faceforwardf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +faceforwardf1f a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.float1 a) b (Glsl.float1 c) + + +faceforwardff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +faceforwardff1 a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.float1 a) (Glsl.float1 b) c + + +faceforwardfff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +faceforwardfff a b c = + Glsl.unsafeCall3 + "faceforward" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + + +faceforwardwd1d1d1 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +faceforwardwd1d1d1 a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.double1 a) b c + + +faceforwardwd1d1wd1 : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +faceforwardwd1d1wd1 a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.double1 a) b (Glsl.double1 c) + + +faceforwardwd1wd1d1 : Float -> Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +faceforwardwd1wd1d1 a b c = + Glsl.unsafeCall3 "faceforward" [] (Glsl.double1 a) (Glsl.double1 b) c + + +faceforwardwd1wd1wd1 : Float -> Float -> Float -> Glsl.Expression Glsl.Double +faceforwardwd1wd1wd1 a b c = + Glsl.unsafeCall3 + "faceforward" + [] + (Glsl.double1 a) + (Glsl.double1 b) + (Glsl.double1 c) + + +faceforward : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +faceforward a b c = + Glsl.unsafeCall3 "faceforward" [] a b c + + +floatBitsToInt1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Int_ +floatBitsToInt1 a = + Glsl.unsafeCall1 "floatBitsToInt" [] a + + +floatBitsToInt2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.IVec2 +floatBitsToInt2 a = + Glsl.unsafeCall1 "floatBitsToInt" [] a + + +floatBitsToInt3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.IVec3 +floatBitsToInt3 a = + Glsl.unsafeCall1 "floatBitsToInt" [] a + + +floatBitsToInt4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.IVec4 +floatBitsToInt4 a = + Glsl.unsafeCall1 "floatBitsToInt" [] a + + +floatBitsToIntf : Float -> Glsl.Expression Glsl.Int_ +floatBitsToIntf a = + Glsl.unsafeCall1 "floatBitsToInt" [] (Glsl.float1 a) + + +floatBitsToUint1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Uint +floatBitsToUint1 a = + Glsl.unsafeCall1 "floatBitsToUint" [] a + + +floatBitsToUint2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.UVec2 +floatBitsToUint2 a = + Glsl.unsafeCall1 "floatBitsToUint" [] a + + +floatBitsToUint3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.UVec3 +floatBitsToUint3 a = + Glsl.unsafeCall1 "floatBitsToUint" [] a + + +floatBitsToUint4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.UVec4 +floatBitsToUint4 a = + Glsl.unsafeCall1 "floatBitsToUint" [] a + + +floatBitsToUintf : Float -> Glsl.Expression Glsl.Uint +floatBitsToUintf a = + Glsl.unsafeCall1 "floatBitsToUint" [] (Glsl.float1 a) + + +floati1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Float_ +floati1 a = + Glsl.unsafeCall1 "float" [] a + + +floatwi1 : Int -> Glsl.Expression Glsl.Float_ +floatwi1 a = + Glsl.unsafeCall1 "float" [] (Glsl.int1 a) + + +floor1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +floor1 a = + Glsl.unsafeCall1 "floor" [] a + + +floor2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +floor2 a = + Glsl.unsafeCall1 "floor" [] a + + +floor3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +floor3 a = + Glsl.unsafeCall1 "floor" [] a + + +floor4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +floor4 a = + Glsl.unsafeCall1 "floor" [] a + + +floord1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +floord1 a = + Glsl.unsafeCall1 "floor" [] a + + +floord2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +floord2 a = + Glsl.unsafeCall1 "floor" [] a + + +floord3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +floord3 a = + Glsl.unsafeCall1 "floor" [] a + + +floord4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +floord4 a = + Glsl.unsafeCall1 "floor" [] a + + +floorf : Float -> Glsl.Expression Glsl.Float_ +floorf a = + Glsl.unsafeCall1 "floor" [] (Glsl.float1 a) + + +floorwd1 : Float -> Glsl.Expression Glsl.Double +floorwd1 a = + Glsl.unsafeCall1 "floor" [] (Glsl.double1 a) + + +fma111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +fma111 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fma11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +fma11f a b c = + Glsl.unsafeCall3 "fma" [] a b (Glsl.float1 c) + + +fma1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +fma1f1 a b c = + Glsl.unsafeCall3 "fma" [] a (Glsl.float1 b) c + + +fma1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +fma1ff a b c = + Glsl.unsafeCall3 "fma" [] a (Glsl.float1 b) (Glsl.float1 c) + + +fma222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +fma222 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fma333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +fma333 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fma444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +fma444 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fmad1d1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +fmad1d1d1 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fmad1d1wd1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +fmad1d1wd1 a b c = + Glsl.unsafeCall3 "fma" [] a b (Glsl.double1 c) + + +fmad1wd1d1 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +fmad1wd1d1 a b c = + Glsl.unsafeCall3 "fma" [] a (Glsl.double1 b) c + + +fmad1wd1wd1 : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +fmad1wd1wd1 a b c = + Glsl.unsafeCall3 "fma" [] a (Glsl.double1 b) (Glsl.double1 c) + + +fmad2d2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +fmad2d2d2 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fmad3d3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +fmad3d3d3 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fmad4d4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +fmad4d4d4 a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fmaf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +fmaf11 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.float1 a) b c + + +fmaf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +fmaf1f a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.float1 a) b (Glsl.float1 c) + + +fmaff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +fmaff1 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.float1 a) (Glsl.float1 b) c + + +fmafff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +fmafff a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) + + +fmawd1d1d1 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +fmawd1d1d1 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.double1 a) b c + + +fmawd1d1wd1 : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +fmawd1d1wd1 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.double1 a) b (Glsl.double1 c) + + +fmawd1wd1d1 : Float -> Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +fmawd1wd1d1 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.double1 a) (Glsl.double1 b) c + + +fmawd1wd1wd1 : Float -> Float -> Float -> Glsl.Expression Glsl.Double +fmawd1wd1wd1 a b c = + Glsl.unsafeCall3 "fma" [] (Glsl.double1 a) (Glsl.double1 b) (Glsl.double1 c) + + +fma : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +fma a b c = + Glsl.unsafeCall3 "fma" [] a b c + + +fract1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +fract1 a = + Glsl.unsafeCall1 "fract" [] a + + +fract2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +fract2 a = + Glsl.unsafeCall1 "fract" [] a + + +fract3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +fract3 a = + Glsl.unsafeCall1 "fract" [] a + + +fract4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +fract4 a = + Glsl.unsafeCall1 "fract" [] a + + +fractd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +fractd1 a = + Glsl.unsafeCall1 "fract" [] a + + +fractd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +fractd2 a = + Glsl.unsafeCall1 "fract" [] a + + +fractd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +fractd3 a = + Glsl.unsafeCall1 "fract" [] a + + +fractd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +fractd4 a = + Glsl.unsafeCall1 "fract" [] a + + +fractf : Float -> Glsl.Expression Glsl.Float_ +fractf a = + Glsl.unsafeCall1 "fract" [] (Glsl.float1 a) + + +fractwd1 : Float -> Glsl.Expression Glsl.Double +fractwd1 a = + Glsl.unsafeCall1 "fract" [] (Glsl.double1 a) + + +fract : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +fract a = + Glsl.unsafeCall1 "fract" [] a + + +frexp1oi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression (Glsl.Out Glsl.Int_) + -> Glsl.Expression Glsl.Float_ +frexp1oi1 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexp1owi1 : Glsl.Expression Glsl.Float_ -> Int -> Glsl.Expression Glsl.Float_ +frexp1owi1 a b = + Glsl.unsafeCall2 "frexp" [] a (Glsl.int1 b) + + +frexp2oi2 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression (Glsl.Out Glsl.IVec2) + -> Glsl.Expression Glsl.Vec2 +frexp2oi2 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexp3oi3 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression (Glsl.Out Glsl.IVec3) + -> Glsl.Expression Glsl.Vec3 +frexp3oi3 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexp4oi4 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression (Glsl.Out Glsl.IVec4) + -> Glsl.Expression Glsl.Vec4 +frexp4oi4 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexpd1oi1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression (Glsl.Out Glsl.Int_) + -> Glsl.Expression Glsl.Double +frexpd1oi1 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexpd1owi1 : Glsl.Expression Glsl.Double -> Int -> Glsl.Expression Glsl.Double +frexpd1owi1 a b = + Glsl.unsafeCall2 "frexp" [] a (Glsl.int1 b) + + +frexpd2oi2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression (Glsl.Out Glsl.IVec2) + -> Glsl.Expression Glsl.DVec2 +frexpd2oi2 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexpd3oi3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression (Glsl.Out Glsl.IVec3) + -> Glsl.Expression Glsl.DVec3 +frexpd3oi3 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexpd4oi4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression (Glsl.Out Glsl.IVec4) + -> Glsl.Expression Glsl.DVec4 +frexpd4oi4 a b = + Glsl.unsafeCall2 "frexp" [] a b + + +frexpfoi1 : Float -> Glsl.Expression (Glsl.Out Glsl.Int_) -> Glsl.Expression Glsl.Float_ +frexpfoi1 a b = + Glsl.unsafeCall2 "frexp" [] (Glsl.float1 a) b + + +frexpfowi1 : Float -> Int -> Glsl.Expression Glsl.Float_ +frexpfowi1 a b = + Glsl.unsafeCall2 "frexp" [] (Glsl.float1 a) (Glsl.int1 b) + + +frexpwd1oi1 : Float -> Glsl.Expression (Glsl.Out Glsl.Int_) -> Glsl.Expression Glsl.Double +frexpwd1oi1 a b = + Glsl.unsafeCall2 "frexp" [] (Glsl.double1 a) b + + +frexpwd1owi1 : Float -> Int -> Glsl.Expression Glsl.Double +frexpwd1owi1 a b = + Glsl.unsafeCall2 "frexp" [] (Glsl.double1 a) (Glsl.int1 b) + + +int1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Int_ +int1 a = + Glsl.unsafeCall1 "int" [] a + + +intf : Float -> Glsl.Expression Glsl.Int_ +intf a = + Glsl.unsafeCall1 "int" [] (Glsl.float1 a) + + +intBitsToFloati1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Float_ +intBitsToFloati1 a = + Glsl.unsafeCall1 "intBitsToFloat" [] a + + +intBitsToFloati2 : Glsl.Expression Glsl.IVec2 -> Glsl.Expression Glsl.Vec2 +intBitsToFloati2 a = + Glsl.unsafeCall1 "intBitsToFloat" [] a + + +intBitsToFloati3 : Glsl.Expression Glsl.IVec3 -> Glsl.Expression Glsl.Vec3 +intBitsToFloati3 a = + Glsl.unsafeCall1 "intBitsToFloat" [] a + + +intBitsToFloati4 : Glsl.Expression Glsl.IVec4 -> Glsl.Expression Glsl.Vec4 +intBitsToFloati4 a = + Glsl.unsafeCall1 "intBitsToFloat" [] a + + +intBitsToFloatwi1 : Int -> Glsl.Expression Glsl.Float_ +intBitsToFloatwi1 a = + Glsl.unsafeCall1 "intBitsToFloat" [] (Glsl.int1 a) + + +inversesqrt1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +inversesqrt1 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrt2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +inversesqrt2 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrt3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +inversesqrt3 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrt4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +inversesqrt4 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrtd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +inversesqrtd1 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrtd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +inversesqrtd2 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrtd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +inversesqrtd3 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrtd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +inversesqrtd4 a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +inversesqrtf : Float -> Glsl.Expression Glsl.Float_ +inversesqrtf a = + Glsl.unsafeCall1 "inversesqrt" [] (Glsl.float1 a) + + +inversesqrtwd1 : Float -> Glsl.Expression Glsl.Double +inversesqrtwd1 a = + Glsl.unsafeCall1 "inversesqrt" [] (Glsl.double1 a) + + +inversesqrt : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +inversesqrt a = + Glsl.unsafeCall1 "inversesqrt" [] a + + +isinf1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Bool_ +isinf1 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinf2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.BVec2 +isinf2 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinf3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.BVec3 +isinf3 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinf4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.BVec4 +isinf4 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinfd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Bool_ +isinfd1 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinfd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.BVec2 +isinfd2 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinfd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.BVec3 +isinfd3 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinfd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.BVec4 +isinfd4 a = + Glsl.unsafeCall1 "isinf" [] a + + +isinff : Float -> Glsl.Expression Glsl.Bool_ +isinff a = + Glsl.unsafeCall1 "isinf" [] (Glsl.float1 a) + + +isinfwd1 : Float -> Glsl.Expression Glsl.Bool_ +isinfwd1 a = + Glsl.unsafeCall1 "isinf" [] (Glsl.double1 a) + + +isnan1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Bool_ +isnan1 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnan2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.BVec2 +isnan2 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnan3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.BVec3 +isnan3 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnan4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.BVec4 +isnan4 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnand1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Bool_ +isnand1 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnand2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.BVec2 +isnand2 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnand3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.BVec3 +isnand3 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnand4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.BVec4 +isnand4 a = + Glsl.unsafeCall1 "isnan" [] a + + +isnanf : Float -> Glsl.Expression Glsl.Bool_ +isnanf a = + Glsl.unsafeCall1 "isnan" [] (Glsl.float1 a) + + +isnanwd1 : Float -> Glsl.Expression Glsl.Bool_ +isnanwd1 a = + Glsl.unsafeCall1 "isnan" [] (Glsl.double1 a) + + +ivec2i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec2 +ivec2i1i1 a b = + Glsl.unsafeCall2 "ivec2" [] a b + + +ivec2i1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec2 +ivec2i1wi1 a b = + Glsl.unsafeCall2 "ivec2" [] a (Glsl.int1 b) + + +ivec2wi1i1 : Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec2 +ivec2wi1i1 a b = + Glsl.unsafeCall2 "ivec2" [] (Glsl.int1 a) b + + +ivec2wi1wi1 : Int -> Int -> Glsl.Expression Glsl.Vec2 +ivec2wi1wi1 a b = + Glsl.unsafeCall2 "ivec2" [] (Glsl.int1 a) (Glsl.int1 b) + + +ivec3i1i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +ivec3i1i1i1 a b c = + Glsl.unsafeCall3 "ivec3" [] a b c + + +ivec3i1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec3 +ivec3i1i1wi1 a b c = + Glsl.unsafeCall3 "ivec3" [] a b (Glsl.int1 c) + + +ivec3i1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +ivec3i1wi1i1 a b c = + Glsl.unsafeCall3 "ivec3" [] a (Glsl.int1 b) c + + +ivec3i1wi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Int -> Glsl.Expression Glsl.Vec3 +ivec3i1wi1wi1 a b c = + Glsl.unsafeCall3 "ivec3" [] a (Glsl.int1 b) (Glsl.int1 c) + + +ivec3wi1i1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +ivec3wi1i1i1 a b c = + Glsl.unsafeCall3 "ivec3" [] (Glsl.int1 a) b c + + +ivec3wi1i1wi1 : Int -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec3 +ivec3wi1i1wi1 a b c = + Glsl.unsafeCall3 "ivec3" [] (Glsl.int1 a) b (Glsl.int1 c) + + +ivec3wi1wi1i1 : Int -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +ivec3wi1wi1i1 a b c = + Glsl.unsafeCall3 "ivec3" [] (Glsl.int1 a) (Glsl.int1 b) c + + +ivec3wi1wi1wi1 : Int -> Int -> Int -> Glsl.Expression Glsl.Vec3 +ivec3wi1wi1wi1 a b c = + Glsl.unsafeCall3 "ivec3" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) + + +ivec4i1i1i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4i1i1i1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a b c d + + +ivec4i1i1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +ivec4i1i1i1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a b c (Glsl.int1 d) + + +ivec4i1i1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4i1i1wi1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a b (Glsl.int1 c) d + + +ivec4i1i1wi1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +ivec4i1i1wi1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a b (Glsl.int1 c) (Glsl.int1 d) + + +ivec4i1wi1i1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4i1wi1i1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a (Glsl.int1 b) c d + + +ivec4i1wi1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +ivec4i1wi1i1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a (Glsl.int1 b) c (Glsl.int1 d) + + +ivec4i1wi1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4i1wi1wi1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a (Glsl.int1 b) (Glsl.int1 c) d + + +ivec4i1wi1wi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Int -> Int -> Glsl.Expression Glsl.Vec4 +ivec4i1wi1wi1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] a (Glsl.int1 b) (Glsl.int1 c) (Glsl.int1 d) + + +ivec4wi1i1i1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4wi1i1i1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) b c d + + +ivec4wi1i1i1wi1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +ivec4wi1i1i1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) b c (Glsl.int1 d) + + +ivec4wi1i1wi1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4wi1i1wi1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) b (Glsl.int1 c) d + + +ivec4wi1i1wi1wi1 : Int -> Glsl.Expression Glsl.Int_ -> Int -> Int -> Glsl.Expression Glsl.Vec4 +ivec4wi1i1wi1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) b (Glsl.int1 c) (Glsl.int1 d) + + +ivec4wi1wi1i1i1 : + Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +ivec4wi1wi1i1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) (Glsl.int1 b) c d + + +ivec4wi1wi1i1wi1 : Int -> Int -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec4 +ivec4wi1wi1i1wi1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) (Glsl.int1 b) c (Glsl.int1 d) + + +ivec4wi1wi1wi1i1 : Int -> Int -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec4 +ivec4wi1wi1wi1i1 a b c d = + Glsl.unsafeCall4 "ivec4" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) d + + +ivec4wi1wi1wi1wi1 : Int -> Int -> Int -> Int -> Glsl.Expression Glsl.Vec4 +ivec4wi1wi1wi1wi1 a b c d = + Glsl.unsafeCall4 + "ivec4" + [] + (Glsl.int1 a) + (Glsl.int1 b) + (Glsl.int1 c) + (Glsl.int1 d) + + +ldexp1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ +ldexp1i1 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexp1wi1 : Glsl.Expression Glsl.Float_ -> Int -> Glsl.Expression Glsl.Float_ +ldexp1wi1 a b = + Glsl.unsafeCall2 "ldexp" [] a (Glsl.int1 b) + + +ldexp2i2 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.Vec2 +ldexp2i2 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexp3i3 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.Vec3 +ldexp3i3 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexp4i4 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.Vec4 +ldexp4i4 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexpd1i1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Double +ldexpd1i1 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexpd1wi1 : Glsl.Expression Glsl.Double -> Int -> Glsl.Expression Glsl.Double +ldexpd1wi1 a b = + Glsl.unsafeCall2 "ldexp" [] a (Glsl.int1 b) + + +ldexpd2i2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.DVec2 +ldexpd2i2 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexpd3i3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.DVec3 +ldexpd3i3 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexpd4i4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.DVec4 +ldexpd4i4 a b = + Glsl.unsafeCall2 "ldexp" [] a b + + +ldexpfi1 : Float -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Float_ +ldexpfi1 a b = + Glsl.unsafeCall2 "ldexp" [] (Glsl.float1 a) b + + +ldexpfwi1 : Float -> Int -> Glsl.Expression Glsl.Float_ +ldexpfwi1 a b = + Glsl.unsafeCall2 "ldexp" [] (Glsl.float1 a) (Glsl.int1 b) + + +ldexpwd1i1 : Float -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Double +ldexpwd1i1 a b = + Glsl.unsafeCall2 "ldexp" [] (Glsl.double1 a) b + + +ldexpwd1wi1 : Float -> Int -> Glsl.Expression Glsl.Double +ldexpwd1wi1 a b = + Glsl.unsafeCall2 "ldexp" [] (Glsl.double1 a) (Glsl.int1 b) + + +length1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +length1 a = + Glsl.unsafeCall1 "length" [] a + + +length2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Float_ +length2 a = + Glsl.unsafeCall1 "length" [] a + + +length3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Float_ +length3 a = + Glsl.unsafeCall1 "length" [] a + + +length4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Float_ +length4 a = + Glsl.unsafeCall1 "length" [] a + + +lengthd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +lengthd1 a = + Glsl.unsafeCall1 "length" [] a + + +lengthd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.Double +lengthd2 a = + Glsl.unsafeCall1 "length" [] a + + +lengthd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.Double +lengthd3 a = + Glsl.unsafeCall1 "length" [] a + + +lengthd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.Double +lengthd4 a = + Glsl.unsafeCall1 "length" [] a + + +lengthf : Float -> Glsl.Expression Glsl.Float_ +lengthf a = + Glsl.unsafeCall1 "length" [] (Glsl.float1 a) + + +lengthwd1 : Float -> Glsl.Expression Glsl.Double +lengthwd1 a = + Glsl.unsafeCall1 "length" [] (Glsl.double1 a) + + +length : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t Glsl.D1) +length a = + Glsl.unsafeCall1 "length" [] a + + +mat21111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat21111 a b c d = + Glsl.unsafeCall4 "mat2" [] a b c d + + +mat2111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat2 +mat2111f a b c d = + Glsl.unsafeCall4 "mat2" [] a b c (Glsl.float1 d) + + +mat211f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat211f1 a b c d = + Glsl.unsafeCall4 "mat2" [] a b (Glsl.float1 c) d + + +mat211ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat2 +mat211ff a b c d = + Glsl.unsafeCall4 "mat2" [] a b (Glsl.float1 c) (Glsl.float1 d) + + +mat21f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat21f11 a b c d = + Glsl.unsafeCall4 "mat2" [] a (Glsl.float1 b) c d + + +mat21f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat2 +mat21f1f a b c d = + Glsl.unsafeCall4 "mat2" [] a (Glsl.float1 b) c (Glsl.float1 d) + + +mat21ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat21ff1 a b c d = + Glsl.unsafeCall4 "mat2" [] a (Glsl.float1 b) (Glsl.float1 c) d + + +mat21fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat2 +mat21fff a b c d = + Glsl.unsafeCall4 "mat2" [] a (Glsl.float1 b) (Glsl.float1 c) (Glsl.float1 d) + + +mat222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Mat2 +mat222 a b = + Glsl.unsafeCall2 "mat2" [] a b + + +mat2f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat2f111 a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) b c d + + +mat2f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat2 +mat2f11f a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) b c (Glsl.float1 d) + + +mat2f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat2f1f1 a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) b (Glsl.float1 c) d + + +mat2f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat2 +mat2f1ff a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) b (Glsl.float1 c) (Glsl.float1 d) + + +mat2ff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat2ff11 a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) (Glsl.float1 b) c d + + +mat2ff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat2 +mat2ff1f a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) (Glsl.float1 b) c (Glsl.float1 d) + + +mat2fff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat2 +mat2fff1 a b c d = + Glsl.unsafeCall4 "mat2" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) d + + +mat2ffff : Float -> Float -> Float -> Float -> Glsl.Expression Glsl.Mat2 +mat2ffff a b c d = + Glsl.unsafeCall4 + "mat2" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + + +mat3111111111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f g h i + + +mat311111111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311111111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f g h (Glsl.float1 i) + + +mat31111111f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111111f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f g (Glsl.float1 h) i + + +mat31111111ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111111ff a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f g (Glsl.float1 h) (Glsl.float1 i) + + +mat3111111f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111111f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f (Glsl.float1 g) h i + + +mat3111111f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111111f1f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f (Glsl.float1 g) h (Glsl.float1 i) + + +mat3111111ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111111ff1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e f (Glsl.float1 g) (Glsl.float1 h) i + + +mat3111111fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311111f111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311111f111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e (Glsl.float1 f) g h i + + +mat311111f11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311111f11f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e (Glsl.float1 f) g h (Glsl.float1 i) + + +mat311111f1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311111f1f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e (Glsl.float1 f) g (Glsl.float1 h) i + + +mat311111f1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311111f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311111ff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311111ff11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d e (Glsl.float1 f) (Glsl.float1 g) h i + + +mat311111ff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311111ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311111fff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311111fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311111ffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311111ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31111f1111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111f1111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d (Glsl.float1 e) f g h i + + +mat31111f111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111f111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d (Glsl.float1 e) f g h (Glsl.float1 i) + + +mat31111f11f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111f11f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d (Glsl.float1 e) f g (Glsl.float1 h) i + + +mat31111f11ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31111f1f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111f1f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d (Glsl.float1 e) f (Glsl.float1 g) h i + + +mat31111f1f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31111f1ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31111f1fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31111ff111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111ff111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c d (Glsl.float1 e) (Glsl.float1 f) g h i + + +mat31111ff11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31111ff1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31111ff1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31111fff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31111fff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31111ffff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31111ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31111fffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31111fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111f11111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f11111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) e f g h i + + +mat3111f1111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f1111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) e f g h (Glsl.float1 i) + + +mat3111f111f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f111f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) e f g (Glsl.float1 h) i + + +mat3111f111ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111f11f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f11f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) e f (Glsl.float1 g) h i + + +mat3111f11f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3111f11ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3111f11fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111f1f111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f1f111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) e (Glsl.float1 f) g h i + + +mat3111f1f11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3111f1f1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3111f1f1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111f1ff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3111f1ff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3111f1fff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111f1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3111f1ffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111f1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111ff1111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111ff1111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b c (Glsl.float1 d) (Glsl.float1 e) f g h i + + +mat3111ff111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3111ff11f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111ff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3111ff11ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111ff1f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111ff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3111ff1f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3111ff1ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111ff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3111ff1fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111fff111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111fff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3111fff11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111fff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3111fff1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111fff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3111fff1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111fff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3111ffff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111ffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3111ffff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3111fffff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3111fffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3111ffffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3111ffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f111111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d e f g h i + + +mat311f11111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f11111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d e f g h (Glsl.float1 i) + + +mat311f1111f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1111f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d e f g (Glsl.float1 h) i + + +mat311f1111ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f111f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f111f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d e f (Glsl.float1 g) h i + + +mat311f111f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311f111ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311f111fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f11f111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f11f111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d e (Glsl.float1 f) g h i + + +mat311f11f11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f11f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat311f11f1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f11f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat311f11f1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f11f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f11ff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f11ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat311f11ff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f11ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311f11fff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f11fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311f11ffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f11ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f1f1111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1f1111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) d (Glsl.float1 e) f g h i + + +mat311f1f111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat311f1f11f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat311f1f11ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f1f1f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat311f1f1f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311f1f1ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311f1f1fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f1ff111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat311f1ff11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat311f1ff1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat311f1ff1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311f1fff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat311f1fff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311f1ffff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311f1ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311f1fffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311f1fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311ff11111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff11111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a b (Glsl.float1 c) (Glsl.float1 d) e f g h i + + +mat311ff1111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat311ff111f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat311ff111ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311ff11f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat311ff11f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311ff11ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311ff11fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311ff1f111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat311ff1f11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat311ff1f1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat311ff1f1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311ff1ff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat311ff1ff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311ff1fff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ff1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311ff1ffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ff1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311fff1111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311fff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat311fff111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat311fff11f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311fff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat311fff11ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311fff1f11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311fff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat311fff1f1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311fff1ff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311fff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311fff1fff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311ffff111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ffff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat311ffff11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ffff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat311ffff1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ffff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat311ffff1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311ffff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat311fffff11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311fffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat311fffff1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat311ffffff1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat311ffffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat311fffffff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat311fffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1111111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d e f g h i + + +mat31f111111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f111111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d e f g h (Glsl.float1 i) + + +mat31f11111f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11111f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d e f g (Glsl.float1 h) i + + +mat31f11111ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1111f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1111f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d e f (Glsl.float1 g) h i + + +mat31f1111f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f1111ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f1111fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f111f111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f111f111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d e (Glsl.float1 f) g h i + + +mat31f111f11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f111f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31f111f1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f111f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31f111f1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f111f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f111ff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f111ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31f111ff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f111ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f111fff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f111fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f111ffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f111ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f11f1111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11f1111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c d (Glsl.float1 e) f g h i + + +mat31f11f111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat31f11f11f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat31f11f11ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f11f1f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat31f11f1f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f11f1ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f11f1fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f11ff111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat31f11ff11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31f11ff1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31f11ff1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f11fff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31f11fff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f11ffff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f11ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f11fffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f11fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1f11111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f11111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) c (Glsl.float1 d) e f g h i + + +mat31f1f1111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat31f1f111f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat31f1f111ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1f11f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat31f1f11f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f1f11ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f1f11fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1f1f111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat31f1f1f11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31f1f1f1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31f1f1f1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1f1ff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31f1f1ff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f1f1fff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1f1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f1f1ffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1f1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1ff1111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1ff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat31f1ff111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat31f1ff11f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1ff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat31f1ff11ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1ff1f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1ff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat31f1ff1f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f1ff1ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1ff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f1ff1fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1fff111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1fff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat31f1fff11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1fff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31f1fff1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1fff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31f1fff1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1fff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31f1ffff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1ffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31f1ffff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31f1fffff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31f1fffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31f1ffffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31f1ffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff111111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] a (Glsl.float1 b) (Glsl.float1 c) d e f g h i + + +mat31ff11111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff11111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + h + (Glsl.float1 i) + + +mat31ff1111f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + i + + +mat31ff1111ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff111f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff111f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + i + + +mat31ff111f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31ff111ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ff111fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff11f111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff11f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + i + + +mat31ff11f11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff11f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31ff11f1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff11f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31ff11f1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff11f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff11ff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff11ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31ff11ff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff11ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31ff11fff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff11fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ff11ffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff11ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff1f1111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1f1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + i + + +mat31ff1f111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat31ff1f11f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat31ff1f11ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff1f1f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat31ff1f1f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31ff1f1ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ff1f1fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff1ff111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat31ff1ff11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31ff1ff1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31ff1ff1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ff1fff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31ff1fff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31ff1ffff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ff1ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ff1fffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ff1fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31fff11111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff11111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + i + + +mat31fff1111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat31fff111f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat31fff111ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31fff11f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat31fff11f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31fff11ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31fff11fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31fff1f111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat31fff1f11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31fff1f1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31fff1f1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31fff1ff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31fff1ff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31fff1fff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fff1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31fff1ffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fff1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ffff1111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ffff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat31ffff111f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat31ffff11f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ffff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat31ffff11ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ffff1f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ffff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat31ffff1f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31ffff1ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ffff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ffff1fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31fffff111 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fffff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat31fffff11f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fffff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat31fffff1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fffff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat31fffff1ff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31fffff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat31ffffff11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31ffffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat31ffffff1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat31fffffff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat31fffffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat31ffffffff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat31ffffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + a + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Mat3 +mat3333 a b c = + Glsl.unsafeCall3 "mat3" [] a b c + + +mat3f11111111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d e f g h i + + +mat3f1111111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1111111f a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d e f g h (Glsl.float1 i) + + +mat3f111111f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111111f1 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d e f g (Glsl.float1 h) i + + +mat3f111111ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11111f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11111f11 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d e f (Glsl.float1 g) h i + + +mat3f11111f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f11111ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f11111fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1111f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1111f111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d e (Glsl.float1 f) g h i + + +mat3f1111f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1111f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f1111f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1111f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f1111f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1111f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1111ff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1111ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f1111ff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1111ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1111fff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1111fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1111ffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1111ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f111f1111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111f1111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c d (Glsl.float1 e) f g h i + + +mat3f111f111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3f111f11f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3f111f11ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f111f1f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3f111f1f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f111f1ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f111f1fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f111ff111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3f111ff11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f111ff1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f111ff1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f111fff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f111fff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f111ffff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f111ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f111fffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f111fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11f11111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f11111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b c (Glsl.float1 d) e f g h i + + +mat3f11f1111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat3f11f111f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat3f11f111ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11f11f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat3f11f11f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f11f11ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f11f11fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11f1f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat3f11f1f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f11f1f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f11f1f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11f1ff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f11f1ff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f11f1fff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11f1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f11f1ffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11f1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11ff1111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11ff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat3f11ff111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3f11ff11f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11ff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3f11ff11ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11ff1f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11ff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3f11ff1f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f11ff1ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11ff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f11ff1fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11fff111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11fff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3f11fff11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11fff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f11fff1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11fff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f11fff1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11fff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f11ffff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11ffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f11ffff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f11fffff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f11fffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f11ffffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f11ffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f111111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) b (Glsl.float1 c) d e f g h i + + +mat3f1f11111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f11111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + g + h + (Glsl.float1 i) + + +mat3f1f1111f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + i + + +mat3f1f1111ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f111f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f111f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + i + + +mat3f1f111f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1f111ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1f111fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f11f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f11f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + i + + +mat3f1f11f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f11f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f1f11f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f11f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f1f11f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f11f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f11ff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f11ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f1f11ff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f11ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1f11fff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f11fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1f11ffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f11ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f1f1111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + i + + +mat3f1f1f111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3f1f1f11f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3f1f1f11ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f1f1f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3f1f1f1f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1f1f1ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1f1f1fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f1ff111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3f1f1ff11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f1f1ff1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f1f1ff1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1f1fff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f1f1fff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1f1ffff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1f1ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1f1fffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1f1fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1ff11111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff11111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + i + + +mat3f1ff1111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat3f1ff111f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat3f1ff111ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1ff11f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat3f1ff11f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1ff11ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1ff11fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1ff1f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat3f1ff1f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f1ff1f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f1ff1f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1ff1ff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f1ff1ff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1ff1fff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1ff1ffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ff1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1fff1111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1fff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat3f1fff111f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3f1fff11f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1fff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3f1fff11ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1fff1f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1fff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3f1fff1f1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1fff1ff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1fff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1fff1fff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1ffff111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ffff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3f1ffff11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ffff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3f1ffff1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ffff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3f1ffff1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1ffff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3f1fffff11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1fffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3f1fffff1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3f1ffffff1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3f1ffffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3f1fffffff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3f1fffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + b + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1111111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1111111 a b c d e f g h i = + Glsl.unsafeCall9 "mat3" [] (Glsl.float1 a) (Glsl.float1 b) c d e f g h i + + +mat3ff111111f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff111111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + g + h + (Glsl.float1 i) + + +mat3ff11111f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + g + (Glsl.float1 h) + i + + +mat3ff11111ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1111f11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1111f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + h + i + + +mat3ff1111f1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff1111ff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff1111fff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff111f111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff111f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + h + i + + +mat3ff111f11f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff111f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ff111f1f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff111f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ff111f1ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff111f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff111ff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff111ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3ff111ff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff111ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff111fff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff111fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff111ffff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff111ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff11f1111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11f1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + h + i + + +mat3ff11f111f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3ff11f11f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3ff11f11ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff11f1f11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3ff11f1f1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff11f1ff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff11f1fff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff11ff111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3ff11ff11f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ff11ff1f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ff11ff1ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff11fff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3ff11fff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff11ffff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff11ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff11fffff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff11fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1f11111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f11111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + h + i + + +mat3ff1f1111f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat3ff1f111f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat3ff1f111ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1f11f11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat3ff1f11f1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff1f11ff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff1f11fff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1f1f111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat3ff1f1f11f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ff1f1f1f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ff1f1f1ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1f1ff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3ff1f1ff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff1f1fff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff1f1ffff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1f1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1ff1111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat3ff1ff111f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3ff1ff11f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3ff1ff11ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1ff1f11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3ff1ff1f1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff1ff1ff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff1ff1fff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1fff111 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1fff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3ff1fff11f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1fff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ff1fff1f1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1fff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ff1fff1ff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1fff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ff1ffff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1ffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3ff1ffff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ff1fffff1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ff1fffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ff1ffffff : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ff1ffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + c + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff111111 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff111111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + h + i + + +mat3fff11111f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff11111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + h + (Glsl.float1 i) + + +mat3fff1111f1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + i + + +mat3fff1111ff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff111f11 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff111f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + i + + +mat3fff111f1f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff111f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3fff111ff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff111ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fff111fff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff111fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff11f111 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff11f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + i + + +mat3fff11f11f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff11f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3fff11f1f1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff11f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3fff11f1ff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff11f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff11ff11 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff11ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3fff11ff1f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff11ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3fff11fff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff11fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fff11ffff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff11ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff1f1111 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1f1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + i + + +mat3fff1f111f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1f111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3fff1f11f1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1f11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3fff1f11ff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1f11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff1f1f11 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1f1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3fff1f1f1f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1f1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3fff1f1ff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1f1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fff1f1fff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1f1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff1ff111 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1ff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3fff1ff11f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1ff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3fff1ff1f1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1ff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3fff1ff1ff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1ff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fff1fff11 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1fff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3fff1fff1f : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1fff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3fff1ffff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fff1ffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fff1fffff : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fff1fffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + d + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ffff11111 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff11111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + i + + +mat3ffff1111f : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff1111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + h + (Glsl.float1 i) + + +mat3ffff111f1 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff111f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + i + + +mat3ffff111ff : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff111ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ffff11f11 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff11f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + i + + +mat3ffff11f1f : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff11f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ffff11ff1 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff11ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ffff11fff : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff11fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ffff1f111 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff1f111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + i + + +mat3ffff1f11f : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff1f11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ffff1f1f1 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff1f1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ffff1f1ff : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff1f1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ffff1ff11 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff1ff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3ffff1ff1f : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff1ff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ffff1fff1 : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffff1fff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3ffff1ffff : + Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffff1ffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + e + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fffff1111 : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fffff1111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + i + + +mat3fffff111f : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffff111f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + h + (Glsl.float1 i) + + +mat3fffff11f1 : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fffff11f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + i + + +mat3fffff11ff : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffff11ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fffff1f11 : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fffff1f11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + i + + +mat3fffff1f1f : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffff1f1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3fffff1ff1 : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fffff1ff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fffff1fff : + Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffff1fff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + f + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3ffffff111 : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffffff111 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + i + + +mat3ffffff11f : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffffff11f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + h + (Glsl.float1 i) + + +mat3ffffff1f1 : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffffff1f1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + i + + +mat3ffffff1ff : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3ffffff1ff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + g + (Glsl.float1 h) + (Glsl.float1 i) + + +mat3fffffff11 : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3fffffff11 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + i + + +mat3fffffff1f : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffffff1f a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + h + (Glsl.float1 i) + + +mat3ffffffff1 : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Mat3 +mat3ffffffff1 a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + i + + +mat3fffffffff : + Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Mat3 +mat3fffffffff a b c d e f g h i = + Glsl.unsafeCall9 + "mat3" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + (Glsl.float1 e) + (Glsl.float1 f) + (Glsl.float1 g) + (Glsl.float1 h) + (Glsl.float1 i) + + +mat44444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Mat4 +mat44444 a b c d = + Glsl.unsafeCall4 "mat4" [] a b c d + + +max11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +max11 a b = + Glsl.unsafeCall2 "max" [] a b + + +max1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +max1f a b = + Glsl.unsafeCall2 "max" [] a (Glsl.float1 b) + + +max21 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +max21 a b = + Glsl.unsafeCall2 "max" [] a b + + +max22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +max22 a b = + Glsl.unsafeCall2 "max" [] a b + + +max2f : Glsl.Expression Glsl.Vec2 -> Float -> Glsl.Expression Glsl.Vec2 +max2f a b = + Glsl.unsafeCall2 "max" [] a (Glsl.float1 b) + + +max31 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +max31 a b = + Glsl.unsafeCall2 "max" [] a b + + +max33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +max33 a b = + Glsl.unsafeCall2 "max" [] a b + + +max3f : Glsl.Expression Glsl.Vec3 -> Float -> Glsl.Expression Glsl.Vec3 +max3f a b = + Glsl.unsafeCall2 "max" [] a (Glsl.float1 b) + + +max41 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +max41 a b = + Glsl.unsafeCall2 "max" [] a b + + +max44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +max44 a b = + Glsl.unsafeCall2 "max" [] a b + + +max4f : Glsl.Expression Glsl.Vec4 -> Float -> Glsl.Expression Glsl.Vec4 +max4f a b = + Glsl.unsafeCall2 "max" [] a (Glsl.float1 b) + + +maxd1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +maxd1d1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +maxd1wd1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.double1 b) + + +maxd2d1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +maxd2d1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +maxd2d2 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd2wd1 : Glsl.Expression Glsl.DVec2 -> Float -> Glsl.Expression Glsl.DVec2 +maxd2wd1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.double1 b) + + +maxd3d1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +maxd3d1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +maxd3d3 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd3wd1 : Glsl.Expression Glsl.DVec3 -> Float -> Glsl.Expression Glsl.DVec3 +maxd3wd1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.double1 b) + + +maxd4d1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +maxd4d1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +maxd4d4 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxd4wd1 : Glsl.Expression Glsl.DVec4 -> Float -> Glsl.Expression Glsl.DVec4 +maxd4wd1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.double1 b) + + +maxf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +maxf1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.float1 a) b + + +maxff : Float -> Float -> Glsl.Expression Glsl.Float_ +maxff a b = + Glsl.unsafeCall2 "max" [] (Glsl.float1 a) (Glsl.float1 b) + + +maxi1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ +maxi1i1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Int_ +maxi1wi1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.int1 b) + + +maxi2i1 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec2 +maxi2i1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi2i2 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 +maxi2i2 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi2wi1 : Glsl.Expression Glsl.IVec2 -> Int -> Glsl.Expression Glsl.IVec2 +maxi2wi1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.int1 b) + + +maxi3i1 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec3 +maxi3i1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi3i3 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 +maxi3i3 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi3wi1 : Glsl.Expression Glsl.IVec3 -> Int -> Glsl.Expression Glsl.IVec3 +maxi3wi1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.int1 b) + + +maxi4i1 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec4 +maxi4i1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi4i4 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 +maxi4i4 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxi4wi1 : Glsl.Expression Glsl.IVec4 -> Int -> Glsl.Expression Glsl.IVec4 +maxi4wi1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.int1 b) + + +maxu1u1 : + Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint +maxu1u1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu1wu1 : Glsl.Expression Glsl.Uint -> Int -> Glsl.Expression Glsl.Uint +maxu1wu1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.uint1 b) + + +maxu2u1 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec2 +maxu2u1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu2u2 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 +maxu2u2 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu2wu1 : Glsl.Expression Glsl.UVec2 -> Int -> Glsl.Expression Glsl.UVec2 +maxu2wu1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.uint1 b) + + +maxu3u1 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec3 +maxu3u1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu3u3 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 +maxu3u3 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu3wu1 : Glsl.Expression Glsl.UVec3 -> Int -> Glsl.Expression Glsl.UVec3 +maxu3wu1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.uint1 b) + + +maxu4u1 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec4 +maxu4u1 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu4u4 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 +maxu4u4 a b = + Glsl.unsafeCall2 "max" [] a b + + +maxu4wu1 : Glsl.Expression Glsl.UVec4 -> Int -> Glsl.Expression Glsl.UVec4 +maxu4wu1 a b = + Glsl.unsafeCall2 "max" [] a (Glsl.uint1 b) + + +maxwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +maxwd1d1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.double1 a) b + + +maxwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +maxwd1wd1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.double1 a) (Glsl.double1 b) + + +maxwi1i1 : Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Int_ +maxwi1i1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.int1 a) b + + +maxwi1wi1 : Int -> Int -> Glsl.Expression Glsl.Int_ +maxwi1wi1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.int1 a) (Glsl.int1 b) + + +maxwu1u1 : Int -> Glsl.Expression Glsl.Uint -> Glsl.Expression Glsl.Uint +maxwu1u1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.uint1 a) b + + +maxwu1wu1 : Int -> Int -> Glsl.Expression Glsl.Uint +maxwu1wu1 a b = + Glsl.unsafeCall2 "max" [] (Glsl.uint1 a) (Glsl.uint1 b) + + +min11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +min11 a b = + Glsl.unsafeCall2 "min" [] a b + + +min1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +min1f a b = + Glsl.unsafeCall2 "min" [] a (Glsl.float1 b) + + +min21 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +min21 a b = + Glsl.unsafeCall2 "min" [] a b + + +min22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +min22 a b = + Glsl.unsafeCall2 "min" [] a b + + +min2f : Glsl.Expression Glsl.Vec2 -> Float -> Glsl.Expression Glsl.Vec2 +min2f a b = + Glsl.unsafeCall2 "min" [] a (Glsl.float1 b) + + +min31 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +min31 a b = + Glsl.unsafeCall2 "min" [] a b + + +min33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +min33 a b = + Glsl.unsafeCall2 "min" [] a b + + +min3f : Glsl.Expression Glsl.Vec3 -> Float -> Glsl.Expression Glsl.Vec3 +min3f a b = + Glsl.unsafeCall2 "min" [] a (Glsl.float1 b) + + +min41 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +min41 a b = + Glsl.unsafeCall2 "min" [] a b + + +min44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +min44 a b = + Glsl.unsafeCall2 "min" [] a b + + +min4f : Glsl.Expression Glsl.Vec4 -> Float -> Glsl.Expression Glsl.Vec4 +min4f a b = + Glsl.unsafeCall2 "min" [] a (Glsl.float1 b) + + +mind1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +mind1d1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +mind1wd1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.double1 b) + + +mind2d1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +mind2d1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +mind2d2 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind2wd1 : Glsl.Expression Glsl.DVec2 -> Float -> Glsl.Expression Glsl.DVec2 +mind2wd1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.double1 b) + + +mind3d1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +mind3d1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +mind3d3 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind3wd1 : Glsl.Expression Glsl.DVec3 -> Float -> Glsl.Expression Glsl.DVec3 +mind3wd1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.double1 b) + + +mind4d1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +mind4d1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +mind4d4 a b = + Glsl.unsafeCall2 "min" [] a b + + +mind4wd1 : Glsl.Expression Glsl.DVec4 -> Float -> Glsl.Expression Glsl.DVec4 +mind4wd1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.double1 b) + + +minf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +minf1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.float1 a) b + + +minff : Float -> Float -> Glsl.Expression Glsl.Float_ +minff a b = + Glsl.unsafeCall2 "min" [] (Glsl.float1 a) (Glsl.float1 b) + + +mini1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ +mini1i1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Int_ +mini1wi1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.int1 b) + + +mini2i1 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec2 +mini2i1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini2i2 : + Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 + -> Glsl.Expression Glsl.IVec2 +mini2i2 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini2wi1 : Glsl.Expression Glsl.IVec2 -> Int -> Glsl.Expression Glsl.IVec2 +mini2wi1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.int1 b) + + +mini3i1 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec3 +mini3i1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini3i3 : + Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 + -> Glsl.Expression Glsl.IVec3 +mini3i3 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini3wi1 : Glsl.Expression Glsl.IVec3 -> Int -> Glsl.Expression Glsl.IVec3 +mini3wi1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.int1 b) + + +mini4i1 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.IVec4 +mini4i1 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini4i4 : + Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 + -> Glsl.Expression Glsl.IVec4 +mini4i4 a b = + Glsl.unsafeCall2 "min" [] a b + + +mini4wi1 : Glsl.Expression Glsl.IVec4 -> Int -> Glsl.Expression Glsl.IVec4 +mini4wi1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.int1 b) + + +minu1u1 : + Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.Uint +minu1u1 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu1wu1 : Glsl.Expression Glsl.Uint -> Int -> Glsl.Expression Glsl.Uint +minu1wu1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.uint1 b) + + +minu2u1 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec2 +minu2u1 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu2u2 : + Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 + -> Glsl.Expression Glsl.UVec2 +minu2u2 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu2wu1 : Glsl.Expression Glsl.UVec2 -> Int -> Glsl.Expression Glsl.UVec2 +minu2wu1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.uint1 b) + + +minu3u1 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec3 +minu3u1 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu3u3 : + Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 + -> Glsl.Expression Glsl.UVec3 +minu3u3 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu3wu1 : Glsl.Expression Glsl.UVec3 -> Int -> Glsl.Expression Glsl.UVec3 +minu3wu1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.uint1 b) + + +minu4u1 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.Uint + -> Glsl.Expression Glsl.UVec4 +minu4u1 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu4u4 : + Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 + -> Glsl.Expression Glsl.UVec4 +minu4u4 a b = + Glsl.unsafeCall2 "min" [] a b + + +minu4wu1 : Glsl.Expression Glsl.UVec4 -> Int -> Glsl.Expression Glsl.UVec4 +minu4wu1 a b = + Glsl.unsafeCall2 "min" [] a (Glsl.uint1 b) + + +minwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +minwd1d1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.double1 a) b + + +minwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +minwd1wd1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.double1 a) (Glsl.double1 b) + + +minwi1i1 : Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Int_ +minwi1i1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.int1 a) b + + +minwi1wi1 : Int -> Int -> Glsl.Expression Glsl.Int_ +minwi1wi1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.int1 a) (Glsl.int1 b) + + +minwu1u1 : Int -> Glsl.Expression Glsl.Uint -> Glsl.Expression Glsl.Uint +minwu1u1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.uint1 a) b + + +minwu1wu1 : Int -> Int -> Glsl.Expression Glsl.Uint +minwu1wu1 a b = + Glsl.unsafeCall2 "min" [] (Glsl.uint1 a) (Glsl.uint1 b) + + +mix111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +mix111 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +mix11f a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.float1 c) + + +mix1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +mix1f1 a b c = + Glsl.unsafeCall3 "mix" [] a (Glsl.float1 b) c + + +mix1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +mix1ff a b c = + Glsl.unsafeCall3 "mix" [] a (Glsl.float1 b) (Glsl.float1 c) + + +mix221 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +mix221 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +mix222 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix22f : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Float + -> Glsl.Expression Glsl.Vec2 +mix22f a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.float1 c) + + +mix331 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +mix331 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +mix333 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix33f : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Float + -> Glsl.Expression Glsl.Vec3 +mix33f a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.float1 c) + + +mix441 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +mix441 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +mix444 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mix44f : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Float + -> Glsl.Expression Glsl.Vec4 +mix44f a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.float1 c) + + +mixd1d1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +mixd1d1d1 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd1d1wd1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +mixd1d1wd1 a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.double1 c) + + +mixd1wd1d1 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +mixd1wd1d1 a b c = + Glsl.unsafeCall3 "mix" [] a (Glsl.double1 b) c + + +mixd1wd1wd1 : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +mixd1wd1wd1 a b c = + Glsl.unsafeCall3 "mix" [] a (Glsl.double1 b) (Glsl.double1 c) + + +mixd2d2d1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +mixd2d2d1 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd2d2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +mixd2d2d2 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd2d2wd1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Float + -> Glsl.Expression Glsl.DVec2 +mixd2d2wd1 a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.double1 c) + + +mixd3d3d1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +mixd3d3d1 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd3d3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +mixd3d3d3 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd3d3wd1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Float + -> Glsl.Expression Glsl.DVec3 +mixd3d3wd1 a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.double1 c) + + +mixd4d4d1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +mixd4d4d1 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd4d4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +mixd4d4d4 a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mixd4d4wd1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Float + -> Glsl.Expression Glsl.DVec4 +mixd4d4wd1 a b c = + Glsl.unsafeCall3 "mix" [] a b (Glsl.double1 c) + + +mixf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +mixf11 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.float1 a) b c + + +mixf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +mixf1f a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.float1 a) b (Glsl.float1 c) + + +mixff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +mixff1 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.float1 a) (Glsl.float1 b) c + + +mixfff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +mixfff a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) + + +mixwd1d1d1 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +mixwd1d1d1 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.double1 a) b c + + +mixwd1d1wd1 : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +mixwd1d1wd1 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.double1 a) b (Glsl.double1 c) + + +mixwd1wd1d1 : Float -> Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +mixwd1wd1d1 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.double1 a) (Glsl.double1 b) c + + +mixwd1wd1wd1 : Float -> Float -> Float -> Glsl.Expression Glsl.Double +mixwd1wd1wd1 a b c = + Glsl.unsafeCall3 "mix" [] (Glsl.double1 a) (Glsl.double1 b) (Glsl.double1 c) + + +mix : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +mix a b c = + Glsl.unsafeCall3 "mix" [] a b c + + +mod11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +mod11 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +mod1f a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.float1 b) + + +mod21 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +mod21 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +mod22 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod2f : Glsl.Expression Glsl.Vec2 -> Float -> Glsl.Expression Glsl.Vec2 +mod2f a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.float1 b) + + +mod31 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +mod31 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +mod33 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod3f : Glsl.Expression Glsl.Vec3 -> Float -> Glsl.Expression Glsl.Vec3 +mod3f a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.float1 b) + + +mod41 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +mod41 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +mod44 a b = + Glsl.unsafeCall2 "mod" [] a b + + +mod4f : Glsl.Expression Glsl.Vec4 -> Float -> Glsl.Expression Glsl.Vec4 +mod4f a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.float1 b) + + +modd1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +modd1d1 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +modd1wd1 a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.double1 b) + + +modd2d1 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 +modd2d1 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +modd2d2 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd2wd1 : Glsl.Expression Glsl.DVec2 -> Float -> Glsl.Expression Glsl.DVec2 +modd2wd1 a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.double1 b) + + +modd3d1 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 +modd3d1 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +modd3d3 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd3wd1 : Glsl.Expression Glsl.DVec3 -> Float -> Glsl.Expression Glsl.DVec3 +modd3wd1 a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.double1 b) + + +modd4d1 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 +modd4d1 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +modd4d4 a b = + Glsl.unsafeCall2 "mod" [] a b + + +modd4wd1 : Glsl.Expression Glsl.DVec4 -> Float -> Glsl.Expression Glsl.DVec4 +modd4wd1 a b = + Glsl.unsafeCall2 "mod" [] a (Glsl.double1 b) + + +modf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +modf1 a b = + Glsl.unsafeCall2 "mod" [] (Glsl.float1 a) b + + +modff : Float -> Float -> Glsl.Expression Glsl.Float_ +modff a b = + Glsl.unsafeCall2 "mod" [] (Glsl.float1 a) (Glsl.float1 b) + + +modwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +modwd1d1 a b = + Glsl.unsafeCall2 "mod" [] (Glsl.double1 a) b + + +modwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +modwd1wd1 a b = + Glsl.unsafeCall2 "mod" [] (Glsl.double1 a) (Glsl.double1 b) + + +mod : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +mod a b = + Glsl.unsafeCall2 "mod" [] a b + + +modf1o1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression (Glsl.Out Glsl.Float_) + -> Glsl.Expression Glsl.Float_ +modf1o1 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modf1of : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +modf1of a b = + Glsl.unsafeCall2 "modf" [] a (Glsl.float1 b) + + +modf2o2 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression (Glsl.Out Glsl.Vec2) + -> Glsl.Expression Glsl.Vec2 +modf2o2 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modf3o3 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression (Glsl.Out Glsl.Vec3) + -> Glsl.Expression Glsl.Vec3 +modf3o3 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modf4o4 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression (Glsl.Out Glsl.Vec4) + -> Glsl.Expression Glsl.Vec4 +modf4o4 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modfd1od1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression (Glsl.Out Glsl.Double) + -> Glsl.Expression Glsl.Double +modfd1od1 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modfd1owd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +modfd1owd1 a b = + Glsl.unsafeCall2 "modf" [] a (Glsl.double1 b) + + +modfd2od2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression (Glsl.Out Glsl.DVec2) + -> Glsl.Expression Glsl.DVec2 +modfd2od2 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modfd3od3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression (Glsl.Out Glsl.DVec3) + -> Glsl.Expression Glsl.DVec3 +modfd3od3 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modfd4od4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression (Glsl.Out Glsl.DVec4) + -> Glsl.Expression Glsl.DVec4 +modfd4od4 a b = + Glsl.unsafeCall2 "modf" [] a b + + +modffo1 : + Float + -> Glsl.Expression (Glsl.Out Glsl.Float_) + -> Glsl.Expression Glsl.Float_ +modffo1 a b = + Glsl.unsafeCall2 "modf" [] (Glsl.float1 a) b + + +modffof : Float -> Float -> Glsl.Expression Glsl.Float_ +modffof a b = + Glsl.unsafeCall2 "modf" [] (Glsl.float1 a) (Glsl.float1 b) + + +modfwd1od1 : + Float + -> Glsl.Expression (Glsl.Out Glsl.Double) + -> Glsl.Expression Glsl.Double +modfwd1od1 a b = + Glsl.unsafeCall2 "modf" [] (Glsl.double1 a) b + + +modfwd1owd1 : Float -> Float -> Glsl.Expression Glsl.Double +modfwd1owd1 a b = + Glsl.unsafeCall2 "modf" [] (Glsl.double1 a) (Glsl.double1 b) + + +modf : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Out (Glsl.Vec t a)) + -> Glsl.Expression (Glsl.Vec t a) +modf a b = + Glsl.unsafeCall2 "modf" [] a b + + +normalize1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +normalize1 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalize2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +normalize2 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalize3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +normalize3 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalize4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +normalize4 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalized1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +normalized1 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalized2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +normalized2 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalized3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +normalized3 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalized4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +normalized4 a = + Glsl.unsafeCall1 "normalize" [] a + + +normalizef : Float -> Glsl.Expression Glsl.Float_ +normalizef a = + Glsl.unsafeCall1 "normalize" [] (Glsl.float1 a) + + +normalizewd1 : Float -> Glsl.Expression Glsl.Double +normalizewd1 a = + Glsl.unsafeCall1 "normalize" [] (Glsl.double1 a) + + +normalize : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +normalize a = + Glsl.unsafeCall1 "normalize" [] a + + +reflect11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +reflect11 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflect1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +reflect1f a b = + Glsl.unsafeCall2 "reflect" [] a (Glsl.float1 b) + + +reflect22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +reflect22 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflect33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +reflect33 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflect44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +reflect44 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflectd1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +reflectd1d1 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflectd1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +reflectd1wd1 a b = + Glsl.unsafeCall2 "reflect" [] a (Glsl.double1 b) + + +reflectd2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +reflectd2d2 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflectd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +reflectd3d3 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflectd4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +reflectd4d4 a b = + Glsl.unsafeCall2 "reflect" [] a b + + +reflectf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +reflectf1 a b = + Glsl.unsafeCall2 "reflect" [] (Glsl.float1 a) b + + +reflectff : Float -> Float -> Glsl.Expression Glsl.Float_ +reflectff a b = + Glsl.unsafeCall2 "reflect" [] (Glsl.float1 a) (Glsl.float1 b) + + +reflectwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +reflectwd1d1 a b = + Glsl.unsafeCall2 "reflect" [] (Glsl.double1 a) b + + +reflectwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +reflectwd1wd1 a b = + Glsl.unsafeCall2 "reflect" [] (Glsl.double1 a) (Glsl.double1 b) + + +reflect : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +reflect a b = + Glsl.unsafeCall2 "reflect" [] a b + + +refract111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +refract111 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refract11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +refract11f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refract1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +refract1f1 a b c = + Glsl.unsafeCall3 "refract" [] a (Glsl.float1 b) c + + +refract1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +refract1ff a b c = + Glsl.unsafeCall3 "refract" [] a (Glsl.float1 b) (Glsl.float1 c) + + +refract221 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +refract221 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refract22f : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Float + -> Glsl.Expression Glsl.Vec2 +refract22f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refract331 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +refract331 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refract33f : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Float + -> Glsl.Expression Glsl.Vec3 +refract33f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refract441 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +refract441 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refract44f : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Float + -> Glsl.Expression Glsl.Vec4 +refract44f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refractd1d11 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Double +refractd1d11 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refractd1d1f : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +refractd1d1f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refractd1wd11 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Double +refractd1wd11 a b c = + Glsl.unsafeCall3 "refract" [] a (Glsl.double1 b) c + + +refractd1wd1f : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +refractd1wd1f a b c = + Glsl.unsafeCall3 "refract" [] a (Glsl.double1 b) (Glsl.float1 c) + + +refractd2d21 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.DVec2 +refractd2d21 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refractd2d2f : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Float + -> Glsl.Expression Glsl.DVec2 +refractd2d2f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refractd3d31 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.DVec3 +refractd3d31 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refractd3d3f : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Float + -> Glsl.Expression Glsl.DVec3 +refractd3d3f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refractd4d41 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.DVec4 +refractd4d41 a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +refractd4d4f : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Float + -> Glsl.Expression Glsl.DVec4 +refractd4d4f a b c = + Glsl.unsafeCall3 "refract" [] a b (Glsl.float1 c) + + +refractf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +refractf11 a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.float1 a) b c + + +refractf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +refractf1f a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.float1 a) b (Glsl.float1 c) + + +refractff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +refractff1 a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.float1 a) (Glsl.float1 b) c + + +refractfff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +refractfff a b c = + Glsl.unsafeCall3 + "refract" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + + +refractwd1d11 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Double +refractwd1d11 a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.double1 a) b c + + +refractwd1d1f : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +refractwd1d1f a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.double1 a) b (Glsl.float1 c) + + +refractwd1wd11 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Double +refractwd1wd11 a b c = + Glsl.unsafeCall3 "refract" [] (Glsl.double1 a) (Glsl.double1 b) c + + +refractwd1wd1f : Float -> Float -> Float -> Glsl.Expression Glsl.Double +refractwd1wd1f a b c = + Glsl.unsafeCall3 + "refract" + [] + (Glsl.double1 a) + (Glsl.double1 b) + (Glsl.float1 c) + + +refract : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec Float Glsl.D1) + -> Glsl.Expression (Glsl.Vec t a) +refract a b c = + Glsl.unsafeCall3 "refract" [] a b c + + +round1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +round1 a = + Glsl.unsafeCall1 "round" [] a + + +round2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +round2 a = + Glsl.unsafeCall1 "round" [] a + + +round3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +round3 a = + Glsl.unsafeCall1 "round" [] a + + +round4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +round4 a = + Glsl.unsafeCall1 "round" [] a + + +roundd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +roundd1 a = + Glsl.unsafeCall1 "round" [] a + + +roundd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +roundd2 a = + Glsl.unsafeCall1 "round" [] a + + +roundd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +roundd3 a = + Glsl.unsafeCall1 "round" [] a + + +roundd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +roundd4 a = + Glsl.unsafeCall1 "round" [] a + + +roundf : Float -> Glsl.Expression Glsl.Float_ +roundf a = + Glsl.unsafeCall1 "round" [] (Glsl.float1 a) + + +roundwd1 : Float -> Glsl.Expression Glsl.Double +roundwd1 a = + Glsl.unsafeCall1 "round" [] (Glsl.double1 a) + + +roundEven1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +roundEven1 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEven2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +roundEven2 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEven3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +roundEven3 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEven4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +roundEven4 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEvend1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +roundEvend1 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEvend2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +roundEvend2 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEvend3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +roundEvend3 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEvend4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +roundEvend4 a = + Glsl.unsafeCall1 "roundEven" [] a + + +roundEvenf : Float -> Glsl.Expression Glsl.Float_ +roundEvenf a = + Glsl.unsafeCall1 "roundEven" [] (Glsl.float1 a) + + +roundEvenwd1 : Float -> Glsl.Expression Glsl.Double +roundEvenwd1 a = + Glsl.unsafeCall1 "roundEven" [] (Glsl.double1 a) + + +roundEven : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +roundEven a = + Glsl.unsafeCall1 "roundEven" [] a + + +sign1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +sign1 a = + Glsl.unsafeCall1 "sign" [] a + + +sign2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +sign2 a = + Glsl.unsafeCall1 "sign" [] a + + +sign3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +sign3 a = + Glsl.unsafeCall1 "sign" [] a + + +sign4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +sign4 a = + Glsl.unsafeCall1 "sign" [] a + + +signd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +signd1 a = + Glsl.unsafeCall1 "sign" [] a + + +signd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +signd2 a = + Glsl.unsafeCall1 "sign" [] a + + +signd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +signd3 a = + Glsl.unsafeCall1 "sign" [] a + + +signd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +signd4 a = + Glsl.unsafeCall1 "sign" [] a + + +signf : Float -> Glsl.Expression Glsl.Float_ +signf a = + Glsl.unsafeCall1 "sign" [] (Glsl.float1 a) + + +signi1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Int_ +signi1 a = + Glsl.unsafeCall1 "sign" [] a + + +signi2 : Glsl.Expression Glsl.IVec2 -> Glsl.Expression Glsl.IVec2 +signi2 a = + Glsl.unsafeCall1 "sign" [] a + + +signi3 : Glsl.Expression Glsl.IVec3 -> Glsl.Expression Glsl.IVec3 +signi3 a = + Glsl.unsafeCall1 "sign" [] a + + +signi4 : Glsl.Expression Glsl.IVec4 -> Glsl.Expression Glsl.IVec4 +signi4 a = + Glsl.unsafeCall1 "sign" [] a + + +signwd1 : Float -> Glsl.Expression Glsl.Double +signwd1 a = + Glsl.unsafeCall1 "sign" [] (Glsl.double1 a) + + +signwi1 : Int -> Glsl.Expression Glsl.Int_ +signwi1 a = + Glsl.unsafeCall1 "sign" [] (Glsl.int1 a) + + +sign : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +sign a = + Glsl.unsafeCall1 "sign" [] a + + +smoothstep111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +smoothstep111 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep112 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +smoothstep112 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep113 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +smoothstep113 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep114 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +smoothstep114 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ +smoothstep11f a b c = + Glsl.unsafeCall3 "smoothstep" [] a b (Glsl.float1 c) + + +smoothstep1f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +smoothstep1f1 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.float1 b) c + + +smoothstep1f2 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +smoothstep1f2 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.float1 b) c + + +smoothstep1f3 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +smoothstep1f3 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.float1 b) c + + +smoothstep1f4 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +smoothstep1f4 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.float1 b) c + + +smoothstep1ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Float_ +smoothstep1ff a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.float1 b) (Glsl.float1 c) + + +smoothstep222 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +smoothstep222 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep333 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +smoothstep333 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstep444 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +smoothstep444 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd1d1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +smoothstepd1d1d1 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd1d1d2 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +smoothstepd1d1d2 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd1d1d3 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +smoothstepd1d1d3 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd1d1d4 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +smoothstepd1d1d4 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd1d1wd1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double +smoothstepd1d1wd1 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b (Glsl.double1 c) + + +smoothstepd1wd1d1 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +smoothstepd1wd1d1 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.double1 b) c + + +smoothstepd1wd1d2 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +smoothstepd1wd1d2 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.double1 b) c + + +smoothstepd1wd1d3 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +smoothstepd1wd1d3 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.double1 b) c + + +smoothstepd1wd1d4 : + Glsl.Expression Glsl.Double + -> Float + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +smoothstepd1wd1d4 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.double1 b) c + + +smoothstepd1wd1wd1 : Glsl.Expression Glsl.Double -> Float -> Float -> Glsl.Expression Glsl.Double +smoothstepd1wd1wd1 a b c = + Glsl.unsafeCall3 "smoothstep" [] a (Glsl.double1 b) (Glsl.double1 c) + + +smoothstepd2d2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +smoothstepd2d2d2 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd3d3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +smoothstepd3d3d3 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepd4d4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +smoothstepd4d4d4 a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +smoothstepf11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +smoothstepf11 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) b c + + +smoothstepf12 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +smoothstepf12 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) b c + + +smoothstepf13 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +smoothstepf13 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) b c + + +smoothstepf14 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +smoothstepf14 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) b c + + +smoothstepf1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +smoothstepf1f a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) b (Glsl.float1 c) + + +smoothstepff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +smoothstepff1 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) (Glsl.float1 b) c + + +smoothstepff2 : Float -> Float -> Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +smoothstepff2 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) (Glsl.float1 b) c + + +smoothstepff3 : Float -> Float -> Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +smoothstepff3 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) (Glsl.float1 b) c + + +smoothstepff4 : Float -> Float -> Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +smoothstepff4 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.float1 a) (Glsl.float1 b) c + + +smoothstepfff : Float -> Float -> Float -> Glsl.Expression Glsl.Float_ +smoothstepfff a b c = + Glsl.unsafeCall3 + "smoothstep" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + + +smoothstepwd1d1d1 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +smoothstepwd1d1d1 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) b c + + +smoothstepwd1d1d2 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +smoothstepwd1d1d2 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) b c + + +smoothstepwd1d1d3 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +smoothstepwd1d1d3 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) b c + + +smoothstepwd1d1d4 : + Float + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +smoothstepwd1d1d4 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) b c + + +smoothstepwd1d1wd1 : Float -> Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +smoothstepwd1d1wd1 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) b (Glsl.double1 c) + + +smoothstepwd1wd1d1 : Float -> Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +smoothstepwd1wd1d1 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) (Glsl.double1 b) c + + +smoothstepwd1wd1d2 : Float -> Float -> Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +smoothstepwd1wd1d2 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) (Glsl.double1 b) c + + +smoothstepwd1wd1d3 : Float -> Float -> Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +smoothstepwd1wd1d3 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) (Glsl.double1 b) c + + +smoothstepwd1wd1d4 : Float -> Float -> Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +smoothstepwd1wd1d4 a b c = + Glsl.unsafeCall3 "smoothstep" [] (Glsl.double1 a) (Glsl.double1 b) c + + +smoothstepwd1wd1wd1 : Float -> Float -> Float -> Glsl.Expression Glsl.Double +smoothstepwd1wd1wd1 a b c = + Glsl.unsafeCall3 + "smoothstep" + [] + (Glsl.double1 a) + (Glsl.double1 b) + (Glsl.double1 c) + + +smoothstep : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +smoothstep a b c = + Glsl.unsafeCall3 "smoothstep" [] a b c + + +sqrt1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +sqrt1 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrt2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +sqrt2 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrt3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +sqrt3 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrt4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +sqrt4 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrtd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +sqrtd1 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrtd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +sqrtd2 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrtd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +sqrtd3 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrtd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +sqrtd4 a = + Glsl.unsafeCall1 "sqrt" [] a + + +sqrtf : Float -> Glsl.Expression Glsl.Float_ +sqrtf a = + Glsl.unsafeCall1 "sqrt" [] (Glsl.float1 a) + + +sqrtwd1 : Float -> Glsl.Expression Glsl.Double +sqrtwd1 a = + Glsl.unsafeCall1 "sqrt" [] (Glsl.double1 a) + + +step11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ +step11 a b = + Glsl.unsafeCall2 "step" [] a b + + +step12 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +step12 a b = + Glsl.unsafeCall2 "step" [] a b + + +step13 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +step13 a b = + Glsl.unsafeCall2 "step" [] a b + + +step14 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +step14 a b = + Glsl.unsafeCall2 "step" [] a b + + +step1f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Float_ +step1f a b = + Glsl.unsafeCall2 "step" [] a (Glsl.float1 b) + + +step22 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 +step22 a b = + Glsl.unsafeCall2 "step" [] a b + + +step33 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec3 +step33 a b = + Glsl.unsafeCall2 "step" [] a b + + +step44 : + Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 + -> Glsl.Expression Glsl.Vec4 +step44 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd1d1 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.Double +stepd1d1 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd1d2 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +stepd1d2 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd1d3 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +stepd1d3 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd1d4 : + Glsl.Expression Glsl.Double + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +stepd1d4 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd1wd1 : Glsl.Expression Glsl.Double -> Float -> Glsl.Expression Glsl.Double +stepd1wd1 a b = + Glsl.unsafeCall2 "step" [] a (Glsl.double1 b) + + +stepd2d2 : + Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 + -> Glsl.Expression Glsl.DVec2 +stepd2d2 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd3d3 : + Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 + -> Glsl.Expression Glsl.DVec3 +stepd3d3 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepd4d4 : + Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 + -> Glsl.Expression Glsl.DVec4 +stepd4d4 a b = + Glsl.unsafeCall2 "step" [] a b + + +stepf1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +stepf1 a b = + Glsl.unsafeCall2 "step" [] (Glsl.float1 a) b + + +stepf2 : Float -> Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +stepf2 a b = + Glsl.unsafeCall2 "step" [] (Glsl.float1 a) b + + +stepf3 : Float -> Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +stepf3 a b = + Glsl.unsafeCall2 "step" [] (Glsl.float1 a) b + + +stepf4 : Float -> Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +stepf4 a b = + Glsl.unsafeCall2 "step" [] (Glsl.float1 a) b + + +stepff : Float -> Float -> Glsl.Expression Glsl.Float_ +stepff a b = + Glsl.unsafeCall2 "step" [] (Glsl.float1 a) (Glsl.float1 b) + + +stepwd1d1 : Float -> Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +stepwd1d1 a b = + Glsl.unsafeCall2 "step" [] (Glsl.double1 a) b + + +stepwd1d2 : Float -> Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +stepwd1d2 a b = + Glsl.unsafeCall2 "step" [] (Glsl.double1 a) b + + +stepwd1d3 : Float -> Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +stepwd1d3 a b = + Glsl.unsafeCall2 "step" [] (Glsl.double1 a) b + + +stepwd1d4 : Float -> Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +stepwd1d4 a b = + Glsl.unsafeCall2 "step" [] (Glsl.double1 a) b + + +stepwd1wd1 : Float -> Float -> Glsl.Expression Glsl.Double +stepwd1wd1 a b = + Glsl.unsafeCall2 "step" [] (Glsl.double1 a) (Glsl.double1 b) + + +step : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +step a b = + Glsl.unsafeCall2 "step" [] a b + + +trunc1 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Float_ +trunc1 a = + Glsl.unsafeCall1 "trunc" [] a + + +trunc2 : Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec2 +trunc2 a = + Glsl.unsafeCall1 "trunc" [] a + + +trunc3 : Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec3 +trunc3 a = + Glsl.unsafeCall1 "trunc" [] a + + +trunc4 : Glsl.Expression Glsl.Vec4 -> Glsl.Expression Glsl.Vec4 +trunc4 a = + Glsl.unsafeCall1 "trunc" [] a + + +truncd1 : Glsl.Expression Glsl.Double -> Glsl.Expression Glsl.Double +truncd1 a = + Glsl.unsafeCall1 "trunc" [] a + + +truncd2 : Glsl.Expression Glsl.DVec2 -> Glsl.Expression Glsl.DVec2 +truncd2 a = + Glsl.unsafeCall1 "trunc" [] a + + +truncd3 : Glsl.Expression Glsl.DVec3 -> Glsl.Expression Glsl.DVec3 +truncd3 a = + Glsl.unsafeCall1 "trunc" [] a + + +truncd4 : Glsl.Expression Glsl.DVec4 -> Glsl.Expression Glsl.DVec4 +truncd4 a = + Glsl.unsafeCall1 "trunc" [] a + + +truncf : Float -> Glsl.Expression Glsl.Float_ +truncf a = + Glsl.unsafeCall1 "trunc" [] (Glsl.float1 a) + + +truncwd1 : Float -> Glsl.Expression Glsl.Double +truncwd1 a = + Glsl.unsafeCall1 "trunc" [] (Glsl.double1 a) + + +trunc : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +trunc a = + Glsl.unsafeCall1 "trunc" [] a + + +uintBitsToFloatu1 : Glsl.Expression Glsl.Uint -> Glsl.Expression Glsl.Float_ +uintBitsToFloatu1 a = + Glsl.unsafeCall1 "uintBitsToFloat" [] a + + +uintBitsToFloatu2 : Glsl.Expression Glsl.UVec2 -> Glsl.Expression Glsl.Vec2 +uintBitsToFloatu2 a = + Glsl.unsafeCall1 "uintBitsToFloat" [] a + + +uintBitsToFloatu3 : Glsl.Expression Glsl.UVec3 -> Glsl.Expression Glsl.Vec3 +uintBitsToFloatu3 a = + Glsl.unsafeCall1 "uintBitsToFloat" [] a + + +uintBitsToFloatu4 : Glsl.Expression Glsl.UVec4 -> Glsl.Expression Glsl.Vec4 +uintBitsToFloatu4 a = + Glsl.unsafeCall1 "uintBitsToFloat" [] a + + +uintBitsToFloatwu1 : Int -> Glsl.Expression Glsl.Float_ +uintBitsToFloatwu1 a = + Glsl.unsafeCall1 "uintBitsToFloat" [] (Glsl.uint1 a) + + +vec21 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec2 +vec21 a = + Glsl.unsafeCall1 "vec2" [] a + + +vec211 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +vec211 a b = + Glsl.unsafeCall2 "vec2" [] a b + + +vec21f : Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Vec2 +vec21f a b = + Glsl.unsafeCall2 "vec2" [] a (Glsl.float1 b) + + +vec21i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec2 +vec21i1 a b = + Glsl.unsafeCall2 "vec2" [] a b + + +vec21wi1 : Glsl.Expression Glsl.Float_ -> Int -> Glsl.Expression Glsl.Vec2 +vec21wi1 a b = + Glsl.unsafeCall2 "vec2" [] a (Glsl.int1 b) + + +vec2f : Float -> Glsl.Expression Glsl.Vec2 +vec2f a = + Glsl.unsafeCall1 "vec2" [] (Glsl.float1 a) + + +vec2f1 : Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec2 +vec2f1 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.float1 a) b + + +vec2ff : Float -> Float -> Glsl.Expression Glsl.Vec2 +vec2ff a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.float1 a) (Glsl.float1 b) + + +vec2fi1 : Float -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec2 +vec2fi1 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.float1 a) b + + +vec2fwi1 : Float -> Int -> Glsl.Expression Glsl.Vec2 +vec2fwi1 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.float1 a) (Glsl.int1 b) + + +vec2i1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec2 +vec2i1 a = + Glsl.unsafeCall1 "vec2" [] a + + +vec2i11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 +vec2i11 a b = + Glsl.unsafeCall2 "vec2" [] a b + + +vec2i1f : Glsl.Expression Glsl.Int_ -> Float -> Glsl.Expression Glsl.Vec2 +vec2i1f a b = + Glsl.unsafeCall2 "vec2" [] a (Glsl.float1 b) + + +vec2i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec2 +vec2i1i1 a b = + Glsl.unsafeCall2 "vec2" [] a b + + +vec2i1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec2 +vec2i1wi1 a b = + Glsl.unsafeCall2 "vec2" [] a (Glsl.int1 b) + + +vec2wi1 : Int -> Glsl.Expression Glsl.Vec2 +vec2wi1 a = + Glsl.unsafeCall1 "vec2" [] (Glsl.int1 a) + + +vec2wi11 : Int -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec2 +vec2wi11 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.int1 a) b + + +vec2wi1f : Int -> Float -> Glsl.Expression Glsl.Vec2 +vec2wi1f a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.int1 a) (Glsl.float1 b) + + +vec2wi1i1 : Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec2 +vec2wi1i1 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.int1 a) b + + +vec2wi1wi1 : Int -> Int -> Glsl.Expression Glsl.Vec2 +vec2wi1wi1 a b = + Glsl.unsafeCall2 "vec2" [] (Glsl.int1 a) (Glsl.int1 b) + + +vec31 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec3 +vec31 a = + Glsl.unsafeCall1 "vec3" [] a + + +vec3111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3111 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec311f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec3 +vec311f a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.float1 c) + + +vec311i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec311i1 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec311wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec3 +vec311wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.int1 c) + + +vec312 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec3 +vec312 a b = + Glsl.unsafeCall2 "vec3" [] a b + + +vec31f1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec31f1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) c + + +vec31ff : Glsl.Expression Glsl.Float_ -> Float -> Float -> Glsl.Expression Glsl.Vec3 +vec31ff a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) (Glsl.float1 c) + + +vec31fi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec31fi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) c + + +vec31fwi1 : Glsl.Expression Glsl.Float_ -> Float -> Int -> Glsl.Expression Glsl.Vec3 +vec31fwi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) (Glsl.int1 c) + + +vec31i11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec31i11 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec31i1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec3 +vec31i1f a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.float1 c) + + +vec31i1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec31i1i1 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec31i1wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec3 +vec31i1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.int1 c) + + +vec31wi11 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec31wi11 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) c + + +vec31wi1f : Glsl.Expression Glsl.Float_ -> Int -> Float -> Glsl.Expression Glsl.Vec3 +vec31wi1f a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) (Glsl.float1 c) + + +vec31wi1i1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec31wi1i1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) c + + +vec31wi1wi1 : Glsl.Expression Glsl.Float_ -> Int -> Int -> Glsl.Expression Glsl.Vec3 +vec31wi1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) (Glsl.int1 c) + + +vec321 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec321 a b = + Glsl.unsafeCall2 "vec3" [] a b + + +vec32f : Glsl.Expression Glsl.Vec2 -> Float -> Glsl.Expression Glsl.Vec3 +vec32f a b = + Glsl.unsafeCall2 "vec3" [] a (Glsl.float1 b) + + +vec3f : Float -> Glsl.Expression Glsl.Vec3 +vec3f a = + Glsl.unsafeCall1 "vec3" [] (Glsl.float1 a) + + +vec3f11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3f11 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b c + + +vec3f1f : Float -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Vec3 +vec3f1f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b (Glsl.float1 c) + + +vec3f1i1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3f1i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b c + + +vec3f1wi1 : Float -> Glsl.Expression Glsl.Float_ -> Int -> Glsl.Expression Glsl.Vec3 +vec3f1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b (Glsl.int1 c) + + +vec3f2 : Float -> Glsl.Expression Glsl.Vec2 -> Glsl.Expression Glsl.Vec3 +vec3f2 a b = + Glsl.unsafeCall2 "vec3" [] (Glsl.float1 a) b + + +vec3ff1 : Float -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec3 +vec3ff1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.float1 b) c + + +vec3fff : Float -> Float -> Float -> Glsl.Expression Glsl.Vec3 +vec3fff a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) + + +vec3ffi1 : Float -> Float -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +vec3ffi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.float1 b) c + + +vec3ffwi1 : Float -> Float -> Int -> Glsl.Expression Glsl.Vec3 +vec3ffwi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.int1 c) + + +vec3fi11 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3fi11 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b c + + +vec3fi1f : Float -> Glsl.Expression Glsl.Int_ -> Float -> Glsl.Expression Glsl.Vec3 +vec3fi1f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b (Glsl.float1 c) + + +vec3fi1i1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3fi1i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b c + + +vec3fi1wi1 : Float -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec3 +vec3fi1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) b (Glsl.int1 c) + + +vec3fwi11 : Float -> Int -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec3 +vec3fwi11 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.int1 b) c + + +vec3fwi1f : Float -> Int -> Float -> Glsl.Expression Glsl.Vec3 +vec3fwi1f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.float1 c) + + +vec3fwi1i1 : Float -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +vec3fwi1i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.int1 b) c + + +vec3fwi1wi1 : Float -> Int -> Int -> Glsl.Expression Glsl.Vec3 +vec3fwi1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.int1 c) + + +vec3i1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +vec3i1 a = + Glsl.unsafeCall1 "vec3" [] a + + +vec3i111 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3i111 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec3i11f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec3 +vec3i11f a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.float1 c) + + +vec3i11i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3i11i1 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec3i11wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec3 +vec3i11wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.int1 c) + + +vec3i1f1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3i1f1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) c + + +vec3i1ff : Glsl.Expression Glsl.Int_ -> Float -> Float -> Glsl.Expression Glsl.Vec3 +vec3i1ff a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) (Glsl.float1 c) + + +vec3i1fi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3i1fi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) c + + +vec3i1fwi1 : Glsl.Expression Glsl.Int_ -> Float -> Int -> Glsl.Expression Glsl.Vec3 +vec3i1fwi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.float1 b) (Glsl.int1 c) + + +vec3i1i11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3i1i11 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec3i1i1f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec3 +vec3i1i1f a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.float1 c) + + +vec3i1i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3i1i1i1 a b c = + Glsl.unsafeCall3 "vec3" [] a b c + + +vec3i1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec3 +vec3i1i1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a b (Glsl.int1 c) + + +vec3i1wi11 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3i1wi11 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) c + + +vec3i1wi1f : Glsl.Expression Glsl.Int_ -> Int -> Float -> Glsl.Expression Glsl.Vec3 +vec3i1wi1f a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) (Glsl.float1 c) + + +vec3i1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3i1wi1i1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) c + + +vec3i1wi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Int -> Glsl.Expression Glsl.Vec3 +vec3i1wi1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] a (Glsl.int1 b) (Glsl.int1 c) + + +vec3wi1 : Int -> Glsl.Expression Glsl.Vec3 +vec3wi1 a = + Glsl.unsafeCall1 "vec3" [] (Glsl.int1 a) + + +vec3wi111 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3wi111 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b c + + +vec3wi11f : Int -> Glsl.Expression Glsl.Float_ -> Float -> Glsl.Expression Glsl.Vec3 +vec3wi11f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b (Glsl.float1 c) + + +vec3wi11i1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3wi11i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b c + + +vec3wi11wi1 : Int -> Glsl.Expression Glsl.Float_ -> Int -> Glsl.Expression Glsl.Vec3 +vec3wi11wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b (Glsl.int1 c) + + +vec3wi1f1 : Int -> Float -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec3 +vec3wi1f1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.float1 b) c + + +vec3wi1ff : Int -> Float -> Float -> Glsl.Expression Glsl.Vec3 +vec3wi1ff a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.float1 c) + + +vec3wi1fi1 : Int -> Float -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +vec3wi1fi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.float1 b) c + + +vec3wi1fwi1 : Int -> Float -> Int -> Glsl.Expression Glsl.Vec3 +vec3wi1fwi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.int1 c) + + +vec3wi1i11 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 +vec3wi1i11 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b c + + +vec3wi1i1f : Int -> Glsl.Expression Glsl.Int_ -> Float -> Glsl.Expression Glsl.Vec3 +vec3wi1i1f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b (Glsl.float1 c) + + +vec3wi1i1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec3 +vec3wi1i1i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b c + + +vec3wi1i1wi1 : Int -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec3 +vec3wi1i1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) b (Glsl.int1 c) + + +vec3wi1wi11 : Int -> Int -> Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec3 +vec3wi1wi11 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.int1 b) c + + +vec3wi1wi1f : Int -> Int -> Float -> Glsl.Expression Glsl.Vec3 +vec3wi1wi1f a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.float1 c) + + +vec3wi1wi1i1 : Int -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec3 +vec3wi1wi1i1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.int1 b) c + + +vec3wi1wi1wi1 : Int -> Int -> Int -> Glsl.Expression Glsl.Vec3 +vec3wi1wi1wi1 a b c = + Glsl.unsafeCall3 "vec3" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) + + +vec41 : Glsl.Expression Glsl.Float_ -> Glsl.Expression Glsl.Vec4 +vec41 a = + Glsl.unsafeCall1 "vec4" [] a + + +vec41111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41111 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4111f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4111f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec4111i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4111i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4111wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4111wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec411f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec411f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec411ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec411ff a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.float1 d) + + +vec411fi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec411fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec411fwi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec411fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.int1 d) + + +vec411i11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec411i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec411i1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec411i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec411i1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec411i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec411i1wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec411i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec411wi11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec411wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec411wi1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec411wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.float1 d) + + +vec411wi1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec411wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec411wi1wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec411wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.int1 d) + + +vec413 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Vec4 +vec413 a b = + Glsl.unsafeCall2 "vec4" [] a b + + +vec41f11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41f11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec41f1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41f1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.float1 d) + + +vec41f1i1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41f1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec41f1wi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41f1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.int1 d) + + +vec41ff1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41ff1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) d + + +vec41fff : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41fff a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) (Glsl.float1 d) + + +vec41ffi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41ffi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) d + + +vec41ffwi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41ffwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) (Glsl.int1 d) + + +vec41fi11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41fi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec41fi1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41fi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.float1 d) + + +vec41fi1i1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41fi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec41fi1wi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41fi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.int1 d) + + +vec41fwi11 : + Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41fwi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) d + + +vec41fwi1f : + Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41fwi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) (Glsl.float1 d) + + +vec41fwi1i1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41fwi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) d + + +vec41fwi1wi1 : + Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41fwi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) (Glsl.int1 d) + + +vec41i111 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41i111 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec41i11f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41i11f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec41i11i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41i11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec41i11wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41i11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec41i1f1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41i1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec41i1ff : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41i1ff a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.float1 d) + + +vec41i1fi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41i1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec41i1fwi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41i1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.int1 d) + + +vec41i1i11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41i1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec41i1i1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41i1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec41i1i1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41i1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec41i1i1wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41i1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec41i1wi11 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41i1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec41i1wi1f : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41i1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.float1 d) + + +vec41i1wi1i1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41i1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec41i1wi1wi1 : + Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41i1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.int1 d) + + +vec41wi111 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41wi111 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec41wi11f : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41wi11f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.float1 d) + + +vec41wi11i1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41wi11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec41wi11wi1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41wi11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.int1 d) + + +vec41wi1f1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) d + + +vec41wi1ff : + Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41wi1ff a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) (Glsl.float1 d) + + +vec41wi1fi1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) d + + +vec41wi1fwi1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41wi1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) (Glsl.int1 d) + + +vec41wi1i11 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec41wi1i1f : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41wi1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.float1 d) + + +vec41wi1i1i1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec41wi1i1wi1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41wi1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.int1 d) + + +vec41wi1wi11 : + Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) d + + +vec41wi1wi1f : + Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec41wi1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) (Glsl.float1 d) + + +vec41wi1wi1i1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec41wi1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) d + + +vec41wi1wi1wi1 : + Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec41wi1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) (Glsl.int1 d) + + +vec422 : + Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec2 + -> Glsl.Expression Glsl.Vec4 +vec422 a b = + Glsl.unsafeCall2 "vec4" [] a b + + +vec431 : + Glsl.Expression Glsl.Vec3 + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec431 a b = + Glsl.unsafeCall2 "vec4" [] a b + + +vec43f : Glsl.Expression Glsl.Vec3 -> Float -> Glsl.Expression Glsl.Vec4 +vec43f a b = + Glsl.unsafeCall2 "vec4" [] a (Glsl.float1 b) + + +vec4f : Float -> Glsl.Expression Glsl.Vec4 +vec4f a = + Glsl.unsafeCall1 "vec4" [] (Glsl.float1 a) + + +vec4f111 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4f111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4f11f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4f11f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.float1 d) + + +vec4f11i1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4f11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4f11wi1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4f11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.int1 d) + + +vec4f1f1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4f1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) d + + +vec4f1ff : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4f1ff a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) (Glsl.float1 d) + + +vec4f1fi1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4f1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) d + + +vec4f1fwi1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4f1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) (Glsl.int1 d) + + +vec4f1i11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4f1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4f1i1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4f1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.float1 d) + + +vec4f1i1i1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4f1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4f1i1wi1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4f1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.int1 d) + + +vec4f1wi11 : + Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4f1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) d + + +vec4f1wi1f : + Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4f1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) (Glsl.float1 d) + + +vec4f1wi1i1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4f1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) d + + +vec4f1wi1wi1 : + Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4f1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) (Glsl.int1 d) + + +vec4f3 : Float -> Glsl.Expression Glsl.Vec3 -> Glsl.Expression Glsl.Vec4 +vec4f3 a b = + Glsl.unsafeCall2 "vec4" [] (Glsl.float1 a) b + + +vec4ff11 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4ff11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c d + + +vec4ff1f : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4ff1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c (Glsl.float1 d) + + +vec4ff1i1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4ff1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c d + + +vec4ff1wi1 : + Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4ff1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c (Glsl.int1 d) + + +vec4fff1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fff1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) d + + +vec4ffff : Float -> Float -> Float -> Float -> Glsl.Expression Glsl.Vec4 +vec4ffff a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + + +vec4fffi1 : + Float + -> Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fffi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.float1 c) d + + +vec4fffwi1 : Float -> Float -> Float -> Int -> Glsl.Expression Glsl.Vec4 +vec4fffwi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.int1 d) + + +vec4ffi11 : + Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4ffi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c d + + +vec4ffi1f : + Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4ffi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c (Glsl.float1 d) + + +vec4ffi1i1 : + Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4ffi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c d + + +vec4ffi1wi1 : + Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4ffi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) c (Glsl.int1 d) + + +vec4ffwi11 : + Float + -> Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4ffwi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.int1 c) d + + +vec4ffwi1f : Float -> Float -> Int -> Float -> Glsl.Expression Glsl.Vec4 +vec4ffwi1f a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.int1 c) + (Glsl.float1 d) + + +vec4ffwi1i1 : + Float + -> Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4ffwi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.float1 b) (Glsl.int1 c) d + + +vec4ffwi1wi1 : Float -> Float -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4ffwi1wi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.float1 b) + (Glsl.int1 c) + (Glsl.int1 d) + + +vec4fi111 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fi111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4fi11f : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fi11f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.float1 d) + + +vec4fi11i1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fi11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4fi11wi1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fi11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.int1 d) + + +vec4fi1f1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) d + + +vec4fi1ff : + Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fi1ff a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) (Glsl.float1 d) + + +vec4fi1fi1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) d + + +vec4fi1fwi1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fi1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.float1 c) (Glsl.int1 d) + + +vec4fi1i11 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4fi1i1f : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fi1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.float1 d) + + +vec4fi1i1i1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c d + + +vec4fi1i1wi1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fi1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b c (Glsl.int1 d) + + +vec4fi1wi11 : + Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) d + + +vec4fi1wi1f : + Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fi1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) (Glsl.float1 d) + + +vec4fi1wi1i1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fi1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) d + + +vec4fi1wi1wi1 : + Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fi1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) b (Glsl.int1 c) (Glsl.int1 d) + + +vec4fwi111 : + Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c d + + +vec4fwi11f : + Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fwi11f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c (Glsl.float1 d) + + +vec4fwi11i1 : + Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c d + + +vec4fwi11wi1 : + Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fwi11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c (Glsl.int1 d) + + +vec4fwi1f1 : + Float + -> Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.float1 c) d + + +vec4fwi1ff : Float -> Int -> Float -> Float -> Glsl.Expression Glsl.Vec4 +vec4fwi1ff a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.int1 b) + (Glsl.float1 c) + (Glsl.float1 d) + + +vec4fwi1fi1 : + Float + -> Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.float1 c) d + + +vec4fwi1fwi1 : Float -> Int -> Float -> Int -> Glsl.Expression Glsl.Vec4 +vec4fwi1fwi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.int1 b) + (Glsl.float1 c) + (Glsl.int1 d) + + +vec4fwi1i11 : + Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c d + + +vec4fwi1i1f : + Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4fwi1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c (Glsl.float1 d) + + +vec4fwi1i1i1 : + Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c d + + +vec4fwi1i1wi1 : + Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4fwi1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) c (Glsl.int1 d) + + +vec4fwi1wi11 : + Float + -> Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.int1 c) d + + +vec4fwi1wi1f : Float -> Int -> Int -> Float -> Glsl.Expression Glsl.Vec4 +vec4fwi1wi1f a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.int1 b) + (Glsl.int1 c) + (Glsl.float1 d) + + +vec4fwi1wi1i1 : + Float + -> Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4fwi1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.float1 a) (Glsl.int1 b) (Glsl.int1 c) d + + +vec4fwi1wi1wi1 : Float -> Int -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4fwi1wi1wi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.float1 a) + (Glsl.int1 b) + (Glsl.int1 c) + (Glsl.int1 d) + + +vec4i1 : Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec4 +vec4i1 a = + Glsl.unsafeCall1 "vec4" [] a + + +vec4i1111 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1111 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i111f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i111f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec4i111i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i111i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i111wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i111wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec4i11f1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i11f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec4i11ff : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i11ff a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.float1 d) + + +vec4i11fi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i11fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec4i11fwi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i11fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.int1 d) + + +vec4i11i11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i11i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i11i1f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i11i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec4i11i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i11i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i11i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i11i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec4i11wi11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i11wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec4i11wi1f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i11wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.float1 d) + + +vec4i11wi1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i11wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec4i11wi1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i11wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.int1 d) + + +vec4i1f11 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1f11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec4i1f1f : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1f1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.float1 d) + + +vec4i1f1i1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1f1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec4i1f1wi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1f1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.int1 d) + + +vec4i1ff1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1ff1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) d + + +vec4i1fff : + Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1fff a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) (Glsl.float1 d) + + +vec4i1ffi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1ffi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) d + + +vec4i1ffwi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1ffwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.float1 c) (Glsl.int1 d) + + +vec4i1fi11 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1fi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec4i1fi1f : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1fi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.float1 d) + + +vec4i1fi1i1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1fi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c d + + +vec4i1fi1wi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1fi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) c (Glsl.int1 d) + + +vec4i1fwi11 : + Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1fwi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) d + + +vec4i1fwi1f : + Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1fwi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) (Glsl.float1 d) + + +vec4i1fwi1i1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1fwi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) d + + +vec4i1fwi1wi1 : + Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1fwi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.float1 b) (Glsl.int1 c) (Glsl.int1 d) + + +vec4i1i111 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i111 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i1i11f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1i11f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec4i1i11i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i1i11wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1i11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec4i1i1f1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec4i1i1ff : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1i1ff a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.float1 d) + + +vec4i1i1fi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) d + + +vec4i1i1fwi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1i1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.float1 c) (Glsl.int1 d) + + +vec4i1i1i11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i1i1i1f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1i1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.float1 d) + + +vec4i1i1i1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c d + + +vec4i1i1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1i1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b c (Glsl.int1 d) + + +vec4i1i1wi11 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec4i1i1wi1f : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1i1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.float1 d) + + +vec4i1i1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1i1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) d + + +vec4i1i1wi1wi1 : + Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1i1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a b (Glsl.int1 c) (Glsl.int1 d) + + +vec4i1wi111 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi111 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec4i1wi11f : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1wi11f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.float1 d) + + +vec4i1wi11i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec4i1wi11wi1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1wi11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.int1 d) + + +vec4i1wi1f1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) d + + +vec4i1wi1ff : + Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1ff a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) (Glsl.float1 d) + + +vec4i1wi1fi1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) d + + +vec4i1wi1fwi1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.float1 c) (Glsl.int1 d) + + +vec4i1wi1i11 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec4i1wi1i1f : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.float1 d) + + +vec4i1wi1i1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c d + + +vec4i1wi1i1wi1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) c (Glsl.int1 d) + + +vec4i1wi1wi11 : + Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) d + + +vec4i1wi1wi1f : + Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) (Glsl.float1 d) + + +vec4i1wi1wi1i1 : + Glsl.Expression Glsl.Int_ + -> Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4i1wi1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) d + + +vec4i1wi1wi1wi1 : Glsl.Expression Glsl.Int_ -> Int -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4i1wi1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] a (Glsl.int1 b) (Glsl.int1 c) (Glsl.int1 d) + + +vec4wi1 : Int -> Glsl.Expression Glsl.Vec4 +vec4wi1 a = + Glsl.unsafeCall1 "vec4" [] (Glsl.int1 a) + + +vec4wi1111 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi111f : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi111f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.float1 d) + + +vec4wi111i1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi111i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi111wi1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi111wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.int1 d) + + +vec4wi11f1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) d + + +vec4wi11ff : + Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi11ff a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) (Glsl.float1 d) + + +vec4wi11fi1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) d + + +vec4wi11fwi1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi11fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) (Glsl.int1 d) + + +vec4wi11i11 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi11i1f : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi11i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.float1 d) + + +vec4wi11i1i1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi11i1wi1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi11i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.int1 d) + + +vec4wi11wi11 : + Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) d + + +vec4wi11wi1f : + Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi11wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) (Glsl.float1 d) + + +vec4wi11wi1i1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi11wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) d + + +vec4wi11wi1wi1 : + Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi11wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) (Glsl.int1 d) + + +vec4wi1f11 : + Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1f11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c d + + +vec4wi1f1f : + Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1f1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c (Glsl.float1 d) + + +vec4wi1f1i1 : + Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1f1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c d + + +vec4wi1f1wi1 : + Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1f1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c (Glsl.int1 d) + + +vec4wi1ff1 : + Int + -> Float + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1ff1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.float1 c) d + + +vec4wi1fff : Int -> Float -> Float -> Float -> Glsl.Expression Glsl.Vec4 +vec4wi1fff a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.float1 d) + + +vec4wi1ffi1 : + Int + -> Float + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1ffi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.float1 c) d + + +vec4wi1ffwi1 : Int -> Float -> Float -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1ffwi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.float1 b) + (Glsl.float1 c) + (Glsl.int1 d) + + +vec4wi1fi11 : + Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1fi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c d + + +vec4wi1fi1f : + Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1fi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c (Glsl.float1 d) + + +vec4wi1fi1i1 : + Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1fi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c d + + +vec4wi1fi1wi1 : + Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1fi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) c (Glsl.int1 d) + + +vec4wi1fwi11 : + Int + -> Float + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1fwi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.int1 c) d + + +vec4wi1fwi1f : Int -> Float -> Int -> Float -> Glsl.Expression Glsl.Vec4 +vec4wi1fwi1f a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.float1 b) + (Glsl.int1 c) + (Glsl.float1 d) + + +vec4wi1fwi1i1 : + Int + -> Float + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1fwi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.float1 b) (Glsl.int1 c) d + + +vec4wi1fwi1wi1 : Int -> Float -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1fwi1wi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.float1 b) + (Glsl.int1 c) + (Glsl.int1 d) + + +vec4wi1i111 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi1i11f : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1i11f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.float1 d) + + +vec4wi1i11i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi1i11wi1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1i11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.int1 d) + + +vec4wi1i1f1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) d + + +vec4wi1i1ff : + Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1ff a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) (Glsl.float1 d) + + +vec4wi1i1fi1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) d + + +vec4wi1i1fwi1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1fwi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.float1 c) (Glsl.int1 d) + + +vec4wi1i1i11 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi1i1i1f : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.float1 d) + + +vec4wi1i1i1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c d + + +vec4wi1i1i1wi1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b c (Glsl.int1 d) + + +vec4wi1i1wi11 : + Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) d + + +vec4wi1i1wi1f : + Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1wi1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) (Glsl.float1 d) + + +vec4wi1i1wi1i1 : + Int + -> Glsl.Expression Glsl.Int_ + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1i1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) d + + +vec4wi1i1wi1wi1 : Int -> Glsl.Expression Glsl.Int_ -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1i1wi1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) b (Glsl.int1 c) (Glsl.int1 d) + + +vec4wi1wi111 : + Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi111 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c d + + +vec4wi1wi11f : + Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi11f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c (Glsl.float1 d) + + +vec4wi1wi11i1 : + Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi11i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c d + + +vec4wi1wi11wi1 : + Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Int + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi11wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c (Glsl.int1 d) + + +vec4wi1wi1f1 : + Int + -> Int + -> Float + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1f1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.float1 c) d + + +vec4wi1wi1ff : Int -> Int -> Float -> Float -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1ff a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.int1 b) + (Glsl.float1 c) + (Glsl.float1 d) + + +vec4wi1wi1fi1 : + Int + -> Int + -> Float + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1fi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.float1 c) d + + +vec4wi1wi1fwi1 : Int -> Int -> Float -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1fwi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.int1 b) + (Glsl.float1 c) + (Glsl.int1 d) + + +vec4wi1wi1i11 : + Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1i11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c d + + +vec4wi1wi1i1f : + Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Float + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1i1f a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c (Glsl.float1 d) + + +vec4wi1wi1i1i1 : + Int + -> Int + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Int_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1i1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c d + + +vec4wi1wi1i1wi1 : Int -> Int -> Glsl.Expression Glsl.Int_ -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1i1wi1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) c (Glsl.int1 d) + + +vec4wi1wi1wi11 : + Int + -> Int + -> Int + -> Glsl.Expression Glsl.Float_ + -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1wi11 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) d + + +vec4wi1wi1wi1f : Int -> Int -> Int -> Float -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1wi1f a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.int1 b) + (Glsl.int1 c) + (Glsl.float1 d) + + +vec4wi1wi1wi1i1 : Int -> Int -> Int -> Glsl.Expression Glsl.Int_ -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1wi1i1 a b c d = + Glsl.unsafeCall4 "vec4" [] (Glsl.int1 a) (Glsl.int1 b) (Glsl.int1 c) d + + +vec4wi1wi1wi1wi1 : Int -> Int -> Int -> Int -> Glsl.Expression Glsl.Vec4 +vec4wi1wi1wi1wi1 a b c d = + Glsl.unsafeCall4 + "vec4" + [] + (Glsl.int1 a) + (Glsl.int1 b) + (Glsl.int1 c) + (Glsl.int1 d) + + +radians_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +radians_ a = + Glsl.unsafeCall1 "radians" [] a + + +degrees_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +degrees_ a = + Glsl.unsafeCall1 "degrees" [] a + + +sin_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +sin_ a = + Glsl.unsafeCall1 "sin" [] a + + +cos_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +cos_ a = + Glsl.unsafeCall1 "cos" [] a + + +tan_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +tan_ a = + Glsl.unsafeCall1 "tan" [] a + + +asin_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +asin_ a = + Glsl.unsafeCall1 "asin" [] a + + +acos_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +acos_ a = + Glsl.unsafeCall1 "acos" [] a + + +atan_ : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +atan_ a = + Glsl.unsafeCall1 "atan" [] a + + +atan2_ : + Glsl.Expression (Glsl.Vec Float a) + -> Glsl.Expression (Glsl.Vec Float a) + -> Glsl.Expression (Glsl.Vec Float a) +atan2_ a b = + Glsl.unsafeCall2 "atan" [] a b + + +sinh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +sinh a = + Glsl.unsafeCall1 "sinh" [] a + + +cosh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +cosh a = + Glsl.unsafeCall1 "cosh" [] a + + +tanh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +tanh a = + Glsl.unsafeCall1 "tanh" [] a + + +asinh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +asinh a = + Glsl.unsafeCall1 "asinh" [] a + + +acosh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +acosh a = + Glsl.unsafeCall1 "acosh" [] a + + +atanh : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +atanh a = + Glsl.unsafeCall1 "atanh" [] a + + +pow : + Glsl.Expression (Glsl.Vec Float a) + -> Glsl.Expression (Glsl.Vec Float a) + -> Glsl.Expression (Glsl.Vec Float a) +pow a b = + Glsl.unsafeCall2 "pow" [] a b + + +exp : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +exp a = + Glsl.unsafeCall1 "exp" [] a + + +log : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +log a = + Glsl.unsafeCall1 "log" [] a + + +exp2 : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +exp2 a = + Glsl.unsafeCall1 "exp2" [] a + + +log2 : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +log2 a = + Glsl.unsafeCall1 "log2" [] a + + +sqrt_ : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +sqrt_ a = + Glsl.unsafeCall1 "sqrt" [] a + + +abs_ : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +abs_ a = + Glsl.unsafeCall1 "abs" [] a + + +floor_ : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +floor_ a = + Glsl.unsafeCall1 "floor" [] a + + +round_ : Glsl.Expression (Glsl.Vec t a) -> Glsl.Expression (Glsl.Vec t a) +round_ a = + Glsl.unsafeCall1 "round" [] a + + +min_ : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +min_ a b = + Glsl.unsafeCall2 "min" [] a b + + +max_ : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +max_ a b = + Glsl.unsafeCall2 "max" [] a b + + +clamp_ : + Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) + -> Glsl.Expression (Glsl.Vec t a) +clamp_ a b c = + Glsl.unsafeCall3 "clamp" [] a b c + + +dFdx : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdx a = + Glsl.unsafeCall1 "dFdx" [] a + + +dFdy : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdy a = + Glsl.unsafeCall1 "dFdy" [] a + + +dFdxFine : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdxFine a = + Glsl.unsafeCall1 "dFdxFine" [] a + + +dFdyFine : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdyFine a = + Glsl.unsafeCall1 "dFdyFine" [] a + + +dFdxCoarse : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdxCoarse a = + Glsl.unsafeCall1 "dFdxCoarse" [] a + + +dFdyCoarse : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +dFdyCoarse a = + Glsl.unsafeCall1 "dFdyCoarse" [] a + + +fwidth : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +fwidth a = + Glsl.unsafeCall1 "fwidth" [] a + + +fwidthFine : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +fwidthFine a = + Glsl.unsafeCall1 "fwidthFine" [] a + + +fwidthCoarse : Glsl.Expression (Glsl.Vec Float a) -> Glsl.Expression (Glsl.Vec Float a) +fwidthCoarse a = + Glsl.unsafeCall1 "fwidthCoarse" [] a diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm new file mode 100644 index 00000000..b8138d6e --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm @@ -0,0 +1,591 @@ +module Glsl.Helpers exposing (File, FunDecl, assign, assignAdd, assignBy, assignOut, boolT, break, const, const_, continue, decl, def, def1, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun1_, fun2, fun2_, fun3, fun3_, fun4, fun4_, fun5, fun5_, funDeclToGlsl, ifElse, if_, in_, intT, main_, mat2T, mat3, mat3T, nop, out, return, statementToGlsl, vec2, vec2T, vec3, vec3T, vec4, vec4T, voidT) + +import Glsl exposing (BinaryOperation(..), Bool_, Declaration(..), Expr(..), Expression(..), Float_, Int_, Mat2, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeVar, withContinuation, withExpression, withStatement) +import Glsl.PrettyPrinter +import Set +import SortedSet + + +type alias File = + List FunDecl + + +type FunDecl + = FunDecl { name : String, type_ : String, body : String } + + + +-- UTILS + + +fileToGlsl : File -> String +fileToGlsl decls = + decls + |> List.foldl + (\(FunDecl { name, type_, body }) ( found, output ) -> + if Set.member ( name, type_ ) found then + ( found, output ) + + else + ( Set.insert ( name, type_ ) found, body :: output ) + ) + ( Set.empty, [] ) + |> Tuple.second + |> List.reverse + |> String.join "\n\n" + + +funDeclToGlsl : FunDecl -> String +funDeclToGlsl (FunDecl { body }) = + body + + +statementToGlsl : Statement s -> String +statementToGlsl (Statement r) = + r.stat + |> Glsl.PrettyPrinter.stat 1 + + +expressionToGlsl : Expression t -> String +expressionToGlsl (Expression tree) = + Glsl.PrettyPrinter.expr tree.expr + + + +-- STATEMENTS + + +functionToGlsl : TypedName t -> List ( Type, String ) -> Statement t -> String +functionToGlsl (TypedName rt name) args (Statement body) = + Glsl.PrettyPrinter.declaration + (FunctionDeclaration + { args = args + , returnType = rt + , name = name + , stat = body.stat + } + ) + + +funX : + (String + -> List String + -> a + ) + -> TypingFunction t + -> String + -> Statement t + -> List ( Type, String ) + -> { declaration : Declaration, call : a } +funX call typeF name body args = + let + ((TypedName returnType _) as typed) = + typeF name + + (Statement s) = + body + + funGlsl : String + funGlsl = + functionToGlsl typed args body + in + { declaration = + FunctionDeclaration + { returnType = returnType + , name = name + , args = args + , stat = s.stat + } + , call = + call name + (s.deps + |> SortedSet.insert funGlsl + |> SortedSet.toList + ) + } + + +const : + (String -> TypedName t) + -> String + -> Expression t + -> Expression t +const typeF name value = + (const_ typeF name value).value + + +const_ : + (String -> TypedName t) + -> String + -> Expression t + -> + { declaration : Declaration + , value : Expression t + } +const_ typeF name value = + let + (TypedName constType _) = + typeF name + + (Expression e) = + value + + constGlsl : String + constGlsl = + "const " + ++ Glsl.PrettyPrinter.type_ constType + ++ " " + ++ name + ++ " = " + ++ Glsl.PrettyPrinter.expr e.expr + ++ ";" + in + { declaration = + ConstDeclaration + { tipe = constType + , name = name + , value = e.expr + } + , value = + Expression + { deps = + e.deps + |> SortedSet.insert constGlsl + , expr = Variable name + } + } + + +main_ : + (Statement () -> Statement ()) + -> + { declaration : Declaration + , call : Expression () + } +main_ stat = + fun0 voidT "main" <| \_ -> stat nop + + +fun0 : + TypingFunction t + -> String + -> (() -> Statement t) + -> { declaration : Declaration, call : Expression t } +fun0 typeF name body = + funX unsafeCall0 + typeF + name + (body ()) + [] + + +fun1 : + TypingFunction t + -> String + -> TypedName a + -> (Expression a -> Statement t) + -> Expression a + -> Expression t +fun1 typeF name arg0 body = + (fun1_ typeF name arg0 body).call + + +fun1_ : + TypingFunction t + -> String + -> TypedName a + -> (Expression a -> Statement t) + -> + { declaration : Declaration + , call : Expression a -> Expression t + } +fun1_ typeF name (TypedName t0 arg0) body = + funX unsafeCall1 + typeF + name + (body (unsafeVar arg0)) + [ ( t0, arg0 ) ] + + +fun2 : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> (Expression a -> Expression b -> Statement t) + -> Expression a + -> Expression b + -> Expression t +fun2 typeF name arg0 arg1 body = + (fun2_ typeF name arg0 arg1 body).call + + +fun2_ : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> (Expression a -> Expression b -> Statement t) + -> + { declaration : Declaration + , call : Expression a -> Expression b -> Expression t + } +fun2_ typeF name (TypedName t0 arg0) (TypedName t1 arg1) body = + funX unsafeCall2 + typeF + name + (body (unsafeVar arg0) (unsafeVar arg1)) + [ ( t0, arg0 ), ( t1, arg1 ) ] + + +fun3 : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> (Expression a -> Expression b -> Expression c -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression t +fun3 typeF name arg0 arg1 arg2 body = + (fun3_ typeF name arg0 arg1 arg2 body).call + + +fun3_ : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> (Expression a -> Expression b -> Expression c -> Statement t) + -> + { declaration : Declaration + , call : Expression a -> Expression b -> Expression c -> Expression t + } +fun3_ typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) body = + funX unsafeCall3 + typeF + name + (body (unsafeVar arg0) (unsafeVar arg1) (unsafeVar arg2)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ) ] + + +fun4 : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> (Expression a -> Expression b -> Expression c -> Expression d -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression d + -> Expression t +fun4 typeF name arg0 arg1 arg2 arg3 body = + (fun4_ typeF name arg0 arg1 arg2 arg3 body).call + + +fun4_ : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> (Expression a -> Expression b -> Expression c -> Expression d -> Statement t) + -> + { declaration : Declaration + , call : Expression a -> Expression b -> Expression c -> Expression d -> Expression t + } +fun4_ typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) body = + funX unsafeCall4 + typeF + name + (body (unsafeVar arg0) (unsafeVar arg1) (unsafeVar arg2) (unsafeVar arg3)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ) ] + + +fun5 : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> TypedName e + -> (Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Statement t) + -> Expression a + -> Expression b + -> Expression c + -> Expression d + -> Expression e + -> Expression t +fun5 typeF name arg0 arg1 arg2 arg3 arg4 body = + (fun5_ typeF name arg0 arg1 arg2 arg3 arg4 body).call + + +fun5_ : + TypingFunction t + -> String + -> TypedName a + -> TypedName b + -> TypedName c + -> TypedName d + -> TypedName e + -> (Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Statement t) + -> + { declaration : Declaration + , call : Expression a -> Expression b -> Expression c -> Expression d -> Expression e -> Expression t + } +fun5_ typeF name (TypedName t0 arg0) (TypedName t1 arg1) (TypedName t2 arg2) (TypedName t3 arg3) (TypedName t4 arg4) body = + funX unsafeCall5 + typeF + name + (body (unsafeVar arg0) (unsafeVar arg1) (unsafeVar arg2) (unsafeVar arg3) (unsafeVar arg4)) + [ ( t0, arg0 ), ( t1, arg1 ), ( t2, arg2 ), ( t3, arg3 ), ( t4, arg4 ) ] + + +if_ : Expression Bool_ -> Statement r -> (() -> Statement r) -> Statement r +if_ cond ifTrue next = + build If + |> withExpression cond + |> withStatement ifTrue + |> withContinuation next + + +ifElse : Expression Bool_ -> Statement s -> Statement s -> (() -> Statement s) -> Statement s +ifElse cond ifTrue ifFalse next = + build IfElse + |> withExpression cond + |> withStatement ifTrue + |> withStatement ifFalse + |> withContinuation next + + +for : + ( String, Expression Int, Expression Int ) + -> (Expression Int -> Statement () -> Statement ()) + -> (() -> Statement r) + -> Statement r +for ( name, from, to ) loop next = + build (\f t -> For (Just <| Decl TInt name (Just f)) (BinaryOperation (Variable name) (RelationOperation LessThan) t) (UnaryOperation PostfixIncrement (Variable name))) + |> withExpression from + |> withExpression to + |> withStatement (loop (unsafeVar name) nop) + |> withContinuation next + + +forLeq : + ( String, Expression Int, Expression Int ) + -> (Expression Int -> Statement () -> Statement ()) + -> (() -> Statement r) + -> Statement r +forLeq ( name, from, to ) loop next = + build (\f t -> For (Just <| Decl TInt name (Just f)) (BinaryOperation (Variable name) (RelationOperation LessThanOrEquals) t) (UnaryOperation PostfixIncrement (Variable name))) + |> withExpression from + |> withExpression to + |> withStatement (loop (unsafeVar name) nop) + |> withContinuation next + + +forDown : + ( String, Expression Int, Expression Int ) + -> (Expression Int -> Statement () -> Statement ()) + -> (() -> Statement r) + -> Statement r +forDown ( name, from, to ) loop next = + build (\f t -> For (Just <| Decl TInt name (Just f)) (BinaryOperation (Variable name) (RelationOperation GreaterThan) t) (UnaryOperation PostfixDecrement (Variable name))) + |> withExpression from + |> withExpression to + |> withStatement (loop (unsafeVar name) nop) + |> withContinuation next + + +return : Expression r -> Statement r +return e = + build Return + |> withExpression e + |> buildStatement + + +break : Statement a +break = + build Break + |> buildStatement + + +continue : Statement a +continue = + build Continue + |> buildStatement + + +decl : TypingFunction t -> String -> (Expression t -> Statement r) -> Statement r +decl typeF name k = + let + (TypedName t n) = + typeF name + in + build (Decl t n Nothing) + |> withContinuation (\_ -> k (unsafeVar n)) + + +def : TypingFunction t -> String -> Expression t -> (Expression t -> Statement r) -> Statement r +def typeF name val k = + let + (TypedName t0 n0) = + typeF name + in + build + (\v0 k0 -> + Glsl.block [ Decl t0 n0 (Just v0), k0 ] + ) + |> withExpression val + |> withStatement (k (unsafeVar n0)) + |> buildStatement + + +float : String -> Expression Float_ -> (Expression Float_ -> Statement r) -> Statement r +float = + def floatT + + +vec2 : String -> Expression Vec2 -> (Expression Vec2 -> Statement r) -> Statement r +vec2 = + def vec2T + + +vec3 : String -> Expression Vec3 -> (Expression Vec3 -> Statement r) -> Statement r +vec3 = + def vec3T + + +vec4 : String -> Expression Vec4 -> (Expression Vec4 -> Statement r) -> Statement r +vec4 = + def vec4T + + +mat3 : String -> Expression Mat3 -> (Expression Mat3 -> Statement r) -> Statement r +mat3 = + def mat3T + + +def1 : + ( TypedName a, Expression a ) + -> (Expression a -> Statement r) + -> Statement r +def1 ( tn0, val0 ) k = + let + (TypedName t0 n0) = + tn0 + in + build + (\v0 k0 -> + Glsl.block [ Decl t0 n0 (Just v0), k0 ] + ) + |> withExpression val0 + |> withStatement (k (unsafeVar n0)) + |> buildStatement + + +assign : Expression t -> Expression t -> Expression t +assign name e = + unsafeMap2 (\l r -> BinaryOperation l Assign r) name e + + +assignOut : Expression (Out t) -> Expression t -> Expression t +assignOut name e = + unsafeMap2 (\l r -> BinaryOperation l Assign r) name e + + +expr : Expression t -> (() -> Statement r) -> Statement r +expr e s = + build ExpressionStatement + |> withExpression e + |> withContinuation s + + +nop : Statement () +nop = + Statement { stat = Nop, deps = SortedSet.empty } + + +assignAdd : Expression t -> Expression t -> (() -> Statement q) -> Statement q +assignAdd name val = + expr <| unsafeMap2 (\l r -> BinaryOperation l ComboAdd r) name val + + +assignBy : Expression t -> Expression t -> (() -> Statement q) -> Statement q +assignBy name val = + expr <| unsafeMap2 (\l r -> BinaryOperation l ComboBy r) name val + + + +-- TYPES + + +voidT : TypingFunction () +voidT n = + TypedName TVoid n + + +boolT : TypingFunction Bool_ +boolT n = + TypedName TBool n + + +intT : TypingFunction Int_ +intT n = + TypedName TInt n + + +floatT : TypingFunction Float_ +floatT n = + TypedName TFloat n + + +vec2T : TypingFunction Vec2 +vec2T n = + TypedName TVec2 n + + +vec3T : TypingFunction Vec3 +vec3T n = + TypedName TVec3 n + + +vec4T : TypingFunction Vec4 +vec4T n = + TypedName TVec4 n + + +mat2T : TypingFunction Mat2 +mat2T n = + TypedName TMat2 n + + +mat3T : TypingFunction Mat3 +mat3T n = + TypedName TMat3 n + + +out : TypingFunction t -> TypingFunction t +out inner n = + let + (TypedName t name) = + inner n + in + TypedName (TOut t) name + + +in_ : TypingFunction t -> TypingFunction t +in_ inner n = + let + (TypedName t name) = + inner n + in + TypedName (TIn t) name diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Operations.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Operations.elm new file mode 100644 index 00000000..982bdb1a --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Operations.elm @@ -0,0 +1,320 @@ +module Glsl.Operations exposing + ( add, adds, adds2, adds3, adds4 + , add1f, addf1 + , subtract, subtract1f, subtractf1 + , negate_ + , by, bymv + , by1v, byv1, byfv, byvf + , div, divv1, divvf + , arraymi + , lt, leq, eq, geq, gt + , ternary + , and, or, ands, ors + ) + +{-| + + +# Addition + +@docs add, adds, adds2, adds3, adds4 +@docs add1f, addf1 + + +# Subtraction + +@docs subtract, subtract1f, subtractf1 + + +# Negate + +@docs negate_ + + +# Multiplication + +@docs by, bymv +@docs by1v, byv1, byfv, byvf + + +# Division + +@docs div, divv1, divvf + + +# Array access + +@docs arraymi + + +# Comparison + +@docs lt, leq, eq, geq, gt + + +# Logic + +@docs ternary +@docs and, or, ands, ors + +-} + +import Glsl exposing (BinaryOperation(..), Bool_, D2, Expr(..), Expression, Float_, Mat, RelationOperation(..), UnaryOperation(..), Vec, Vec2, Vec3, Vec4, false, float1, int1, true, unsafeMap, unsafeMap2, unsafeMap3) +import Glsl.Functions exposing (vec2i1, vec3i1, vec4i1) + + + +-- Addition + + +{-| -} +add : Expression (Vec Float d) -> Expression (Vec Float d) -> Expression (Vec Float d) +add = + unsafeBinary Add + + +{-| -} +adds : Expression (Vec Float d) -> List (Expression (Vec Float d)) -> Expression (Vec Float d) +adds vecZero es = + case es of + [] -> + vecZero + + h :: t -> + List.foldl (\e a -> add a e) h t + + +{-| -} +vec2Zero : Expression Vec2 +vec2Zero = + vec2i1 (int1 0) + + +{-| -} +vec3Zero : Expression Vec3 +vec3Zero = + vec3i1 (int1 0) + + +{-| -} +vec4Zero : Expression Vec4 +vec4Zero = + vec4i1 (int1 0) + + +{-| -} +adds2 : List (Expression Vec2) -> Expression Vec2 +adds2 = + adds vec2Zero + + +{-| -} +adds3 : List (Expression Vec3) -> Expression Vec3 +adds3 = + adds vec3Zero + + +{-| -} +adds4 : List (Expression Vec4) -> Expression Vec4 +adds4 = + adds vec4Zero + + +{-| -} +add1f : Expression Float_ -> Float -> Expression Float_ +add1f l r = + add l (float1 r) + + +{-| -} +addf1 : Float -> Expression Float_ -> Expression Float_ +addf1 l r = + add (float1 l) r + + + +-- Subtraction + + +{-| -} +subtract : Expression (Vec Float d) -> Expression (Vec Float d) -> Expression (Vec Float d) +subtract = + unsafeBinary Subtract + + +{-| -} +subtract1f : Expression Float_ -> Float -> Expression Float_ +subtract1f l r = + subtract l (float1 r) + + +{-| -} +subtractf1 : Float -> Expression Float_ -> Expression Float_ +subtractf1 l r = + subtract (float1 l) r + + +{-| -} +negate_ : Expression (Vec Float d) -> Expression (Vec Float d) +negate_ l = + unsafeMap (UnaryOperation Negate) l + + +{-| -} +unsafeBinary : BinaryOperation -> Expression a -> Expression b -> Expression c +unsafeBinary op = + unsafeMap2 (\l r -> BinaryOperation l op r) + + + +-- Multiplication + + +{-| -} +by1v : Expression Float_ -> Expression (Vec Float d) -> Expression (Vec Float d) +by1v = + unsafeBinary By + + +{-| -} +byfv : Float -> Expression (Vec Float d) -> Expression (Vec Float d) +byfv f = + by1v (float1 f) + + +{-| -} +byv1 : Expression (Vec Float d) -> Expression Float_ -> Expression (Vec Float d) +byv1 = + unsafeBinary By + + +{-| -} +byvf : Expression (Vec Float d) -> Float -> Expression (Vec Float d) +byvf v f = + byv1 v (float1 f) + + +{-| -} +bymv : Expression (Mat Float D2 d) -> Expression (Vec Float d) -> Expression (Vec Float d) +bymv = + unsafeBinary By + + +{-| -} +by : Expression (Vec Float d) -> Expression (Vec Float d) -> Expression (Vec Float d) +by = + unsafeBinary By + + + +-- Division + + +{-| -} +divv1 : Expression (Vec Float d) -> Expression Float_ -> Expression (Vec Float d) +divv1 = + unsafeBinary Div + + +{-| -} +divvf : Expression (Vec Float d) -> Float -> Expression (Vec Float d) +divvf l r = + divv1 l (float1 r) + + +{-| -} +div : Expression (Vec Float d) -> Expression (Vec Float d) -> Expression (Vec Float d) +div = + unsafeBinary Div + + + +-- Array access + + +{-| -} +arraymi : Expression (Mat Float d d) -> Expression Int -> Expression (Vec Float d) +arraymi = + unsafeBinary ArraySubscript + + + +-- Comparisons + + +{-| -} +lt : Expression Float_ -> Expression Float_ -> Expression Bool +lt = + unsafeBinary (RelationOperation LessThan) + + +{-| -} +leq : Expression Float_ -> Expression Float_ -> Expression Bool +leq = + unsafeBinary (RelationOperation LessThanOrEquals) + + +{-| -} +gt : Expression Float_ -> Expression Float_ -> Expression Bool +gt = + unsafeBinary (RelationOperation GreaterThan) + + +{-| -} +geq : Expression Float_ -> Expression Float_ -> Expression Bool +geq = + unsafeBinary (RelationOperation GreaterThanOrEquals) + + +{-| -} +eq : Expression t -> Expression t -> Expression Bool +eq = + unsafeBinary (RelationOperation Equals) + + + +--Ternary + + +{-| -} +ternary : Expression Bool_ -> Expression (Vec t d) -> Expression (Vec t d) -> Expression (Vec t d) +ternary = + unsafeMap3 Ternary + + + +-- Logic + + +{-| -} +and : Expression Bool_ -> Expression Bool_ -> Expression Bool_ +and = + unsafeMap2 (\l r -> BinaryOperation l And r) + + +{-| -} +ands : List (Expression Bool_) -> Expression Bool_ +ands es = + case es of + [] -> + true + + h :: t -> + List.foldl (\e a -> and a e) h t + + +{-| -} +or : Expression Bool_ -> Expression Bool_ -> Expression Bool_ +or = + unsafeMap2 (\l r -> BinaryOperation l Or r) + + +{-| -} +ors : List (Expression Bool_) -> Expression Bool_ +ors es = + case es of + [] -> + false + + h :: t -> + List.foldl (\e a -> or a e) h t diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm new file mode 100644 index 00000000..8fb245af --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm @@ -0,0 +1,801 @@ +module Glsl.Parser exposing (expression, file, function, preprocess, statement) + +import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), RelationOperation(..), Stat(..), Type(..), UnaryOperation(..)) +import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, keyword, loop, oneOf, sequence, succeed, symbol) + + +file : Parser ( Maybe { version : String }, List Declaration ) +file = + succeed Tuple.pair + |= oneOf + [ succeed (\version -> Just { version = version }) + |. symbol "#version " + |= (chompWhile Char.isDigit + |> getChompedString + ) + , succeed Nothing + ] + |. spaces + |= sequence + { start = "" + , separator = "" + , item = + oneOf + [ const + , uniform + , function + ] + , end = "" + , trailing = Parser.Optional + , spaces = spaces + } + |. Parser.end + + +function : Parser Declaration +function = + succeed + (\returnType name args stat -> + FunctionDeclaration + { returnType = returnType + , name = name + , args = args + , stat = stat + } + ) + |= typeParser + |. spaces + |= identifierParser + |. spaces + |= sequence + { start = "(" + , end = ")" + , spaces = spaces + , separator = "," + , item = argParser + , trailing = Forbidden + } + |. spaces + |= statement + + +const : Parser Declaration +const = + succeed + (\tipe name value -> + ConstDeclaration + { tipe = tipe + , name = name + , value = value + } + ) + |. keyword "const" + |. spaces + |= typeParser + |. spaces + |= identifierParser + |. spaces + |. symbol "=" + |. spaces + |= expression + |. symbol ";" + + +uniform : Parser Declaration +uniform = + succeed + (\tipe name -> + UniformDeclaration + { tipe = tipe + , name = name + } + ) + |. keyword "uniform" + |. spaces + |= typeParser + |. spaces + |= identifierParser + |. spaces + |. symbol ";" + + +argParser : Parser ( Type, String ) +argParser = + succeed Tuple.pair + |= typeParser + |. spaces + |= identifierParser + + +identifierParser : Parser String +identifierParser = + getChompedString + (succeed () + |. chompIf (\c -> Char.isAlpha c || c == '_') + |. chompWhile (\c -> Char.isAlphaNum c || c == '_') + ) + + +typeParser : Parser Type +typeParser = + let + baseParser : Parser Type + baseParser = + [ ( "void", TVoid ) + , ( "float", TFloat ) + , ( "int", TInt ) + , ( "bool", TBool ) + , ( "vec2", TVec2 ) + , ( "vec3", TVec3 ) + , ( "vec4", TVec4 ) + , ( "ivec2", TIVec2 ) + , ( "ivec3", TIVec3 ) + , ( "ivec4", TIVec4 ) + , ( "mat2", TMat2 ) + , ( "mat3", TMat3 ) + , ( "mat4", TMat4 ) + ] + |> List.map (\( s, t ) -> succeed t |. keyword s) + |> oneOf + in + succeed identity + |. oneOf [ keyword "const" |. spaces, succeed () ] + |= oneOf + [ succeed TOut + |. keyword "out" + |. spaces + |= baseParser + , succeed TIn + |. keyword "in" + |. spaces + |= baseParser + , baseParser + ] + + +statement : Parser Stat +statement = + Parser.lazy <| \_ -> + oneOf + [ blockParser + , returnParser + , breakContinueParser + , ifParser + , forParser + , defParser + , expressionStatementParser + ] + + +breakContinueParser : Parser Stat +breakContinueParser = + oneOf + [ succeed Break + |. keyword "break" + , succeed Continue + |. keyword "continue" + ] + |. spaces + |. symbol ";" + + +expressionStatementParser : Parser Stat +expressionStatementParser = + succeed ExpressionStatement + |= expression + |. spaces + |. symbol ";" + + +ifParser : Parser Stat +ifParser = + succeed (\e s k -> k e s) + |. keyword "if" + |. spaces + |. symbol "(" + |. spaces + |= expression + |. spaces + |. symbol ")" + |. spaces + |= statement + |. spaces + |= oneOf + [ succeed (\b e s -> IfElse e s b) + |. keyword "else" + |. spaces + |= statement + , succeed If + ] + + +forParser : Parser Stat +forParser = + succeed For + |. keyword "for" + |. spaces + |. symbol "(" + |. spaces + |= oneOf + [ succeed Just |= statement + , succeed Nothing + ] + |. spaces + |. symbol ";" + |. spaces + |= expression + |. spaces + |. symbol ";" + |. spaces + |= expression + |. spaces + |. symbol ")" + |. spaces + |= statement + + +returnParser : Parser Stat +returnParser = + succeed Return + |. keyword "return" + |. spaces + |= expression + |. spaces + |. symbol ";" + + +blockParser : Parser Stat +blockParser = + sequence + { start = "{" + , item = statement + , separator = "" + , spaces = spaces + , end = "}" + , trailing = Parser.Optional + } + |> Parser.map Glsl.block + + +defParser : Parser Stat +defParser = + succeed + (\type_ var val -> + Decl type_ var val + ) + |= typeParser + |. spaces + |= identifierParser + |. spaces + |= oneOf + [ succeed Just + |. symbol "=" + |. spaces + |= expression + |. spaces + , succeed Nothing + ] + |. spaces + |. symbol ";" + + +expression : Parser Expr +expression = + prec17Parser + + +prec17Parser : Parser Expr +prec17Parser = + multiSequenceAssocLeft + { separators = [ ( \l r -> BinaryOperation l Comma r, symbol "," ) ] + , item = prec16Parser + } + + +prec16Parser : Parser Expr +prec16Parser = + succeed (\a f -> f a) + |= prec15Parser + |. spaces + |= oneOf + [ succeed (\r l -> BinaryOperation l Assign r) + |. singleSymbol "=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboAdd r) + |. symbol "+=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboSubtract r) + |. symbol "-=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboBy r) + |. symbol "*=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboDiv r) + |. symbol "/=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboMod r) + |. symbol "%=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboLeftShift r) + |. symbol "<<=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboRightShift r) + |. symbol ">>=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboBitwiseAnd r) + |. symbol "&=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboBitwiseOr r) + |. symbol "|=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed (\r l -> BinaryOperation l ComboBitwiseXor r) + |. symbol "^=" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + , succeed identity + ] + + +prec15Parser : Parser Expr +prec15Parser = + succeed (\k f -> f k) + |= prec14Parser + |. spaces + |= oneOf + [ succeed (\t f c -> Ternary c t f) + -- c is passed in last in the lambda because it's passed + -- from above + |. symbol "?" + |. spaces + |= prec14Parser + |. spaces + |. symbol ":" + |. spaces + |= Parser.lazy (\_ -> prec15Parser) + , succeed identity + ] + + +prec14Parser : Parser Expr +prec14Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l Or r, symbol "||" ) + ] + , item = prec13Parser + } + + +prec13Parser : Parser Expr +prec13Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l Xor r, symbol "^^" ) + ] + , item = prec12Parser + } + + +prec12Parser : Parser Expr +prec12Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l And r, symbol "&&" ) + ] + , item = prec11Parser + } + + +prec11Parser : Parser Expr +prec11Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l BitwiseOr r, singleSymbol "|" ) + ] + , item = prec10Parser + } + + +prec10Parser : Parser Expr +prec10Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l BitwiseXor r, singleSymbol "^" ) + ] + , item = prec9Parser + } + + +prec9Parser : Parser Expr +prec9Parser = + multiSequenceAssocLeft + { separators = [ ( \l r -> BinaryOperation l BitwiseAnd r, singleSymbol "&" ) ] + , item = prec8Parser + } + + +singleSymbol : String -> Parser () +singleSymbol s = + symbolNotFollowedBy s [ s ] + + +symbolNotFollowedBy : String -> List String -> Parser () +symbolNotFollowedBy s nots = + succeed () + |. Parser.backtrackable (symbol s) + |. oneOf + [ succeed () + |. oneOf (List.map symbol nots) + |. Parser.problem ("Expecting " ++ s ++ " not follwed by any of " ++ String.join ", " nots) + |> Parser.backtrackable + , succeed () + ] + + +prec8Parser : Parser Expr +prec8Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l (RelationOperation Equals) r, symbol "==" ) + , ( \l r -> BinaryOperation l (RelationOperation NotEquals) r, symbol "!=" ) + ] + , item = prec7Parser + } + + +prec7Parser : Parser Expr +prec7Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l (RelationOperation LessThanOrEquals) r, symbol "<=" ) + , ( \l r -> BinaryOperation l (RelationOperation GreaterThanOrEquals) r, symbol ">=" ) + , ( \l r -> BinaryOperation l (RelationOperation LessThan) r, symbolNotFollowedBy "<" [ "<=" ] ) + , ( \l r -> BinaryOperation l (RelationOperation GreaterThan) r, symbolNotFollowedBy ">" [ ">=" ] ) + ] + , item = prec6Parser + } + + +prec6Parser : Parser Expr +prec6Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l ShiftLeft r, symbolNotFollowedBy "<<" [ "=" ] ) + , ( \l r -> BinaryOperation l ShiftRight r, symbolNotFollowedBy ">>" [ "=" ] ) + ] + , item = prec5Parser + } + + +prec5Parser : Parser Expr +prec5Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l Add r, symbolNotFollowedBy "+" [ "=" ] ) + , ( \l r -> BinaryOperation l Subtract r, symbolNotFollowedBy "-" [ "=" ] ) + ] + , item = prec4Parser + } + + +prec4Parser : Parser Expr +prec4Parser = + multiSequenceAssocLeft + { separators = + [ ( \l r -> BinaryOperation l By r, symbolNotFollowedBy "*" [ "=" ] ) + , ( \l r -> BinaryOperation l Div r, symbolNotFollowedBy "/" [ "=" ] ) + , ( \l r -> BinaryOperation l Mod r, symbolNotFollowedBy "%" [ "=" ] ) + ] + , item = prec3Parser + } + + +prec3Parser : Parser Expr +prec3Parser = + oneOf + [ succeed (UnaryOperation PrefixIncrement) + |. symbol "++" + |= Parser.lazy (\_ -> prec3Parser) + , succeed (UnaryOperation Plus) + |. singleSymbol "+" + |= Parser.lazy (\_ -> prec3Parser) + , succeed (UnaryOperation PrefixDecrement) + |. symbol "--" + |= Parser.lazy (\_ -> prec3Parser) + , succeed + (\c -> + case c of + Float f -> + Float -f + + Int i -> + Int -i + + _ -> + UnaryOperation Negate c + ) + |. singleSymbol "-" + |= Parser.lazy (\_ -> prec3Parser) + , succeed (UnaryOperation Invert) + |. symbol "~" + |= Parser.lazy (\_ -> prec3Parser) + , succeed (UnaryOperation Not) + |. symbol "!" + |= Parser.lazy (\_ -> prec3Parser) + , prec2Parser + ] + + +prec2Parser : Parser Expr +prec2Parser = + succeed (\a f -> f a) + |= prec1Parser + |. spaces + |= Parser.lazy prec2Suffixes + + +prec2Suffixes : () -> Parser (Expr -> Expr) +prec2Suffixes () = + oneOf + [ succeed (\args k v -> k (Call v args)) + |= sequence + { start = "(" + , separator = "," + , item = Parser.lazy <| \_ -> prec16Parser + , end = ")" + , trailing = Forbidden + , spaces = spaces + } + |= oneOf + [ Parser.lazy <| \_ -> prec2Suffixes () + , succeed identity + ] + , succeed (\arg k v -> k (BinaryOperation v ArraySubscript arg)) + |. symbol "[" + |. spaces + |= Parser.lazy (\_ -> prec16Parser) + |. spaces + |. symbol "]" + |= oneOf + [ Parser.lazy <| \_ -> prec2Suffixes () + , succeed identity + ] + , succeed (\p k v -> k (Dot v p)) + |. symbol "." + |= identifierParser + |= oneOf + [ Parser.lazy <| \_ -> prec2Suffixes () + , succeed identity + ] + , succeed (\k v -> k (UnaryOperation PostfixIncrement v)) + |. symbol "++" + |= oneOf + [ Parser.lazy <| \_ -> prec2Suffixes () + , succeed identity + ] + , succeed (\k v -> k (UnaryOperation PostfixDecrement v)) + |. symbol "--" + |= oneOf + [ Parser.lazy <| \_ -> prec2Suffixes () + , succeed identity + ] + , succeed identity + ] + + +prec1Parser : Parser Expr +prec1Parser = + oneOf + [ succeed identity + |. symbol "(" + |. spaces + |= Parser.lazy (\_ -> expression) + |. spaces + |. symbol ")" + , succeed (Bool True) + |. keyword "true" + , succeed (Bool False) + |. keyword "false" + , succeed Variable + |= identifierParser + , succeed Float |= floatParser + , succeed Int |= intParser + ] + + +floatParser : Parser Float +floatParser = + oneOf + [ succeed (\c e -> e c) + |= (oneOf + [ succeed () + |. symbol "." + |. intParser + , succeed () + |. Parser.backtrackable intParser + |. symbol "." + |. Parser.commit () + |. oneOf + [ intParser + , succeed 0 + ] + ] + |> getChompedString + |> Parser.andThen + (\s -> + let + withZero : String + withZero = + if String.endsWith "." s then + s ++ "0" + + else + s + in + case String.toFloat withZero of + Just f -> + succeed f + + Nothing -> + Parser.problem ("Cannot parse \"" ++ s ++ "\" as float") + ) + ) + |= oneOf + [ succeed (\e c -> c * 10 ^ toFloat e) + |. oneOf [ symbol "e", symbol "E" ] + |= oneOf + [ succeed identity + |. symbol "+" + |= intParser + , succeed negate + |. symbol "-" + |= intParser + , intParser + ] + , succeed identity + ] + , succeed (\c e -> toFloat c * 10 ^ toFloat e) + |= Parser.backtrackable intParser + |. oneOf [ symbol "e", symbol "E" ] + |. Parser.commit () + |= oneOf + [ succeed identity + |. symbol "+" + |= intParser + , succeed negate + |. symbol "-" + |= intParser + , intParser + ] + ] + + +intParser : Parser Int +intParser = + succeed () + |. chompIf Char.isDigit + |. chompWhile Char.isDigit + |> getChompedString + |> Parser.andThen + (\s -> + case String.toInt s of + Just i -> + succeed i + + Nothing -> + Parser.problem ("Cannot parse \"" ++ s ++ "\" as int") + ) + + +type alias SequenceData = + { separators : List ( Expr -> Expr -> Expr, Parser () ) + , item : Parser Expr + } + + +multiSequenceAssocLeft : SequenceData -> Parser Expr +multiSequenceAssocLeft data = + succeed identity + |= data.item + |. spaces + |> Parser.andThen + (\first -> + loop first (\expr -> multiSequenceHelpLeft data expr) + ) + + +multiSequenceHelpLeft : + SequenceData + -> Expr + -> Parser (Step Expr Expr) +multiSequenceHelpLeft { separators, item } acc = + let + separated : Parser (Step Expr a) + separated = + separators + |> List.map + (\( f, parser ) -> + succeed (\e -> Loop <| f acc e) + |. parser + |. spaces + |= item + |. spaces + ) + |> oneOf + in + oneOf + [ separated + , succeed (Done acc) + ] + + +preprocess : String -> String +preprocess input = + input + |> String.split "\n" + |> spliceLines + |> removeComments + |> expandMacros + |> String.join "\n" + + +spliceLines : List String -> List String +spliceLines lines = + lines + |> List.foldl + (\e ( last, acc ) -> + case last of + Nothing -> + ( Just e, acc ) + + Just l -> + if String.endsWith "\\" l && not (String.endsWith "\\\\" l) then + ( Just (String.dropRight 1 l ++ e), acc ) + + else + ( Just e, l :: acc ) + ) + ( Nothing, [] ) + |> (\( last, acc ) -> + case last of + Nothing -> + List.reverse acc + + Just l -> + List.reverse (l :: acc) + ) + + +removeComments : List String -> List String +removeComments lines = + lines + |> List.map + (\line -> + case String.indexes "//" line of + head :: _ -> + String.left head line + + [] -> + line + ) + + +expandMacros : List String -> List String +expandMacros lines = + -- TODO: macros + lines + + +spaces : Parser () +spaces = + chompWhile (\c -> c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t') diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/PrettyPrinter.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/PrettyPrinter.elm new file mode 100644 index 00000000..f10e3568 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/PrettyPrinter.elm @@ -0,0 +1,582 @@ +module Glsl.PrettyPrinter exposing (binaryOperation, declaration, expr, float, stat, type_, unaryOperation) + +import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), RelationOperation(..), Stat(..), Type(..), UnaryOperation(..)) + + +stat : Int -> Stat -> String +stat i c = + case c of + Nop -> + "{}" + + Block a b children -> + (indent i "{" + :: List.map (stat (i + 1)) (a :: b :: children) + ++ [ indent i "}" ] + ) + |> String.join "\n" + + If cond t -> + indent i ("if (" ++ expr cond ++ ") ") ++ String.trimLeft (stat (i + 1) t) + + IfElse cond t ((If _ _) as f) -> + [ indent i ("if (" ++ expr cond ++ ") {") + , stat (i + 1) t + , indent i <| "} else " ++ String.trimLeft (stat i f) + ] + |> String.join "\n" + + IfElse cond t ((IfElse _ _ _) as f) -> + [ indent i ("if (" ++ expr cond ++ ") {") + , stat (i + 1) t + , indent i "} else {" + , stat (i + 1) f + , indent i "}" + ] + |> String.join "\n" + + IfElse cond t f -> + [ indent i ("if (" ++ expr cond ++ ") {") + , stat (i + 1) t + , indent i "} else {" + , stat (i + 1) f + , indent i "}" + ] + |> String.join "\n" + + For init check step loop -> + [ indent i ("for ( " ++ maybeStat 0 init ++ "; " ++ expr check ++ "; " ++ expr step ++ ") {") + , stat (i + 1) loop + , indent i "}" + ] + |> String.join "\n" + + Return e -> + indent i <| "return " ++ expr e ++ ";" + + Break -> + indent i "break;" + + Continue -> + indent i "continue;" + + ExpressionStatement e -> + indent i (expr e ++ ";") + + Decl t n (Just e) -> + indent i (type_ t ++ " " ++ n ++ " = " ++ expr e ++ ";") + + Decl t n Nothing -> + indent i (type_ t ++ " " ++ n ++ ";") + + +maybeStat : Int -> Maybe Stat -> String +maybeStat i c = + case c of + Nothing -> + "" + + Just s -> + stat i s + + +indent : Int -> String -> String +indent i line = + String.repeat (4 * i) " " ++ line + + +expr : Expr -> String +expr root = + let + showParen : Bool -> String -> String + showParen show e = + if show then + "(" ++ e ++ ")" + + else + e + + infixl_ : Int -> Int -> Expr -> String -> Expr -> String + infixl_ n p l op r = + showParen (p > n) (go n l ++ " " ++ op ++ " " ++ go (n + 1) r) + + infixr_ : Int -> Int -> Expr -> String -> Expr -> String + infixr_ n p l op r = + showParen (p > n) (go (n + 1) l ++ " " ++ op ++ " " ++ go n r) + + go : Int -> Expr -> String + go p tree = + case tree of + Bool b -> + if b then + "true" + + else + "false" + + Float f -> + float f + + Double d -> + double d + + Int i -> + String.fromInt i + + Uint u -> + String.fromInt u + + Variable v -> + v + + BinaryOperation l ArraySubscript r -> + showParen (p > 15) (go 15 l ++ "[" ++ go 16 r ++ "]") + + Call l r -> + showParen (p > 15) (go 15 l ++ "(" ++ String.join ", " (List.map (go 16) r) ++ ")") + + Dot l r -> + showParen (p > 15) (go 15 l ++ "." ++ r) + + UnaryOperation PostfixIncrement r -> + showParen (p > 15) (go 16 r ++ "++") + + UnaryOperation PostfixDecrement r -> + showParen (p > 15) (go 16 r ++ "--") + + UnaryOperation PrefixIncrement r -> + showParen (p > 14) ("++" ++ go 15 r) + + UnaryOperation PrefixDecrement r -> + showParen (p > 14) ("--" ++ go 15 r) + + UnaryOperation Plus r -> + showParen (p > 14) ("+" ++ go 15 r) + + UnaryOperation Negate r -> + showParen (p > 14) ("-" ++ go 15 r) + + UnaryOperation Invert r -> + showParen (p > 14) ("~" ++ go 15 r) + + UnaryOperation Not r -> + showParen (p > 14) ("!" ++ go 15 r) + + BinaryOperation l By r -> + infixl_ 13 p l "*" r + + BinaryOperation l Div r -> + infixl_ 13 p l "/" r + + BinaryOperation l Mod r -> + infixl_ 13 p l "%" r + + BinaryOperation l Add r -> + infixl_ 12 p l "+" r + + BinaryOperation l Subtract r -> + infixl_ 12 p l "-" r + + BinaryOperation l ShiftLeft r -> + infixl_ 11 p l "<<" r + + BinaryOperation l ShiftRight r -> + infixl_ 11 p l ">>" r + + BinaryOperation l (RelationOperation LessThan) r -> + infixl_ 10 p l "<" r + + BinaryOperation l (RelationOperation LessThanOrEquals) r -> + infixl_ 10 p l "<=" r + + BinaryOperation l (RelationOperation GreaterThan) r -> + infixl_ 10 p l ">" r + + BinaryOperation l (RelationOperation GreaterThanOrEquals) r -> + infixl_ 10 p l ">=" r + + BinaryOperation l (RelationOperation Equals) r -> + infixl_ 9 p l "==" r + + BinaryOperation l (RelationOperation NotEquals) r -> + infixl_ 9 p l "!=" r + + BinaryOperation l BitwiseAnd r -> + infixl_ 8 p l "&" r + + BinaryOperation l BitwiseXor r -> + infixl_ 7 p l "^" r + + BinaryOperation l BitwiseOr r -> + infixl_ 6 p l "|" r + + BinaryOperation l And r -> + infixl_ 5 p l "&&" r + + BinaryOperation l Xor r -> + infixl_ 4 p l "^^" r + + BinaryOperation l Or r -> + infixl_ 3 p l "||" r + + Ternary c t f -> + showParen (p > 2) (go 3 c ++ " ? " ++ go 3 t ++ " : " ++ go 2 f) + + BinaryOperation l Assign r -> + infixr_ 1 p l "=" r + + BinaryOperation l ComboAdd r -> + infixr_ 1 p l "+=" r + + BinaryOperation l ComboSubtract r -> + infixr_ 1 p l "-=" r + + BinaryOperation l ComboBy r -> + infixr_ 1 p l "*=" r + + BinaryOperation l ComboDiv r -> + infixr_ 1 p l "/=" r + + BinaryOperation l ComboMod r -> + infixr_ 1 p l "%=" r + + BinaryOperation l ComboLeftShift r -> + infixr_ 1 p l "<<=" r + + BinaryOperation l ComboRightShift r -> + infixr_ 1 p l ">>=" r + + BinaryOperation l ComboBitwiseAnd r -> + infixr_ 1 p l "&=" r + + BinaryOperation l ComboBitwiseXor r -> + infixr_ 1 p l "^=" r + + BinaryOperation l ComboBitwiseOr r -> + infixr_ 1 p l "|=" r + + BinaryOperation l Comma r -> + infixl_ 0 p l "," r + in + go 0 root + + +binaryOperation : BinaryOperation -> String +binaryOperation op = + case op of + By -> + "*" + + Div -> + "/" + + Mod -> + "%" + + Add -> + "+" + + Subtract -> + "-" + + ShiftLeft -> + "<<" + + ShiftRight -> + ">>" + + RelationOperation LessThan -> + "<" + + RelationOperation LessThanOrEquals -> + "<=" + + RelationOperation GreaterThan -> + ">" + + RelationOperation GreaterThanOrEquals -> + ">=" + + RelationOperation Equals -> + "==" + + RelationOperation NotEquals -> + "!=" + + BitwiseAnd -> + "&" + + BitwiseXor -> + "^" + + BitwiseOr -> + "|" + + And -> + "&&" + + Xor -> + "^^" + + Or -> + "||" + + Assign -> + "=" + + ComboAdd -> + "+=" + + ComboSubtract -> + "-=" + + ComboBy -> + "*=" + + ComboDiv -> + "/=" + + ComboMod -> + "%=" + + ComboLeftShift -> + "<<=" + + ComboRightShift -> + ">>=" + + ComboBitwiseAnd -> + "&=" + + ComboBitwiseXor -> + "^=" + + ComboBitwiseOr -> + "|=" + + Comma -> + "," + + ArraySubscript -> + "[]" + + +type_ : Type -> String +type_ t = + case t of + TFloat -> + "float" + + TInt -> + "int" + + TVec2 -> + "vec2" + + TIVec2 -> + "ivec2" + + TVec3 -> + "vec3" + + TIVec3 -> + "ivec3" + + TVec4 -> + "vec4" + + TIVec4 -> + "ivec4" + + TMat3 -> + "mat3" + + TVoid -> + "void" + + TBool -> + "bool" + + TBVec2 -> + "bvec2" + + TBVec3 -> + "bvec3" + + TBVec4 -> + "bvec4" + + TUint -> + "uint" + + TUVec2 -> + "uvec2" + + TUVec3 -> + "uvec3" + + TUVec4 -> + "uvec4" + + TDouble -> + "double" + + TDVec2 -> + "dvec2" + + TDVec3 -> + "dvec3" + + TDVec4 -> + "dvec4" + + TMat2 -> + "mat2" + + TMat4 -> + "mat4" + + TMat23 -> + "mat2x3" + + TMat24 -> + "mat2x4" + + TMat32 -> + "mat3x2" + + TMat34 -> + "mat3x4" + + TMat42 -> + "mat4x2" + + TMat43 -> + "mat4x3" + + TDMat2 -> + "dmat2" + + TDMat3 -> + "dmat3" + + TDMat4 -> + "dmat4" + + TDMat23 -> + "dmat2x3" + + TDMat24 -> + "dmat2x4" + + TDMat32 -> + "dmat3x2" + + TDMat34 -> + "dmat3x4" + + TDMat42 -> + "dmat4x2" + + TDMat43 -> + "dmat4x3" + + TIn tt -> + "in " ++ type_ tt + + TOut tt -> + "out " ++ type_ tt + + +double : Float -> String +double d = + float d + + +float : Float -> String +float f = + if isNaN f then + "(0./0.)" + + else if isInfinite f then + if f > 0 then + "(1./0.)" + + else + "(-1./0.)" + + else + let + s : String + s = + String.fromFloat f + in + if String.contains "." s || String.contains "e" s then + s + + else + s ++ "." + + +unaryOperation : UnaryOperation -> String +unaryOperation op = + case op of + Negate -> + "-" + + PostfixIncrement -> + "++" + + PostfixDecrement -> + "--" + + PrefixIncrement -> + "(++)" + + PrefixDecrement -> + "(--)" + + Plus -> + "+" + + Invert -> + "~" + + Not -> + "!" + + +declaration : Declaration -> String +declaration decl = + case decl of + ConstDeclaration const -> + "const " ++ type_ const.tipe ++ " " ++ const.name ++ " = " ++ expr const.value ++ ";" + + FunctionDeclaration function -> + let + argsString : String + argsString = + function.args + |> List.map (\( atype, aname ) -> type_ atype ++ " " ++ aname) + |> String.join ", " + + head : String + head = + type_ function.returnType ++ " " ++ function.name ++ "(" ++ argsString ++ ") " + in + case function.stat of + Block _ _ _ -> + head ++ stat 0 function.stat + + Nop -> + head ++ "{}" + + _ -> + [ head ++ "{" + , stat 1 function.stat + , "}" + ] + |> String.join "\n" + + UniformDeclaration uniform -> + "uniform " ++ type_ uniform.tipe ++ " " ++ uniform.name ++ ";" diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Simplify.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Simplify.elm new file mode 100644 index 00000000..d3c0d799 --- /dev/null +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Simplify.elm @@ -0,0 +1,151 @@ +module Glsl.Simplify exposing (expr, stat) + +import Glsl exposing (Expr(..), Stat(..), UnaryOperation(..)) + + +stat : Stat -> Stat +stat root = + case root of + Return e -> + map stat root Return expr e + + ExpressionStatement e -> + map stat root ExpressionStatement expr e + + If e s1 -> + map2 stat root If expr e stat s1 + + IfElse e s1 s2 -> + map3 stat root IfElse expr e stat s1 stat s2 + + Decl tipe name val -> + map stat root (Decl tipe name) (Maybe.map expr) val + + For init check step loop -> + map4 stat root For (Maybe.map stat) init expr check expr step stat loop + + Block a b children -> + map stat root (Block (stat a) (stat b)) (List.map stat) children + + Nop -> + Nop + + Break -> + Break + + Continue -> + Continue + + +expr : Expr -> Expr +expr root = + case root of + Ternary c t f -> + map3 expr root Ternary expr c expr t expr f + + Dot l r -> + map2 expr root Dot expr l identity r + + BinaryOperation l op r -> + map3 expr root BinaryOperation expr l identity op expr r + + UnaryOperation Negate (Int i) -> + Int -i + + UnaryOperation Negate (Float f) -> + Float -f + + UnaryOperation op l -> + map expr root (UnaryOperation op) expr l + + Call l r -> + map2 expr root Call expr l (List.map expr) r + + -- Bool _ -> + -- Int _ -> + -- Float _ -> + -- Uint _ -> + -- Double _ -> + -- Variable _ -> + _ -> + root + + +map : (a -> a) -> a -> (b -> a) -> (b -> b) -> b -> a +map rootKind root ctor kind val = + let + vals : b + vals = + kind val + in + if vals == val then + root + + else + rootKind (ctor vals) + + +map2 : (a -> a) -> a -> (b -> c -> a) -> (b -> b) -> b -> (c -> c) -> c -> a +map2 rootKind root ctor kind1 val1 kind2 val2 = + let + val1s : b + val1s = + kind1 val1 + + val2s : c + val2s = + kind2 val2 + in + if val1s == val1 && val2s == val2 then + root + + else + rootKind (ctor val1s val2s) + + +map3 : (a -> a) -> a -> (b -> c -> d -> a) -> (b -> b) -> b -> (c -> c) -> c -> (d -> d) -> d -> a +map3 rootKind root ctor kind1 val1 kind2 val2 kind3 val3 = + let + val1s : b + val1s = + kind1 val1 + + val2s : c + val2s = + kind2 val2 + + val3s : d + val3s = + kind3 val3 + in + if val1s == val1 && val2s == val2 && val3s == val3 then + root + + else + rootKind (ctor val1s val2s val3s) + + +map4 : (a -> a) -> a -> (b -> c -> d -> e -> a) -> (b -> b) -> b -> (c -> c) -> c -> (d -> d) -> d -> (e -> e) -> e -> a +map4 rootKind root ctor kind1 val1 kind2 val2 kind3 val3 kind4 val4 = + let + val1s : b + val1s = + kind1 val1 + + val2s : c + val2s = + kind2 val2 + + val3s : d + val3s = + kind3 val3 + + val4s : e + val4s = + kind4 val4 + in + if val1s == val1 && val2s == val2 && val3s == val3 && val4s == val4 then + root + + else + rootKind (ctor val1s val2s val3s val4s) diff --git a/codegen/helpers/SortedSet.elm b/vendored/miniBill/elm-glsl/1.0.0/src/SortedSet.elm similarity index 100% rename from codegen/helpers/SortedSet.elm rename to vendored/miniBill/elm-glsl/1.0.0/src/SortedSet.elm diff --git a/yarn.lock b/yarn.lock index 8405ea62..817b52cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,6 +27,210 @@ resolved "https://registry.yarnpkg.com/@avh4/elm-format-win32-x64/-/elm-format-win32-x64-0.8.7-2.tgz#4a4e7489a7b519a810a8a89798c4aab3805626ab" integrity sha512-sBdMBGq/8mD8Y5C+fIr5vlb3N50yB7S1MfgeAq2QEbvkr/sKrCZI540i43lZDH9gWsfA1w2W8wCe0penFYzsGw== +"@esbuild/aix-ppc64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz#b87036f644f572efb2b3c75746c97d1d2d87ace8" + integrity sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag== + +"@esbuild/android-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.25.2.tgz#5ca7dc20a18f18960ad8d5e6ef5cf7b0a256e196" + integrity sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w== + +"@esbuild/android-arm@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.25.2.tgz#3c49f607b7082cde70c6ce0c011c362c57a194ee" + integrity sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA== + +"@esbuild/android-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.25.2.tgz#8a00147780016aff59e04f1036e7cb1b683859e2" + integrity sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg== + +"@esbuild/darwin-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.2.tgz#486efe7599a8d90a27780f2bb0318d9a85c6c423" + integrity sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA== + +"@esbuild/darwin-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.25.2.tgz#95ee222aacf668c7a4f3d7ee87b3240a51baf374" + integrity sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA== + +"@esbuild/freebsd-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.2.tgz#67efceda8554b6fc6a43476feba068fb37fa2ef6" + integrity sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w== + +"@esbuild/freebsd-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.2.tgz#88a9d7ecdd3adadbfe5227c2122d24816959b809" + integrity sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ== + +"@esbuild/linux-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.25.2.tgz#87be1099b2bbe61282333b084737d46bc8308058" + integrity sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g== + +"@esbuild/linux-arm@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.25.2.tgz#72a285b0fe64496e191fcad222185d7bf9f816f6" + integrity sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g== + +"@esbuild/linux-ia32@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.25.2.tgz#337a87a4c4dd48a832baed5cbb022be20809d737" + integrity sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ== + +"@esbuild/linux-loong64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.25.2.tgz#1b81aa77103d6b8a8cfa7c094ed3d25c7579ba2a" + integrity sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w== + +"@esbuild/linux-mips64el@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.2.tgz#afbe380b6992e7459bf7c2c3b9556633b2e47f30" + integrity sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q== + +"@esbuild/linux-ppc64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.2.tgz#6bf8695cab8a2b135cca1aa555226dc932d52067" + integrity sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g== + +"@esbuild/linux-riscv64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.2.tgz#43c2d67a1a39199fb06ba978aebb44992d7becc3" + integrity sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw== + +"@esbuild/linux-s390x@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.25.2.tgz#419e25737ec815c6dce2cd20d026e347cbb7a602" + integrity sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q== + +"@esbuild/linux-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.25.2.tgz#22451f6edbba84abe754a8cbd8528ff6e28d9bcb" + integrity sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg== + +"@esbuild/netbsd-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.2.tgz#744affd3b8d8236b08c5210d828b0698a62c58ac" + integrity sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw== + +"@esbuild/netbsd-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.2.tgz#dbbe7521fd6d7352f34328d676af923fc0f8a78f" + integrity sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg== + +"@esbuild/openbsd-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.2.tgz#f9caf987e3e0570500832b487ce3039ca648ce9f" + integrity sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg== + +"@esbuild/openbsd-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.2.tgz#d2bb6a0f8ffea7b394bb43dfccbb07cabd89f768" + integrity sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw== + +"@esbuild/sunos-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.25.2.tgz#49b437ed63fe333b92137b7a0c65a65852031afb" + integrity sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA== + +"@esbuild/win32-arm64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.25.2.tgz#081424168463c7d6c7fb78f631aede0c104373cf" + integrity sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q== + +"@esbuild/win32-ia32@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.25.2.tgz#3f9e87143ddd003133d21384944a6c6cadf9693f" + integrity sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg== + +"@esbuild/win32-x64@0.25.2": + version "0.25.2" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.2.tgz#839f72c2decd378f86b8f525e1979a97b920c67d" + integrity sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA== + +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + +"@isaacs/fs-minipass@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz#2d59ae3ab4b38fb4270bfa23d30f8e2e86c7fe32" + integrity sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w== + dependencies: + minipass "^7.0.4" + +"@jridgewell/gen-mapping@^0.3.5": + version "0.3.8" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz#4f0e06362e01362f823d348f1872b08f666d8142" + integrity sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA== + dependencies: + "@jridgewell/set-array" "^1.2.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.24" + +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/set-array@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280" + integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A== + +"@jridgewell/source-map@^0.3.3": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.6.tgz#9d71ca886e32502eb9362c9a74a46787c36df81a" + integrity sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ== + dependencies: + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" + +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + +"@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@jsonjoy.com/base64@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/base64/-/base64-1.1.2.tgz#cf8ea9dcb849b81c95f14fc0aaa151c6b54d2578" + integrity sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA== + +"@jsonjoy.com/json-pack@^1.0.3": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pack/-/json-pack-1.2.0.tgz#e658900e81d194903171c42546e1aa27f446846a" + integrity sha512-io1zEbbYcElht3tdlqEOFxZ0dMTYrHz9iMf0gqn1pPjZFTCgM5R4R5IMA20Chb2UPYYsxjzs8CgZ7Nb5n2K2rA== + dependencies: + "@jsonjoy.com/base64" "^1.1.1" + "@jsonjoy.com/util" "^1.1.2" + hyperdyperid "^1.2.0" + thingies "^1.20.0" + +"@jsonjoy.com/util@^1.1.2", "@jsonjoy.com/util@^1.3.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/util/-/util-1.5.0.tgz#6008e35b9d9d8ee27bc4bfaa70c8cbf33a537b4c" + integrity sha512-ojoNsrIuPI9g6o8UxhraZQSyF2ByJanAY4cTFbc8Mf2AXEF4aQRGY1dJxyJpuyav8r9FGflEt/Ff3u5Nt6YMPA== + "@mattpiz/elm-test-rs-darwin-arm64@3.0.0-1": version "3.0.0-1" resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-darwin-arm64/-/elm-test-rs-darwin-arm64-3.0.0-1.tgz#fe2abeb2b472b76242b0e8b69b5d5a18e97f20d1" @@ -57,11 +261,186 @@ resolved "https://registry.yarnpkg.com/@mattpiz/elm-test-rs-win32-x64/-/elm-test-rs-win32-x64-3.0.0-0.tgz#77f5d2adfe9a0dc864d6adfc229b44b2eb613c2a" integrity sha512-7Vr74820XFPwUNrpZVybStPlCTyAjthgnUel23j3fJB2yDm9ydbBSPvLCmngqzkZBAnpX8eruUqDphTx+mR28Q== +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@npmcli/agent@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@npmcli/agent/-/agent-3.0.0.tgz#1685b1fbd4a1b7bb4f930cbb68ce801edfe7aa44" + integrity sha512-S79NdEgDQd/NGCay6TCoVzXSj74skRZIKJcpJjC5lOq34SZzyI6MqtiiWoiVWoVrTcGjNeC4ipbh1VIHlpfF5Q== + dependencies: + agent-base "^7.1.0" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.1" + lru-cache "^10.0.1" + socks-proxy-agent "^8.0.3" + +"@npmcli/fs@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@npmcli/fs/-/fs-4.0.0.tgz#a1eb1aeddefd2a4a347eca0fab30bc62c0e1c0f2" + integrity sha512-/xGlezI6xfGO9NwuJlnwz/K14qD1kCSAGtacBHnGzeAIuJGazcp45KP5NuyARXoKb7cwulAGWVsbeSxdG/cb0Q== + dependencies: + semver "^7.3.5" + +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + +"@pnpm/config.env-replace@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz#ab29da53df41e8948a00f2433f085f54de8b3a4c" + integrity sha512-htyl8TWnKL7K/ESFa1oW2UB5lVDxuF5DpM7tBi6Hu2LNL3mWkIzNLG6N4zoCUP1lCKNxWy/3iu8mS8MvToGd6w== + +"@pnpm/network.ca-file@^1.0.1": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@pnpm/network.ca-file/-/network.ca-file-1.0.2.tgz#2ab05e09c1af0cdf2fcf5035bea1484e222f7983" + integrity sha512-YcPQ8a0jwYU9bTdJDpXjMi7Brhkr1mXsXrUJvjqM2mQDgkRiz8jFaQGOdaLxgjtUfQgZhKy/O3cG/YwmgKaxLA== + dependencies: + graceful-fs "4.2.10" + +"@pnpm/npm-conf@^2.1.0": + version "2.3.1" + resolved "https://registry.yarnpkg.com/@pnpm/npm-conf/-/npm-conf-2.3.1.tgz#bb375a571a0bd63ab0a23bece33033c683e9b6b0" + integrity sha512-c83qWb22rNRuB0UaVCI0uRPNRr8Z0FWnEIvT47jiHAmOIUHbBOg5XvV7pM5x+rKn9HRpjxquDbXYSXr3fAKFcw== + dependencies: + "@pnpm/config.env-replace" "^1.1.0" + "@pnpm/network.ca-file" "^1.0.1" + config-chain "^1.1.11" + +"@rollup/rollup-android-arm-eabi@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.0.tgz#d964ee8ce4d18acf9358f96adc408689b6e27fe3" + integrity sha512-+Fbls/diZ0RDerhE8kyC6hjADCXA1K4yVNlH0EYfd2XjyH0UGgzaQ8MlT0pCXAThfxv3QUAczHaL+qSv1E4/Cg== + +"@rollup/rollup-android-arm64@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.40.0.tgz#9b5e130ecc32a5fc1e96c09ff371743ee71a62d3" + integrity sha512-PPA6aEEsTPRz+/4xxAmaoWDqh67N7wFbgFUJGMnanCFs0TV99M0M8QhhaSCks+n6EbQoFvLQgYOGXxlMGQe/6w== + +"@rollup/rollup-darwin-arm64@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.40.0.tgz#ef439182c739b20b3c4398cfc03e3c1249ac8903" + integrity sha512-GwYOcOakYHdfnjjKwqpTGgn5a6cUX7+Ra2HeNj/GdXvO2VJOOXCiYYlRFU4CubFM67EhbmzLOmACKEfvp3J1kQ== + +"@rollup/rollup-darwin-x64@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.40.0.tgz#d7380c1531ab0420ca3be16f17018ef72dd3d504" + integrity sha512-CoLEGJ+2eheqD9KBSxmma6ld01czS52Iw0e2qMZNpPDlf7Z9mj8xmMemxEucinev4LgHalDPczMyxzbq+Q+EtA== + +"@rollup/rollup-freebsd-arm64@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.40.0.tgz#cbcbd7248823c6b430ce543c59906dd3c6df0936" + integrity sha512-r7yGiS4HN/kibvESzmrOB/PxKMhPTlz+FcGvoUIKYoTyGd5toHp48g1uZy1o1xQvybwwpqpe010JrcGG2s5nkg== + +"@rollup/rollup-freebsd-x64@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.40.0.tgz#96bf6ff875bab5219c3472c95fa6eb992586a93b" + integrity sha512-mVDxzlf0oLzV3oZOr0SMJ0lSDd3xC4CmnWJ8Val8isp9jRGl5Dq//LLDSPFrasS7pSm6m5xAcKaw3sHXhBjoRw== + +"@rollup/rollup-linux-arm-gnueabihf@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.40.0.tgz#d80cd62ce6d40f8e611008d8dbf03b5e6bbf009c" + integrity sha512-y/qUMOpJxBMy8xCXD++jeu8t7kzjlOCkoxxajL58G62PJGBZVl/Gwpm7JK9+YvlB701rcQTzjUZ1JgUoPTnoQA== + +"@rollup/rollup-linux-arm-musleabihf@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.40.0.tgz#75440cfc1e8d0f87a239b4c31dfeaf4719b656b7" + integrity sha512-GoCsPibtVdJFPv/BOIvBKO/XmwZLwaNWdyD8TKlXuqp0veo2sHE+A/vpMQ5iSArRUz/uaoj4h5S6Pn0+PdhRjg== + +"@rollup/rollup-linux-arm64-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.40.0.tgz#ac527485ecbb619247fb08253ec8c551a0712e7c" + integrity sha512-L5ZLphTjjAD9leJzSLI7rr8fNqJMlGDKlazW2tX4IUF9P7R5TMQPElpH82Q7eNIDQnQlAyiNVfRPfP2vM5Avvg== + +"@rollup/rollup-linux-arm64-musl@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.40.0.tgz#74d2b5cb11cf714cd7d1682e7c8b39140e908552" + integrity sha512-ATZvCRGCDtv1Y4gpDIXsS+wfFeFuLwVxyUBSLawjgXK2tRE6fnsQEkE4csQQYWlBlsFztRzCnBvWVfcae/1qxQ== + +"@rollup/rollup-linux-loongarch64-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.40.0.tgz#a0a310e51da0b5fea0e944b0abd4be899819aef6" + integrity sha512-wG9e2XtIhd++QugU5MD9i7OnpaVb08ji3P1y/hNbxrQ3sYEelKJOq1UJ5dXczeo6Hj2rfDEL5GdtkMSVLa/AOg== + +"@rollup/rollup-linux-powerpc64le-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.40.0.tgz#4077e2862b0ac9f61916d6b474d988171bd43b83" + integrity sha512-vgXfWmj0f3jAUvC7TZSU/m/cOE558ILWDzS7jBhiCAFpY2WEBn5jqgbqvmzlMjtp8KlLcBlXVD2mkTSEQE6Ixw== + +"@rollup/rollup-linux-riscv64-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.40.0.tgz#5812a1a7a2f9581cbe12597307cc7ba3321cf2f3" + integrity sha512-uJkYTugqtPZBS3Z136arevt/FsKTF/J9dEMTX/cwR7lsAW4bShzI2R0pJVw+hcBTWF4dxVckYh72Hk3/hWNKvA== + +"@rollup/rollup-linux-riscv64-musl@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.40.0.tgz#973aaaf4adef4531375c36616de4e01647f90039" + integrity sha512-rKmSj6EXQRnhSkE22+WvrqOqRtk733x3p5sWpZilhmjnkHkpeCgWsFFo0dGnUGeA+OZjRl3+VYq+HyCOEuwcxQ== + +"@rollup/rollup-linux-s390x-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.40.0.tgz#9bad59e907ba5bfcf3e9dbd0247dfe583112f70b" + integrity sha512-SpnYlAfKPOoVsQqmTFJ0usx0z84bzGOS9anAC0AZ3rdSo3snecihbhFTlJZ8XMwzqAcodjFU4+/SM311dqE5Sw== + +"@rollup/rollup-linux-x64-gnu@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.0.tgz#68b045a720bd9b4d905f462b997590c2190a6de0" + integrity sha512-RcDGMtqF9EFN8i2RYN2W+64CdHruJ5rPqrlYw+cgM3uOVPSsnAQps7cpjXe9be/yDp8UC7VLoCoKC8J3Kn2FkQ== + +"@rollup/rollup-linux-x64-musl@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.40.0.tgz#8e703e2c2ad19ba7b2cb3d8c3a4ad11d4ee3a282" + integrity sha512-HZvjpiUmSNx5zFgwtQAV1GaGazT2RWvqeDi0hV+AtC8unqqDSsaFjPxfsO6qPtKRRg25SisACWnJ37Yio8ttaw== + +"@rollup/rollup-win32-arm64-msvc@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.40.0.tgz#c5bee19fa670ff5da5f066be6a58b4568e9c650b" + integrity sha512-UtZQQI5k/b8d7d3i9AZmA/t+Q4tk3hOC0tMOMSq2GlMYOfxbesxG4mJSeDp0EHs30N9bsfwUvs3zF4v/RzOeTQ== + +"@rollup/rollup-win32-ia32-msvc@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.40.0.tgz#846e02c17044bd922f6f483a3b4d36aac6e2b921" + integrity sha512-+m03kvI2f5syIqHXCZLPVYplP8pQch9JHyXKZ3AGMKlg8dCyr2PKHjwRLiW53LTrN/Nc3EqHOKxUxzoSPdKddA== + +"@rollup/rollup-win32-x64-msvc@4.40.0": + version "4.40.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.40.0.tgz#fd92d31a2931483c25677b9c6698106490cbbc76" + integrity sha512-lpPE1cLfP5oPzVjKMx10pgBmKELQnFJXHgvtHCtuJWOv8MxqdEIMNtgHgBFf7Ea2/7EuVwa9fodWUfXAlXZLZQ== + "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== +"@sindresorhus/merge-streams@^2.1.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz#719df7fb41766bc143369eaa0dd56d8dc87c9958" + integrity sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg== + +"@sindresorhus/merge-streams@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz#abb11d99aeb6d27f1b563c38147a72d50058e339" + integrity sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ== + "@szmarczak/http-timer@^4.0.5": version "4.0.6" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" @@ -79,6 +458,42 @@ "@types/node" "*" "@types/responselike" "^1.0.0" +"@types/configstore@^2.1.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@types/configstore/-/configstore-2.1.1.tgz#cd1e8553633ad3185c3f2f239ecff5d2643e92b6" + integrity sha512-YY+hm3afkDHeSM2rsFXxeZtu0garnusBWNG1+7MknmDWQHqcH2w21/xOU9arJUi8ch4qyFklidANLCu3ihhVwQ== + +"@types/debug@^0.0.30": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-0.0.30.tgz#dc1e40f7af3b9c815013a7860e6252f6352a84df" + integrity sha512-orGL5LXERPYsLov6CWs3Fh6203+dXzJkR7OnddIr2514Hsecwc8xRpzCapshBbKFImCsvS/mk6+FWiN5LyZJAQ== + +"@types/estree@1.0.7": + version "1.0.7" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.7.tgz#4158d3105276773d5b7695cd4834b1722e4f37a8" + integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ== + +"@types/get-port@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@types/get-port/-/get-port-3.2.0.tgz#f9e0a11443cc21336470185eae3dfba4495d29bc" + integrity sha512-TiNg8R1kjDde5Pub9F9vCwZA/BNW9HeXP5b9j7Qucqncy/McfPZ6xze/EyBdXS5FhMIGN6Fx3vg75l5KHy3V1Q== + +"@types/glob@*": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.1.0.tgz#b63e70155391b0584dce44e7ea25190bbc38f2fc" + integrity sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w== + dependencies: + "@types/minimatch" "^5.1.2" + "@types/node" "*" + +"@types/glob@^5.0.34": + version "5.0.38" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-5.0.38.tgz#20e29f3c6332f6b3329f34711ebb31a03dd74a51" + integrity sha512-rTtf75rwyP9G2qO5yRpYtdJ6aU1QqEhWbtW55qEgquEDa6bXW0s2TWZfDm02GuppjEozOWG/F2UnPq5hAQb+gw== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + "@types/http-cache-semantics@*": version "4.0.4" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4" @@ -99,6 +514,23 @@ dependencies: "@types/node" "*" +"@types/lodash@^4.14.92": + version "4.17.16" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.16.tgz#94ae78fab4a38d73086e962d0b65c30d816bfb0a" + integrity sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g== + +"@types/minimatch@*", "@types/minimatch@^5.1.2": + version "5.1.2" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" + integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== + +"@types/mkdirp@^0.5.2": + version "0.5.2" + resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f" + integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg== + dependencies: + "@types/node" "*" + "@types/node@*": version "22.14.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.14.1.tgz#53b54585cec81c21eee3697521e31312d6ca1e6f" @@ -106,6 +538,11 @@ dependencies: undici-types "~6.21.0" +"@types/node@^8.5.7": + version "8.10.66" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.66.tgz#dd035d409df322acc83dff62a602f12a5783bbb3" + integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== + "@types/responselike@^1.0.0": version "1.0.3" resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.3.tgz#cc29706f0a397cfe6df89debfe4bf5cea159db50" @@ -113,7 +550,38 @@ dependencies: "@types/node" "*" -ansi-escapes@^4.2.1: +"@types/rimraf@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.5.tgz#368fb04d59630b727fc05a74d2ca557f64a8ef98" + integrity sha512-YyP+VfeaqAyFmXoTh3HChxOQMyjByRMsHU7kc5KOJkSlXudhMhQIALbYV7rHh/l8d2lX3VUQzprrcAgWdRuU8g== + dependencies: + "@types/glob" "*" + "@types/node" "*" + +"@types/tmp@^0.0.33": + version "0.0.33" + resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.0.33.tgz#1073c4bc824754ae3d10cfab88ab0237ba964e4d" + integrity sha512-gVC1InwyVrO326wbBZw+AO3u2vRXz/iRWq9jYhpG4W8LXyIgDv3ZmcLQ5Q4Gs+gFMyqx+viFoFT+l3p61QFCmQ== + +accepts@~1.3.4, accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + +acorn@^8.8.2: + version "8.14.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== + +agent-base@^7.1.0, agent-base@^7.1.2: + version "7.1.3" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.3.tgz#29435eb821bc4194633a5b89e5bc4703bafc25a1" + integrity sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw== + +ansi-escapes@^4.2.1, ansi-escapes@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== @@ -125,6 +593,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.1.0.tgz#95ec409c69619d6cb1b8b34f14b660ef28ebd654" + integrity sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA== + ansi-styles@^4.0.0, ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" @@ -137,6 +610,11 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + anymatch@~3.1.2: version "3.1.3" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" @@ -145,6 +623,23 @@ anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" +application-config-path@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/application-config-path/-/application-config-path-0.1.1.tgz#8b5ac64ff6afdd9bd70ce69f6f64b6998f5f756e" + integrity sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw== + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -155,6 +650,11 @@ base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== + binary-extensions@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" @@ -169,6 +669,24 @@ bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" +body-parser@1.20.3: + version "1.20.3" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.3.tgz#1953431221c6fb5cd63c4b36d53fab0928e548c6" + integrity sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g== + dependencies: + bytes "3.1.2" + content-type "~1.0.5" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.13.0" + raw-body "2.5.2" + type-is "~1.6.18" + unpipe "1.0.0" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -177,13 +695,25 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@~3.0.2: +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.3, braces@~3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: fill-range "^7.1.1" +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + buffer@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" @@ -192,6 +722,43 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" +bundle-name@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" + integrity sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q== + dependencies: + run-applescript "^7.0.0" + +busboy@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" + integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== + dependencies: + streamsearch "^1.1.0" + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +cacache@^19.0.1: + version "19.0.1" + resolved "https://registry.yarnpkg.com/cacache/-/cacache-19.0.1.tgz#3370cc28a758434c85c2585008bd5bdcff17d6cd" + integrity sha512-hdsUxulXCi5STId78vRVYEtDAjq99ICAUktLTeTYsLoTE6Z8dS0c8pWNCxwdrk9YfJeobDZc2Y186hD/5ZQgFQ== + dependencies: + "@npmcli/fs" "^4.0.0" + fs-minipass "^3.0.0" + glob "^10.2.2" + lru-cache "^10.0.1" + minipass "^7.0.3" + minipass-collect "^2.0.1" + minipass-flush "^1.0.5" + minipass-pipeline "^1.2.4" + p-map "^7.0.2" + ssri "^12.0.0" + tar "^7.4.3" + unique-filename "^4.0.0" + cacheable-lookup@^5.0.3: version "5.0.4" resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" @@ -210,6 +777,22 @@ cacheable-request@^7.0.2: normalize-url "^6.0.1" responselike "^2.0.0" +call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" + integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + +call-bound@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.4.tgz#238de935d2a2a692928c538c7ccfa91067fd062a" + integrity sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg== + dependencies: + call-bind-apply-helpers "^1.0.2" + get-intrinsic "^1.3.0" + chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -218,7 +801,12 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: ansi-styles "^4.1.0" supports-color "^7.1.0" -chokidar@^3.5.1, chokidar@^3.5.2, chokidar@^3.5.3: +chalk@^5.3.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.4.1.tgz#1b48bf0963ec158dce2aacf69c093ae2dd2092d8" + integrity sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w== + +chokidar@^3.5.1, chokidar@^3.5.2, chokidar@^3.5.3, chokidar@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== @@ -233,6 +821,18 @@ chokidar@^3.5.1, chokidar@^3.5.2, chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" +chokidar@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30" + integrity sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA== + dependencies: + readdirp "^4.0.1" + +chownr@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-3.0.0.tgz#9855e64ecd240a9cc4267ce8a4aa5d24a1da15e4" + integrity sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g== + cli-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" @@ -240,6 +840,13 @@ cli-cursor@^3.1.0: dependencies: restore-cursor "^3.1.0" +cli-cursor@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-5.0.0.tgz#24a4831ecf5a6b01ddeb32fb71a4b2088b0dce38" + integrity sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw== + dependencies: + restore-cursor "^5.0.0" + cli-spinners@^2.5.0: version "2.9.2" resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" @@ -269,6 +876,26 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +command-exists@^1.2.4: + version "1.2.9" + resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" + integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== + +commander@^12.1.0: + version "12.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" + integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== + +commander@^13.1.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-13.1.0.tgz#776167db68c78f38dcce1f9b8d7b8b9a488abf46" + integrity sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw== + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + commander@^6.0.0: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" @@ -284,6 +911,51 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== +config-chain@^1.1.11: + version "1.1.13" + resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4" + integrity sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ== + dependencies: + ini "^1.3.4" + proto-list "~1.2.1" + +connect@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" + integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== + dependencies: + debug "2.6.9" + finalhandler "1.1.2" + parseurl "~1.3.3" + utils-merge "1.0.1" + +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + +content-type@~1.0.4, content-type@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== + +cookie-signature@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.2.2.tgz#57c7fc3cc293acab9fec54d73e15690ebe4a1793" + integrity sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg== + +cookie@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.1.tgz#2f73c42142d5d5cf71310a74fc4ae61670e5dbc9" + integrity sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w== + cross-spawn@6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -295,7 +967,7 @@ cross-spawn@6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.3, cross-spawn@^7.0.6: +cross-spawn@7.0.6, cross-spawn@^7.0.3, cross-spawn@^7.0.6: version "7.0.6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -304,13 +976,27 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6: shebang-command "^2.0.0" which "^2.0.1" -debug@^4.1.1: +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@4, debug@^4.1.1, debug@^4.3.4: version "4.4.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== dependencies: ms "^2.1.3" +debug@^3.1.0: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + decompress-response@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" @@ -318,6 +1004,24 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +default-browser-id@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/default-browser-id/-/default-browser-id-5.0.0.tgz#a1d98bf960c15082d8a3fa69e83150ccccc3af26" + integrity sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA== + +default-browser@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/default-browser/-/default-browser-5.2.1.tgz#7b7ba61204ff3e425b556869ae6d3e9d9f1712cf" + integrity sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg== + dependencies: + bundle-name "^4.1.0" + default-browser-id "^5.0.0" + defaults@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" @@ -330,11 +1034,79 @@ defer-to-connect@^2.0.0: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== +define-lazy-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" + integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +devcert@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/devcert/-/devcert-1.2.2.tgz#7ebbefeb74991e269ceafcd66f2bb78677c12652" + integrity sha512-UsLqvtJGPiGwsIZnJINUnFYaWgK7CroreGRndWHZkRD58tPFr3pVbbSyHR8lbh41+azR4jKvuNZ+eCoBZGA5kA== + dependencies: + "@types/configstore" "^2.1.1" + "@types/debug" "^0.0.30" + "@types/get-port" "^3.2.0" + "@types/glob" "^5.0.34" + "@types/lodash" "^4.14.92" + "@types/mkdirp" "^0.5.2" + "@types/node" "^8.5.7" + "@types/rimraf" "^2.0.2" + "@types/tmp" "^0.0.33" + application-config-path "^0.1.0" + command-exists "^1.2.4" + debug "^3.1.0" + eol "^0.9.1" + get-port "^3.2.0" + glob "^7.1.2" + is-valid-domain "^0.1.6" + lodash "^4.17.4" + mkdirp "^0.5.1" + password-prompt "^1.0.4" + rimraf "^2.6.2" + sudo-prompt "^8.2.0" + tmp "^0.0.33" + tslib "^1.10.0" + diff-sequences@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== +dunder-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" + integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== + dependencies: + call-bind-apply-helpers "^1.0.1" + es-errors "^1.3.0" + gopd "^1.2.0" + +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + elm-codegen@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/elm-codegen/-/elm-codegen-0.6.1.tgz#396bb401e05a0ea911ea289d688f247daa43b60a" @@ -345,6 +1117,25 @@ elm-codegen@^0.6.1: commander "^8.3.0" node-elm-compiler "^5.0.6" +elm-doc-preview@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/elm-doc-preview/-/elm-doc-preview-6.0.1.tgz#bbdeebeb97135e8bfa78c029520a2a14754db4f7" + integrity sha512-G/xgVRKpbLuqliQmBINQFE6I0YAwqET2+SabiyXE47kaVChkhIz91HlZudUvCzTG/CV2ci7AERtAwYzQ4bjOKA== + dependencies: + chalk "^5.3.0" + chokidar "^3.6.0" + commander "^12.1.0" + cross-spawn "^7.0.6" + express "^4.21.2" + express-ws "^5.0.2" + glob "^11.0.0" + latest-version "^9.0.0" + open "^10.1.0" + serve-index "^1.9.1" + serve-static "^1.16.2" + tmp "0.2.3" + ws "^8.18.0" + elm-format@^0.8.7: version "0.8.7" resolved "https://registry.yarnpkg.com/elm-format/-/elm-format-0.8.7.tgz#23d8a320ef896400b01b26609f99f579b2ed2d84" @@ -356,6 +1147,11 @@ elm-format@^0.8.7: "@avh4/elm-format-linux-x64" "0.8.7-2" "@avh4/elm-format-win32-x64" "0.8.7-2" +elm-hot@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/elm-hot/-/elm-hot-1.1.6.tgz#93e3962b40670e65f0a3640951b3add2702bfd0e" + integrity sha512-zYZJlfs7Gt4BdjA+D+857K+XAWzwwySJmXCgFpHW1dIEfaHSZCIPYPf7/jinZBLfKRkOAlKzI32AA84DY50g7Q== + elm-optimize-level-2@^0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/elm-optimize-level-2/-/elm-optimize-level-2-0.3.5.tgz#a0ac9b825d9ff68be50ed1b819780f88693a872a" @@ -368,6 +1164,36 @@ elm-optimize-level-2@^0.3.5: ts-union "^2.2.1" typescript "^4.5.5" +elm-pages@3.0.22: + version "3.0.22" + resolved "https://registry.yarnpkg.com/elm-pages/-/elm-pages-3.0.22.tgz#4ede3a0e4577b581243cb36c84826cb1afc6579d" + integrity sha512-Q2h9YPmIZu/q+LK2dFk7eh5EdpAPRUXekeZwCnzETZsw83wmN9bHZ64ekn3P7jL5ZpjS5VQ3FipvDI1AoOEkuA== + dependencies: + "@sindresorhus/merge-streams" "^4.0.0" + busboy "^1.6.0" + chokidar "^4.0.3" + cli-cursor "^5.0.0" + commander "^13.1.0" + connect "^3.7.0" + cookie-signature "^1.2.2" + cross-spawn "7.0.6" + devcert "^1.2.2" + elm-doc-preview "^6.0.1" + elm-hot "^1.1.6" + esbuild "^0.25.0" + fs-extra "^11.3.0" + globby "14.1.0" + gray-matter "^4.0.3" + jsesc "^3.1.0" + kleur "^4.1.5" + make-fetch-happen "^14.0.3" + memfs "^4.17.0" + micromatch "^4.0.8" + serve-static "^1.16.2" + terser "^5.39.0" + vite "^6.2.0" + which "^5.0.0" + elm-review@^2.13.2: version "2.13.2" resolved "https://registry.yarnpkg.com/elm-review/-/elm-review-2.13.2.tgz#e303bb976f6a6de70f1a3bd1f392f21eb9f34e49" @@ -424,6 +1250,28 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + +encodeurl@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-2.0.0.tgz#7b8ea898077d7e409d3ac45474ea38eaf0857a58" + integrity sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg== + +encoding@^0.1.13: + version "0.1.13" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" + integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== + dependencies: + iconv-lite "^0.6.2" + end-of-stream@^1.1.0: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -431,12 +1279,154 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" +eol@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/eol/-/eol-0.9.1.tgz#f701912f504074be35c6117a5c4ade49cd547acd" + integrity sha512-Ds/TEoZjwggRoz/Q2O7SE3i4Jm66mqTDfmdHdq/7DKVk3bro9Q8h6WdXKdPqFLMoqxrDK5SVRzHVPOS6uuGtrg== + +err-code@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/err-code/-/err-code-2.0.3.tgz#23c2f3b756ffdfc608d30e27c9a941024807e7f9" + integrity sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA== + +es-define-property@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" + integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz#1c4f2c4837327597ce69d2ca190a7fdd172338c1" + integrity sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA== + dependencies: + es-errors "^1.3.0" + +esbuild@^0.25.0: + version "0.25.2" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.25.2.tgz#55a1d9ebcb3aa2f95e8bba9e900c1a5061bc168b" + integrity sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ== + optionalDependencies: + "@esbuild/aix-ppc64" "0.25.2" + "@esbuild/android-arm" "0.25.2" + "@esbuild/android-arm64" "0.25.2" + "@esbuild/android-x64" "0.25.2" + "@esbuild/darwin-arm64" "0.25.2" + "@esbuild/darwin-x64" "0.25.2" + "@esbuild/freebsd-arm64" "0.25.2" + "@esbuild/freebsd-x64" "0.25.2" + "@esbuild/linux-arm" "0.25.2" + "@esbuild/linux-arm64" "0.25.2" + "@esbuild/linux-ia32" "0.25.2" + "@esbuild/linux-loong64" "0.25.2" + "@esbuild/linux-mips64el" "0.25.2" + "@esbuild/linux-ppc64" "0.25.2" + "@esbuild/linux-riscv64" "0.25.2" + "@esbuild/linux-s390x" "0.25.2" + "@esbuild/linux-x64" "0.25.2" + "@esbuild/netbsd-arm64" "0.25.2" + "@esbuild/netbsd-x64" "0.25.2" + "@esbuild/openbsd-arm64" "0.25.2" + "@esbuild/openbsd-x64" "0.25.2" + "@esbuild/sunos-x64" "0.25.2" + "@esbuild/win32-arm64" "0.25.2" + "@esbuild/win32-ia32" "0.25.2" + "@esbuild/win32-x64" "0.25.2" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + +express-ws@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/express-ws/-/express-ws-5.0.2.tgz#5b02d41b937d05199c6c266d7cc931c823bda8eb" + integrity sha512-0uvmuk61O9HXgLhGl3QhNSEtRsQevtmbL94/eILaliEADZBHZOQUAiHFrGPrgsjikohyrmSG5g+sCfASTt0lkQ== + dependencies: + ws "^7.4.6" + +express@^4.21.2: + version "4.21.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.21.2.tgz#cf250e48362174ead6cea4a566abef0162c1ec32" + integrity sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA== + dependencies: + accepts "~1.3.8" + array-flatten "1.1.1" + body-parser "1.20.3" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.7.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "2.0.0" + encodeurl "~2.0.0" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.3.1" + fresh "0.5.2" + http-errors "2.0.0" + merge-descriptors "1.0.3" + methods "~1.1.2" + on-finished "2.4.1" + parseurl "~1.3.3" + path-to-regexp "0.1.12" + proxy-addr "~2.0.7" + qs "6.13.0" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.19.0" + serve-static "1.16.2" + setprototypeof "1.2.0" + statuses "2.0.1" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + +fast-glob@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.3.tgz#d06d585ce8dba90a16b0505c543c3ccfb3aeb818" + integrity sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.8" + fastest-levenshtein@^1.0.16: version "1.0.16" resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== -fdir@^6.4.4: +fastq@^1.6.0: + version "1.19.1" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.19.1.tgz#d50eaba803c8846a883c16492821ebcd2cda55f5" + integrity sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ== + dependencies: + reusify "^1.0.4" + +fdir@^6.4.3, fdir@^6.4.4: version "6.4.4" resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.4.tgz#1cfcf86f875a883e19a8fab53622cfe992e8d2f9" integrity sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg== @@ -448,6 +1438,32 @@ fill-range@^7.1.1: dependencies: to-regex-range "^5.0.1" +finalhandler@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.3" + statuses "~1.5.0" + unpipe "~1.0.0" + +finalhandler@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.3.1.tgz#0c575f1d1d324ddd1da35ad7ece3df7d19088019" + integrity sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ== + dependencies: + debug "2.6.9" + encodeurl "~2.0.0" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + find-elm-dependencies@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/find-elm-dependencies/-/find-elm-dependencies-2.0.4.tgz#0a327fc8c0c0297b54115efbf0a9d6de474cfc89" @@ -478,16 +1494,84 @@ folder-hash@^3.3.0: graceful-fs "~4.2.0" minimatch "~3.0.4" +foreground-child@^3.1.0: + version "3.3.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.1.tgz#32e8e9ed1b68a3497befb9ac2b6adf92a638576f" + integrity sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw== + dependencies: + cross-spawn "^7.0.6" + signal-exit "^4.0.1" + +forwarded@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + +fs-extra@^11.3.0: + version "11.3.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.3.0.tgz#0daced136bbaf65a555a326719af931adc7a314d" + integrity sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fs-minipass@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-3.0.3.tgz#79a85981c4dc120065e96f62086bf6f9dc26cc54" + integrity sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw== + dependencies: + minipass "^7.0.3" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@~2.3.2: +fsevents@~2.3.2, fsevents@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +get-intrinsic@^1.2.5, get-intrinsic@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" + integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== + dependencies: + call-bind-apply-helpers "^1.0.2" + es-define-property "^1.0.1" + es-errors "^1.3.0" + es-object-atoms "^1.1.1" + function-bind "^1.1.2" + get-proto "^1.0.1" + gopd "^1.2.0" + has-symbols "^1.1.0" + hasown "^2.0.2" + math-intrinsics "^1.1.0" + +get-port@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc" + integrity sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg== + +get-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" + integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== + dependencies: + dunder-proto "^1.0.1" + es-object-atoms "^1.0.0" + get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" @@ -495,14 +1579,38 @@ get-stream@^5.1.0: dependencies: pump "^3.0.0" -glob-parent@~5.1.2: +glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@^7.1.3: +glob@^10.2.2: + version "10.4.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956" + integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^3.1.2" + minimatch "^9.0.4" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^1.11.1" + +glob@^11.0.0: + version "11.0.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.1.tgz#1c3aef9a59d680e611b53dcd24bb8639cef064d9" + integrity sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw== + dependencies: + foreground-child "^3.1.0" + jackspeak "^4.0.1" + minimatch "^10.0.0" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^2.0.0" + +glob@^7.1.2, glob@^7.1.3: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -514,6 +1622,23 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +globby@14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-14.1.0.tgz#138b78e77cf5a8d794e327b15dce80bf1fb0a73e" + integrity sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA== + dependencies: + "@sindresorhus/merge-streams" "^2.1.0" + fast-glob "^3.3.3" + ignore "^7.0.3" + path-type "^6.0.0" + slash "^5.1.0" + unicorn-magic "^0.3.0" + +gopd@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" + integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== + got@^11.8.5: version "11.8.6" resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" @@ -531,21 +1656,77 @@ got@^11.8.5: p-cancelable "^2.0.0" responselike "^2.0.0" -graceful-fs@^4.2.11, graceful-fs@~4.2.0: +graceful-fs@4.2.10: + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + +graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@~4.2.0: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== +gray-matter@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.3.tgz#e893c064825de73ea1f5f7d88c7a9f7274288798" + integrity sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q== + dependencies: + js-yaml "^3.13.1" + kind-of "^6.0.2" + section-matter "^1.0.0" + strip-bom-string "^1.0.0" + has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -http-cache-semantics@^4.0.0: +has-symbols@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" + integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== + +hasown@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + integrity sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A== + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + +http-proxy-agent@^7.0.0: + version "7.0.2" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" + integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== + dependencies: + agent-base "^7.1.0" + debug "^4.3.4" + http2-wrapper@^1.0.0-beta.5.2: version "1.0.3" resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d" @@ -554,16 +1735,53 @@ http2-wrapper@^1.0.0-beta.5.2: quick-lru "^5.1.1" resolve-alpn "^1.0.0" +https-proxy-agent@^7.0.1: + version "7.0.6" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz#da8dfeac7da130b05c2ba4b59c9b6cd66611a6b9" + integrity sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw== + dependencies: + agent-base "^7.1.2" + debug "4" + +hyperdyperid@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" + integrity sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A== + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.2: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + ieee754@^1.1.13: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== +ignore@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-7.0.3.tgz#397ef9315dfe0595671eefe8b633fec6943ab733" + integrity sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA== + immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -572,11 +1790,34 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@^2.0.4: +inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== + +ini@^1.3.4, ini@~1.3.0: + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== + +ip-address@^9.0.5: + version "9.0.5" + resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" + integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== + dependencies: + jsbn "1.1.0" + sprintf-js "^1.1.3" + +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -584,6 +1825,16 @@ is-binary-path@~2.1.0: dependencies: binary-extensions "^2.0.0" +is-docker@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-3.0.0.tgz#90093aa3106277d8a77a5910dbae71747e15a200" + integrity sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ== + +is-extendable@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" @@ -601,6 +1852,13 @@ is-glob@^4.0.1, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" +is-inside-container@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" + integrity sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA== + dependencies: + is-docker "^3.0.0" + is-interactive@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" @@ -616,11 +1874,46 @@ is-unicode-supported@^0.1.0: resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== +is-valid-domain@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-valid-domain/-/is-valid-domain-0.1.6.tgz#3c85469d2938f170c8f82ce6e52df8ad9fca8105" + integrity sha512-ZKtq737eFkZr71At8NxOFcP9O1K89gW3DkdrGMpp1upr/ueWjj+Weh4l9AI4rN0Gt8W2M1w7jrG2b/Yv83Ljpg== + dependencies: + punycode "^2.1.1" + +is-wsl@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-3.1.0.tgz#e1c657e39c10090afcbedec61720f6b924c3cbd2" + integrity sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw== + dependencies: + is-inside-container "^1.0.0" + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== +isexe@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-3.1.1.tgz#4a407e2bd78ddfb14bea0c27c6f7072dde775f0d" + integrity sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ== + +jackspeak@^3.1.2: + version "3.4.3" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a" + integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + +jackspeak@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.1.0.tgz#c489c079f2b636dc4cbe9b0312a13ff1282e561b" + integrity sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw== + dependencies: + "@isaacs/cliui" "^8.0.2" + jest-diff@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def" @@ -646,11 +1939,38 @@ jest-matcher-utils@^27.0.0: jest-get-type "^27.5.1" pretty-format "^27.5.1" +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsbn@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" + integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== + +jsesc@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d" + integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA== + json-buffer@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + keyv@^4.0.0: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -658,11 +1978,33 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + kleur@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== +kleur@^4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780" + integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ== + +ky@^1.2.0: + version "1.8.1" + resolved "https://registry.yarnpkg.com/ky/-/ky-1.8.1.tgz#b1adaa473bc30aced2bab4c408ec177b78d198f0" + integrity sha512-7Bp3TpsE+L+TARSnnDpk3xg8Idi8RwSLdj6CMbNWoOARIrGrbuLGusV0dYwbZOm4bB3jHNxSw8Wk/ByDqJEnDw== + +latest-version@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-9.0.0.tgz#e91ed216e7a4badc6f73b66c65adb46c58ec6ba1" + integrity sha512-7W0vV3rqv5tokqkBAFV1LbR7HPOWzXQDpDgEuib/aJ1jsZZx6x3c2mBI+TJhJzOhkGeaLbCKEHXEXLfirtG2JA== + dependencies: + package-json "^10.0.0" + lie@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" @@ -684,7 +2026,7 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -lodash@^4.17.19: +lodash@^4.17.19, lodash@^4.17.4: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -702,11 +2044,103 @@ lowercase-keys@^2.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== +lru-cache@^10.0.1, lru-cache@^10.2.0: + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== + +lru-cache@^11.0.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.1.0.tgz#afafb060607108132dbc1cf8ae661afb69486117" + integrity sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A== + +make-fetch-happen@^14.0.3: + version "14.0.3" + resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-14.0.3.tgz#d74c3ecb0028f08ab604011e0bc6baed483fcdcd" + integrity sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ== + dependencies: + "@npmcli/agent" "^3.0.0" + cacache "^19.0.1" + http-cache-semantics "^4.1.1" + minipass "^7.0.2" + minipass-fetch "^4.0.0" + minipass-flush "^1.0.5" + minipass-pipeline "^1.2.4" + negotiator "^1.0.0" + proc-log "^5.0.0" + promise-retry "^2.0.1" + ssri "^12.0.0" + +math-intrinsics@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" + integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== + +memfs@^4.17.0: + version "4.17.0" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-4.17.0.tgz#a3c4b5490b9b1e7df5d433adc163e08208ce7ca2" + integrity sha512-4eirfZ7thblFmqFjywlTmuWVSvccHAJbn1r8qQLzmTO11qcqpohOjmY2mFce6x7x7WtskzRqApPD0hv+Oa74jg== + dependencies: + "@jsonjoy.com/json-pack" "^1.0.3" + "@jsonjoy.com/util" "^1.3.0" + tree-dump "^1.0.1" + tslib "^2.0.0" + +merge-descriptors@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.3.tgz#d80319a65f3c7935351e5cfdac8f9318504dbed5" + integrity sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ== + +merge2@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== + +micromatch@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mimic-function@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/mimic-function/-/mimic-function-5.0.1.tgz#acbe2b3349f99b9deaca7fb70e48b83e94e67076" + integrity sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA== + mimic-response@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" @@ -717,6 +2151,13 @@ mimic-response@^3.1.0: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== +minimatch@^10.0.0: + version "10.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b" + integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ== + dependencies: + brace-expansion "^2.0.1" + minimatch@^3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -724,6 +2165,13 @@ minimatch@^3.1.1: dependencies: brace-expansion "^1.1.7" +minimatch@^9.0.4: + version "9.0.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + minimatch@~3.0.4: version "3.0.8" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" @@ -731,11 +2179,69 @@ minimatch@~3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.6: +minimist@^1.2.0, minimist@^1.2.6: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +minipass-collect@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/minipass-collect/-/minipass-collect-2.0.1.tgz#1621bc77e12258a12c60d34e2276ec5c20680863" + integrity sha512-D7V8PO9oaz7PWGLbCACuI1qEOsq7UKfLotx/C0Aet43fCUB/wfQ7DYeq2oR/svFJGYDHPr38SHATeaj/ZoKHKw== + dependencies: + minipass "^7.0.3" + +minipass-fetch@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/minipass-fetch/-/minipass-fetch-4.0.1.tgz#f2d717d5a418ad0b1a7274f9b913515d3e78f9e5" + integrity sha512-j7U11C5HXigVuutxebFadoYBbd7VSdZWggSe64NVdvWNBqGAiXPL2QVCehjmw7lY1oF9gOllYbORh+hiNgfPgQ== + dependencies: + minipass "^7.0.3" + minipass-sized "^1.0.3" + minizlib "^3.0.1" + optionalDependencies: + encoding "^0.1.13" + +minipass-flush@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/minipass-flush/-/minipass-flush-1.0.5.tgz#82e7135d7e89a50ffe64610a787953c4c4cbb373" + integrity sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw== + dependencies: + minipass "^3.0.0" + +minipass-pipeline@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz#68472f79711c084657c067c5c6ad93cddea8214c" + integrity sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A== + dependencies: + minipass "^3.0.0" + +minipass-sized@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/minipass-sized/-/minipass-sized-1.0.3.tgz#70ee5a7c5052070afacfbc22977ea79def353b70" + integrity sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g== + dependencies: + minipass "^3.0.0" + +minipass@^3.0.0: + version "3.3.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.6.tgz#7bba384db3a1520d18c9c0e5251c3444e95dd94a" + integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw== + dependencies: + yallist "^4.0.0" + +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.2, minipass@^7.0.3, minipass@^7.0.4, minipass@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" + integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== + +minizlib@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-3.0.2.tgz#f33d638eb279f664439aa38dc5f91607468cb574" + integrity sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA== + dependencies: + minipass "^7.1.2" + mkdirp@^0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" @@ -743,11 +2249,36 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.6" -ms@^2.1.3: +mkdirp@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" + integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + +ms@2.1.3, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +nanoid@^3.3.8: + version "3.3.11" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b" + integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w== + +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + +negotiator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-1.0.0.tgz#b6c91bb47172d69f93cfd7c357bbb529019b5f6a" + integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg== + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -773,6 +2304,25 @@ normalize-url@^6.0.1: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== +object-inspect@^1.13.3: + version "1.13.4" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.4.tgz#8375265e21bc20d0fa582c22e1b13485d6e00213" + integrity sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew== + +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww== + dependencies: + ee-first "1.1.1" + once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -787,6 +2337,23 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" +onetime@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-7.0.0.tgz#9f16c92d8c9ef5120e3acd9dd9957cceecc1ab60" + integrity sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ== + dependencies: + mimic-function "^5.0.0" + +open@^10.1.0: + version "10.1.1" + resolved "https://registry.yarnpkg.com/open/-/open-10.1.1.tgz#5fd814699e47ae3e1a09962d39f4f4441cae6c22" + integrity sha512-zy1wx4+P3PfhXSEPJNtZmJXfhkkIaxU1VauWIrDZw1O7uJRDRJtKr9n3Ic4NgbA16KyOxOXO2ng9gYwCdXuSXA== + dependencies: + default-browser "^5.2.1" + define-lazy-prop "^3.0.0" + is-inside-container "^1.0.0" + is-wsl "^3.1.0" + ora@^5.4.0: version "5.4.1" resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18" @@ -802,6 +2369,11 @@ ora@^5.4.0: strip-ansi "^6.0.0" wcwidth "^1.0.1" +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + p-cancelable@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" @@ -821,6 +2393,39 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +p-map@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-7.0.3.tgz#7ac210a2d36f81ec28b736134810f7ba4418cdb6" + integrity sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA== + +package-json-from-dist@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505" + integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw== + +package-json@^10.0.0: + version "10.0.1" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-10.0.1.tgz#e49ee07b8de63b638e7f1b5bb353733e428fe7d7" + integrity sha512-ua1L4OgXSBdsu1FPb7F3tYH0F48a6kxvod4pLUlGY9COeJAJQNX/sNH2IiEmsxw7lqYiAwrdHMjz1FctOsyDQg== + dependencies: + ky "^1.2.0" + registry-auth-token "^5.0.2" + registry-url "^6.0.1" + semver "^7.6.0" + +parseurl@~1.3.2, parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +password-prompt@^1.0.4: + version "1.1.3" + resolved "https://registry.yarnpkg.com/password-prompt/-/password-prompt-1.1.3.tgz#05e539f4e7ca4d6c865d479313f10eb9db63ee5f" + integrity sha512-HkrjG2aJlvF0t2BMH0e2LB/EHf3Lcq3fNMzy4GYHcQblAvOl+QQji1Lx7WRBMqpVK8p+KR7bCg7oqAMXtdgqyw== + dependencies: + ansi-escapes "^4.3.2" + cross-spawn "^7.0.3" + path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -841,7 +2446,38 @@ path-key@^3.1.0, path-key@^3.1.1: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -picomatch@^2.0.4, picomatch@^2.2.1: +path-scurry@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + +path-scurry@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.0.tgz#9f052289f23ad8bf9397a2a0425e7b8615c58580" + integrity sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg== + dependencies: + lru-cache "^11.0.0" + minipass "^7.1.2" + +path-to-regexp@0.1.12: + version "0.1.12" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7" + integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ== + +path-type@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-6.0.0.tgz#2f1bb6791a91ce99194caede5d6c5920ed81eb51" + integrity sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ== + +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -851,6 +2487,15 @@ picomatch@^4.0.2: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab" integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== +postcss@^8.5.3: + version "8.5.3" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.3.tgz#1463b6f1c7fb16fe258736cba29a2de35237eafb" + integrity sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A== + dependencies: + nanoid "^3.3.8" + picocolors "^1.1.1" + source-map-js "^1.2.1" + pretty-format@^27.0.0, pretty-format@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" @@ -860,6 +2505,19 @@ pretty-format@^27.0.0, pretty-format@^27.5.1: ansi-styles "^5.0.0" react-is "^17.0.1" +proc-log@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-5.0.0.tgz#e6c93cf37aef33f835c53485f314f50ea906a9d8" + integrity sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ== + +promise-retry@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/promise-retry/-/promise-retry-2.0.1.tgz#ff747a13620ab57ba688f5fc67855410c370da22" + integrity sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g== + dependencies: + err-code "^2.0.2" + retry "^0.12.0" + prompts@^2.2.1: version "2.4.2" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" @@ -868,6 +2526,19 @@ prompts@^2.2.1: kleur "^3.0.3" sisteransi "^1.0.5" +proto-list@~1.2.1: + version "1.2.4" + resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" + integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA== + +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + dependencies: + forwarded "0.2.0" + ipaddr.js "1.9.1" + pump@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.2.tgz#836f3edd6bc2ee599256c924ffe0d88573ddcbf8" @@ -876,11 +2547,53 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" +punycode@^2.1.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +qs@6.13.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906" + integrity sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg== + dependencies: + side-channel "^1.0.6" + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + quick-lru@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== +range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +rc@1.2.8: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + react-is@^17.0.1: version "17.0.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" @@ -895,6 +2608,11 @@ readable-stream@^3.4.0: string_decoder "^1.1.1" util-deprecate "^1.0.1" +readdirp@^4.0.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.1.2.tgz#eb85801435fbf2a7ee58f19e0921b068fc69948d" + integrity sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg== + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -902,6 +2620,20 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" +registry-auth-token@^5.0.2: + version "5.1.0" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-5.1.0.tgz#3c659047ecd4caebd25bc1570a3aa979ae490eca" + integrity sha512-GdekYuwLXLxMuFTwAPg5UKGLW/UXzQrZvH/Zj791BQif5T05T0RsaLfHc9q3ZOKi7n+BoprPD9mJ0O0k4xzUlw== + dependencies: + "@pnpm/npm-conf" "^2.1.0" + +registry-url@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-6.0.1.tgz#056d9343680f2f64400032b1e199faa692286c58" + integrity sha512-+crtS5QjFRqFCoQmvGduwYWEBng99ZvmFvF+cUJkGYF1L1BfU8C6Zp9T7f5vPAwyLkUExpvK+ANVZmGU49qi4Q== + dependencies: + rc "1.2.8" + resolve-alpn@^1.0.0: version "1.2.1" resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" @@ -922,6 +2654,31 @@ restore-cursor@^3.1.0: onetime "^5.1.0" signal-exit "^3.0.2" +restore-cursor@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-5.1.0.tgz#0766d95699efacb14150993f55baf0953ea1ebe7" + integrity sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA== + dependencies: + onetime "^7.0.0" + signal-exit "^4.1.0" + +retry@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" + integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow== + +reusify@^1.0.4: + version "1.1.0" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.1.0.tgz#0fe13b9522e1473f51b558ee796e08f11f9b489f" + integrity sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw== + +rimraf@^2.6.2: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + rimraf@~2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" @@ -929,16 +2686,127 @@ rimraf@~2.6.2: dependencies: glob "^7.1.3" -safe-buffer@~5.2.0: +rollup@^4.34.9: + version "4.40.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.40.0.tgz#13742a615f423ccba457554f006873d5a4de1920" + integrity sha512-Noe455xmA96nnqH5piFtLobsGbCij7Tu+tb3c1vYjNbTkfzGqXqQXG3wJaYXkRZuQ0vEYN4bhwg7QnIrqB5B+w== + dependencies: + "@types/estree" "1.0.7" + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.40.0" + "@rollup/rollup-android-arm64" "4.40.0" + "@rollup/rollup-darwin-arm64" "4.40.0" + "@rollup/rollup-darwin-x64" "4.40.0" + "@rollup/rollup-freebsd-arm64" "4.40.0" + "@rollup/rollup-freebsd-x64" "4.40.0" + "@rollup/rollup-linux-arm-gnueabihf" "4.40.0" + "@rollup/rollup-linux-arm-musleabihf" "4.40.0" + "@rollup/rollup-linux-arm64-gnu" "4.40.0" + "@rollup/rollup-linux-arm64-musl" "4.40.0" + "@rollup/rollup-linux-loongarch64-gnu" "4.40.0" + "@rollup/rollup-linux-powerpc64le-gnu" "4.40.0" + "@rollup/rollup-linux-riscv64-gnu" "4.40.0" + "@rollup/rollup-linux-riscv64-musl" "4.40.0" + "@rollup/rollup-linux-s390x-gnu" "4.40.0" + "@rollup/rollup-linux-x64-gnu" "4.40.0" + "@rollup/rollup-linux-x64-musl" "4.40.0" + "@rollup/rollup-win32-arm64-msvc" "4.40.0" + "@rollup/rollup-win32-ia32-msvc" "4.40.0" + "@rollup/rollup-win32-x64-msvc" "4.40.0" + fsevents "~2.3.2" + +run-applescript@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-7.0.0.tgz#e5a553c2bffd620e169d276c1cd8f1b64778fbeb" + integrity sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A== + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +safe-buffer@5.2.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +section-matter@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/section-matter/-/section-matter-1.0.0.tgz#e9041953506780ec01d59f292a19c7b850b84167" + integrity sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA== + dependencies: + extend-shallow "^2.0.1" + kind-of "^6.0.0" + semver@^5.5.0: version "5.7.2" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== +semver@^7.3.5, semver@^7.6.0: + version "7.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.1.tgz#abd5098d82b18c6c81f6074ff2647fd3e7220c9f" + integrity sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA== + +send@0.19.0: + version "0.19.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.19.0.tgz#bbc5a388c8ea6c048967049dbeac0e4a3f09d7f8" + integrity sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + +serve-index@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" + integrity sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw== + dependencies: + accepts "~1.3.4" + batch "0.6.1" + debug "2.6.9" + escape-html "~1.0.3" + http-errors "~1.6.2" + mime-types "~2.1.17" + parseurl "~1.3.2" + +serve-static@1.16.2, serve-static@^1.16.2: + version "1.16.2" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.2.tgz#b6a5343da47f6bdd2673848bf45754941e803296" + integrity sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw== + dependencies: + encodeurl "~2.0.0" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.19.0" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -963,16 +2831,147 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +side-channel-list@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/side-channel-list/-/side-channel-list-1.0.0.tgz#10cb5984263115d3b7a0e336591e290a830af8ad" + integrity sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA== + dependencies: + es-errors "^1.3.0" + object-inspect "^1.13.3" + +side-channel-map@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/side-channel-map/-/side-channel-map-1.0.1.tgz#d6bb6b37902c6fef5174e5f533fab4c732a26f42" + integrity sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + get-intrinsic "^1.2.5" + object-inspect "^1.13.3" + +side-channel-weakmap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz#11dda19d5368e40ce9ec2bdc1fb0ecbc0790ecea" + integrity sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + get-intrinsic "^1.2.5" + object-inspect "^1.13.3" + side-channel-map "^1.0.1" + +side-channel@^1.0.6: + version "1.1.0" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.1.0.tgz#c3fcff9c4da932784873335ec9765fa94ff66bc9" + integrity sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw== + dependencies: + es-errors "^1.3.0" + object-inspect "^1.13.3" + side-channel-list "^1.0.0" + side-channel-map "^1.0.1" + side-channel-weakmap "^1.0.2" + signal-exit@^3.0.2: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.0.1, signal-exit@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== +slash@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce" + integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg== + +smart-buffer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" + integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== + +socks-proxy-agent@^8.0.3: + version "8.0.5" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz#b9cdb4e7e998509d7659d689ce7697ac21645bee" + integrity sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw== + dependencies: + agent-base "^7.1.2" + debug "^4.3.4" + socks "^2.8.3" + +socks@^2.8.3: + version "2.8.4" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.4.tgz#07109755cdd4da03269bda4725baa061ab56d5cc" + integrity sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ== + dependencies: + ip-address "^9.0.5" + smart-buffer "^4.2.0" + +source-map-js@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== + +source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +sprintf-js@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" + integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +ssri@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-12.0.0.tgz#bcb4258417c702472f8191981d3c8a771fee6832" + integrity sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ== + dependencies: + minipass "^7.0.3" + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +"statuses@>= 1.4.0 < 2", statuses@~1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== + +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== + +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^4.1.0: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -982,6 +2981,15 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string_decoder@^1.1.1: version "1.3.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" @@ -989,6 +2997,13 @@ string_decoder@^1.1.1: dependencies: safe-buffer "~5.2.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -996,6 +3011,28 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + +strip-bom-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom-string/-/strip-bom-string-1.0.0.tgz#e5211e9224369fbb81d633a2f00044dc8cedad92" + integrity sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g== + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== + +sudo-prompt@^8.2.0: + version "8.2.5" + resolved "https://registry.yarnpkg.com/sudo-prompt/-/sudo-prompt-8.2.5.tgz#cc5ef3769a134bb94b24a631cc09628d4d53603e" + integrity sha512-rlBo3HU/1zAJUrkY6jNxDOC9eVYliG6nS4JA8u8KAshITd07tafMc/Br7xQwCSseXwJ2iCcHCE8SNWX3q8Z+kw== + supports-color@^7.0.0, supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -1011,6 +3048,18 @@ supports-hyperlinks@^2.0.0: has-flag "^4.0.0" supports-color "^7.0.0" +tar@^7.4.3: + version "7.4.3" + resolved "https://registry.yarnpkg.com/tar/-/tar-7.4.3.tgz#88bbe9286a3fcd900e94592cda7a22b192e80571" + integrity sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw== + dependencies: + "@isaacs/fs-minipass" "^4.0.0" + chownr "^3.0.0" + minipass "^7.1.2" + minizlib "^3.0.1" + mkdirp "^3.0.1" + yallist "^5.0.0" + temp@^0.9.0: version "0.9.4" resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.4.tgz#cd20a8580cb63635d0e4e9d4bd989d44286e7620" @@ -1027,12 +3076,27 @@ terminal-link@^2.1.1: ansi-escapes "^4.2.1" supports-hyperlinks "^2.0.0" +terser@^5.39.0: + version "5.39.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.39.0.tgz#0e82033ed57b3ddf1f96708d123cca717d86ca3a" + integrity sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw== + dependencies: + "@jridgewell/source-map" "^0.3.3" + acorn "^8.8.2" + commander "^2.20.0" + source-map-support "~0.5.20" + +thingies@^1.20.0: + version "1.21.0" + resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.21.0.tgz#e80fbe58fd6fdaaab8fad9b67bd0a5c943c445c1" + integrity sha512-hsqsJsFMsV+aD4s3CWKk85ep/3I9XzYV/IXaSouJMYIoDlgyi11cBhsqYe9/geRfB0YIikBQg6raRaM+nIMP9g== + tiny-decoders@^23.0.0: version "23.0.0" resolved "https://registry.yarnpkg.com/tiny-decoders/-/tiny-decoders-23.0.0.tgz#49acf51455612c7729b04be6147fcea6d2a20f8b" integrity sha512-gQB+za3EW9JN1ASDmrVl1a1I6Q/jzg4M75YLI9ToHCdCW4/9KvBTTNH4u3kFbg8e+/8Zn68VRF+ayuiPNqYAmg== -tinyglobby@^0.2.10: +tinyglobby@^0.2.10, tinyglobby@^0.2.12: version "0.2.13" resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.13.tgz#a0e46515ce6cbcd65331537e57484af5a7b2ff7e" integrity sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw== @@ -1040,6 +3104,18 @@ tinyglobby@^0.2.10: fdir "^6.4.4" picomatch "^4.0.2" +tmp@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae" + integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w== + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -1047,16 +3123,44 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +tree-dump@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.0.2.tgz#c460d5921caeb197bde71d0e9a7b479848c5b8ac" + integrity sha512-dpev9ABuLWdEubk+cIaI9cHwRNNDjkBBLXTwI4UCUFdQ5xXKqNXoK4FEciw/vxf+NQ7Cb7sGUyeUtORvHIdRXQ== + ts-union@^2.2.1: version "2.3.0" resolved "https://registry.yarnpkg.com/ts-union/-/ts-union-2.3.0.tgz#2dc5240e0a1ceea2159bf06cacdc96a78475dd04" integrity sha512-OP+W9WoYvGlOMjc90D6nYz60jU1zQlXAg3VBtuSoMDejY94PaORkya9HtHjaaqqwA4I5/hN38fmKK0nSWj7jPg== +tslib@^1.10.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +tslib@^2.0.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + type-fest@^0.21.3: version "0.21.3" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + typescript@^4.5.5: version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" @@ -1072,11 +3176,64 @@ undici-types@~6.21.0: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== +unicorn-magic@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.3.0.tgz#4efd45c85a69e0dd576d25532fbfa22aa5c8a104" + integrity sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA== + +unique-filename@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-4.0.0.tgz#a06534d370e7c977a939cd1d11f7f0ab8f1fed13" + integrity sha512-XSnEewXmQ+veP7xX2dS5Q4yZAvO40cBN2MWkJ7D/6sW4Dg6wYBNwM1Vrnz1FhH5AdeLIlUXRI9e28z1YZi71NQ== + dependencies: + unique-slug "^5.0.0" + +unique-slug@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-5.0.0.tgz#ca72af03ad0dbab4dad8aa683f633878b1accda8" + integrity sha512-9OdaqO5kwqR+1kVgHAhsp5vPNU0hnxRa26rBFNfNgM7M6pNtgzeBn3s/xbyCQL3dcjzOatcef6UUHpB/6MaETg== + dependencies: + imurmurhash "^0.1.4" + +universalify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + util-deprecate@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== + +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + +vite@^6.2.0: + version "6.3.2" + resolved "https://registry.yarnpkg.com/vite/-/vite-6.3.2.tgz#4c1bb01b1cea853686a191657bbc14272a038f0a" + integrity sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg== + dependencies: + esbuild "^0.25.0" + fdir "^6.4.3" + picomatch "^4.0.2" + postcss "^8.5.3" + rollup "^4.34.9" + tinyglobby "^0.2.12" + optionalDependencies: + fsevents "~2.3.3" + wcwidth@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" @@ -1098,6 +3255,22 @@ which@^2.0.1, which@^2.0.2: dependencies: isexe "^2.0.0" +which@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/which/-/which-5.0.0.tgz#d93f2d93f79834d4363c7d0c23e00d07c466c8d6" + integrity sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ== + dependencies: + isexe "^3.1.1" + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -1107,16 +3280,40 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== +ws@^7.4.6: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + ws@^8.18.0: version "8.18.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.1.tgz#ea131d3784e1dfdff91adb0a4a116b127515e3cb" integrity sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w== +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yallist@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-5.0.0.tgz#00e2de443639ed0d78fd87de0d27469fbcffb533" + integrity sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 0673bdb1c07d4193f58d827b587bf394cbba72df Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 19:36:52 +0200 Subject: [PATCH 120/139] Merge updates to elm-glsl --- vendored/miniBill/elm-glsl/1.0.0/LICENSE | 12 +- vendored/miniBill/elm-glsl/1.0.0/README.md | 2 +- .../elm-glsl/1.0.0/src/Glsl/Helpers.elm | 119 +++++++++++++++++- 3 files changed, 129 insertions(+), 4 deletions(-) diff --git a/vendored/miniBill/elm-glsl/1.0.0/LICENSE b/vendored/miniBill/elm-glsl/1.0.0/LICENSE index a1773b4d..83f164fe 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/LICENSE +++ b/vendored/miniBill/elm-glsl/1.0.0/LICENSE @@ -1 +1,11 @@ -BSD-3 +Copyright 2025 Leonardo Taglialegne + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendored/miniBill/elm-glsl/1.0.0/README.md b/vendored/miniBill/elm-glsl/1.0.0/README.md index 6ff91132..43d23a59 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/README.md +++ b/vendored/miniBill/elm-glsl/1.0.0/README.md @@ -1 +1 @@ -A library to produce glsl shaders as strings. +A library to produce GLSL shaders as strings. diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm index b8138d6e..0d2770fe 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Helpers.elm @@ -1,6 +1,56 @@ -module Glsl.Helpers exposing (File, FunDecl, assign, assignAdd, assignBy, assignOut, boolT, break, const, const_, continue, decl, def, def1, expr, expressionToGlsl, fileToGlsl, float, floatT, for, forDown, forLeq, fun0, fun1, fun1_, fun2, fun2_, fun3, fun3_, fun4, fun4_, fun5, fun5_, funDeclToGlsl, ifElse, if_, in_, intT, main_, mat2T, mat3, mat3T, nop, out, return, statementToGlsl, vec2, vec2T, vec3, vec3T, vec4, vec4T, voidT) +module Glsl.Helpers exposing + ( File, FunDecl + , boolT, bvec2T, bvec3T, bvec4T + , floatT, vec2T, vec3T, vec4T, mat2T, mat3T, mat4T + , doubleT, dvec2T, dvec3T, dvec4T, dmat2T, dmat3T, dmat4T + , intT + , voidT + , in_, out + , const, const_ + , decl, def, def1 + , fun0, fun1, fun2, fun3, fun4, fun5 + , fun1_, fun2_, fun3_, fun4_, fun5_ + , float, vec2, vec3, vec4, mat2, mat3, mat4 + , if_, ifElse, for, forDown, forLeq + , break, continue, return, nop + , assign, assignAdd, assignBy, assignOut + , expr + , expressionToGlsl, statementToGlsl, funDeclToGlsl, fileToGlsl + , main_ + ) + +{-| + +@docs File, FunDecl + +@docs boolT, bvec2T, bvec3T, bvec4T +@docs floatT, vec2T, vec3T, vec4T, mat2T, mat3T, mat4T +@docs doubleT, dvec2T, dvec3T, dvec4T, dmat2T, dmat3T, dmat4T +@docs intT +@docs voidT + +@docs in_, out + +@docs const, const_ + +@docs decl, def, def1 +@docs fun0, fun1, fun2, fun3, fun4, fun5 +@docs fun1_, fun2_, fun3_, fun4_, fun5_ + +@docs float, vec2, vec3, vec4, mat2, mat3, mat4 + +@docs if_, ifElse, for, forDown, forLeq +@docs break, continue, return, nop +@docs assign, assignAdd, assignBy, assignOut +@docs expr + +@docs expressionToGlsl, statementToGlsl, funDeclToGlsl, fileToGlsl -import Glsl exposing (BinaryOperation(..), Bool_, Declaration(..), Expr(..), Expression(..), Float_, Int_, Mat2, Mat3, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeVar, withContinuation, withExpression, withStatement) +@docs main_ + +-} + +import Glsl exposing (BVec2, BVec3, BVec4, BinaryOperation(..), Bool_, DMat2, DMat3, DMat4, DVec2, DVec3, DVec4, Declaration(..), Double, Expr(..), Expression(..), Float_, Int_, Mat2, Mat3, Mat4, Out, RelationOperation(..), Stat(..), Statement(..), Type(..), TypedName(..), TypingFunction, UnaryOperation(..), Vec2, Vec3, Vec4, build, buildStatement, unsafeCall0, unsafeCall1, unsafeCall2, unsafeCall3, unsafeCall4, unsafeCall5, unsafeMap2, unsafeVar, withContinuation, withExpression, withStatement) import Glsl.PrettyPrinter import Set import SortedSet @@ -469,11 +519,21 @@ vec4 = def vec4T +mat2 : String -> Expression Mat2 -> (Expression Mat2 -> Statement r) -> Statement r +mat2 = + def mat2T + + mat3 : String -> Expression Mat3 -> (Expression Mat3 -> Statement r) -> Statement r mat3 = def mat3T +mat4 : String -> Expression Mat4 -> (Expression Mat4 -> Statement r) -> Statement r +mat4 = + def mat4T + + def1 : ( TypedName a, Expression a ) -> (Expression a -> Statement r) @@ -548,31 +608,86 @@ floatT n = TypedName TFloat n +doubleT : TypingFunction Double +doubleT n = + TypedName TDouble n + + vec2T : TypingFunction Vec2 vec2T n = TypedName TVec2 n +bvec2T : TypingFunction BVec2 +bvec2T n = + TypedName TBVec2 n + + +dvec2T : TypingFunction DVec2 +dvec2T n = + TypedName TDVec2 n + + vec3T : TypingFunction Vec3 vec3T n = TypedName TVec3 n +bvec3T : TypingFunction BVec3 +bvec3T n = + TypedName TBVec3 n + + +dvec3T : TypingFunction DVec3 +dvec3T n = + TypedName TDVec3 n + + vec4T : TypingFunction Vec4 vec4T n = TypedName TVec4 n +bvec4T : TypingFunction BVec4 +bvec4T n = + TypedName TBVec4 n + + +dvec4T : TypingFunction DVec4 +dvec4T n = + TypedName TDVec4 n + + mat2T : TypingFunction Mat2 mat2T n = TypedName TMat2 n +dmat2T : TypingFunction DMat2 +dmat2T n = + TypedName TDMat2 n + + mat3T : TypingFunction Mat3 mat3T n = TypedName TMat3 n +dmat3T : TypingFunction DMat3 +dmat3T n = + TypedName TDMat3 n + + +mat4T : TypingFunction Mat4 +mat4T n = + TypedName TMat4 n + + +dmat4T : TypingFunction DMat4 +dmat4T n = + TypedName TDMat4 n + + out : TypingFunction t -> TypingFunction t out inner n = let From 0e8aa807fed63dc48858e7b1e440a276c747f4ad Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 19:37:59 +0200 Subject: [PATCH 121/139] Update dependencies --- elm.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/elm.json b/elm.json index ac8245ba..c6bad12b 100644 --- a/elm.json +++ b/elm.json @@ -11,9 +11,6 @@ "direct": { "avh4/elm-color": "1.0.0", "dillonkearns/elm-markdown": "7.0.1", - "elm-community/list-extra": "8.7.0", - "elm-community/maybe-extra": "5.3.0", - "elm-community/result-extra": "2.4.0", "elm/browser": "1.0.2", "elm/bytes": "1.0.8", "elm/core": "1.0.5", @@ -23,10 +20,13 @@ "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/url": "1.0.0", + "elm-community/list-extra": "8.7.0", + "elm-community/maybe-extra": "5.3.0", + "elm-community/result-extra": "2.4.0", "lemol/ant-design-icons-elm-ui": "1.0.0", - "miniBill/elm-codec": "2.0.0", + "miniBill/elm-codec": "2.2.0", "miniBill/elm-ui-with-context": "2.0.0", - "miniBill/elm-unicode": "1.0.3" + "miniBill/elm-unicode": "1.1.1" }, "indirect": { "elm/regex": "1.0.0", @@ -40,10 +40,10 @@ }, "test-dependencies": { "direct": { - "elm-explorations/test": "2.1.1" + "elm-explorations/test": "2.2.0" }, "indirect": { "elm/random": "1.0.0" } } -} \ No newline at end of file +} From 8be9845c852fa92000ba2458fa539408cd4fd79f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 19:54:51 +0200 Subject: [PATCH 122/139] Implement missing bits in codegen --- codegen/Generate.elm | 73 ++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index f1082974..3dbb75da 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -6,7 +6,7 @@ import Elm.Annotation as Type import Gen.CodeGen.Generate as Generate import Gen.Debug import Gen.Glsl -import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), Function, Stat(..), Statement(..), Type(..), Uniform) +import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), Uniform) import Glsl.Parser import Glsl.PrettyPrinter import List.Extra @@ -375,79 +375,79 @@ typeToAnnotation type_ = Gen.Glsl.annotation_.out (typeToAnnotation tt) TUint -> - Debug.todo "branch 'TUint' not implemented" + Type.int TUVec2 -> - Debug.todo "branch 'TUVec2' not implemented" + Gen.Glsl.annotation_.uVec2 TUVec3 -> - Debug.todo "branch 'TUVec3' not implemented" + Gen.Glsl.annotation_.uVec3 TUVec4 -> - Debug.todo "branch 'TUVec4' not implemented" + Gen.Glsl.annotation_.uVec4 TDouble -> - Debug.todo "branch 'TDouble' not implemented" + Type.float TDVec2 -> - Debug.todo "branch 'TDVec2' not implemented" + Gen.Glsl.annotation_.dVec2 TDVec3 -> - Debug.todo "branch 'TDVec3' not implemented" + Gen.Glsl.annotation_.dVec3 TDVec4 -> - Debug.todo "branch 'TDVec4' not implemented" + Gen.Glsl.annotation_.dVec4 TMat2 -> - Debug.todo "branch 'TMat2' not implemented" + Gen.Glsl.annotation_.mat2 TMat4 -> - Debug.todo "branch 'TMat4' not implemented" + Gen.Glsl.annotation_.mat4 TMat23 -> - Debug.todo "branch 'TMat23' not implemented" + Gen.Glsl.annotation_.mat23 TMat24 -> - Debug.todo "branch 'TMat24' not implemented" + Gen.Glsl.annotation_.mat24 TMat32 -> - Debug.todo "branch 'TMat32' not implemented" + Gen.Glsl.annotation_.mat32 TMat34 -> - Debug.todo "branch 'TMat34' not implemented" + Gen.Glsl.annotation_.mat34 TMat42 -> - Debug.todo "branch 'TMat42' not implemented" + Gen.Glsl.annotation_.mat42 TMat43 -> - Debug.todo "branch 'TMat43' not implemented" + Gen.Glsl.annotation_.mat43 TDMat2 -> - Debug.todo "branch 'TDMat2' not implemented" + Gen.Glsl.annotation_.dMat2 TDMat3 -> - Debug.todo "branch 'TDMat3' not implemented" + Gen.Glsl.annotation_.dMat3 TDMat4 -> - Debug.todo "branch 'TDMat4' not implemented" + Gen.Glsl.annotation_.dMat4 TDMat23 -> - Debug.todo "branch 'TDMat23' not implemented" + Gen.Glsl.annotation_.dMat23 TDMat24 -> - Debug.todo "branch 'TDMat24' not implemented" + Gen.Glsl.annotation_.dMat24 TDMat32 -> - Debug.todo "branch 'TDMat32' not implemented" + Gen.Glsl.annotation_.dMat32 TDMat34 -> - Debug.todo "branch 'TDMat34' not implemented" + Gen.Glsl.annotation_.dMat34 TDMat42 -> - Debug.todo "branch 'TDMat42' not implemented" + Gen.Glsl.annotation_.dMat42 TDMat43 -> - Debug.todo "branch 'TDMat43' not implemented" + Gen.Glsl.annotation_.dMat43 variableHasType : String -> Type -> Env -> Env @@ -691,9 +691,6 @@ binaryOperationToString bop = ShiftRight -> ">>" - RelationOperation _ -> - Debug.todo "branch 'RelationOperation _' not implemented" - BitwiseAnd -> "&" @@ -742,6 +739,24 @@ binaryOperationToString bop = Comma -> "," + RelationOperation LessThan -> + "<" + + RelationOperation GreaterThan -> + ">" + + RelationOperation LessThanOrEquals -> + "<=" + + RelationOperation GreaterThanOrEquals -> + ">=" + + RelationOperation Equals -> + "==" + + RelationOperation NotEquals -> + "!=" + fullName : String -> List Type -> String fullName baseName argTypes = From b27a8abee15ced96728a4590960eca4c0b31a678 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:05:45 +0200 Subject: [PATCH 123/139] Switch to using elm-codegen via elm-pages --- codegen/Generate.elm | 70 +++++++++++++++++++++++++++----------------- codegen/elm.json | 29 +++++++++++++++++- 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/codegen/Generate.elm b/codegen/Generate.elm index 3dbb75da..8ae4fb9e 100644 --- a/codegen/Generate.elm +++ b/codegen/Generate.elm @@ -1,45 +1,61 @@ -module Generate exposing (main) +module Generate exposing (run) +import BackendTask exposing (BackendTask) +import BackendTask.File as File import Dict exposing (Dict) import Elm import Elm.Annotation as Type -import Gen.CodeGen.Generate as Generate +import FatalError exposing (FatalError) import Gen.Debug import Gen.Glsl import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), Uniform) import Glsl.Parser import Glsl.PrettyPrinter import List.Extra +import Pages.Script as Script exposing (Script) import Parser import Result.Extra import SortedSet exposing (SortedSet) -main : Program String () () -main = - let - file : String -> Elm.File - file glsl = - generate glsl - |> List.Extra.gatherEqualsBy Tuple.first - |> List.map - (\( head, tail ) -> - let - group : List Elm.Declaration - group = - List.map Tuple.second (head :: tail) - in - case Tuple.first head of - Just groupName -> - Elm.group (Elm.docs ("#" ++ groupName) :: group) - - Nothing -> - Elm.group group - ) - |> Elm.file - [ "Glsl", "Functions", "NuPlot" ] - in - Generate.fromText (\glsl -> [ file glsl ]) +run : Script +run = + Script.withoutCliOptions task + + +task : BackendTask FatalError () +task = + File.rawFile "codegen/functions.frag" + |> BackendTask.allowFatal + |> BackendTask.andThen + (\glsl -> + let + file = + generate glsl + |> List.Extra.gatherEqualsBy Tuple.first + |> List.map + (\( head, tail ) -> + let + group : List Elm.Declaration + group = + List.map Tuple.second (head :: tail) + in + case Tuple.first head of + Just groupName -> + Elm.group (Elm.docs ("#" ++ groupName) :: group) + + Nothing -> + Elm.group group + ) + |> Elm.file + [ "Glsl", "Functions", "NuPlot" ] + in + Script.writeFile + { path = file.path + , body = file.contents + } + |> BackendTask.allowFatal + ) generate : String -> List ( Maybe String, Elm.Declaration ) diff --git a/codegen/elm.json b/codegen/elm.json index d5eb426a..d3fe1698 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -7,6 +7,7 @@ "elm-version": "0.19.1", "dependencies": { "direct": { + "dillonkearns/elm-pages": "10.2.1", "elm/browser": "1.0.2", "elm/core": "1.0.5", "elm/html": "1.0.0", @@ -19,15 +20,41 @@ "pithub/elm-parser-bug-workaround": "1.0.0" }, "indirect": { + "Chadtech/elm-bool-extra": "2.4.2", + "avh4/elm-color": "1.0.0", + "danfishgold/base64-bytes": "1.1.0", + "danyx23/elm-mimetype": "4.0.1", + "dillonkearns/elm-bcp47-language-tag": "2.0.0", + "dillonkearns/elm-cli-options-parser": "3.2.0", + "dillonkearns/elm-date-or-date-time": "2.0.0", + "dillonkearns/elm-form": "3.0.1", + "elm/bytes": "1.0.8", + "elm/file": "1.0.5", + "elm/http": "2.0.0", + "elm/random": "1.0.0", + "elm/regex": "1.0.0", "elm/time": "1.0.0", "elm/url": "1.0.0", "elm/virtual-dom": "1.0.3", "elm-community/basics-extra": "4.1.0", + "elm-community/maybe-extra": "5.3.0", + "fredcy/elm-parseint": "2.0.1", + "jluckyiv/elm-utc-date-strings": "1.0.0", + "justinmimbs/date": "4.1.0", + "miniBill/elm-codec": "2.2.0", + "miniBill/elm-unicode": "1.1.1", + "noahzgordon/elm-color-extra": "1.0.2", "pithub/elm-parser-extra": "1.0.0", + "robinheghan/fnv1a": "1.0.0", + "robinheghan/murmur3": "1.0.0", + "rtfeldman/elm-css": "18.0.0", "rtfeldman/elm-hex": "1.0.0", + "rtfeldman/elm-iso8601-date-strings": "1.1.4", "stil4m/elm-syntax": "7.3.8", "stil4m/structured-writer": "1.0.3", - "the-sett/elm-pretty-printer": "3.1.1" + "the-sett/elm-pretty-printer": "3.1.1", + "the-sett/elm-syntax-dsl": "6.0.3", + "wolfadex/elm-ansi": "3.0.0" } }, "test-dependencies": { From 3e2fcb1140c719441295c7f5bfb96c6791f8899f Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:11:05 +0200 Subject: [PATCH 124/139] Restoring elm-codegen functionality --- Makefile | 12 +++++++----- codegen/.gitignore | 2 +- codegen/elm.json | 3 ++- codegen/{ => src}/Generate.elm | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) rename codegen/{ => src}/Generate.elm (99%) diff --git a/Makefile b/Makefile index 7310be55..b63ab6f8 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,16 @@ build: generated/Glsl/Functions/NuPlot.elm src/optimized.js Makefile src/optimized.js: $(ELM_FILES) Makefile yarn elm-optimize-level-2 src/elm/UI.elm --output $@ -generated/Glsl/Functions/NuPlot.elm: codegen/functions.frag codegen/Generate.elm codegen/Gen/Glsl.elm Makefile +generated/Glsl/Functions/NuPlot.elm: codegen/functions.frag codegen/src/Generate.elm codegen/bindings/Gen/Glsl.elm Makefile rm -rf generated - yarn elm-codegen run --flags-from $< codegen/Generate.elm - elm-format --yes $@ + yarn elm-pages run codegen/src/Generate.elm + elm-format --yes generated -codegen/Gen/Glsl.elm: codegen/Generate.elm codegen/elm.codegen.json Makefile - rm -rf codegen/Gen +codegen/bindings/Gen/Glsl.elm: codegen/elm.codegen.json Makefile + rm -rf codegen/bindings yarn elm-codegen install + mkdir -p codegen/bindings + mv codegen/Gen codegen/bindings .PHONY: clean diff --git a/codegen/.gitignore b/codegen/.gitignore index 1f0e079e..a6ea7088 100644 --- a/codegen/.gitignore +++ b/codegen/.gitignore @@ -1 +1 @@ -/Gen +Gen diff --git a/codegen/elm.json b/codegen/elm.json index d3fe1698..8ccb2e68 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -1,7 +1,8 @@ { "type": "application", "source-directories": [ - ".", + "src", + "bindings", "../vendored/miniBill/elm-glsl/1.0.0/src" ], "elm-version": "0.19.1", diff --git a/codegen/Generate.elm b/codegen/src/Generate.elm similarity index 99% rename from codegen/Generate.elm rename to codegen/src/Generate.elm index 8ae4fb9e..382f4108 100644 --- a/codegen/Generate.elm +++ b/codegen/src/Generate.elm @@ -51,7 +51,7 @@ task = [ "Glsl", "Functions", "NuPlot" ] in Script.writeFile - { path = file.path + { path = "generated/" ++ file.path , body = file.contents } |> BackendTask.allowFatal From 7c996647648fead0b35479b936d9b712725a520c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:14:42 +0200 Subject: [PATCH 125/139] Make failure more noisy in codegen --- codegen/elm.json | 6 +-- codegen/src/Generate.elm | 83 ++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/codegen/elm.json b/codegen/elm.json index 8ccb2e68..2c4b49dc 100644 --- a/codegen/elm.json +++ b/codegen/elm.json @@ -18,7 +18,8 @@ "elm-community/result-extra": "2.4.0", "mdgriffith/elm-codegen": "5.2.0", "mdgriffith/elm-ui": "1.1.8", - "pithub/elm-parser-bug-workaround": "1.0.0" + "pithub/elm-parser-bug-workaround": "1.0.0", + "wolfadex/elm-ansi": "3.0.0" }, "indirect": { "Chadtech/elm-bool-extra": "2.4.2", @@ -54,8 +55,7 @@ "stil4m/elm-syntax": "7.3.8", "stil4m/structured-writer": "1.0.3", "the-sett/elm-pretty-printer": "3.1.1", - "the-sett/elm-syntax-dsl": "6.0.3", - "wolfadex/elm-ansi": "3.0.0" + "the-sett/elm-syntax-dsl": "6.0.3" } }, "test-dependencies": { diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index 382f4108..c108101d 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -1,12 +1,12 @@ module Generate exposing (run) +import Ansi.Color import BackendTask exposing (BackendTask) import BackendTask.File as File import Dict exposing (Dict) import Elm import Elm.Annotation as Type import FatalError exposing (FatalError) -import Gen.Debug import Gen.Glsl import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), Expression(..), Function, RelationOperation(..), Stat(..), Statement(..), Type(..), Uniform) import Glsl.Parser @@ -29,45 +29,50 @@ task = |> BackendTask.allowFatal |> BackendTask.andThen (\glsl -> - let - file = - generate glsl - |> List.Extra.gatherEqualsBy Tuple.first - |> List.map - (\( head, tail ) -> - let - group : List Elm.Declaration - group = - List.map Tuple.second (head :: tail) - in - case Tuple.first head of - Just groupName -> - Elm.group (Elm.docs ("#" ++ groupName) :: group) - - Nothing -> - Elm.group group - ) - |> Elm.file - [ "Glsl", "Functions", "NuPlot" ] - in - Script.writeFile - { path = "generated/" ++ file.path - , body = file.contents - } - |> BackendTask.allowFatal + case generate glsl of + Err msg -> + let + coloredMsg : String + coloredMsg = + Ansi.Color.fontColor Ansi.Color.red "Error:" ++ " " ++ msg + in + BackendTask.fail (FatalError.fromString coloredMsg) + + Ok declarations -> + let + file = + declarations + |> List.Extra.gatherEqualsBy Tuple.first + |> List.map + (\( head, tail ) -> + let + group : List Elm.Declaration + group = + List.map Tuple.second (head :: tail) + in + case Tuple.first head of + Just groupName -> + Elm.group (Elm.docs ("#" ++ groupName) :: group) + + Nothing -> + Elm.group group + ) + |> Elm.file + [ "Glsl", "Functions", "NuPlot" ] + in + Script.writeFile + { path = "generated/" ++ file.path + , body = file.contents + } + |> BackendTask.allowFatal ) -generate : String -> List ( Maybe String, Elm.Declaration ) +generate : String -> Result String (List ( Maybe String, Elm.Declaration )) generate glsl = case Parser.run Glsl.Parser.file glsl of Err e -> - [ ( Nothing - , Gen.Debug.todo "Error parsing file" - |> Elm.declaration "err" - |> Elm.withDocumentation (errorToString e) - ) - ] + Err (errorToString e) Ok ( _, declarations ) -> let @@ -155,16 +160,10 @@ generate glsl = in case maybeDecls of Ok decls -> - decls ++ builtinDecls ++ uniformDecls + Ok (decls ++ builtinDecls ++ uniformDecls) Err e -> - [ ( Nothing - , "Error generating file" - |> Gen.Debug.todo - |> Elm.declaration "err" - |> Elm.withDocumentation e - ) - ] + Err ("Error generating file: " ++ e) uniformToDeclaration : Uniform -> ( Maybe String, Elm.Declaration ) From 2f5226e3a914cb8fbfeccfcaff58c384dca2cb8a Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:17:17 +0200 Subject: [PATCH 126/139] Add check for broken parser functions --- review/elm.json | 1 + review/src/ReviewConfig.elm | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/review/elm.json b/review/elm.json index 35c80c33..10e4412d 100644 --- a/review/elm.json +++ b/review/elm.json @@ -19,6 +19,7 @@ "jfmengels/elm-review-unused": "1.2.4", "jsuder-xx/elm-review-reducible-lambdas": "2.0.1", "lue-bird/elm-review-record-alias-constructor": "1.1.3", + "miniBill/elm-review-no-broken-elm-parser-functions": "1.0.0", "sparksp/elm-review-always": "1.0.6", "sparksp/elm-review-imports": "1.0.2", "sparksp/elm-review-ports": "1.3.1", diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 578b51fe..655f017b 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -3,11 +3,11 @@ module ReviewConfig exposing (config) import Docs.ReviewAtDocs import NoAlways import NoBooleanCase +import NoBrokenParserFunctions import NoConfusingPrefixOperator import NoDebug.Log import NoDebug.TodoOrToString import NoDuplicatePorts -import NoEtaReducibleLambdas import NoExposingEverything import NoImportingEverything import NoMissingTypeAnnotation @@ -57,9 +57,8 @@ config = , NoRecordAliasConstructor.rule , NoSimpleLetBody.rule , NoUnsafePorts.rule NoUnsafePorts.any - - -- , NoUnused.CustomTypeConstructorArgs.rule - -- , NoUnused.CustomTypeConstructors.rule [] + , NoUnused.CustomTypeConstructorArgs.rule + , NoUnused.CustomTypeConstructors.rule [] , NoUnused.Dependencies.rule , NoUnused.Exports.rule |> Rule.ignoreErrorsForDirectories [ "generated" ] @@ -75,4 +74,5 @@ config = , ReviewPipelineStyles.forbid ReviewPipelineStyles.rightCompositionPipelines |> ReviewPipelineStyles.andCallThem "forbidden >> composition" ] + , NoBrokenParserFunctions.rule ] From 3f3d1a3b6e5983773b6b21dbd560808939934304 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:21:17 +0200 Subject: [PATCH 127/139] Refine review config --- review/src/ReviewConfig.elm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 655f017b..18b060f3 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -40,7 +40,10 @@ config = , NoConfusingPrefixOperator.rule , NoDebug.Log.rule , NoDebug.TodoOrToString.rule - |> Rule.ignoreErrorsForDirectories [ "tests" ] + |> Rule.ignoreErrorsForDirectories + [ "tests" + , "vendored/miniBill/elm-glsl" + ] , NoDuplicatePorts.rule -- , NoEtaReducibleLambdas.rule @@ -58,11 +61,24 @@ config = , NoSimpleLetBody.rule , NoUnsafePorts.rule NoUnsafePorts.any , NoUnused.CustomTypeConstructorArgs.rule + |> Rule.ignoreErrorsForDirectories + [ "vendored/miniBill/elm-glsl" + ] , NoUnused.CustomTypeConstructors.rule [] - , NoUnused.Dependencies.rule + |> Rule.ignoreErrorsForDirectories + [ "vendored/miniBill/elm-glsl" + ] + + -- , NoUnused.Dependencies.rule , NoUnused.Exports.rule - |> Rule.ignoreErrorsForDirectories [ "generated" ] + |> Rule.ignoreErrorsForDirectories + [ "generated" + , "vendored/miniBill/elm-glsl" + ] , NoUnused.Modules.rule + |> Rule.ignoreErrorsForDirectories + [ "vendored/miniBill/elm-glsl" + ] , NoUnused.Parameters.rule , NoUnused.Patterns.rule , NoUnused.Variables.rule From 566249a6449432f602038f9e63a8e9245a19fde5 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:28:26 +0200 Subject: [PATCH 128/139] Rewrite defines as constants --- codegen/functions.frag | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/codegen/functions.frag b/codegen/functions.frag index 4930d91b..56aaf8e9 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -1,11 +1,11 @@ -#define MAX_DEPTH 30 -//#define MAX_DEPTH 60 - -#define P31 2147483648 -#define P32M1 4294967295 -#define PIHALF 1.5707963267948966 -#define PI 3.141592653589793 -#define TWOPI 6.283185307179586 +const int MAX_DEPTH = 30; +//const int MAX_DEPTH = 60; + +const int P31 = 2147483648; +const int P32M1 = 4294967295; +const float PIHALF = 1.5707963267948966; +const float PI = 3.141592653589793; +const float TWOPI = 6.283185307179586; precision highp float; From d5fc386e4313302087ebf5629ee59ab15a090041 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:28:36 +0200 Subject: [PATCH 129/139] Parse comments --- .../elm-glsl/1.0.0/src/Glsl/Parser.elm | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm index 8fb245af..2b7ada02 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm @@ -2,6 +2,7 @@ module Glsl.Parser exposing (expression, file, function, preprocess, statement) import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), RelationOperation(..), Stat(..), Type(..), UnaryOperation(..)) import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, keyword, loop, oneOf, sequence, succeed, symbol) +import Parser.Workaround file : Parser ( Maybe { version : String }, List Declaration ) @@ -155,16 +156,17 @@ typeParser = statement : Parser Stat statement = - Parser.lazy <| \_ -> - oneOf - [ blockParser - , returnParser - , breakContinueParser - , ifParser - , forParser - , defParser - , expressionStatementParser - ] + Parser.lazy <| + \_ -> + oneOf + [ blockParser + , returnParser + , breakContinueParser + , ifParser + , forParser + , defParser + , expressionStatementParser + ] breakContinueParser : Parser Stat @@ -798,4 +800,24 @@ expandMacros lines = spaces : Parser () spaces = - chompWhile (\c -> c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t') + let + inner : Parser () + inner = + chompWhile (\c -> c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t') + + comment : Parser () + comment = + Parser.oneOf + [ Parser.Workaround.lineCommentAfter "//" + , Parser.Workaround.multiCommentAfter "/*" "*/" Parser.NotNestable + ] + in + Parser.sequence + { start = "" + , end = "" + , trailing = Parser.Optional + , spaces = inner + , separator = "" + , item = comment + } + |> Parser.map (\_ -> ()) From 43c75a12bc5fcace72f442df67d29578a8533187 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:31:07 +0200 Subject: [PATCH 130/139] This is not parsed yet --- codegen/functions.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/functions.frag b/codegen/functions.frag index 56aaf8e9..3f28cd75 100644 --- a/codegen/functions.frag +++ b/codegen/functions.frag @@ -7,7 +7,7 @@ const float PIHALF = 1.5707963267948966; const float PI = 3.141592653589793; const float TWOPI = 6.283185307179586; -precision highp float; +// precision highp float; uniform float u_whiteLines; uniform float u_completelyReal; From 252da96eb54e89993c333fce8fde08ea936f2dac Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 21 Apr 2025 20:34:22 +0200 Subject: [PATCH 131/139] Switch to core-extra --- elm.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/elm.json b/elm.json index c6bad12b..bb32cfc6 100644 --- a/elm.json +++ b/elm.json @@ -20,9 +20,7 @@ "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/url": "1.0.0", - "elm-community/list-extra": "8.7.0", - "elm-community/maybe-extra": "5.3.0", - "elm-community/result-extra": "2.4.0", + "elmcraft/core-extra": "2.1.0", "lemol/ant-design-icons-elm-ui": "1.0.0", "miniBill/elm-codec": "2.2.0", "miniBill/elm-ui-with-context": "2.0.0", From 93ddd1d3e0d62c05fe8555b649458f8fc583b023 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 16:26:26 +0200 Subject: [PATCH 132/139] Better error message --- codegen/src/Generate.elm | 67 ++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index c108101d..cc2a7fc0 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -15,6 +15,7 @@ import List.Extra import Pages.Script as Script exposing (Script) import Parser import Result.Extra +import Set import SortedSet exposing (SortedSet) @@ -32,9 +33,17 @@ task = case generate glsl of Err msg -> let + reflowedMsg : String + reflowedMsg = + msg + |> String.split "\n" + |> (::) "" + |> String.join "\n " + coloredMsg : String coloredMsg = - Ansi.Color.fontColor Ansi.Color.red "Error:" ++ " " ++ msg + Ansi.Color.fontColor Ansi.Color.red "Error:" + ++ reflowedMsg in BackendTask.fail (FatalError.fromString coloredMsg) @@ -72,7 +81,7 @@ generate : String -> Result String (List ( Maybe String, Elm.Declaration )) generate glsl = case Parser.run Glsl.Parser.file glsl of Err e -> - Err (errorToString e) + Err (parserErrorToString glsl e) Ok ( _, declarations ) -> let @@ -181,16 +190,54 @@ functionHasType baseName argTypes returnType env = { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } -errorToString : List Parser.DeadEnd -> String -errorToString deadEnds = - deadEnds - |> List.map deadEndToString - |> String.join "\n" +parserErrorToString : String -> List Parser.DeadEnd -> String +parserErrorToString input err = + err + |> List.Extra.gatherEqualsBy (\{ row, col } -> ( row, col )) + |> List.map (errorToString input) + |> String.join "\n\n" -deadEndToString : Parser.DeadEnd -> String -deadEndToString { row, col, problem } = - "R " ++ String.fromInt row ++ " C " ++ String.fromInt col ++ " " ++ problemToString problem +errorToString : String -> ( Parser.DeadEnd, List Parser.DeadEnd ) -> String +errorToString source ( error, errors ) = + let + -- How many lines of context to show + context : Int + context = + 4 + + lines : List String + lines = + String.split "\n" source + |> List.drop (error.row - context) + |> List.take (context * 2) + + errorString : String + errorString = + [ String.repeat (error.col - 1) " " + , Ansi.Color.fontColor Ansi.Color.red "^ " + , " at row " + , String.fromInt error.row + , ", col " + , String.fromInt error.col + , " " + , (error :: errors) + |> List.map (\{ problem } -> problemToString problem) + |> Set.fromList + |> Set.toList + |> String.join ", " + |> Ansi.Color.fontColor Ansi.Color.yellow + ] + |> String.concat + + before : Int + before = + min error.row context + in + List.take before lines + ++ errorString + :: List.drop before lines + |> String.join "\n" problemToString : Parser.Problem -> String From fc06a0a478767bd393b8b4d7794d970fdb8b6ee0 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 17:13:37 +0200 Subject: [PATCH 133/139] Switch to a nicer parser wrapping --- codegen/src/Generate.elm | 7 +- codegen/src/ParserWithContext.elm | 241 ++++++++++++++ .../elm-glsl/1.0.0/src/Glsl/Parser.elm | 311 +++++------------- 3 files changed, 323 insertions(+), 236 deletions(-) create mode 100644 codegen/src/ParserWithContext.elm diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index cc2a7fc0..85d075ca 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -14,6 +14,7 @@ import Glsl.PrettyPrinter import List.Extra import Pages.Script as Script exposing (Script) import Parser +import Parser.Advanced import Result.Extra import Set import SortedSet exposing (SortedSet) @@ -79,7 +80,7 @@ task = generate : String -> Result String (List ( Maybe String, Elm.Declaration )) generate glsl = - case Parser.run Glsl.Parser.file glsl of + case Parser.Advanced.run Glsl.Parser.file glsl of Err e -> Err (parserErrorToString glsl e) @@ -190,7 +191,7 @@ functionHasType baseName argTypes returnType env = { env | functionsEnv = Dict.insert (fullName baseName argTypes) returnType env.functionsEnv } -parserErrorToString : String -> List Parser.DeadEnd -> String +parserErrorToString : String -> List Glsl.Parser.DeadEnd -> String parserErrorToString input err = err |> List.Extra.gatherEqualsBy (\{ row, col } -> ( row, col )) @@ -198,7 +199,7 @@ parserErrorToString input err = |> String.join "\n\n" -errorToString : String -> ( Parser.DeadEnd, List Parser.DeadEnd ) -> String +errorToString : String -> ( Glsl.Parser.DeadEnd, List Glsl.Parser.DeadEnd ) -> String errorToString source ( error, errors ) = let -- How many lines of context to show diff --git a/codegen/src/ParserWithContext.elm b/codegen/src/ParserWithContext.elm new file mode 100644 index 00000000..b5f8288e --- /dev/null +++ b/codegen/src/ParserWithContext.elm @@ -0,0 +1,241 @@ +module ParserWithContext exposing (Parser, andThen, backtrackable, chompIf, chompWhile, commit, end, float, getChompedString, inContext, int, keyword, lazy, loop, many, map, oneOf, problem, sequence, spaces, succeed, symbol, token) + +import Parser exposing (Problem(..)) +import Parser.Advanced exposing ((|.), (|=), Step, Token(..)) +import Parser.Advanced.Workaround + + +type alias Parser c a = + Parser.Advanced.Parser c Problem a + + +inContext : c -> Parser c a -> Parser c a +inContext ctx parser = + Parser.Advanced.inContext ctx parser + + +succeed : a -> Parser c a +succeed x = + Parser.Advanced.succeed x + + +getChompedString : Parser c a -> Parser c String +getChompedString parser = + Parser.Advanced.getChompedString parser + + +symbol : String -> Parser c () +symbol k = + Parser.Advanced.symbol (token k) + |. spaces + + +keyword : String -> Parser c () +keyword k = + Parser.Advanced.keyword (token k) + |. spaces + + +token : String -> Token Problem +token k = + if String.isEmpty k then + Token k UnexpectedChar + + else + Token k (Expecting k) + + +end : Parser c () +end = + Parser.Advanced.end ExpectingEnd + + +many : Parser c a -> Parser c (List a) +many item = + sequence + { start = "" + , separator = "" + , item = item + , end = "" + , trailing = Parser.Advanced.Optional + } + + +chompWhile : (Char -> Bool) -> Parser c () +chompWhile cond = + Parser.Advanced.chompWhile cond + + +chompIf : (Char -> Bool) -> Problem -> Parser c () +chompIf cond k = + Parser.Advanced.chompIf cond k + + +oneOf : List (Parser c a) -> Parser c a +oneOf options = + Parser.Advanced.oneOf options + + +spaces : Parser c () +spaces = + let + inner : Parser c () + inner = + chompWhile (\c -> c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t') + + comment : Parser c () + comment = + oneOf + [ Parser.Advanced.Workaround.lineCommentAfter (token "//") + , Parser.Advanced.Workaround.multiCommentAfter (token "/*") (token "*/") Parser.Advanced.NotNestable + ] + in + Parser.Advanced.sequence + { start = token "" + , end = token "" + , trailing = Parser.Advanced.Optional + , spaces = inner + , separator = token "" + , item = comment + } + |> Parser.Advanced.map (\_ -> ()) + + +sequence : + { start : String + , end : String + , trailing : Parser.Advanced.Trailing + , separator : String + , item : Parser c a + } + -> Parser c (List a) +sequence config = + Parser.Advanced.sequence + { start = token config.start + , end = token config.end + , trailing = config.trailing + , spaces = spaces + , separator = token config.separator + , item = config.item + } + |. spaces + + +lazy : (() -> Parser c a) -> Parser c a +lazy k = + Parser.Advanced.lazy k + + +map : (a -> b) -> Parser c a -> Parser c b +map f parser = + Parser.Advanced.map f parser + + +loop : a -> (a -> Parser c (Step a b)) -> Parser c b +loop acc step = + Parser.Advanced.loop acc step + + +backtrackable : Parser c x -> Parser c x +backtrackable parser = + Parser.Advanced.backtrackable parser + + +problem : String -> Parser c a +problem msg = + Parser.Advanced.problem (Problem msg) + + +int : Parser c Int +int = + (succeed () + |. chompIf Char.isDigit ExpectingInt + |. chompWhile Char.isDigit + |> getChompedString + |> andThen + (\s -> + case String.toInt s of + Just i -> + succeed i + + Nothing -> + Parser.Advanced.problem ExpectingInt + ) + ) + |. spaces + + +float : Parser c Float +float = + let + mantissaWithDot : Parser c Float + mantissaWithDot = + oneOf + [ succeed () + |. symbol "." + |. int + , succeed () + |. backtrackable int + |. symbol "." + |. commit () + |. oneOf + [ int + , succeed 0 + ] + ] + |> getChompedString + |> andThen + (\s -> + let + withZero : String + withZero = + if String.endsWith "." s then + s ++ "0" + + else + s + in + case String.toFloat (String.trimRight withZero) of + Just f -> + succeed f + + Nothing -> + problem ("Cannot parse \"" ++ s ++ "\" as float") + ) + + exponent : Parser c Int + exponent = + succeed identity + |. oneOf [ symbol "e", symbol "E" ] + |. commit () + |= oneOf + [ succeed identity + |. symbol "+" + |= int + , succeed negate + |. symbol "-" + |= int + , int + ] + in + oneOf + [ succeed (\c e -> c * 10 ^ toFloat e) + |= mantissaWithDot + |= oneOf + [ exponent + , succeed 0 + ] + , succeed (\c e -> toFloat c * 10 ^ toFloat e) + |= backtrackable int + |= exponent + ] + + +andThen : (a -> Parser c b) -> Parser c a -> Parser c b +andThen f parser = + Parser.Advanced.andThen f parser + + +commit : a -> Parser c a +commit x = + Parser.Advanced.commit x diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm index 2b7ada02..6902d190 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm @@ -1,36 +1,45 @@ -module Glsl.Parser exposing (expression, file, function, preprocess, statement) +module Glsl.Parser exposing (Context(..), DeadEnd, Parser, expression, file, function, preprocess, statement) import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), RelationOperation(..), Stat(..), Type(..), UnaryOperation(..)) -import Parser exposing ((|.), (|=), Parser, Step(..), Trailing(..), chompIf, chompWhile, getChompedString, keyword, loop, oneOf, sequence, succeed, symbol) -import Parser.Workaround +import Parser exposing (Problem(..)) +import Parser.Advanced exposing ((|.), (|=), Step(..), Token(..), Trailing(..)) +import ParserWithContext exposing (chompIf, chompWhile, end, float, getChompedString, inContext, int, keyword, loop, many, oneOf, sequence, spaces, succeed, symbol) -file : Parser ( Maybe { version : String }, List Declaration ) +type Context + = ParsingFile + | ParsingFunction + | ParsingStatement + | ParsingExpression + + +type alias Parser a = + ParserWithContext.Parser Context a + + +type alias DeadEnd = + Parser.Advanced.DeadEnd Context Parser.Problem + + +file : Parser ( Maybe { version : Int }, List Declaration ) file = succeed Tuple.pair + |. spaces |= oneOf [ succeed (\version -> Just { version = version }) - |. symbol "#version " - |= (chompWhile Char.isDigit - |> getChompedString - ) + |. symbol "#version" + |= int , succeed Nothing ] - |. spaces - |= sequence - { start = "" - , separator = "" - , item = - oneOf - [ const - , uniform - , function - ] - , end = "" - , trailing = Parser.Optional - , spaces = spaces - } - |. Parser.end + |= many + (oneOf + [ const + , uniform + , function + ] + ) + |. end + |> inContext ParsingFile function : Parser Declaration @@ -45,19 +54,16 @@ function = } ) |= typeParser - |. spaces |= identifierParser - |. spaces |= sequence { start = "(" , end = ")" - , spaces = spaces , separator = "," , item = argParser , trailing = Forbidden } - |. spaces |= statement + |> inContext ParsingFunction const : Parser Declaration @@ -71,13 +77,9 @@ const = } ) |. keyword "const" - |. spaces |= typeParser - |. spaces |= identifierParser - |. spaces |. symbol "=" - |. spaces |= expression |. symbol ";" @@ -92,11 +94,8 @@ uniform = } ) |. keyword "uniform" - |. spaces |= typeParser - |. spaces |= identifierParser - |. spaces |. symbol ";" @@ -104,7 +103,6 @@ argParser : Parser ( Type, String ) argParser = succeed Tuple.pair |= typeParser - |. spaces |= identifierParser @@ -112,9 +110,10 @@ identifierParser : Parser String identifierParser = getChompedString (succeed () - |. chompIf (\c -> Char.isAlpha c || c == '_') + |. chompIf (\c -> Char.isAlpha c || c == '_') (Expecting "Letter or underscore") |. chompWhile (\c -> Char.isAlphaNum c || c == '_') ) + |. spaces typeParser : Parser Type @@ -140,15 +139,16 @@ typeParser = |> oneOf in succeed identity - |. oneOf [ keyword "const" |. spaces, succeed () ] + |. oneOf + [ keyword "const" + , succeed () + ] |= oneOf [ succeed TOut |. keyword "out" - |. spaces |= baseParser , succeed TIn |. keyword "in" - |. spaces |= baseParser , baseParser ] @@ -156,7 +156,7 @@ typeParser = statement : Parser Stat statement = - Parser.lazy <| + (ParserWithContext.lazy <| \_ -> oneOf [ blockParser @@ -167,6 +167,8 @@ statement = , defParser , expressionStatementParser ] + ) + |> inContext ParsingStatement breakContinueParser : Parser Stat @@ -177,7 +179,6 @@ breakContinueParser = , succeed Continue |. keyword "continue" ] - |. spaces |. symbol ";" @@ -185,7 +186,6 @@ expressionStatementParser : Parser Stat expressionStatementParser = succeed ExpressionStatement |= expression - |. spaces |. symbol ";" @@ -193,19 +193,13 @@ ifParser : Parser Stat ifParser = succeed (\e s k -> k e s) |. keyword "if" - |. spaces |. symbol "(" - |. spaces |= expression - |. spaces |. symbol ")" - |. spaces |= statement - |. spaces |= oneOf [ succeed (\b e s -> IfElse e s b) |. keyword "else" - |. spaces |= statement , succeed If ] @@ -215,24 +209,16 @@ forParser : Parser Stat forParser = succeed For |. keyword "for" - |. spaces |. symbol "(" - |. spaces |= oneOf [ succeed Just |= statement , succeed Nothing ] - |. spaces |. symbol ";" - |. spaces |= expression - |. spaces |. symbol ";" - |. spaces |= expression - |. spaces |. symbol ")" - |. spaces |= statement @@ -240,9 +226,7 @@ returnParser : Parser Stat returnParser = succeed Return |. keyword "return" - |. spaces |= expression - |. spaces |. symbol ";" @@ -252,11 +236,10 @@ blockParser = { start = "{" , item = statement , separator = "" - , spaces = spaces , end = "}" - , trailing = Parser.Optional + , trailing = Optional } - |> Parser.map Glsl.block + |> ParserWithContext.map Glsl.block defParser : Parser Stat @@ -266,24 +249,20 @@ defParser = Decl type_ var val ) |= typeParser - |. spaces |= identifierParser - |. spaces |= oneOf [ succeed Just |. symbol "=" - |. spaces |= expression - |. spaces , succeed Nothing ] - |. spaces |. symbol ";" expression : Parser Expr expression = prec17Parser + |> inContext ParsingExpression prec17Parser : Parser Expr @@ -298,52 +277,40 @@ prec16Parser : Parser Expr prec16Parser = succeed (\a f -> f a) |= prec15Parser - |. spaces |= oneOf [ succeed (\r l -> BinaryOperation l Assign r) |. singleSymbol "=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboAdd r) |. symbol "+=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboSubtract r) |. symbol "-=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboBy r) |. symbol "*=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboDiv r) |. symbol "/=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboMod r) |. symbol "%=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboLeftShift r) |. symbol "<<=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboRightShift r) |. symbol ">>=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboBitwiseAnd r) |. symbol "&=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboBitwiseOr r) |. symbol "|=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed (\r l -> BinaryOperation l ComboBitwiseXor r) |. symbol "^=" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) + |= ParserWithContext.lazy (\_ -> prec16Parser) , succeed identity ] @@ -352,18 +319,14 @@ prec15Parser : Parser Expr prec15Parser = succeed (\k f -> f k) |= prec14Parser - |. spaces |= oneOf [ succeed (\t f c -> Ternary c t f) -- c is passed in last in the lambda because it's passed -- from above |. symbol "?" - |. spaces |= prec14Parser - |. spaces |. symbol ":" - |. spaces - |= Parser.lazy (\_ -> prec15Parser) + |= ParserWithContext.lazy (\_ -> prec15Parser) , succeed identity ] @@ -434,12 +397,12 @@ singleSymbol s = symbolNotFollowedBy : String -> List String -> Parser () symbolNotFollowedBy s nots = succeed () - |. Parser.backtrackable (symbol s) + |. ParserWithContext.backtrackable (symbol s) |. oneOf [ succeed () |. oneOf (List.map symbol nots) - |. Parser.problem ("Expecting " ++ s ++ " not follwed by any of " ++ String.join ", " nots) - |> Parser.backtrackable + |. ParserWithContext.problem ("Expecting " ++ s ++ " not follwed by any of " ++ String.join ", " nots) + |> ParserWithContext.backtrackable , succeed () ] @@ -507,13 +470,13 @@ prec3Parser = oneOf [ succeed (UnaryOperation PrefixIncrement) |. symbol "++" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , succeed (UnaryOperation Plus) |. singleSymbol "+" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , succeed (UnaryOperation PrefixDecrement) |. symbol "--" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , succeed (\c -> case c of @@ -527,13 +490,13 @@ prec3Parser = UnaryOperation Negate c ) |. singleSymbol "-" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , succeed (UnaryOperation Invert) |. symbol "~" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , succeed (UnaryOperation Not) |. symbol "!" - |= Parser.lazy (\_ -> prec3Parser) + |= ParserWithContext.lazy (\_ -> prec3Parser) , prec2Parser ] @@ -542,8 +505,7 @@ prec2Parser : Parser Expr prec2Parser = succeed (\a f -> f a) |= prec1Parser - |. spaces - |= Parser.lazy prec2Suffixes + |= ParserWithContext.lazy prec2Suffixes prec2Suffixes : () -> Parser (Expr -> Expr) @@ -553,42 +515,39 @@ prec2Suffixes () = |= sequence { start = "(" , separator = "," - , item = Parser.lazy <| \_ -> prec16Parser + , item = ParserWithContext.lazy <| \_ -> prec16Parser , end = ")" , trailing = Forbidden - , spaces = spaces } |= oneOf - [ Parser.lazy <| \_ -> prec2Suffixes () + [ ParserWithContext.lazy <| \_ -> prec2Suffixes () , succeed identity ] , succeed (\arg k v -> k (BinaryOperation v ArraySubscript arg)) |. symbol "[" - |. spaces - |= Parser.lazy (\_ -> prec16Parser) - |. spaces + |= ParserWithContext.lazy (\_ -> prec16Parser) |. symbol "]" |= oneOf - [ Parser.lazy <| \_ -> prec2Suffixes () + [ ParserWithContext.lazy <| \_ -> prec2Suffixes () , succeed identity ] , succeed (\p k v -> k (Dot v p)) |. symbol "." |= identifierParser |= oneOf - [ Parser.lazy <| \_ -> prec2Suffixes () + [ ParserWithContext.lazy <| \_ -> prec2Suffixes () , succeed identity ] , succeed (\k v -> k (UnaryOperation PostfixIncrement v)) |. symbol "++" |= oneOf - [ Parser.lazy <| \_ -> prec2Suffixes () + [ ParserWithContext.lazy <| \_ -> prec2Suffixes () , succeed identity ] , succeed (\k v -> k (UnaryOperation PostfixDecrement v)) |. symbol "--" |= oneOf - [ Parser.lazy <| \_ -> prec2Suffixes () + [ ParserWithContext.lazy <| \_ -> prec2Suffixes () , succeed identity ] , succeed identity @@ -600,9 +559,7 @@ prec1Parser = oneOf [ succeed identity |. symbol "(" - |. spaces - |= Parser.lazy (\_ -> expression) - |. spaces + |= ParserWithContext.lazy (\_ -> expression) |. symbol ")" , succeed (Bool True) |. keyword "true" @@ -610,95 +567,11 @@ prec1Parser = |. keyword "false" , succeed Variable |= identifierParser - , succeed Float |= floatParser - , succeed Int |= intParser - ] - - -floatParser : Parser Float -floatParser = - oneOf - [ succeed (\c e -> e c) - |= (oneOf - [ succeed () - |. symbol "." - |. intParser - , succeed () - |. Parser.backtrackable intParser - |. symbol "." - |. Parser.commit () - |. oneOf - [ intParser - , succeed 0 - ] - ] - |> getChompedString - |> Parser.andThen - (\s -> - let - withZero : String - withZero = - if String.endsWith "." s then - s ++ "0" - - else - s - in - case String.toFloat withZero of - Just f -> - succeed f - - Nothing -> - Parser.problem ("Cannot parse \"" ++ s ++ "\" as float") - ) - ) - |= oneOf - [ succeed (\e c -> c * 10 ^ toFloat e) - |. oneOf [ symbol "e", symbol "E" ] - |= oneOf - [ succeed identity - |. symbol "+" - |= intParser - , succeed negate - |. symbol "-" - |= intParser - , intParser - ] - , succeed identity - ] - , succeed (\c e -> toFloat c * 10 ^ toFloat e) - |= Parser.backtrackable intParser - |. oneOf [ symbol "e", symbol "E" ] - |. Parser.commit () - |= oneOf - [ succeed identity - |. symbol "+" - |= intParser - , succeed negate - |. symbol "-" - |= intParser - , intParser - ] + , succeed Float |= float + , succeed Int |= int ] -intParser : Parser Int -intParser = - succeed () - |. chompIf Char.isDigit - |. chompWhile Char.isDigit - |> getChompedString - |> Parser.andThen - (\s -> - case String.toInt s of - Just i -> - succeed i - - Nothing -> - Parser.problem ("Cannot parse \"" ++ s ++ "\" as int") - ) - - type alias SequenceData = { separators : List ( Expr -> Expr -> Expr, Parser () ) , item : Parser Expr @@ -709,8 +582,7 @@ multiSequenceAssocLeft : SequenceData -> Parser Expr multiSequenceAssocLeft data = succeed identity |= data.item - |. spaces - |> Parser.andThen + |> ParserWithContext.andThen (\first -> loop first (\expr -> multiSequenceHelpLeft data expr) ) @@ -729,9 +601,7 @@ multiSequenceHelpLeft { separators, item } acc = (\( f, parser ) -> succeed (\e -> Loop <| f acc e) |. parser - |. spaces |= item - |. spaces ) |> oneOf in @@ -796,28 +666,3 @@ expandMacros : List String -> List String expandMacros lines = -- TODO: macros lines - - -spaces : Parser () -spaces = - let - inner : Parser () - inner = - chompWhile (\c -> c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t') - - comment : Parser () - comment = - Parser.oneOf - [ Parser.Workaround.lineCommentAfter "//" - , Parser.Workaround.multiCommentAfter "/*" "*/" Parser.NotNestable - ] - in - Parser.sequence - { start = "" - , end = "" - , trailing = Parser.Optional - , spaces = inner - , separator = "" - , item = comment - } - |> Parser.map (\_ -> ()) From a3b2353adacad1417ea08f00da7576f94c8f6e16 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 17:35:43 +0200 Subject: [PATCH 134/139] Fixed parsing of for loops --- codegen/src/Generate.elm | 44 ++++++++++++++++--- .../elm-glsl/1.0.0/src/Glsl/Parser.elm | 28 ++++++++---- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index 85d075ca..d5e9def9 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -194,7 +194,7 @@ functionHasType baseName argTypes returnType env = parserErrorToString : String -> List Glsl.Parser.DeadEnd -> String parserErrorToString input err = err - |> List.Extra.gatherEqualsBy (\{ row, col } -> ( row, col )) + |> List.Extra.gatherEqualsBy (\{ row, col, contextStack } -> ( row, col, contextStack )) |> List.map (errorToString input) |> String.join "\n\n" @@ -203,15 +203,15 @@ errorToString : String -> ( Glsl.Parser.DeadEnd, List Glsl.Parser.DeadEnd ) -> S errorToString source ( error, errors ) = let -- How many lines of context to show - context : Int - context = + contextSize : Int + contextSize = 4 lines : List String lines = String.split "\n" source - |> List.drop (error.row - context) - |> List.take (context * 2) + |> List.drop (error.row - contextSize) + |> List.take (contextSize * 2) errorString : String errorString = @@ -228,12 +228,16 @@ errorToString source ( error, errors ) = |> Set.toList |> String.join ", " |> Ansi.Color.fontColor Ansi.Color.yellow + , " while " + , error.contextStack + |> List.map (\frame -> contextToString frame.context) + |> String.join ", while " ] |> String.concat before : Int before = - min error.row context + min error.row contextSize in List.take before lines ++ errorString @@ -241,6 +245,34 @@ errorToString source ( error, errors ) = |> String.join "\n" +contextToString : Glsl.Parser.Context -> String +contextToString context = + case context of + Glsl.Parser.ParsingFile -> + "parsing a file" + + Glsl.Parser.ParsingFunction -> + "parsing a function" + + Glsl.Parser.ParsingStatement -> + "parsing a statement" + + Glsl.Parser.ParsingExpression -> + "parsing an expression" + + Glsl.Parser.ParsingForInitialization -> + "parsing a for's initialization" + + Glsl.Parser.ParsingForCondition -> + "parsing a for's condition" + + Glsl.Parser.ParsingForStep -> + "parsing a for's step" + + Glsl.Parser.ParsingForBody -> + "parsing a for's body" + + problemToString : Parser.Problem -> String problemToString problem = case problem of diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm index 6902d190..e7ac5e4f 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm @@ -11,6 +11,10 @@ type Context | ParsingFunction | ParsingStatement | ParsingExpression + | ParsingForInitialization + | ParsingForCondition + | ParsingForStep + | ParsingForBody type alias Parser a = @@ -18,7 +22,11 @@ type alias Parser a = type alias DeadEnd = - Parser.Advanced.DeadEnd Context Parser.Problem + { row : Int + , col : Int + , problem : Parser.Problem + , contextStack : List { row : Int, col : Int, context : Context } + } file : Parser ( Maybe { version : Int }, List Declaration ) @@ -210,16 +218,18 @@ forParser = succeed For |. keyword "for" |. symbol "(" - |= oneOf - [ succeed Just |= statement - , succeed Nothing - ] - |. symbol ";" - |= expression + |= (oneOf + [ succeed Just |= statement + , succeed Nothing + |. symbol ";" + ] + |> inContext ParsingForInitialization + ) + |= (expression |> inContext ParsingForCondition) |. symbol ";" - |= expression + |= (expression |> inContext ParsingForStep) |. symbol ")" - |= statement + |= (statement |> inContext ParsingForBody) returnParser : Parser Stat From dd1de5a4daf7f04feed25644a91df2789ff0e328 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 17:53:54 +0200 Subject: [PATCH 135/139] Use a more monadic structure --- codegen/src/Generate.elm | 130 +++++++++++------- .../elm-glsl/1.0.0/src/Glsl/Parser.elm | 4 +- 2 files changed, 81 insertions(+), 53 deletions(-) diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index d5e9def9..f1341a44 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -163,13 +163,14 @@ generate glsl = (functionToDeclarations env) functions |> Result.map List.concat - - uniformDecls : List ( Maybe String, Elm.Declaration ) - uniformDecls = - List.map uniformToDeclaration uniforms in case maybeDecls of Ok decls -> + let + uniformDecls : List ( Maybe String, Elm.Declaration ) + uniformDecls = + List.map uniformToDeclaration uniforms + in Ok (decls ++ builtinDecls ++ uniformDecls) Err e -> @@ -329,27 +330,28 @@ type alias Env = functionToDeclarations : Env -> Function -> Result String (List ( Maybe String, Elm.Declaration )) functionToDeclarations env function = let - fname = + functionName : String + functionName = fullName function.name (List.map Tuple.first function.args) envWithArgs : Env envWithArgs = List.foldl (\( type_, name ) -> variableHasType name type_) env function.args - maybeDeps : Result String (SortedSet String) + maybeDeps : Result String ( Env, SortedSet String ) maybeDeps = - findDepsStatement envWithArgs function.stat - |> Result.mapError (\e -> e ++ " while generating " ++ fname) + findDepsStatement function.stat envWithArgs + |> Result.mapError (\e -> e ++ " while generating " ++ functionName) in Result.map - (\deps -> + (\( _, deps ) -> [ ( Nothing , function.stat |> Glsl.PrettyPrinter.stat 0 |> Elm.string - |> Elm.declaration (fname ++ "Body") + |> Elm.declaration (functionName ++ "Body") ) - , wrapFunction function.name (SortedSet.insert fname deps) function.args function.returnType + , wrapFunction function.name (SortedSet.insert functionName deps) function.args function.returnType ] ) maybeDeps @@ -550,71 +552,93 @@ variableHasType var type_ env = { env | variablesEnv = Dict.insert var type_ env.variablesEnv } -union : List (Result String (SortedSet comparable)) -> Result String (SortedSet comparable) -union = - List.foldl (Result.map2 SortedSet.insertAll) (Ok SortedSet.empty) +union : List (Env -> Result String ( Env, SortedSet comparable )) -> Env -> Result String ( Env, SortedSet comparable ) +union list initialEnv = + List.foldl + (\e a -> + a + |> Result.andThen + (\( env, deps ) -> + e env + |> Result.map + (Tuple.mapSecond + (\newDeps -> SortedSet.insertAll newDeps deps) + ) + ) + ) + (Ok ( initialEnv, SortedSet.empty )) + list -findDepsStatement : Env -> Stat -> Result String (SortedSet String) -findDepsStatement env statement = +findDepsStatement : Stat -> Env -> Result String ( Env, SortedSet String ) +findDepsStatement statement = case statement of If cond true -> union - [ findDepsExpression env cond - , findDepsStatement env true + [ findDepsExpression cond + , findDepsStatement true ] IfElse cond true false -> union - [ findDepsExpression env cond - , findDepsStatement env true - , findDepsStatement env false + [ findDepsExpression cond + , findDepsStatement true + , findDepsStatement false ] ExpressionStatement e -> - findDepsExpression env e + findDepsExpression e For from cond step loop -> union [ case from of Just f -> - findDepsStatement env f + findDepsStatement f Nothing -> - Ok SortedSet.empty - , findDepsExpression env cond - , findDepsExpression env step - , findDepsStatement env loop + nop + , findDepsExpression cond + , findDepsExpression step + , findDepsStatement loop ] Return e -> - findDepsExpression env e + findDepsExpression e Decl type_ var maybeVal -> - let - newEnv : Env - newEnv = - variableHasType var type_ env - in - maybeVal - |> Maybe.map (findDepsExpression newEnv) - |> Maybe.withDefault (Ok SortedSet.empty) + \env -> + let + newEnv : Env + newEnv = + variableHasType var type_ env + in + case maybeVal of + Nothing -> + nop newEnv + + Just val -> + findDepsExpression val newEnv Nop -> - Ok SortedSet.empty + nop Break -> - Ok SortedSet.empty + nop Continue -> - Ok SortedSet.empty + nop Block l m r -> - union (List.map (findDepsStatement env) (l :: m :: r)) + union (List.map findDepsStatement (l :: m :: r)) + + +nop : Env -> Result String ( Env, SortedSet String ) +nop env = + Ok ( env, SortedSet.empty ) -findDepsExpression : Env -> Expr -> Result String (SortedSet String) -findDepsExpression env = +findDepsExpression : Expr -> Env -> Result String ( Env, SortedSet String ) +findDepsExpression root env = let go : Expr -> Result String ( Type, SortedSet String ) go expr = @@ -683,13 +707,6 @@ findDepsExpression env = |> Result.andThen (\( argTypes, argDeps ) -> let - deps = - if Dict.member fname builtinFunctions then - List.foldl SortedSet.insertAll SortedSet.empty argDeps - - else - List.foldl SortedSet.insertAll (SortedSet.singleton fname) argDeps - fname = fullName f argTypes in @@ -698,6 +715,14 @@ findDepsExpression env = Err <| "Function " ++ fname ++ " not found" Just to -> + let + deps = + if Dict.member fname builtinFunctions then + List.foldl SortedSet.insertAll SortedSet.empty argDeps + + else + List.foldl SortedSet.insertAll (SortedSet.singleton fname) argDeps + in Ok ( to, deps ) ) @@ -750,7 +775,8 @@ findDepsExpression env = (go r) ) in - go >> Result.map Tuple.second + go root + |> Result.map (\( _, deps ) -> ( env, deps )) binaryOperationToString : BinaryOperation -> String @@ -1041,7 +1067,9 @@ builtinFunctions = mats : List ( String, List Type, Type ) mats = - [ ( [ TVec3, TVec3, TVec3 ], 3, TMat3 ) ] + [ ( [ TVec3, TVec3, TVec3 ], 3, TMat3 ) + , ( [ TFloat ], 3, TMat3 ) + ] |> List.map (\( inTypes, size, type_ ) -> ( "mat" ++ String.fromInt size diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm index e7ac5e4f..686db752 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Parser.elm @@ -2,7 +2,7 @@ module Glsl.Parser exposing (Context(..), DeadEnd, Parser, expression, file, fun import Glsl exposing (BinaryOperation(..), Declaration(..), Expr(..), RelationOperation(..), Stat(..), Type(..), UnaryOperation(..)) import Parser exposing (Problem(..)) -import Parser.Advanced exposing ((|.), (|=), Step(..), Token(..), Trailing(..)) +import Parser.Advanced exposing ((|.), (|=), Step(..), Trailing(..)) import ParserWithContext exposing (chompIf, chompWhile, end, float, getChompedString, inContext, int, keyword, loop, many, oneOf, sequence, spaces, succeed, symbol) @@ -24,7 +24,7 @@ type alias Parser a = type alias DeadEnd = { row : Int , col : Int - , problem : Parser.Problem + , problem : Problem , contextStack : List { row : Int, col : Int, context : Context } } From f11dcf150aec93bb5388d56c1df4efd942bf4d45 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 17:57:45 +0200 Subject: [PATCH 136/139] Move ParserWithContext to vendored --- .../miniBill/elm-glsl/1.0.0}/src/ParserWithContext.elm | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {codegen => vendored/miniBill/elm-glsl/1.0.0}/src/ParserWithContext.elm (100%) diff --git a/codegen/src/ParserWithContext.elm b/vendored/miniBill/elm-glsl/1.0.0/src/ParserWithContext.elm similarity index 100% rename from codegen/src/ParserWithContext.elm rename to vendored/miniBill/elm-glsl/1.0.0/src/ParserWithContext.elm From a909a0fe10b19fc24693cf28106be14dcf2d9ebc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 18:21:19 +0200 Subject: [PATCH 137/139] Improve formatting of docs for functions --- .../elm-glsl/1.0.0/src/Glsl/Functions.elm | 723 +++++++++++++++++- 1 file changed, 721 insertions(+), 2 deletions(-) diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm index 92944cb9..57862cf7 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm @@ -1,8 +1,727 @@ -module Glsl.Functions exposing (abs1, abs2, abs3, abs4, abs_, absd1, absd2, absd3, absd4, absf, absi1, absi2, absi3, absi4, abswd1, abswi1, acos_, acosh, asin_, asinh, atan2_, atan_, atanh, ceil, ceil1, ceil2, ceil3, ceil4, ceild1, ceild2, ceild3, ceild4, ceilf, ceilwd1, clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f, clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333, clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1, clamp4ff, clamp_, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1, clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1, clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4, clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff, clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1, clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3, clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1, clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1, clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1, clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4, clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1, clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1, clampwu1wu1u1, clampwu1wu1wu1, cos_, cosh, cross33, crossd3d3, dFdx, dFdxCoarse, dFdxFine, dFdy, dFdyCoarse, dFdyFine, degrees_, distance, distance11, distance1f, distance22, distance33, distance44, distanced1d1, distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff, distancewd1d1, distancewd1wd1, dot, dot11, dot1f, dot22, dot33, dot44, dotd1d1, dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff, dotwd1d1, dotwd1wd1, exp, exp2, faceforward, faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333, faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2, faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff, faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf, floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf, floati1, floatwi1, floor1, floor2, floor3, floor4, floor_, floord1, floord2, floord3, floord4, floorf, floorwd1, fma, fma111, fma11f, fma1f1, fma1ff, fma222, fma333, fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2, fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff, fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fract, fract1, fract2, fract3, fract4, fractd1, fractd2, fractd3, fractd4, fractf, fractwd1, frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1, frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1, frexpwd1oi1, frexpwd1owi1, fwidth, fwidthCoarse, fwidthFine, int1, intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1, intf, inversesqrt, inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2, inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2, isinfd3, isinfd4, isinff, isinfwd1, isnan1, isnan2, isnan3, isnan4, isnand1, isnand2, isnand3, isnand4, isnanf, isnanwd1, ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1, ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1, ivec3wi1wi1i1, ivec3wi1wi1wi1, ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1, ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1, ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1, ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1, ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1, ldexpwd1i1, ldexpwd1wi1, length, length1, length2, length3, length4, lengthd1, lengthd2, lengthd3, lengthd4, lengthf, lengthwd1, log, log2, mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f, mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1, mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff, mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f, mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff, mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f, mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff, mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f, mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff, mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f, mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff, mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f, mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff, mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f, mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff, mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f, mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff, mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f, mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff, mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f, mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff, mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f, mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff, mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f, mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff, mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f, mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff, mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f, mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff, mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f, mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff, mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f, mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff, mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f, mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff, mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f, mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff, mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f, mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff, mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f, mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff, mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f, mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff, mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f, mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff, mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111, mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1, mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11, mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1, mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111, mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1, mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11, mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1, mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111, mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1, mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11, mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1, mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111, mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1, mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11, mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1, mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111, mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1, mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11, mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1, mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111, mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1, mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11, mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1, mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111, mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1, mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11, mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1, mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111, mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1, mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11, mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1, mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111, mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1, mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11, mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1, mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111, mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1, mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11, mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1, mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111, mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1, mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11, mat3fffffff1f, mat3ffffffff1, mat3fffffffff, mat44444, max11, max1f, max21, max22, max2f, max31, max33, max3f, max41, max44, max4f, max_, maxd1d1, maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3, maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff, maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1, maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1, maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3, maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1, maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1, min11, min1f, min21, min22, min2f, min31, min33, min3f, min41, min44, min4f, min_, mind1d1, mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3, mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff, mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1, mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1, minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3, minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1, minwi1i1, minwi1wi1, minwu1u1, minwu1wu1, mix, mix111, mix11f, mix1f1, mix1ff, mix221, mix222, mix22f, mix331, mix333, mix33f, mix441, mix444, mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1, mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1, mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff, mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mod, mod11, mod1f, mod21, mod22, mod2f, mod31, mod33, mod3f, mod41, mod44, mod4f, modd1d1, modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3, modd3wd1, modd4d1, modd4d4, modd4wd1, modf, modf1, modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1, modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modff, modffo1, modffof, modfwd1od1, modfwd1owd1, modwd1d1, modwd1wd1, normalize, normalize1, normalize2, normalize3, normalize4, normalized1, normalized2, normalized3, normalized4, normalizef, normalizewd1, pow, radians_, reflect, reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1, reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff, reflectwd1d1, reflectwd1wd1, refract, refract111, refract11f, refract1f1, refract1ff, refract221, refract22f, refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f, refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f, refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff, refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, round1, round2, round3, round4, roundEven, roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2, roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, round_, roundd1, roundd2, roundd3, roundd4, roundf, roundwd1, sign, sign1, sign2, sign3, sign4, signd1, signd2, signd3, signd4, signf, signi1, signi2, signi3, signi4, signwd1, signwi1, sin_, sinh, smoothstep, smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1, smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333, smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1, smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2, smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14, smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff, smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1, smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, sqrt1, sqrt2, sqrt3, sqrt4, sqrt_, sqrtd1, sqrtd2, sqrtd3, sqrtd4, sqrtf, sqrtwd1, step, step11, step12, step13, step14, step1f, step22, step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4, stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2, stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3, stepwd1d4, stepwd1wd1, tan_, tanh, trunc, trunc1, trunc2, trunc3, trunc4, truncd1, truncd2, truncd3, truncd4, truncf, truncwd1, uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1, vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f, vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11, vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f, vec2wi1i1, vec2wi1wi1, vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312, vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f, vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1, vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1, vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1, vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f, vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1, vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11, vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1, vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1, vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f, vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1, vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1, vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1, vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413, vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff, vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1, vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f, vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1, vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f, vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1, vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f, vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1, vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f, vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1, vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f, vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1, vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11, vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1, vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1, vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1, vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111, vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1, vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11, vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f, vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1, vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f, vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1, vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f, vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1, vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff, vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1, vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f, vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1, vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f, vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1, vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11, vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1, vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1, vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1, vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111, vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1, vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11, vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1, vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11, vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1, vec4wi1wi1wi1wi1) +module Glsl.Functions exposing + ( abs1, abs2, abs3, abs4, absd1, absd2 + , absd3, absd4, absf, absi1, absi2, absi3 + , absi4, abswd1, abswi1 + , ceil1, ceil2, ceil3, ceil4, ceild1, ceild2 + , ceild3, ceild4, ceilf, ceilwd1, ceil + , clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f + , clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333 + , clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1 + , clamp4ff, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1 + , clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1 + , clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4 + , clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff + , clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1 + , clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3 + , clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1 + , clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1 + , clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1 + , clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4 + , clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1 + , clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1 + , clampwu1wu1u1, clampwu1wu1wu1 + , cross33, crossd3d3 + , distance11, distance1f, distance22, distance33, distance44, distanced1d1 + , distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff + , distancewd1d1, distancewd1wd1, distance + , dot11, dot1f, dot22, dot33, dot44, dotd1d1 + , dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff + , dotwd1d1, dotwd1wd1, dot + , faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333 + , faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2 + , faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff + , faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, faceforward + , floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf + , floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf + , floati1, floatwi1 + , floor1, floor2, floor3, floor4, floord1, floord2 + , floord3, floord4, floorf, floorwd1 + , fma111, fma11f, fma1f1, fma1ff, fma222, fma333 + , fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2 + , fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff + , fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fma + , fract1, fract2, fract3, fract4, fractd1, fractd2 + , fractd3, fractd4, fractf, fractwd1, fract + , frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1 + , frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1 + , frexpwd1oi1, frexpwd1owi1 + , int1, intf + , intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1 + , inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2 + , inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, inversesqrt + , isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2 + , isinfd3, isinfd4, isinff, isinfwd1 + , isnan1, isnan2, isnan3, isnan4, isnand1, isnand2 + , isnand3, isnand4, isnanf, isnanwd1 + , ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1 + , ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1 + , ivec3wi1wi1i1, ivec3wi1wi1wi1 + , ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1 + , ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1 + , ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1 + , ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1 + , ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1 + , ldexpwd1i1, ldexpwd1wi1 + , length1, length2, length3, length4, lengthd1, lengthd2 + , lengthd3, lengthd4, lengthf, lengthwd1, length + , mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f + , mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1 + , mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff + , mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f + , mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff + , mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f + , mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff + , mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f + , mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff + , mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f + , mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff + , mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f + , mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff + , mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f + , mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff + , mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f + , mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff + , mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f + , mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff + , mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f + , mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff + , mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f + , mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff + , mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f + , mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff + , mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f + , mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff + , mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f + , mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff + , mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f + , mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff + , mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f + , mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff + , mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f + , mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff + , mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f + , mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff + , mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f + , mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff + , mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f + , mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff + , mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f + , mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff + , mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f + , mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff + , mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111 + , mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1 + , mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11 + , mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1 + , mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111 + , mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1 + , mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11 + , mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1 + , mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111 + , mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1 + , mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11 + , mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1 + , mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111 + , mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1 + , mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11 + , mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1 + , mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111 + , mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1 + , mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11 + , mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1 + , mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111 + , mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1 + , mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11 + , mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1 + , mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111 + , mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1 + , mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11 + , mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1 + , mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111 + , mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1 + , mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11 + , mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1 + , mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111 + , mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1 + , mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11 + , mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1 + , mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111 + , mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1 + , mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11 + , mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1 + , mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111 + , mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1 + , mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11 + , mat3fffffff1f, mat3ffffffff1, mat3fffffffff + , mat44444 + , max11, max1f, max21, max22, max2f, max31 + , max33, max3f, max41, max44, max4f, maxd1d1 + , maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3 + , maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff + , maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1 + , maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1 + , maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3 + , maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1 + , maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1 + , min11, min1f, min21, min22, min2f, min31 + , min33, min3f, min41, min44, min4f, mind1d1 + , mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3 + , mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff + , mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1 + , mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1 + , minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3 + , minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1 + , minwi1i1, minwi1wi1, minwu1u1, minwu1wu1 + , mix111, mix11f, mix1f1, mix1ff, mix221, mix222 + , mix22f, mix331, mix333, mix33f, mix441, mix444 + , mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1 + , mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1 + , mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff + , mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mix + , mod11, mod1f, mod21, mod22, mod2f, mod31 + , mod33, mod3f, mod41, mod44, mod4f, modd1d1 + , modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3 + , modd3wd1, modd4d1, modd4d4, modd4wd1, modf1, modff + , modwd1d1, modwd1wd1, mod + , modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1 + , modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modffo1, modffof + , modfwd1od1, modfwd1owd1, modf + , normalize1, normalize2, normalize3, normalize4, normalized1, normalized2 + , normalized3, normalized4, normalizef, normalizewd1, normalize + , reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1 + , reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff + , reflectwd1d1, reflectwd1wd1, reflect + , refract111, refract11f, refract1f1, refract1ff, refract221, refract22f + , refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f + , refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f + , refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff + , refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, refract + , round1, round2, round3, round4, roundd1, roundd2 + , roundd3, roundd4, roundf, roundwd1 + , roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2 + , roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, roundEven + , sign1, sign2, sign3, sign4, signd1, signd2 + , signd3, signd4, signf, signi1, signi2, signi3 + , signi4, signwd1, signwi1, sign + , smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1 + , smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333 + , smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1 + , smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2 + , smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14 + , smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff + , smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1 + , smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, smoothstep + , sqrt1, sqrt2, sqrt3, sqrt4, sqrtd1, sqrtd2 + , sqrtd3, sqrtd4, sqrtf, sqrtwd1 + , step11, step12, step13, step14, step1f, step22 + , step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4 + , stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2 + , stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3 + , stepwd1d4, stepwd1wd1, step + , trunc1, trunc2, trunc3, trunc4, truncd1, truncd2 + , truncd3, truncd4, truncf, truncwd1, trunc + , uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1 + , vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f + , vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11 + , vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f + , vec2wi1i1, vec2wi1wi1 + , vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312 + , vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f + , vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1 + , vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1 + , vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1 + , vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f + , vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1 + , vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11 + , vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1 + , vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1 + , vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f + , vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1 + , vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1 + , vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1 + , vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413 + , vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff + , vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1 + , vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f + , vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1 + , vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f + , vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1 + , vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f + , vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1 + , vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f + , vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1 + , vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f + , vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1 + , vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11 + , vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1 + , vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1 + , vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1 + , vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111 + , vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1 + , vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11 + , vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f + , vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1 + , vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f + , vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1 + , vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f + , vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1 + , vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff + , vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1 + , vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f + , vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1 + , vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f + , vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1 + , vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11 + , vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1 + , vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1 + , vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1 + , vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111 + , vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1 + , vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11 + , vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1 + , vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11 + , vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1 + , vec4wi1wi1wi1wi1 + , radians_ + , degrees_ + , sin_ + , cos_ + , tan_ + , asin_ + , acos_ + , atan_ + , atan2_ + , sinh + , cosh + , tanh + , asinh + , acosh + , atanh + , pow + , exp + , log + , exp2 + , log2 + , sqrt_ + , abs_ + , floor_ + , round_ + , min_ + , max_ + , clamp_ + , dFdx + , dFdy + , dFdxFine + , dFdyFine + , dFdxCoarse + , dFdyCoarse + , fwidth + , fwidthFine + , fwidthCoarse + ) {-| -@docs abs1, abs2, abs3, abs4, abs_, absd1, absd2, absd3, absd4, absf, absi1, absi2, absi3, absi4, abswd1, abswi1, acos_, acosh, asin_, asinh, atan2_, atan_, atanh, ceil, ceil1, ceil2, ceil3, ceil4, ceild1, ceild2, ceild3, ceild4, ceilf, ceilwd1, clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f, clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333, clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1, clamp4ff, clamp_, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1, clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1, clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4, clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff, clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1, clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3, clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1, clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1, clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1, clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4, clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1, clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1, clampwu1wu1u1, clampwu1wu1wu1, cos_, cosh, cross33, crossd3d3, dFdx, dFdxCoarse, dFdxFine, dFdy, dFdyCoarse, dFdyFine, degrees_, distance, distance11, distance1f, distance22, distance33, distance44, distanced1d1, distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff, distancewd1d1, distancewd1wd1, dot, dot11, dot1f, dot22, dot33, dot44, dotd1d1, dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff, dotwd1d1, dotwd1wd1, exp, exp2, faceforward, faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333, faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2, faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff, faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf, floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf, floati1, floatwi1, floor1, floor2, floor3, floor4, floor_, floord1, floord2, floord3, floord4, floorf, floorwd1, fma, fma111, fma11f, fma1f1, fma1ff, fma222, fma333, fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2, fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff, fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fract, fract1, fract2, fract3, fract4, fractd1, fractd2, fractd3, fractd4, fractf, fractwd1, frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1, frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1, frexpwd1oi1, frexpwd1owi1, fwidth, fwidthCoarse, fwidthFine, int1, intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1, intf, inversesqrt, inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2, inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2, isinfd3, isinfd4, isinff, isinfwd1, isnan1, isnan2, isnan3, isnan4, isnand1, isnand2, isnand3, isnand4, isnanf, isnanwd1, ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1, ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1, ivec3wi1wi1i1, ivec3wi1wi1wi1, ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1, ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1, ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1, ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1, ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1, ldexpwd1i1, ldexpwd1wi1, length, length1, length2, length3, length4, lengthd1, lengthd2, lengthd3, lengthd4, lengthf, lengthwd1, log, log2, mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f, mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1, mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff, mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f, mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff, mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f, mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff, mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f, mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff, mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f, mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff, mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f, mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff, mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f, mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff, mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f, mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff, mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f, mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff, mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f, mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff, mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f, mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff, mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f, mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff, mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f, mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff, mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f, mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff, mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f, mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff, mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f, mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff, mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f, mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff, mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f, mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff, mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f, mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff, mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f, mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff, mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f, mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff, mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f, mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff, mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111, mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1, mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11, mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1, mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111, mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1, mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11, mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1, mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111, mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1, mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11, mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1, mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111, mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1, mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11, mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1, mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111, mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1, mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11, mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1, mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111, mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1, mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11, mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1, mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111, mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1, mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11, mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1, mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111, mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1, mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11, mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1, mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111, mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1, mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11, mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1, mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111, mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1, mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11, mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1, mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111, mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1, mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11, mat3fffffff1f, mat3ffffffff1, mat3fffffffff, mat44444, max11, max1f, max21, max22, max2f, max31, max33, max3f, max41, max44, max4f, max_, maxd1d1, maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3, maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff, maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1, maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1, maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3, maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1, maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1, min11, min1f, min21, min22, min2f, min31, min33, min3f, min41, min44, min4f, min_, mind1d1, mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3, mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff, mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1, mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1, minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3, minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1, minwi1i1, minwi1wi1, minwu1u1, minwu1wu1, mix, mix111, mix11f, mix1f1, mix1ff, mix221, mix222, mix22f, mix331, mix333, mix33f, mix441, mix444, mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1, mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1, mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff, mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mod, mod11, mod1f, mod21, mod22, mod2f, mod31, mod33, mod3f, mod41, mod44, mod4f, modd1d1, modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3, modd3wd1, modd4d1, modd4d4, modd4wd1, modf, modf1, modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1, modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modff, modffo1, modffof, modfwd1od1, modfwd1owd1, modwd1d1, modwd1wd1, normalize, normalize1, normalize2, normalize3, normalize4, normalized1, normalized2, normalized3, normalized4, normalizef, normalizewd1, pow, radians_, reflect, reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1, reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff, reflectwd1d1, reflectwd1wd1, refract, refract111, refract11f, refract1f1, refract1ff, refract221, refract22f, refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f, refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f, refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff, refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, round1, round2, round3, round4, roundEven, roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2, roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, round_, roundd1, roundd2, roundd3, roundd4, roundf, roundwd1, sign, sign1, sign2, sign3, sign4, signd1, signd2, signd3, signd4, signf, signi1, signi2, signi3, signi4, signwd1, signwi1, sin_, sinh, smoothstep, smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1, smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333, smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1, smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2, smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14, smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff, smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1, smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, sqrt1, sqrt2, sqrt3, sqrt4, sqrt_, sqrtd1, sqrtd2, sqrtd3, sqrtd4, sqrtf, sqrtwd1, step, step11, step12, step13, step14, step1f, step22, step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4, stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2, stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3, stepwd1d4, stepwd1wd1, tan_, tanh, trunc, trunc1, trunc2, trunc3, trunc4, truncd1, truncd2, truncd3, truncd4, truncf, truncwd1, uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1, vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f, vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11, vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f, vec2wi1i1, vec2wi1wi1, vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312, vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f, vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1, vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1, vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1, vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f, vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1, vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11, vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1, vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1, vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f, vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1, vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1, vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1, vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413, vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff, vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1, vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f, vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1, vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f, vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1, vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f, vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1, vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f, vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1, vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f, vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1, vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11, vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1, vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1, vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1, vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111, vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1, vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11, vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f, vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1, vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f, vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1, vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f, vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1, vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff, vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1, vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f, vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1, vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f, vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1, vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11, vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1, vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1, vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1, vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111, vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1, vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11, vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1, vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11, vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1, vec4wi1wi1wi1wi1 +@docs abs1, abs2, abs3, abs4, absd1, absd2 +@docs absd3, absd4, absf, absi1, absi2, absi3 +@docs absi4, abswd1, abswi1 + +@docs ceil1, ceil2, ceil3, ceil4, ceild1, ceild2 +@docs ceild3, ceild4, ceilf, ceilwd1, ceil + +@docs clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f +@docs clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333 +@docs clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1 +@docs clamp4ff, clampd1d1d1, clampd1d1wd1, clampd1wd1d1, clampd1wd1wd1, clampd2d1d1 +@docs clampd2d1wd1, clampd2d2d2, clampd2wd1d1, clampd2wd1wd1, clampd3d1d1, clampd3d1wd1 +@docs clampd3d3d3, clampd3wd1d1, clampd3wd1wd1, clampd4d1d1, clampd4d1wd1, clampd4d4d4 +@docs clampd4wd1d1, clampd4wd1wd1, clampf11, clampf1f, clampff1, clampfff +@docs clampi1i1i1, clampi1i1wi1, clampi1wi1i1, clampi1wi1wi1, clampi2i1i1, clampi2i1wi1 +@docs clampi2i2i2, clampi2wi1i1, clampi2wi1wi1, clampi3i1i1, clampi3i1wi1, clampi3i3i3 +@docs clampi3wi1i1, clampi3wi1wi1, clampi4i1i1, clampi4i1wi1, clampi4i4i4, clampi4wi1i1 +@docs clampi4wi1wi1, clampu1u1u1, clampu1u1wu1, clampu1wu1u1, clampu1wu1wu1, clampu2u1u1 +@docs clampu2u1wu1, clampu2u2u2, clampu2wu1u1, clampu2wu1wu1, clampu3u1u1, clampu3u1wu1 +@docs clampu3u3u3, clampu3wu1u1, clampu3wu1wu1, clampu4u1u1, clampu4u1wu1, clampu4u4u4 +@docs clampu4wu1u1, clampu4wu1wu1, clampwd1d1d1, clampwd1d1wd1, clampwd1wd1d1, clampwd1wd1wd1 +@docs clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1 +@docs clampwu1wu1u1, clampwu1wu1wu1 + +@docs cross33, crossd3d3 + +@docs distance11, distance1f, distance22, distance33, distance44, distanced1d1 +@docs distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff +@docs distancewd1d1, distancewd1wd1, distance + +@docs dot11, dot1f, dot22, dot33, dot44, dotd1d1 +@docs dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff +@docs dotwd1d1, dotwd1wd1, dot + +@docs faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333 +@docs faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2 +@docs faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff +@docs faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, faceforward + +@docs floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf + +@docs floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf + +@docs floati1, floatwi1 + +@docs floor1, floor2, floor3, floor4, floord1, floord2 +@docs floord3, floord4, floorf, floorwd1 + +@docs fma111, fma11f, fma1f1, fma1ff, fma222, fma333 +@docs fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2 +@docs fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff +@docs fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fma + +@docs fract1, fract2, fract3, fract4, fractd1, fractd2 +@docs fractd3, fractd4, fractf, fractwd1, fract + +@docs frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1 +@docs frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1 +@docs frexpwd1oi1, frexpwd1owi1 + +@docs int1, intf + +@docs intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1 + +@docs inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2 +@docs inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, inversesqrt + +@docs isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2 +@docs isinfd3, isinfd4, isinff, isinfwd1 + +@docs isnan1, isnan2, isnan3, isnan4, isnand1, isnand2 +@docs isnand3, isnand4, isnanf, isnanwd1 + +@docs ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1 + +@docs ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1 +@docs ivec3wi1wi1i1, ivec3wi1wi1wi1 + +@docs ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1 +@docs ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1 +@docs ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1 + +@docs ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1 +@docs ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1 +@docs ldexpwd1i1, ldexpwd1wi1 + +@docs length1, length2, length3, length4, lengthd1, lengthd2 +@docs lengthd3, lengthd4, lengthf, lengthwd1, length + +@docs mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f +@docs mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1 +@docs mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff + +@docs mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f +@docs mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff +@docs mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f +@docs mat31111f11f1, mat31111f11ff, mat31111f1f11, mat31111f1f1f, mat31111f1ff1, mat31111f1fff +@docs mat31111ff111, mat31111ff11f, mat31111ff1f1, mat31111ff1ff, mat31111fff11, mat31111fff1f +@docs mat31111ffff1, mat31111fffff, mat3111f11111, mat3111f1111f, mat3111f111f1, mat3111f111ff +@docs mat3111f11f11, mat3111f11f1f, mat3111f11ff1, mat3111f11fff, mat3111f1f111, mat3111f1f11f +@docs mat3111f1f1f1, mat3111f1f1ff, mat3111f1ff11, mat3111f1ff1f, mat3111f1fff1, mat3111f1ffff +@docs mat3111ff1111, mat3111ff111f, mat3111ff11f1, mat3111ff11ff, mat3111ff1f11, mat3111ff1f1f +@docs mat3111ff1ff1, mat3111ff1fff, mat3111fff111, mat3111fff11f, mat3111fff1f1, mat3111fff1ff +@docs mat3111ffff11, mat3111ffff1f, mat3111fffff1, mat3111ffffff, mat311f111111, mat311f11111f +@docs mat311f1111f1, mat311f1111ff, mat311f111f11, mat311f111f1f, mat311f111ff1, mat311f111fff +@docs mat311f11f111, mat311f11f11f, mat311f11f1f1, mat311f11f1ff, mat311f11ff11, mat311f11ff1f +@docs mat311f11fff1, mat311f11ffff, mat311f1f1111, mat311f1f111f, mat311f1f11f1, mat311f1f11ff +@docs mat311f1f1f11, mat311f1f1f1f, mat311f1f1ff1, mat311f1f1fff, mat311f1ff111, mat311f1ff11f +@docs mat311f1ff1f1, mat311f1ff1ff, mat311f1fff11, mat311f1fff1f, mat311f1ffff1, mat311f1fffff +@docs mat311ff11111, mat311ff1111f, mat311ff111f1, mat311ff111ff, mat311ff11f11, mat311ff11f1f +@docs mat311ff11ff1, mat311ff11fff, mat311ff1f111, mat311ff1f11f, mat311ff1f1f1, mat311ff1f1ff +@docs mat311ff1ff11, mat311ff1ff1f, mat311ff1fff1, mat311ff1ffff, mat311fff1111, mat311fff111f +@docs mat311fff11f1, mat311fff11ff, mat311fff1f11, mat311fff1f1f, mat311fff1ff1, mat311fff1fff +@docs mat311ffff111, mat311ffff11f, mat311ffff1f1, mat311ffff1ff, mat311fffff11, mat311fffff1f +@docs mat311ffffff1, mat311fffffff, mat31f1111111, mat31f111111f, mat31f11111f1, mat31f11111ff +@docs mat31f1111f11, mat31f1111f1f, mat31f1111ff1, mat31f1111fff, mat31f111f111, mat31f111f11f +@docs mat31f111f1f1, mat31f111f1ff, mat31f111ff11, mat31f111ff1f, mat31f111fff1, mat31f111ffff +@docs mat31f11f1111, mat31f11f111f, mat31f11f11f1, mat31f11f11ff, mat31f11f1f11, mat31f11f1f1f +@docs mat31f11f1ff1, mat31f11f1fff, mat31f11ff111, mat31f11ff11f, mat31f11ff1f1, mat31f11ff1ff +@docs mat31f11fff11, mat31f11fff1f, mat31f11ffff1, mat31f11fffff, mat31f1f11111, mat31f1f1111f +@docs mat31f1f111f1, mat31f1f111ff, mat31f1f11f11, mat31f1f11f1f, mat31f1f11ff1, mat31f1f11fff +@docs mat31f1f1f111, mat31f1f1f11f, mat31f1f1f1f1, mat31f1f1f1ff, mat31f1f1ff11, mat31f1f1ff1f +@docs mat31f1f1fff1, mat31f1f1ffff, mat31f1ff1111, mat31f1ff111f, mat31f1ff11f1, mat31f1ff11ff +@docs mat31f1ff1f11, mat31f1ff1f1f, mat31f1ff1ff1, mat31f1ff1fff, mat31f1fff111, mat31f1fff11f +@docs mat31f1fff1f1, mat31f1fff1ff, mat31f1ffff11, mat31f1ffff1f, mat31f1fffff1, mat31f1ffffff +@docs mat31ff111111, mat31ff11111f, mat31ff1111f1, mat31ff1111ff, mat31ff111f11, mat31ff111f1f +@docs mat31ff111ff1, mat31ff111fff, mat31ff11f111, mat31ff11f11f, mat31ff11f1f1, mat31ff11f1ff +@docs mat31ff11ff11, mat31ff11ff1f, mat31ff11fff1, mat31ff11ffff, mat31ff1f1111, mat31ff1f111f +@docs mat31ff1f11f1, mat31ff1f11ff, mat31ff1f1f11, mat31ff1f1f1f, mat31ff1f1ff1, mat31ff1f1fff +@docs mat31ff1ff111, mat31ff1ff11f, mat31ff1ff1f1, mat31ff1ff1ff, mat31ff1fff11, mat31ff1fff1f +@docs mat31ff1ffff1, mat31ff1fffff, mat31fff11111, mat31fff1111f, mat31fff111f1, mat31fff111ff +@docs mat31fff11f11, mat31fff11f1f, mat31fff11ff1, mat31fff11fff, mat31fff1f111, mat31fff1f11f +@docs mat31fff1f1f1, mat31fff1f1ff, mat31fff1ff11, mat31fff1ff1f, mat31fff1fff1, mat31fff1ffff +@docs mat31ffff1111, mat31ffff111f, mat31ffff11f1, mat31ffff11ff, mat31ffff1f11, mat31ffff1f1f +@docs mat31ffff1ff1, mat31ffff1fff, mat31fffff111, mat31fffff11f, mat31fffff1f1, mat31fffff1ff +@docs mat31ffffff11, mat31ffffff1f, mat31fffffff1, mat31ffffffff, mat3333, mat3f11111111 +@docs mat3f1111111f, mat3f111111f1, mat3f111111ff, mat3f11111f11, mat3f11111f1f, mat3f11111ff1 +@docs mat3f11111fff, mat3f1111f111, mat3f1111f11f, mat3f1111f1f1, mat3f1111f1ff, mat3f1111ff11 +@docs mat3f1111ff1f, mat3f1111fff1, mat3f1111ffff, mat3f111f1111, mat3f111f111f, mat3f111f11f1 +@docs mat3f111f11ff, mat3f111f1f11, mat3f111f1f1f, mat3f111f1ff1, mat3f111f1fff, mat3f111ff111 +@docs mat3f111ff11f, mat3f111ff1f1, mat3f111ff1ff, mat3f111fff11, mat3f111fff1f, mat3f111ffff1 +@docs mat3f111fffff, mat3f11f11111, mat3f11f1111f, mat3f11f111f1, mat3f11f111ff, mat3f11f11f11 +@docs mat3f11f11f1f, mat3f11f11ff1, mat3f11f11fff, mat3f11f1f111, mat3f11f1f11f, mat3f11f1f1f1 +@docs mat3f11f1f1ff, mat3f11f1ff11, mat3f11f1ff1f, mat3f11f1fff1, mat3f11f1ffff, mat3f11ff1111 +@docs mat3f11ff111f, mat3f11ff11f1, mat3f11ff11ff, mat3f11ff1f11, mat3f11ff1f1f, mat3f11ff1ff1 +@docs mat3f11ff1fff, mat3f11fff111, mat3f11fff11f, mat3f11fff1f1, mat3f11fff1ff, mat3f11ffff11 +@docs mat3f11ffff1f, mat3f11fffff1, mat3f11ffffff, mat3f1f111111, mat3f1f11111f, mat3f1f1111f1 +@docs mat3f1f1111ff, mat3f1f111f11, mat3f1f111f1f, mat3f1f111ff1, mat3f1f111fff, mat3f1f11f111 +@docs mat3f1f11f11f, mat3f1f11f1f1, mat3f1f11f1ff, mat3f1f11ff11, mat3f1f11ff1f, mat3f1f11fff1 +@docs mat3f1f11ffff, mat3f1f1f1111, mat3f1f1f111f, mat3f1f1f11f1, mat3f1f1f11ff, mat3f1f1f1f11 +@docs mat3f1f1f1f1f, mat3f1f1f1ff1, mat3f1f1f1fff, mat3f1f1ff111, mat3f1f1ff11f, mat3f1f1ff1f1 +@docs mat3f1f1ff1ff, mat3f1f1fff11, mat3f1f1fff1f, mat3f1f1ffff1, mat3f1f1fffff, mat3f1ff11111 +@docs mat3f1ff1111f, mat3f1ff111f1, mat3f1ff111ff, mat3f1ff11f11, mat3f1ff11f1f, mat3f1ff11ff1 +@docs mat3f1ff11fff, mat3f1ff1f111, mat3f1ff1f11f, mat3f1ff1f1f1, mat3f1ff1f1ff, mat3f1ff1ff11 +@docs mat3f1ff1ff1f, mat3f1ff1fff1, mat3f1ff1ffff, mat3f1fff1111, mat3f1fff111f, mat3f1fff11f1 +@docs mat3f1fff11ff, mat3f1fff1f11, mat3f1fff1f1f, mat3f1fff1ff1, mat3f1fff1fff, mat3f1ffff111 +@docs mat3f1ffff11f, mat3f1ffff1f1, mat3f1ffff1ff, mat3f1fffff11, mat3f1fffff1f, mat3f1ffffff1 +@docs mat3f1fffffff, mat3ff1111111, mat3ff111111f, mat3ff11111f1, mat3ff11111ff, mat3ff1111f11 +@docs mat3ff1111f1f, mat3ff1111ff1, mat3ff1111fff, mat3ff111f111, mat3ff111f11f, mat3ff111f1f1 +@docs mat3ff111f1ff, mat3ff111ff11, mat3ff111ff1f, mat3ff111fff1, mat3ff111ffff, mat3ff11f1111 +@docs mat3ff11f111f, mat3ff11f11f1, mat3ff11f11ff, mat3ff11f1f11, mat3ff11f1f1f, mat3ff11f1ff1 +@docs mat3ff11f1fff, mat3ff11ff111, mat3ff11ff11f, mat3ff11ff1f1, mat3ff11ff1ff, mat3ff11fff11 +@docs mat3ff11fff1f, mat3ff11ffff1, mat3ff11fffff, mat3ff1f11111, mat3ff1f1111f, mat3ff1f111f1 +@docs mat3ff1f111ff, mat3ff1f11f11, mat3ff1f11f1f, mat3ff1f11ff1, mat3ff1f11fff, mat3ff1f1f111 +@docs mat3ff1f1f11f, mat3ff1f1f1f1, mat3ff1f1f1ff, mat3ff1f1ff11, mat3ff1f1ff1f, mat3ff1f1fff1 +@docs mat3ff1f1ffff, mat3ff1ff1111, mat3ff1ff111f, mat3ff1ff11f1, mat3ff1ff11ff, mat3ff1ff1f11 +@docs mat3ff1ff1f1f, mat3ff1ff1ff1, mat3ff1ff1fff, mat3ff1fff111, mat3ff1fff11f, mat3ff1fff1f1 +@docs mat3ff1fff1ff, mat3ff1ffff11, mat3ff1ffff1f, mat3ff1fffff1, mat3ff1ffffff, mat3fff111111 +@docs mat3fff11111f, mat3fff1111f1, mat3fff1111ff, mat3fff111f11, mat3fff111f1f, mat3fff111ff1 +@docs mat3fff111fff, mat3fff11f111, mat3fff11f11f, mat3fff11f1f1, mat3fff11f1ff, mat3fff11ff11 +@docs mat3fff11ff1f, mat3fff11fff1, mat3fff11ffff, mat3fff1f1111, mat3fff1f111f, mat3fff1f11f1 +@docs mat3fff1f11ff, mat3fff1f1f11, mat3fff1f1f1f, mat3fff1f1ff1, mat3fff1f1fff, mat3fff1ff111 +@docs mat3fff1ff11f, mat3fff1ff1f1, mat3fff1ff1ff, mat3fff1fff11, mat3fff1fff1f, mat3fff1ffff1 +@docs mat3fff1fffff, mat3ffff11111, mat3ffff1111f, mat3ffff111f1, mat3ffff111ff, mat3ffff11f11 +@docs mat3ffff11f1f, mat3ffff11ff1, mat3ffff11fff, mat3ffff1f111, mat3ffff1f11f, mat3ffff1f1f1 +@docs mat3ffff1f1ff, mat3ffff1ff11, mat3ffff1ff1f, mat3ffff1fff1, mat3ffff1ffff, mat3fffff1111 +@docs mat3fffff111f, mat3fffff11f1, mat3fffff11ff, mat3fffff1f11, mat3fffff1f1f, mat3fffff1ff1 +@docs mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11 +@docs mat3fffffff1f, mat3ffffffff1, mat3fffffffff + +@docs mat44444 + +@docs max11, max1f, max21, max22, max2f, max31 +@docs max33, max3f, max41, max44, max4f, maxd1d1 +@docs maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3 +@docs maxd3wd1, maxd4d1, maxd4d4, maxd4wd1, maxf1, maxff +@docs maxi1i1, maxi1wi1, maxi2i1, maxi2i2, maxi2wi1, maxi3i1 +@docs maxi3i3, maxi3wi1, maxi4i1, maxi4i4, maxi4wi1, maxu1u1 +@docs maxu1wu1, maxu2u1, maxu2u2, maxu2wu1, maxu3u1, maxu3u3 +@docs maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1 +@docs maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1 + +@docs min11, min1f, min21, min22, min2f, min31 +@docs min33, min3f, min41, min44, min4f, mind1d1 +@docs mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3 +@docs mind3wd1, mind4d1, mind4d4, mind4wd1, minf1, minff +@docs mini1i1, mini1wi1, mini2i1, mini2i2, mini2wi1, mini3i1 +@docs mini3i3, mini3wi1, mini4i1, mini4i4, mini4wi1, minu1u1 +@docs minu1wu1, minu2u1, minu2u2, minu2wu1, minu3u1, minu3u3 +@docs minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1 +@docs minwi1i1, minwi1wi1, minwu1u1, minwu1wu1 + +@docs mix111, mix11f, mix1f1, mix1ff, mix221, mix222 +@docs mix22f, mix331, mix333, mix33f, mix441, mix444 +@docs mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1 +@docs mixd2d2d2, mixd2d2wd1, mixd3d3d1, mixd3d3d3, mixd3d3wd1, mixd4d4d1 +@docs mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff +@docs mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mix + +@docs mod11, mod1f, mod21, mod22, mod2f, mod31 +@docs mod33, mod3f, mod41, mod44, mod4f, modd1d1 +@docs modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3 +@docs modd3wd1, modd4d1, modd4d4, modd4wd1, modf1, modff +@docs modwd1d1, modwd1wd1, mod + +@docs modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1 +@docs modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modffo1, modffof +@docs modfwd1od1, modfwd1owd1, modf + +@docs normalize1, normalize2, normalize3, normalize4, normalized1, normalized2 +@docs normalized3, normalized4, normalizef, normalizewd1, normalize + +@docs reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1 +@docs reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff +@docs reflectwd1d1, reflectwd1wd1, reflect + +@docs refract111, refract11f, refract1f1, refract1ff, refract221, refract22f +@docs refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f +@docs refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f +@docs refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff +@docs refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, refract + +@docs round1, round2, round3, round4, roundd1, roundd2 +@docs roundd3, roundd4, roundf, roundwd1 + +@docs roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2 +@docs roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, roundEven + +@docs sign1, sign2, sign3, sign4, signd1, signd2 +@docs signd3, signd4, signf, signi1, signi2, signi3 +@docs signi4, signwd1, signwi1, sign + +@docs smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1 +@docs smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333 +@docs smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1 +@docs smoothstepd1wd1d1, smoothstepd1wd1d2, smoothstepd1wd1d3, smoothstepd1wd1d4, smoothstepd1wd1wd1, smoothstepd2d2d2 +@docs smoothstepd3d3d3, smoothstepd4d4d4, smoothstepf11, smoothstepf12, smoothstepf13, smoothstepf14 +@docs smoothstepf1f, smoothstepff1, smoothstepff2, smoothstepff3, smoothstepff4, smoothstepfff +@docs smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1 +@docs smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, smoothstep + +@docs sqrt1, sqrt2, sqrt3, sqrt4, sqrtd1, sqrtd2 +@docs sqrtd3, sqrtd4, sqrtf, sqrtwd1 + +@docs step11, step12, step13, step14, step1f, step22 +@docs step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4 +@docs stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2 +@docs stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3 +@docs stepwd1d4, stepwd1wd1, step + +@docs trunc1, trunc2, trunc3, trunc4, truncd1, truncd2 +@docs truncd3, truncd4, truncf, truncwd1, trunc + +@docs uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1 + +@docs vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f +@docs vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11 +@docs vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f +@docs vec2wi1i1, vec2wi1wi1 + +@docs vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312 +@docs vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f +@docs vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1 +@docs vec321, vec32f, vec3f, vec3f11, vec3f1f, vec3f1i1 +@docs vec3f1wi1, vec3f2, vec3ff1, vec3fff, vec3ffi1, vec3ffwi1 +@docs vec3fi11, vec3fi1f, vec3fi1i1, vec3fi1wi1, vec3fwi11, vec3fwi1f +@docs vec3fwi1i1, vec3fwi1wi1, vec3i1, vec3i111, vec3i11f, vec3i11i1 +@docs vec3i11wi1, vec3i1f1, vec3i1ff, vec3i1fi1, vec3i1fwi1, vec3i1i11 +@docs vec3i1i1f, vec3i1i1i1, vec3i1i1wi1, vec3i1wi11, vec3i1wi1f, vec3i1wi1i1 +@docs vec3i1wi1wi1, vec3wi1, vec3wi111, vec3wi11f, vec3wi11i1, vec3wi11wi1 +@docs vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f +@docs vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1 + +@docs vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1 +@docs vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1 +@docs vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413 +@docs vec41f11, vec41f1f, vec41f1i1, vec41f1wi1, vec41ff1, vec41fff +@docs vec41ffi1, vec41ffwi1, vec41fi11, vec41fi1f, vec41fi1i1, vec41fi1wi1 +@docs vec41fwi11, vec41fwi1f, vec41fwi1i1, vec41fwi1wi1, vec41i111, vec41i11f +@docs vec41i11i1, vec41i11wi1, vec41i1f1, vec41i1ff, vec41i1fi1, vec41i1fwi1 +@docs vec41i1i11, vec41i1i1f, vec41i1i1i1, vec41i1i1wi1, vec41i1wi11, vec41i1wi1f +@docs vec41i1wi1i1, vec41i1wi1wi1, vec41wi111, vec41wi11f, vec41wi11i1, vec41wi11wi1 +@docs vec41wi1f1, vec41wi1ff, vec41wi1fi1, vec41wi1fwi1, vec41wi1i11, vec41wi1i1f +@docs vec41wi1i1i1, vec41wi1i1wi1, vec41wi1wi11, vec41wi1wi1f, vec41wi1wi1i1, vec41wi1wi1wi1 +@docs vec422, vec431, vec43f, vec4f, vec4f111, vec4f11f +@docs vec4f11i1, vec4f11wi1, vec4f1f1, vec4f1ff, vec4f1fi1, vec4f1fwi1 +@docs vec4f1i11, vec4f1i1f, vec4f1i1i1, vec4f1i1wi1, vec4f1wi11, vec4f1wi1f +@docs vec4f1wi1i1, vec4f1wi1wi1, vec4f3, vec4ff11, vec4ff1f, vec4ff1i1 +@docs vec4ff1wi1, vec4fff1, vec4ffff, vec4fffi1, vec4fffwi1, vec4ffi11 +@docs vec4ffi1f, vec4ffi1i1, vec4ffi1wi1, vec4ffwi11, vec4ffwi1f, vec4ffwi1i1 +@docs vec4ffwi1wi1, vec4fi111, vec4fi11f, vec4fi11i1, vec4fi11wi1, vec4fi1f1 +@docs vec4fi1ff, vec4fi1fi1, vec4fi1fwi1, vec4fi1i11, vec4fi1i1f, vec4fi1i1i1 +@docs vec4fi1i1wi1, vec4fi1wi11, vec4fi1wi1f, vec4fi1wi1i1, vec4fi1wi1wi1, vec4fwi111 +@docs vec4fwi11f, vec4fwi11i1, vec4fwi11wi1, vec4fwi1f1, vec4fwi1ff, vec4fwi1fi1 +@docs vec4fwi1fwi1, vec4fwi1i11, vec4fwi1i1f, vec4fwi1i1i1, vec4fwi1i1wi1, vec4fwi1wi11 +@docs vec4fwi1wi1f, vec4fwi1wi1i1, vec4fwi1wi1wi1, vec4i1, vec4i1111, vec4i111f +@docs vec4i111i1, vec4i111wi1, vec4i11f1, vec4i11ff, vec4i11fi1, vec4i11fwi1 +@docs vec4i11i11, vec4i11i1f, vec4i11i1i1, vec4i11i1wi1, vec4i11wi11, vec4i11wi1f +@docs vec4i11wi1i1, vec4i11wi1wi1, vec4i1f11, vec4i1f1f, vec4i1f1i1, vec4i1f1wi1 +@docs vec4i1ff1, vec4i1fff, vec4i1ffi1, vec4i1ffwi1, vec4i1fi11, vec4i1fi1f +@docs vec4i1fi1i1, vec4i1fi1wi1, vec4i1fwi11, vec4i1fwi1f, vec4i1fwi1i1, vec4i1fwi1wi1 +@docs vec4i1i111, vec4i1i11f, vec4i1i11i1, vec4i1i11wi1, vec4i1i1f1, vec4i1i1ff +@docs vec4i1i1fi1, vec4i1i1fwi1, vec4i1i1i11, vec4i1i1i1f, vec4i1i1i1i1, vec4i1i1i1wi1 +@docs vec4i1i1wi11, vec4i1i1wi1f, vec4i1i1wi1i1, vec4i1i1wi1wi1, vec4i1wi111, vec4i1wi11f +@docs vec4i1wi11i1, vec4i1wi11wi1, vec4i1wi1f1, vec4i1wi1ff, vec4i1wi1fi1, vec4i1wi1fwi1 +@docs vec4i1wi1i11, vec4i1wi1i1f, vec4i1wi1i1i1, vec4i1wi1i1wi1, vec4i1wi1wi11, vec4i1wi1wi1f +@docs vec4i1wi1wi1i1, vec4i1wi1wi1wi1, vec4wi1, vec4wi1111, vec4wi111f, vec4wi111i1 +@docs vec4wi111wi1, vec4wi11f1, vec4wi11ff, vec4wi11fi1, vec4wi11fwi1, vec4wi11i11 +@docs vec4wi11i1f, vec4wi11i1i1, vec4wi11i1wi1, vec4wi11wi11, vec4wi11wi1f, vec4wi11wi1i1 +@docs vec4wi11wi1wi1, vec4wi1f11, vec4wi1f1f, vec4wi1f1i1, vec4wi1f1wi1, vec4wi1ff1 +@docs vec4wi1fff, vec4wi1ffi1, vec4wi1ffwi1, vec4wi1fi11, vec4wi1fi1f, vec4wi1fi1i1 +@docs vec4wi1fi1wi1, vec4wi1fwi11, vec4wi1fwi1f, vec4wi1fwi1i1, vec4wi1fwi1wi1, vec4wi1i111 +@docs vec4wi1i11f, vec4wi1i11i1, vec4wi1i11wi1, vec4wi1i1f1, vec4wi1i1ff, vec4wi1i1fi1 +@docs vec4wi1i1fwi1, vec4wi1i1i11, vec4wi1i1i1f, vec4wi1i1i1i1, vec4wi1i1i1wi1, vec4wi1i1wi11 +@docs vec4wi1i1wi1f, vec4wi1i1wi1i1, vec4wi1i1wi1wi1, vec4wi1wi111, vec4wi1wi11f, vec4wi1wi11i1 +@docs vec4wi1wi11wi1, vec4wi1wi1f1, vec4wi1wi1ff, vec4wi1wi1fi1, vec4wi1wi1fwi1, vec4wi1wi1i11 +@docs vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1 +@docs vec4wi1wi1wi1wi1 + +@docs radians_ + +@docs degrees_ + +@docs sin_ + +@docs cos_ + +@docs tan_ + +@docs asin_ + +@docs acos_ + +@docs atan_ + +@docs atan2_ + +@docs sinh + +@docs cosh + +@docs tanh + +@docs asinh + +@docs acosh + +@docs atanh + +@docs pow + +@docs exp + +@docs log + +@docs exp2 + +@docs log2 + +@docs sqrt_ + +@docs abs_ + +@docs floor_ + +@docs round_ + +@docs min_ + +@docs max_ + +@docs clamp_ + +@docs dFdx + +@docs dFdy + +@docs dFdxFine + +@docs dFdyFine + +@docs dFdxCoarse + +@docs dFdyCoarse + +@docs fwidth + +@docs fwidthFine + +@docs fwidthCoarse -} From 9254a681809ec8d5fa24fb3a8ec5ec4b7c6bd3dc Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 22 Apr 2025 18:24:21 +0200 Subject: [PATCH 138/139] Even better formatting --- .../elm-glsl/1.0.0/src/Glsl/Functions.elm | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) diff --git a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm index 57862cf7..1b0035d7 100644 --- a/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm +++ b/vendored/miniBill/elm-glsl/1.0.0/src/Glsl/Functions.elm @@ -322,13 +322,22 @@ module Glsl.Functions exposing {-| + +## abs + @docs abs1, abs2, abs3, abs4, absd1, absd2 @docs absd3, absd4, absf, absi1, absi2, absi3 @docs absi4, abswd1, abswi1 + +## ceil + @docs ceil1, ceil2, ceil3, ceil4, ceild1, ceild2 @docs ceild3, ceild4, ceilf, ceilwd1, ceil + +## clamp + @docs clamp111, clamp11f, clamp1f1, clamp1ff, clamp211, clamp21f @docs clamp222, clamp2f1, clamp2ff, clamp311, clamp31f, clamp333 @docs clamp3f1, clamp3ff, clamp411, clamp41f, clamp444, clamp4f1 @@ -346,75 +355,144 @@ module Glsl.Functions exposing @docs clampwi1i1i1, clampwi1i1wi1, clampwi1wi1i1, clampwi1wi1wi1, clampwu1u1u1, clampwu1u1wu1 @docs clampwu1wu1u1, clampwu1wu1wu1 + +## cross + @docs cross33, crossd3d3 + +## distance + @docs distance11, distance1f, distance22, distance33, distance44, distanced1d1 @docs distanced1wd1, distanced2d2, distanced3d3, distanced4d4, distancef1, distanceff @docs distancewd1d1, distancewd1wd1, distance + +## dot + @docs dot11, dot1f, dot22, dot33, dot44, dotd1d1 @docs dotd1wd1, dotd2d2, dotd3d3, dotd4d4, dotf1, dotff @docs dotwd1d1, dotwd1wd1, dot + +## faceforward + @docs faceforward111, faceforward11f, faceforward1f1, faceforward1ff, faceforward222, faceforward333 @docs faceforward444, faceforwardd1d1d1, faceforwardd1d1wd1, faceforwardd1wd1d1, faceforwardd1wd1wd1, faceforwardd2d2d2 @docs faceforwardd3d3d3, faceforwardd4d4d4, faceforwardf11, faceforwardf1f, faceforwardff1, faceforwardfff @docs faceforwardwd1d1d1, faceforwardwd1d1wd1, faceforwardwd1wd1d1, faceforwardwd1wd1wd1, faceforward + +## floatBitsToInt + @docs floatBitsToInt1, floatBitsToInt2, floatBitsToInt3, floatBitsToInt4, floatBitsToIntf + +## floatBitsToUint + @docs floatBitsToUint1, floatBitsToUint2, floatBitsToUint3, floatBitsToUint4, floatBitsToUintf + +## float + @docs floati1, floatwi1 + +## floor + @docs floor1, floor2, floor3, floor4, floord1, floord2 @docs floord3, floord4, floorf, floorwd1 + +## fma + @docs fma111, fma11f, fma1f1, fma1ff, fma222, fma333 @docs fma444, fmad1d1d1, fmad1d1wd1, fmad1wd1d1, fmad1wd1wd1, fmad2d2d2 @docs fmad3d3d3, fmad4d4d4, fmaf11, fmaf1f, fmaff1, fmafff @docs fmawd1d1d1, fmawd1d1wd1, fmawd1wd1d1, fmawd1wd1wd1, fma + +## fract + @docs fract1, fract2, fract3, fract4, fractd1, fractd2 @docs fractd3, fractd4, fractf, fractwd1, fract + +## frexp + @docs frexp1oi1, frexp1owi1, frexp2oi2, frexp3oi3, frexp4oi4, frexpd1oi1 @docs frexpd1owi1, frexpd2oi2, frexpd3oi3, frexpd4oi4, frexpfoi1, frexpfowi1 @docs frexpwd1oi1, frexpwd1owi1 + +## int + @docs int1, intf + +## intBitsToFloat + @docs intBitsToFloati1, intBitsToFloati2, intBitsToFloati3, intBitsToFloati4, intBitsToFloatwi1 + +## inversesqrt + @docs inversesqrt1, inversesqrt2, inversesqrt3, inversesqrt4, inversesqrtd1, inversesqrtd2 @docs inversesqrtd3, inversesqrtd4, inversesqrtf, inversesqrtwd1, inversesqrt + +## isinf + @docs isinf1, isinf2, isinf3, isinf4, isinfd1, isinfd2 @docs isinfd3, isinfd4, isinff, isinfwd1 + +## isnan + @docs isnan1, isnan2, isnan3, isnan4, isnand1, isnand2 @docs isnand3, isnand4, isnanf, isnanwd1 + +## ivec2 + @docs ivec2i1i1, ivec2i1wi1, ivec2wi1i1, ivec2wi1wi1 + +## ivec3 + @docs ivec3i1i1i1, ivec3i1i1wi1, ivec3i1wi1i1, ivec3i1wi1wi1, ivec3wi1i1i1, ivec3wi1i1wi1 @docs ivec3wi1wi1i1, ivec3wi1wi1wi1 + +## ivec4 + @docs ivec4i1i1i1i1, ivec4i1i1i1wi1, ivec4i1i1wi1i1, ivec4i1i1wi1wi1, ivec4i1wi1i1i1, ivec4i1wi1i1wi1 @docs ivec4i1wi1wi1i1, ivec4i1wi1wi1wi1, ivec4wi1i1i1i1, ivec4wi1i1i1wi1, ivec4wi1i1wi1i1, ivec4wi1i1wi1wi1 @docs ivec4wi1wi1i1i1, ivec4wi1wi1i1wi1, ivec4wi1wi1wi1i1, ivec4wi1wi1wi1wi1 + +## ldexp + @docs ldexp1i1, ldexp1wi1, ldexp2i2, ldexp3i3, ldexp4i4, ldexpd1i1 @docs ldexpd1wi1, ldexpd2i2, ldexpd3i3, ldexpd4i4, ldexpfi1, ldexpfwi1 @docs ldexpwd1i1, ldexpwd1wi1 + +## length + @docs length1, length2, length3, length4, lengthd1, lengthd2 @docs lengthd3, lengthd4, lengthf, lengthwd1, length + +## mat2 + @docs mat21111, mat2111f, mat211f1, mat211ff, mat21f11, mat21f1f @docs mat21ff1, mat21fff, mat222, mat2f111, mat2f11f, mat2f1f1 @docs mat2f1ff, mat2ff11, mat2ff1f, mat2fff1, mat2ffff + +## mat3 + @docs mat3111111111, mat311111111f, mat31111111f1, mat31111111ff, mat3111111f11, mat3111111f1f @docs mat3111111ff1, mat3111111fff, mat311111f111, mat311111f11f, mat311111f1f1, mat311111f1ff @docs mat311111ff11, mat311111ff1f, mat311111fff1, mat311111ffff, mat31111f1111, mat31111f111f @@ -502,8 +580,14 @@ module Glsl.Functions exposing @docs mat3fffff1fff, mat3ffffff111, mat3ffffff11f, mat3ffffff1f1, mat3ffffff1ff, mat3fffffff11 @docs mat3fffffff1f, mat3ffffffff1, mat3fffffffff + +## mat4 + @docs mat44444 + +## max + @docs max11, max1f, max21, max22, max2f, max31 @docs max33, max3f, max41, max44, max4f, maxd1d1 @docs maxd1wd1, maxd2d1, maxd2d2, maxd2wd1, maxd3d1, maxd3d3 @@ -514,6 +598,9 @@ module Glsl.Functions exposing @docs maxu3wu1, maxu4u1, maxu4u4, maxu4wu1, maxwd1d1, maxwd1wd1 @docs maxwi1i1, maxwi1wi1, maxwu1u1, maxwu1wu1 + +## min + @docs min11, min1f, min21, min22, min2f, min31 @docs min33, min3f, min41, min44, min4f, mind1d1 @docs mind1wd1, mind2d1, mind2d2, mind2wd1, mind3d1, mind3d3 @@ -524,6 +611,9 @@ module Glsl.Functions exposing @docs minu3wu1, minu4u1, minu4u4, minu4wu1, minwd1d1, minwd1wd1 @docs minwi1i1, minwi1wi1, minwu1u1, minwu1wu1 + +## mix + @docs mix111, mix11f, mix1f1, mix1ff, mix221, mix222 @docs mix22f, mix331, mix333, mix33f, mix441, mix444 @docs mix44f, mixd1d1d1, mixd1d1wd1, mixd1wd1d1, mixd1wd1wd1, mixd2d2d1 @@ -531,39 +621,66 @@ module Glsl.Functions exposing @docs mixd4d4d4, mixd4d4wd1, mixf11, mixf1f, mixff1, mixfff @docs mixwd1d1d1, mixwd1d1wd1, mixwd1wd1d1, mixwd1wd1wd1, mix + +## mod + @docs mod11, mod1f, mod21, mod22, mod2f, mod31 @docs mod33, mod3f, mod41, mod44, mod4f, modd1d1 @docs modd1wd1, modd2d1, modd2d2, modd2wd1, modd3d1, modd3d3 @docs modd3wd1, modd4d1, modd4d4, modd4wd1, modf1, modff @docs modwd1d1, modwd1wd1, mod + +## modf + @docs modf1o1, modf1of, modf2o2, modf3o3, modf4o4, modfd1od1 @docs modfd1owd1, modfd2od2, modfd3od3, modfd4od4, modffo1, modffof @docs modfwd1od1, modfwd1owd1, modf + +## normalize + @docs normalize1, normalize2, normalize3, normalize4, normalized1, normalized2 @docs normalized3, normalized4, normalizef, normalizewd1, normalize + +## reflect + @docs reflect11, reflect1f, reflect22, reflect33, reflect44, reflectd1d1 @docs reflectd1wd1, reflectd2d2, reflectd3d3, reflectd4d4, reflectf1, reflectff @docs reflectwd1d1, reflectwd1wd1, reflect + +## refract + @docs refract111, refract11f, refract1f1, refract1ff, refract221, refract22f @docs refract331, refract33f, refract441, refract44f, refractd1d11, refractd1d1f @docs refractd1wd11, refractd1wd1f, refractd2d21, refractd2d2f, refractd3d31, refractd3d3f @docs refractd4d41, refractd4d4f, refractf11, refractf1f, refractff1, refractfff @docs refractwd1d11, refractwd1d1f, refractwd1wd11, refractwd1wd1f, refract + +## round + @docs round1, round2, round3, round4, roundd1, roundd2 @docs roundd3, roundd4, roundf, roundwd1 + +## roundEven + @docs roundEven1, roundEven2, roundEven3, roundEven4, roundEvend1, roundEvend2 @docs roundEvend3, roundEvend4, roundEvenf, roundEvenwd1, roundEven + +## sign + @docs sign1, sign2, sign3, sign4, signd1, signd2 @docs signd3, signd4, signf, signi1, signi2, signi3 @docs signi4, signwd1, signwi1, sign + +## smoothstep + @docs smoothstep111, smoothstep112, smoothstep113, smoothstep114, smoothstep11f, smoothstep1f1 @docs smoothstep1f2, smoothstep1f3, smoothstep1f4, smoothstep1ff, smoothstep222, smoothstep333 @docs smoothstep444, smoothstepd1d1d1, smoothstepd1d1d2, smoothstepd1d1d3, smoothstepd1d1d4, smoothstepd1d1wd1 @@ -573,25 +690,43 @@ module Glsl.Functions exposing @docs smoothstepwd1d1d1, smoothstepwd1d1d2, smoothstepwd1d1d3, smoothstepwd1d1d4, smoothstepwd1d1wd1, smoothstepwd1wd1d1 @docs smoothstepwd1wd1d2, smoothstepwd1wd1d3, smoothstepwd1wd1d4, smoothstepwd1wd1wd1, smoothstep + +## sqrt + @docs sqrt1, sqrt2, sqrt3, sqrt4, sqrtd1, sqrtd2 @docs sqrtd3, sqrtd4, sqrtf, sqrtwd1 + +## step + @docs step11, step12, step13, step14, step1f, step22 @docs step33, step44, stepd1d1, stepd1d2, stepd1d3, stepd1d4 @docs stepd1wd1, stepd2d2, stepd3d3, stepd4d4, stepf1, stepf2 @docs stepf3, stepf4, stepff, stepwd1d1, stepwd1d2, stepwd1d3 @docs stepwd1d4, stepwd1wd1, step + +## trunc + @docs trunc1, trunc2, trunc3, trunc4, truncd1, truncd2 @docs truncd3, truncd4, truncf, truncwd1, trunc + +## uintBitsToFloat + @docs uintBitsToFloatu1, uintBitsToFloatu2, uintBitsToFloatu3, uintBitsToFloatu4, uintBitsToFloatwu1 + +## vec2 + @docs vec21, vec211, vec21f, vec21i1, vec21wi1, vec2f @docs vec2f1, vec2ff, vec2fi1, vec2fwi1, vec2i1, vec2i11 @docs vec2i1f, vec2i1i1, vec2i1wi1, vec2wi1, vec2wi11, vec2wi1f @docs vec2wi1i1, vec2wi1wi1 + +## vec3 + @docs vec31, vec3111, vec311f, vec311i1, vec311wi1, vec312 @docs vec31f1, vec31ff, vec31fi1, vec31fwi1, vec31i11, vec31i1f @docs vec31i1i1, vec31i1wi1, vec31wi11, vec31wi1f, vec31wi1i1, vec31wi1wi1 @@ -605,6 +740,9 @@ module Glsl.Functions exposing @docs vec3wi1f1, vec3wi1ff, vec3wi1fi1, vec3wi1fwi1, vec3wi1i11, vec3wi1i1f @docs vec3wi1i1i1, vec3wi1i1wi1, vec3wi1wi11, vec3wi1wi1f, vec3wi1wi1i1, vec3wi1wi1wi1 + +## vec4 + @docs vec41, vec41111, vec4111f, vec4111i1, vec4111wi1, vec411f1 @docs vec411ff, vec411fi1, vec411fwi1, vec411i11, vec411i1f, vec411i1i1 @docs vec411i1wi1, vec411wi11, vec411wi1f, vec411wi1i1, vec411wi1wi1, vec413 @@ -651,76 +789,184 @@ module Glsl.Functions exposing @docs vec4wi1wi1i1f, vec4wi1wi1i1i1, vec4wi1wi1i1wi1, vec4wi1wi1wi11, vec4wi1wi1wi1f, vec4wi1wi1wi1i1 @docs vec4wi1wi1wi1wi1 + +## radians\_ + @docs radians_ + +## degrees\_ + @docs degrees_ + +## sin\_ + @docs sin_ + +## cos\_ + @docs cos_ + +## tan\_ + @docs tan_ + +## asin\_ + @docs asin_ + +## acos\_ + @docs acos_ + +## atan\_ + @docs atan_ + +## atan2\_ + @docs atan2_ + +## sinh + @docs sinh + +## cosh + @docs cosh + +## tanh + @docs tanh + +## asinh + @docs asinh + +## acosh + @docs acosh + +## atanh + @docs atanh + +## pow + @docs pow + +## exp + @docs exp + +## log + @docs log + +## exp2 + @docs exp2 + +## log2 + @docs log2 + +## sqrt\_ + @docs sqrt_ + +## abs\_ + @docs abs_ + +## floor\_ + @docs floor_ + +## round\_ + @docs round_ + +## min\_ + @docs min_ + +## max\_ + @docs max_ + +## clamp\_ + @docs clamp_ + +## dFdx + @docs dFdx + +## dFdy + @docs dFdy + +## dFdxFine + @docs dFdxFine + +## dFdyFine + @docs dFdyFine + +## dFdxCoarse + @docs dFdxCoarse + +## dFdyCoarse + @docs dFdyCoarse + +## fwidth + @docs fwidth + +## fwidthFine + @docs fwidthFine + +## fwidthCoarse + @docs fwidthCoarse -} From 8a2e7e50be72cb6f91e28b0a2b7e6b2f5d844d13 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 1 Jul 2025 01:09:19 +0200 Subject: [PATCH 139/139] More cleanup --- codegen/src/Generate.elm | 535 ++------------------------------- src/elm/UI/Glsl/Polynomial.elm | 16 +- 2 files changed, 37 insertions(+), 514 deletions(-) diff --git a/codegen/src/Generate.elm b/codegen/src/Generate.elm index f1341a44..ade3a8be 100644 --- a/codegen/src/Generate.elm +++ b/codegen/src/Generate.elm @@ -146,10 +146,7 @@ generate glsl = |> Dict.fromList |> Dict.insert "P32M1" TInt |> Dict.insert "P31" TInt - , functionsEnv = - builtinFunctions - |> Dict.map - (\_ { return } -> return) + , functionsEnv = Dict.empty , variablesEnv = uniforms |> List.map (\{ tipe, name } -> ( name, tipe )) @@ -171,7 +168,7 @@ generate glsl = uniformDecls = List.map uniformToDeclaration uniforms in - Ok (decls ++ builtinDecls ++ uniformDecls) + Ok (decls ++ uniformDecls) Err e -> Err ("Error generating file: " ++ e) @@ -640,90 +637,43 @@ nop env = findDepsExpression : Expr -> Env -> Result String ( Env, SortedSet String ) findDepsExpression root env = let - go : Expr -> Result String ( Type, SortedSet String ) + go : Expr -> Result String (SortedSet String) go expr = case expr of Float _ -> - Ok ( TFloat, SortedSet.empty ) + Ok SortedSet.empty Int _ -> - Ok ( TInt, SortedSet.empty ) + Ok SortedSet.empty Uint _ -> - Ok ( TInt, SortedSet.empty ) + Ok SortedSet.empty Double _ -> - Ok ( TInt, SortedSet.empty ) + Ok SortedSet.empty Bool _ -> - Ok ( TBool, SortedSet.empty ) - - Dot e field -> - Result.andThen - (\( et, deps ) -> - Result.map - (\t -> - ( t - , deps - ) - ) - (case ( et, String.length field ) of - ( TIVec2, 1 ) -> - Ok TInt - - ( _, 1 ) -> - Ok TFloat - - ( _, 2 ) -> - Ok TVec2 - - ( _, 3 ) -> - Ok TVec3 - - _ -> - Err <| "Unknown size when accessing field " ++ field - ) - ) - (go e) + Ok SortedSet.empty - Variable "P32M1" -> - Ok ( TInt, SortedSet.empty ) - - Variable "P31" -> - Ok ( TInt, SortedSet.empty ) - - Variable v -> - case Dict.get v env.variablesEnv of - Nothing -> - Err <| "Couldn't find variable " ++ v + Dot e _ -> + go e - Just t -> - Ok ( t, SortedSet.empty ) + Variable _ -> + Ok SortedSet.empty Call (Variable f) args -> args |> Result.Extra.combineMap go - |> Result.map List.unzip |> Result.andThen - (\( argTypes, argDeps ) -> + (\argDeps -> let - fname = - fullName f argTypes + initial = + SortedSet.singleton (fullName f []) + + deps = + List.foldl SortedSet.insertAll initial argDeps in - case Dict.get fname env.functionsEnv of - Nothing -> - Err <| "Function " ++ fname ++ " not found" - - Just to -> - let - deps = - if Dict.member fname builtinFunctions then - List.foldl SortedSet.insertAll SortedSet.empty argDeps - - else - List.foldl SortedSet.insertAll (SortedSet.singleton fname) argDeps - in - Ok ( to, deps ) + Ok deps ) Call _ _ -> @@ -731,11 +681,9 @@ findDepsExpression root env = Ternary c t f -> Result.map3 - (\( _, cd ) ( tt, td ) ( _, fd ) -> - ( tt - , SortedSet.insertAll cd td + (\cd td fd -> + SortedSet.insertAll cd td |> SortedSet.insertAll fd - ) ) (go c) (go t) @@ -744,139 +692,16 @@ findDepsExpression root env = UnaryOperation _ e -> go e - BinaryOperation l bop r -> - Result.andThen - (\( ( lt, ld ), ( rt, rd ) ) -> - Result.map - (\t -> ( t, SortedSet.insertAll ld rd )) - (if lt == rt then - Ok lt - - else - case ( lt, rt ) of - ( TFloat, _ ) -> - Ok rt - - ( _, TFloat ) -> - Ok lt - - ( TInt, _ ) -> - Ok rt - - ( _, TInt ) -> - Ok lt - - _ -> - Err <| "Don't know what the result of " ++ Glsl.PrettyPrinter.type_ lt ++ " " ++ binaryOperationToString bop ++ " " ++ Glsl.PrettyPrinter.type_ rt - ) - ) - (Result.map2 Tuple.pair - (go l) - (go r) + BinaryOperation l _ r -> + Result.map2 + (\ld rd -> + SortedSet.insertAll ld rd ) + (go l) + (go r) in go root - |> Result.map (\( _, deps ) -> ( env, deps )) - - -binaryOperationToString : BinaryOperation -> String -binaryOperationToString bop = - case bop of - Add -> - "+" - - Subtract -> - "-" - - By -> - "*" - - Div -> - "/" - - And -> - "&&" - - Or -> - "||" - - ArraySubscript -> - "[]" - - Mod -> - "%" - - ShiftLeft -> - "<<" - - ShiftRight -> - ">>" - - BitwiseAnd -> - "&" - - BitwiseOr -> - "|" - - BitwiseXor -> - "^" - - Xor -> - "^^" - - Assign -> - "=" - - ComboAdd -> - "+=" - - ComboSubtract -> - "-=" - - ComboBy -> - "*=" - - ComboDiv -> - "/=" - - ComboMod -> - "%=" - - ComboLeftShift -> - "<<=" - - ComboRightShift -> - ">>=" - - ComboBitwiseAnd -> - "&=" - - ComboBitwiseXor -> - "^=" - - ComboBitwiseOr -> - "|=" - - Comma -> - "," - - RelationOperation LessThan -> - "<" - - RelationOperation GreaterThan -> - ">" - - RelationOperation LessThanOrEquals -> - "<=" - - RelationOperation GreaterThanOrEquals -> - ">=" - - RelationOperation Equals -> - "==" - - RelationOperation NotEquals -> - "!=" + |> Result.map (\deps -> ( env, deps )) fullName : String -> List Type -> String @@ -1009,307 +834,3 @@ typeToShort t = TOut tt -> "o" ++ typeToShort tt - - -builtinFunctions : Dict String { baseName : String, args : List Type, return : Type } -builtinFunctions = - let - overload : List String -> List ( List Type, Type ) -> List ( String, List Type, Type ) - overload names kinds = - List.Extra.lift2 - (\name ( inTypes, result ) -> ( name, inTypes, result )) - names - kinds - - regular : List ( String, List Type, Type ) - regular = - [ builtin_v_v - , builtin_v_s - , builtin_vv_v - , builtin_vv_s - , builtin_vs_v - , builtin_sv_v - , builtin_vvv_v - , builtin_vss_v - , builtin_ssv_v - , builtin_vvs_v - ] - |> List.concatMap (\( names, kinds ) -> overload names kinds) - - vecs : List ( String, List Type, Type ) - vecs = - [ ( 2, TVec2 ) - , ( 3, TVec3 ) - , ( 4, TVec4 ) - ] - |> List.concatMap - (\( size, type_ ) -> - List.map - (\inTypes -> - ( "vec" ++ String.fromInt size, inTypes, type_ ) - ) - ([ TFloat, TInt ] - |> List.repeat size - |> List.Extra.cartesianProduct - |> (++) - (if size == 4 then - [ [ TInt ] - , [ TFloat ] - , [ TFloat, TVec3 ] - , [ TVec3, TFloat ] - ] - - else - [ [ TInt ], [ TFloat ] ] - ) - ) - ) - - mats : List ( String, List Type, Type ) - mats = - [ ( [ TVec3, TVec3, TVec3 ], 3, TMat3 ) - , ( [ TFloat ], 3, TMat3 ) - ] - |> List.map - (\( inTypes, size, type_ ) -> - ( "mat" ++ String.fromInt size - , inTypes - , type_ - ) - ) - - ivecs : List ( String, List Type, Type ) - ivecs = - [ ( 2, TVec2 ) - , ( 3, TVec3 ) - , ( 4, TVec4 ) - ] - |> List.map - (\( size, type_ ) -> - ( "ivec" ++ String.fromInt size, List.repeat size TInt, type_ ) - ) - - others : List ( String, List Type, Type ) - others = - [ ( "cross", [ TVec3, TVec3 ], TVec3 ) - , ( "float", [ TInt ], TFloat ) - , ( "int", [ TFloat ], TInt ) - ] - - builtTuple : - ( String, List Type, Type ) - -> ( String, { baseName : String, args : List Type, return : Type } ) - builtTuple ( name, inTypes, resultType ) = - ( fullName name inTypes, { baseName = name, args = inTypes, return = resultType } ) - in - (regular ++ vecs ++ ivecs ++ mats ++ others) - |> List.map builtTuple - |> Dict.fromList - - -builtin_v_s : ( List String, List ( List Type, Type ) ) -builtin_v_s = - ( [ -- Geometric - "length" - ] - , [ ( [ TFloat ], TFloat ) - , ( [ TVec2 ], TFloat ) - , ( [ TVec3 ], TFloat ) - , ( [ TVec4 ], TFloat ) - ] - ) - - -builtin_v_v : ( List String, List ( List Type, Type ) ) -builtin_v_v = - ( [ "fwidth" - - -- Rounding - , "ceil" - , "floor" - , "fract" - - -- Complex and power - , "sign" - , "exp" - , "log" - , "abs" - , "exp2" - , "log2" - , "sqrt" - , "inversesqrt" - - -- Trig - , "radians" - , "degrees" - , "sin" - , "cos" - , "tan" - , "asin" - , "acos" - , "atan" - , "normalize" - ] - , [ ( [ TFloat ], TFloat ) - , ( [ TVec2 ], TVec2 ) - , ( [ TVec3 ], TVec3 ) - , ( [ TVec4 ], TVec4 ) - ] - ) - - -builtin_vv_v : ( List String, List ( List Type, Type ) ) -builtin_vv_v = - ( [ -- Comparison - "min" - , "max" - - -- Complex and power - , "pow" - - -- Trig - , "atan" - - -- Geometry - , "reflect" - - -- Other - , "mod" - , "step" - ] - , [ ( [ TFloat, TFloat ], TFloat ) - , ( [ TVec2, TVec2 ], TVec2 ) - , ( [ TVec3, TVec3 ], TVec3 ) - , ( [ TVec4, TVec4 ], TVec4 ) - ] - ) - - -builtin_sv_v : ( List String, List ( List Type, Type ) ) -builtin_sv_v = - ( [ -- Other - "step" - ] - , [ ( [ TFloat, TFloat ], TFloat ) - , ( [ TFloat, TVec2 ], TVec2 ) - , ( [ TFloat, TVec3 ], TVec3 ) - , ( [ TFloat, TVec4 ], TVec4 ) - ] - ) - - -builtin_vs_v : ( List String, List ( List Type, Type ) ) -builtin_vs_v = - ( [ -- Comparison - "min" - , "max" - - -- Other - , "mod" - ] - , [ ( [ TFloat, TFloat ], TFloat ) - , ( [ TVec2, TFloat ], TVec2 ) - , ( [ TVec3, TFloat ], TVec3 ) - , ( [ TVec4, TFloat ], TVec4 ) - ] - ) - - -builtin_vv_s : ( List String, List ( List Type, Type ) ) -builtin_vv_s = - ( [ -- Geometric - "distance" - , "dot" - ] - , [ ( [ TFloat, TFloat ], TFloat ) - , ( [ TVec2, TVec2 ], TFloat ) - , ( [ TVec3, TVec3 ], TFloat ) - , ( [ TVec4, TVec4 ], TFloat ) - ] - ) - - -builtin_vvs_v : ( List String, List ( List Type, Type ) ) -builtin_vvs_v = - ( [ --Geometric - "refract" - - -- Other - , "mix" - ] - , [ ( [ TFloat, TFloat, TFloat ], TFloat ) - , ( [ TVec2, TVec2, TFloat ], TVec2 ) - , ( [ TVec3, TVec3, TFloat ], TVec3 ) - , ( [ TVec4, TVec4, TFloat ], TVec4 ) - ] - ) - - -builtin_ssv_v : ( List String, List ( List Type, Type ) ) -builtin_ssv_v = - ( [ -- Other - "smoothstep" - ] - , [ ( [ TFloat, TFloat, TFloat ], TFloat ) - , ( [ TFloat, TFloat, TVec2 ], TVec2 ) - , ( [ TFloat, TFloat, TVec3 ], TVec3 ) - , ( [ TFloat, TFloat, TVec4 ], TVec4 ) - ] - ) - - -builtin_vss_v : ( List String, List ( List Type, Type ) ) -builtin_vss_v = - ( [ -- Other - "clamp" - ] - , [ ( [ TFloat, TFloat, TFloat ], TFloat ) - , ( [ TVec2, TFloat, TFloat ], TVec2 ) - , ( [ TVec3, TFloat, TFloat ], TVec3 ) - , ( [ TVec4, TFloat, TFloat ], TVec4 ) - ] - ) - - -builtin_vvv_v : ( List String, List ( List Type, Type ) ) -builtin_vvv_v = - ( [ -- Other - "clamp" - , "mix" - , "smoothstep" - - -- Geometry - , "faceforward" - ] - , [ ( [ TFloat, TFloat, TFloat ], TFloat ) - , ( [ TVec2, TVec2, TVec2 ], TVec2 ) - , ( [ TVec3, TVec3, TVec3 ], TVec3 ) - , ( [ TVec4, TVec4, TVec4 ], TVec4 ) - ] - ) - - -builtinDecls : List ( Maybe String, Elm.Declaration ) -builtinDecls = - builtinFunctions - |> Dict.toList - |> List.map - (\( _, { baseName, args, return } ) -> - ( Just baseName - , wrapFunction - baseName - SortedSet.empty - (List.indexedMap - (\i type_ -> ( type_, indexedVar i )) - args - ) - return - |> Tuple.second - |> Elm.expose - ) - ) - - -indexedVar : Int -> String -indexedVar i = - String.fromChar <| Char.fromCode <| Char.toCode 'a' + i diff --git a/src/elm/UI/Glsl/Polynomial.elm b/src/elm/UI/Glsl/Polynomial.elm index 18c4747e..b690841f 100644 --- a/src/elm/UI/Glsl/Polynomial.elm +++ b/src/elm/UI/Glsl/Polynomial.elm @@ -4,10 +4,12 @@ import Dict exposing (Dict) import Expression exposing (AssociativeOperation(..), BinaryOperation(..), Expression(..), RelationOperation(..), UnaryOperation(..)) import Expression.Polynomial exposing (Exponents) import Expression.Utils -import Glsl exposing (BisectSignature, Statement, Vec3, float1, int1) +import Glsl exposing (BisectSignature, Bool_, Float_, Statement, Vec3, float1, int1) +import Glsl.Constants exposing (zero) import Glsl.Functions exposing (mix331) import Glsl.Generator exposing (ands, assignOut, boolT, def, expr, floatT, fun4, mat3T, out, return, vec3, vec3T, zero) -import Glsl.Operations exposing (add33, array33, by11, by13, gt, lt) +import Glsl.Helpers exposing (boolT, def, expr, floatT, fun4, intT, mat3T, out, return, vec3, vec3T) +import Glsl.Operations exposing (add, add33, array33, arraymi, by, by11, by13, by1v, gt, lt) import Maybe.Extra as Maybe @@ -184,20 +186,20 @@ toFloat e = glslFromSolutions : String -> - ({ t : Glsl.Expression Float + ({ t : Glsl.Expression Float_ , o : Glsl.Expression Vec3 , dMix : Glsl.Expression Vec3 } - -> (() -> Statement Bool) - -> Statement Bool + -> (() -> Statement Bool_) + -> Statement Bool_ ) -> BisectSignature glslFromSolutions suffix sols = fun4 boolT ("bisect" ++ suffix) (vec3T "o") (mat3T "d") (floatT "max_distance") (out vec3T "found") <| \o d maxDistance found -> vec3 "dMix" (mix331 (array33 d (int1 0)) (array33 d (int1 1)) (float1 0.5)) <| \dMix -> - def floatT "t" (by11 maxDistance <| float1 2) <| \t -> + def floatT "t" (by maxDistance <| float1 2) <| \t -> sols { dMix = dMix, o = o, t = t } <| \_ -> - expr (assignOut found (add33 o (by13 t (mix331 (array33 d (int1 0)) (array33 d (int1 1)) (float1 0.5))))) <| \_ -> + expr (assignOut found (add o (by1v t (mix331 (arraymi d (int1 0)) (array33 d (int1 1)) (float1 0.5))))) <| \_ -> return (ands [ lt t maxDistance, gt t zero ])