{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

module Mischief.Shader.Functions where

import Data.Data
import Data.Singletons (SingI)
import Data.Text (Text)
import GHC.TypeLits hiding (Div)
import Mischief.Render.Core
import Mischief.Render.Texture
import Mischief.Shader.Internal.Bindings
import Mischief.Shader.Internal.Singletons
import Mischief.Shader.Internal.State
import Mischief.Shader.Types
import Prelude (Bool (..), undefined, ($), type (~))

sample :: Expr TTexture -> Expr TSampler -> Vec 2 Float -> Vec 4 Float
sample :: Expr 'TTexture -> Expr 'TSampler -> Vec 2 Float -> Vec 4 Float
sample Expr 'TTexture
tex Expr 'TSampler
sampler Vec 2 Float
v =
  Text -> [Param] -> Expr ('VectorType 4 'TFloat)
forall (a :: Types). Text -> [Param] -> Expr a
Function
    Text
"textureSample"
    [ Expr 'TTexture -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr 'TTexture
tex,
      Expr 'TSampler -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr 'TSampler
sampler,
      Expr ('VectorType 2 'TFloat) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType 2 'TFloat)
Vec 2 Float
v
    ]

unsafeCall :: (SingI a) => Text -> [Param] -> Expr a
unsafeCall :: forall (a :: Types). SingI a => Text -> [Param] -> Expr a
unsafeCall = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function

-- Binary
(&) :: (Algebric a ~ True, Integral a ~ True) => Expr a -> Expr a -> Expr a
& :: forall (a :: Types).
(Algebric a ~ 'True, Integral a ~ 'True) =>
Expr a -> Expr a -> Expr a
(&) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"&"

-- Arithmetics

class Num a where
  (+) :: Expr a -> Expr a -> Expr a
  (+) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"+"

  (-) :: Expr a -> Expr a -> Expr a
  (-) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"-"

  (*) :: Expr a -> Expr a -> Expr a
  (*) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

instance Num (Primitive a)

instance Num (VectorType n a)

instance Num (MatrixType n m)

(^+) :: Expr (VectorType n a) -> Expr (Primitive a) -> Expr (VectorType n a)
^+ :: forall (n :: Natural) (a :: PrimitiveTypes).
Expr ('VectorType n a)
-> Expr ('Primitive a) -> Expr ('VectorType n a)
(^+) = Text
-> Expr ('VectorType n a)
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"+"

(+^) :: Expr (Primitive a) -> Expr (VectorType n a) -> Expr (VectorType n a)
+^ :: forall (a :: PrimitiveTypes) (n :: Natural).
Expr ('Primitive a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
(+^) = Text
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"+"

(^-) :: Expr (VectorType n a) -> Expr (Primitive a) -> Expr (VectorType n a)
^- :: forall (n :: Natural) (a :: PrimitiveTypes).
Expr ('VectorType n a)
-> Expr ('Primitive a) -> Expr ('VectorType n a)
(^-) = Text
-> Expr ('VectorType n a)
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"-"

(-^) :: Expr (Primitive a) -> Expr (VectorType n a) -> Expr (VectorType n a)
-^ :: forall (a :: PrimitiveTypes) (n :: Natural).
Expr ('Primitive a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
(-^) = Text
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"-"

(^*) :: Expr (VectorType n a) -> Expr (Primitive a) -> Expr (VectorType n a)
^* :: forall (n :: Natural) (a :: PrimitiveTypes).
Expr ('VectorType n a)
-> Expr ('Primitive a) -> Expr ('VectorType n a)
(^*) = Text
-> Expr ('VectorType n a)
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(*^) :: Expr (Primitive a) -> Expr (VectorType n a) -> Expr (VectorType n a)
*^ :: forall (a :: PrimitiveTypes) (n :: Natural).
Expr ('Primitive a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
(*^) = Text
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(*!) :: Float -> Mat n m -> Mat n m
*! :: forall (n :: Natural) (m :: Natural). Float -> Mat n m -> Mat n m
(*!) = Text -> Float -> Expr ('MatrixType n m) -> Expr ('MatrixType n m)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(!*) :: Mat n m -> Float -> Mat n m
!* :: forall (n :: Natural) (m :: Natural). Mat n m -> Float -> Mat n m
(!*) = Text -> Expr ('MatrixType n m) -> Float -> Expr ('MatrixType n m)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(^*!) :: Vec m Float -> Mat n m -> Vec n Float
^*! :: forall (m :: Natural) (n :: Natural).
Vec m Float -> Mat n m -> Vec n Float
(^*!) = Text
-> Expr ('VectorType m 'TFloat)
-> Expr ('MatrixType n m)
-> Expr ('VectorType n 'TFloat)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(!*^) :: Mat n m -> Vec n Float -> Vec m Float
!*^ :: forall (n :: Natural) (m :: Natural).
Mat n m -> Vec n Float -> Vec m Float
(!*^) = Text
-> Expr ('MatrixType n m)
-> Expr ('VectorType n 'TFloat)
-> Expr ('VectorType m 'TFloat)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

(!*!) :: Mat k r -> Mat c k -> Mat c r
!*! :: forall (k :: Natural) (r :: Natural) (c :: Natural).
Mat k r -> Mat c k -> Mat c r
(!*!) = Text
-> Expr ('MatrixType k r)
-> Expr ('MatrixType c k)
-> Expr ('MatrixType c r)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"*"

class Div a where
  (/) :: Expr a -> Expr a -> Expr a
  (/) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"/"

instance {-# OVERLAPPABLE #-} (Algebric a ~ True) => Div a

(^/) :: Expr (VectorType n a) -> Expr (Primitive a) -> Expr (VectorType n a)
^/ :: forall (n :: Natural) (a :: PrimitiveTypes).
Expr ('VectorType n a)
-> Expr ('Primitive a) -> Expr ('VectorType n a)
(^/) = Text
-> Expr ('VectorType n a)
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"/"

(/^) :: Expr (Primitive a) -> Expr (VectorType n a) -> Expr (VectorType n a)
/^ :: forall (a :: PrimitiveTypes) (n :: Natural).
Expr ('Primitive a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
(/^) = Text
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"/"

class Modulo a where
  (%) :: Expr a -> Expr a -> Expr a
  (%) = Text -> Expr a -> Expr a -> Expr a
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"%"

instance {-# OVERLAPPABLE #-} (Integral a ~ True) => Modulo a

(^%) :: (Integral (Primitive a) ~ True) => Expr (VectorType n a) -> Expr (Primitive a) -> Expr (VectorType n a)
^% :: forall (a :: PrimitiveTypes) (n :: Natural).
(Integral ('Primitive a) ~ 'True) =>
Expr ('VectorType n a)
-> Expr ('Primitive a) -> Expr ('VectorType n a)
(^%) = Text
-> Expr ('VectorType n a)
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"%"

(%^) :: (Integral (Primitive a) ~ True) => Expr (Primitive a) -> Expr (VectorType n a) -> Expr (VectorType n a)
%^ :: forall (a :: PrimitiveTypes) (n :: Natural).
(Integral ('Primitive a) ~ 'True) =>
Expr ('Primitive a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
(%^) = Text
-> Expr ('Primitive a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
forall (a1 :: Types) (b :: Types) (a :: Types).
Text -> Expr a1 -> Expr b -> Expr a
CustomOperator Text
"%"

-- Numeric Functions

abs :: (SingI a, Algebric a ~ True) => Expr a -> Expr a
abs :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a
abs = Expr a -> Expr a
forall (a :: Types). SingI a => Expr a -> Expr a
Abs

acos :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
acos :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
acos Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"acos" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

acosh :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
acosh :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
acosh Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"acosh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

asin :: (SingI a, Algebric a ~ True) => Expr a -> Expr a
asin :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a
asin Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"asin" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

asinh :: (SingI a, Algebric a ~ True) => Expr a -> Expr a
asinh :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a
asinh Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"asinh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

atan :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
atan :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
atan Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"atan" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

atanh :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
atanh :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
atanh Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"atanh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

atan2 :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a -> Expr a
atan2 :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a -> Expr a
atan2 Expr a
x Expr a
y = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"atan2" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
y]

ceil :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
ceil :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
ceil Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"ceil" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

clamp :: (SingI a, Algebric a ~ True) => Expr a -> Expr a -> Expr a -> Expr a
clamp :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a -> Expr a -> Expr a
clamp Expr a
e Expr a
low Expr a
high = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"clamp" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
e, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
low, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
high]

cos :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
cos :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
cos Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"cos" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

cosh :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
cosh :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
cosh Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"cosh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

countLeadingZeros :: (SingI a, Integral a ~ True) => Expr a -> Expr a
countLeadingZeros :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Expr a
countLeadingZeros Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"countLeadingZeros" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

countOneBits :: (SingI a, Integral a ~ True) => Expr a -> Expr a
countOneBits :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Expr a
countOneBits Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"countOneBits" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

countTrailingZeros :: (SingI a, Integral a ~ True) => Expr a -> Expr a
countTrailingZeros :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Expr a
countTrailingZeros Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"countTrailingZeros" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

cross :: (SingI (VectorType 3 a), Fractional (Expr (Primitive a)) ~ True) => Expr (VectorType 3 a) -> Expr (VectorType 3 a) -> Expr (VectorType 3 a)
cross :: forall (a :: PrimitiveTypes).
(SingI ('VectorType 3 a),
 Fractional (Expr ('Primitive a)) ~ 'True) =>
Expr ('VectorType 3 a)
-> Expr ('VectorType 3 a) -> Expr ('VectorType 3 a)
cross Expr ('VectorType 3 a)
a Expr ('VectorType 3 a)
b = Text -> [Param] -> Expr ('VectorType 3 a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"cross" [Expr ('VectorType 3 a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType 3 a)
a, Expr ('VectorType 3 a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType 3 a)
b]

degrees :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
degrees :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
degrees Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"degrees" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

determinant :: (SingI n) => Expr (MatrixType n n) -> Float
determinant :: forall (n :: Natural). SingI n => Expr ('MatrixType n n) -> Float
determinant Expr ('MatrixType n n)
x = Text -> [Param] -> Float
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"determinant" [Expr ('MatrixType n n) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('MatrixType n n)
x]

distance :: (SingI a, Fractional (Expr a) ~ True, VectorOrSingleOf a ~ b) => Expr a -> Expr a -> Expr (Primitive b)
distance :: forall (a :: Types) (b :: PrimitiveTypes).
(SingI a, Fractional (Expr a) ~ 'True, VectorOrSingleOf a ~ b) =>
Expr a -> Expr a -> Expr ('Primitive b)
distance Expr a
a Expr a
b = Text -> [Param] -> Expr ('Primitive b)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"distance" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b]

dot :: (SingI (Expr (VectorType n a)), SingI a, SingI n, Algebric (Primitive a) ~ True) => Expr (VectorType n a) -> Expr (VectorType n a) -> Expr (Primitive a)
dot :: forall (n :: Natural) (a :: PrimitiveTypes).
(SingI (Expr ('VectorType n a)), SingI a, SingI n,
 Algebric ('Primitive a) ~ 'True) =>
Expr ('VectorType n a)
-> Expr ('VectorType n a) -> Expr ('Primitive a)
dot Expr ('VectorType n a)
a Expr ('VectorType n a)
b = Text -> [Param] -> Expr ('Primitive a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"dot" [Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
a, Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
b]

dot4U8Packed :: Uint -> Uint -> Uint
dot4U8Packed :: Uint -> Uint -> Uint
dot4U8Packed Uint
a Uint
b = Text -> [Param] -> Uint
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"dot4U8Packed" [Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
a, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
b]

dot4I8Packed :: Uint -> Uint -> Int
dot4I8Packed :: Uint -> Uint -> Int
dot4I8Packed Uint
a Uint
b = Text -> [Param] -> Int
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"dot4I8Packed" [Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
a, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
b]

exp :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
exp :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
exp Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"exp" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

exp2 :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
exp2 :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
exp2 Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"exp2" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

extractBits :: (SingI a, Integral a ~ True) => Expr a -> Uint -> Uint -> Expr a
extractBits :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Uint -> Uint -> Expr a
extractBits Expr a
e Uint
offset Uint
count = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"extractBits" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
e, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
offset, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
count]

faceForward :: (SingI a, SingI n, Fractional (Expr (Primitive a)) ~ True) => Expr (VectorType n a) -> Expr (VectorType n a) -> Expr (VectorType n a) -> Expr (VectorType n a)
faceForward :: forall (a :: PrimitiveTypes) (n :: Natural).
(SingI a, SingI n, Fractional (Expr ('Primitive a)) ~ 'True) =>
Expr ('VectorType n a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
-> Expr ('VectorType n a)
faceForward Expr ('VectorType n a)
a Expr ('VectorType n a)
b Expr ('VectorType n a)
c = Text -> [Param] -> Expr ('VectorType n a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"faceForward" [Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
a, Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
b, Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
c]

firstLeadingBit :: (SingI a, SingI n, Integral a ~ True) => Expr a -> Expr a
firstLeadingBit :: forall {k} (a :: Types) (n :: k).
(SingI a, SingI n, Integral a ~ 'True) =>
Expr a -> Expr a
firstLeadingBit Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"firstLeadingBit" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

firstTrailingBit :: (SingI a, SingI n, Integral a ~ True) => Expr a -> Expr a
firstTrailingBit :: forall {k} (a :: Types) (n :: k).
(SingI a, SingI n, Integral a ~ 'True) =>
Expr a -> Expr a
firstTrailingBit Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"firstTrailingBit" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

floor :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
floor :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
floor Expr a
x = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"floor" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
x]

fma :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a -> Expr a -> Expr a
fma :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a -> Expr a -> Expr a
fma Expr a
a Expr a
b Expr a
c = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"fma" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
c]

fract :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
fract :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
fract Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"fract" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

-- TODO: frexp (custom struct)

insertBits :: (SingI a, Integral a ~ True) => Expr a -> Expr a -> Uint -> Uint -> Expr a
insertBits :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Expr a -> Uint -> Uint -> Expr a
insertBits Expr a
e Expr a
newbits Uint
offset Uint
count = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"insertBits" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
e, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
newbits, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
offset, Uint -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Uint
count]

inverseSqrt :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
inverseSqrt :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
inverseSqrt Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"inverseSqrt" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

-- TODO: ldexp

length :: (SingI a, SingI b, SingI n, VectorOrSingleOf b ~ a) => Expr b -> Expr (Primitive a)
length :: forall {k} (a :: PrimitiveTypes) (b :: Types) (n :: k).
(SingI a, SingI b, SingI n, VectorOrSingleOf b ~ a) =>
Expr b -> Expr ('Primitive a)
length Expr b
a = Text -> [Param] -> Expr ('Primitive a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"length" [Expr b -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr b
a]

log :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
log :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
log Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"log" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

log2 :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
log2 :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
log2 Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"log2" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

max :: (SingI a, Algebric a ~ True) => Expr a -> Expr a -> Expr a
max :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a -> Expr a
max Expr a
a Expr a
b = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"max" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b]

min :: (SingI a, Algebric a ~ True) => Expr a -> Expr a -> Expr a
min :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a -> Expr a
min Expr a
a Expr a
b = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"min" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b]

class Mix a b

instance Mix a a

instance Mix (VectorType n a) (Primitive a)

mix :: (SingI a, SingI b, Fractional (Expr a) ~ True, Fractional (Expr b) ~ True, Mix a b) => Expr a -> Expr a -> Expr b -> Expr a
mix :: forall (a :: Types) (b :: Types).
(SingI a, SingI b, Fractional (Expr a) ~ 'True,
 Fractional (Expr b) ~ 'True, Mix a b) =>
Expr a -> Expr a -> Expr b -> Expr a
mix Expr a
a Expr a
b Expr b
c = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"mix" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b, Expr b -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr b
c]

-- TODO: modf (custom struct)

normalize :: (SingI n, SingI a, Fractional (Expr (VectorType n a)) ~ True) => Expr (VectorType n a) -> Expr (VectorType n a)
normalize :: forall (n :: Natural) (a :: PrimitiveTypes).
(SingI n, SingI a, Fractional (Expr ('VectorType n a)) ~ 'True) =>
Expr ('VectorType n a) -> Expr ('VectorType n a)
normalize Expr ('VectorType n a)
a = Text -> [Param] -> Expr ('VectorType n a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"normalize" [Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
a]

pow :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a -> Expr a
pow :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a -> Expr a
pow Expr a
a Expr a
b = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"pow" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b]

quantizeToF16 :: (SingI a, VectorOrSingleOf a ~ TFloat) => Expr a -> Expr a
quantizeToF16 :: forall (a :: Types).
(SingI a, VectorOrSingleOf a ~ 'TFloat) =>
Expr a -> Expr a
quantizeToF16 Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"quantizeToF16" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

radians :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
radians :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
radians Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"radians" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

reflect :: (SingI n, SingI a, Fractional (Expr (VectorType n a)) ~ True) => Expr (VectorType n a) -> Expr (VectorType n a) -> Expr (VectorType n a)
reflect :: forall (n :: Natural) (a :: PrimitiveTypes).
(SingI n, SingI a, Fractional (Expr ('VectorType n a)) ~ 'True) =>
Expr ('VectorType n a)
-> Expr ('VectorType n a) -> Expr ('VectorType n a)
reflect Expr ('VectorType n a)
a Expr ('VectorType n a)
b = Text -> [Param] -> Expr ('VectorType n a)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"reflect" [Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
a, Expr ('VectorType n a) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('VectorType n a)
b]

refract :: (SingI a, SingI b, VectorOrSingleOf a ~ b) => Expr a -> Expr a -> Expr (Primitive b) -> Expr a
refract :: forall (a :: Types) (b :: PrimitiveTypes).
(SingI a, SingI b, VectorOrSingleOf a ~ b) =>
Expr a -> Expr a -> Expr ('Primitive b) -> Expr a
refract Expr a
a Expr a
b Expr ('Primitive b)
c = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"refract" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b, Expr ('Primitive b) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('Primitive b)
c]

reverseBits :: (SingI a, Integral a ~ True) => Expr a -> Expr a
reverseBits :: forall (a :: Types).
(SingI a, Integral a ~ 'True) =>
Expr a -> Expr a
reverseBits Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"reverseBits" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

round :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
round :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
round Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"round" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

saturate :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
saturate :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
saturate Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"saturate" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

sign :: (SingI a, Algebric a ~ True) => Expr a -> Expr a
sign :: forall (a :: Types).
(SingI a, Algebric a ~ 'True) =>
Expr a -> Expr a
sign Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"sign" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

sin :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
sin :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
sin Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"sin" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

sinh :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
sinh :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
sinh Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"sinh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

smoothstep :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a -> Expr a -> Expr a
smoothstep :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a -> Expr a -> Expr a
smoothstep Expr a
a Expr a
b Expr a
c = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"smoothstep" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
c]

sqrt :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
sqrt :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
sqrt Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"sqrt" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

step :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a -> Expr a
step :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a -> Expr a
step Expr a
a Expr a
b = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"step" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a, Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
b]

tan :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
tan :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
tan Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"tan" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

tanh :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
tanh :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
tanh Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"tanh" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

transpose :: (SingI n, SingI m) => Expr (MatrixType n m) -> Expr (MatrixType m n)
transpose :: forall (n :: Natural) (m :: Natural).
(SingI n, SingI m) =>
Expr ('MatrixType n m) -> Expr ('MatrixType m n)
transpose Expr ('MatrixType n m)
a = Text -> [Param] -> Expr ('MatrixType m n)
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"transpose" [Expr ('MatrixType n m) -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr ('MatrixType n m)
a]

trunc :: (SingI a, Fractional (Expr a) ~ True) => Expr a -> Expr a
trunc :: forall (a :: Types).
(SingI a, Fractional (Expr a) ~ 'True) =>
Expr a -> Expr a
trunc Expr a
a = Text -> [Param] -> Expr a
forall (a :: Types). Text -> [Param] -> Expr a
Function Text
"trunc" [Expr a -> Param
forall (a :: Types). SingI a => Expr a -> Param
Param Expr a
a]

-- TODO: Bit Reinterpretation Functions

-- TODO: Logical Functions

-- TODO: Array Functions

-- TODO: Derivative Functions

-- TODO: Texture Functions

-- TODO: Atomic Functions

-- TODO: Data Packing Functions

-- TODO: Data Unpacking Functions

-- TODO: Synchronization Functions