webgpu-dawn-0.1.1.0: Haskell bindings to WebGPU Dawn for GPU computing and graphics
Safe HaskellSafe-Inferred
LanguageHaskell2010

WGSL.AST

Synopsis

Documentation

data F32 Source #

Phantom Types for WGSL types

Instances

Instances details
WGSLType F32 Source #

Primitive type instances

Instance details

Defined in WGSL.AST

Num (Exp F32) Source #

Numeric operations for F32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp F32 -> Exp F32 -> Exp F32 #

(-) :: Exp F32 -> Exp F32 -> Exp F32 #

(*) :: Exp F32 -> Exp F32 -> Exp F32 #

negate :: Exp F32 -> Exp F32 #

abs :: Exp F32 -> Exp F32 #

signum :: Exp F32 -> Exp F32 #

fromInteger :: Integer -> Exp F32 #

Fractional (Exp F32) Source #

Fractional for F32

Instance details

Defined in WGSL.DSL

Eq' (Exp F32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp F32) Source # 
Instance details

Defined in WGSL.DSL

data F16 Source #

Instances

Instances details
WGSLType F16 Source # 
Instance details

Defined in WGSL.AST

Num (Exp F16) Source #

Numeric operations for F16

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp F16 -> Exp F16 -> Exp F16 #

(-) :: Exp F16 -> Exp F16 -> Exp F16 #

(*) :: Exp F16 -> Exp F16 -> Exp F16 #

negate :: Exp F16 -> Exp F16 #

abs :: Exp F16 -> Exp F16 #

signum :: Exp F16 -> Exp F16 #

fromInteger :: Integer -> Exp F16 #

Fractional (Exp F16) Source #

Fractional for F16

Instance details

Defined in WGSL.DSL

Eq' (Exp F16) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp F16) Source # 
Instance details

Defined in WGSL.DSL

data I32 Source #

Instances

Instances details
WGSLType I32 Source # 
Instance details

Defined in WGSL.AST

Num (Exp I32) Source #

Numeric operations for I32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp I32 -> Exp I32 -> Exp I32 #

(-) :: Exp I32 -> Exp I32 -> Exp I32 #

(*) :: Exp I32 -> Exp I32 -> Exp I32 #

negate :: Exp I32 -> Exp I32 #

abs :: Exp I32 -> Exp I32 #

signum :: Exp I32 -> Exp I32 #

fromInteger :: Integer -> Exp I32 #

Eq' (Exp I32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp I32) Source # 
Instance details

Defined in WGSL.DSL

data U32 Source #

Instances

Instances details
WGSLType U32 Source # 
Instance details

Defined in WGSL.AST

Num (Exp U32) Source #

Numeric operations for U32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp U32 -> Exp U32 -> Exp U32 #

(-) :: Exp U32 -> Exp U32 -> Exp U32 #

(*) :: Exp U32 -> Exp U32 -> Exp U32 #

negate :: Exp U32 -> Exp U32 #

abs :: Exp U32 -> Exp U32 #

signum :: Exp U32 -> Exp U32 #

fromInteger :: Integer -> Exp U32 #

Eq' (Exp U32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp U32) Source # 
Instance details

Defined in WGSL.DSL

data Bool_ Source #

Instances

Instances details
WGSLType Bool_ Source # 
Instance details

Defined in WGSL.AST

data AtomicI32 Source #

Atomic types (for atomic operations) These are distinct from I32/U32 to prevent use in regular arithmetic

data Vec2 a Source #

Instances

Instances details
WGSLType a => WGSLType (Vec2 a) Source #

Vec instances

Instance details

Defined in WGSL.AST

data Vec3 a Source #

Instances

Instances details
WGSLType a => WGSLType (Vec3 a) Source # 
Instance details

Defined in WGSL.AST

data Vec4 a Source #

data Array (n :: Nat) a Source #

data Struct a Source #

Struct type - phantom type representing a user-defined struct The parameter a is the Haskell type that corresponds to the WGSL struct

data Texture2D format Source #

Texture types (for texture sampling and storage) The format parameter tracks the texture format (e.g., rgba8unorm, f32, etc.)

data View1D (size :: Nat) a Source #

Multi-dimensional views for safe array indexing These are logical views over 1D storage buffers

data View2D (rows :: Nat) (cols :: Nat) a Source #

data View3D (d1 :: Nat) (d2 :: Nat) (d3 :: Nat) a Source #

data SubgroupMatrixLeft (precision :: *) (m :: Nat) (n :: Nat) Source #

Subgroup Matrix Types (for chromium_experimental_subgroup_matrix)

data SubgroupMatrixRight (precision :: *) (m :: Nat) (n :: Nat) Source #

data SubgroupMatrixResult (precision :: *) (m :: Nat) (n :: Nat) Source #

data Storage Source #

Memory Address Space Tags

newtype Ptr space a Source #

Typed Pointer ensuring space safety

Constructors

Ptr String 

Instances

Instances details
Show (Ptr space a) Source # 
Instance details

Defined in WGSL.AST

Methods

showsPrec :: Int -> Ptr space a -> ShowS #

show :: Ptr space a -> String #

showList :: [Ptr space a] -> ShowS #

Eq (Ptr space a) Source # 
Instance details

Defined in WGSL.AST

Methods

(==) :: Ptr space a -> Ptr space a -> Bool #

(/=) :: Ptr space a -> Ptr space a -> Bool #

data View space a where Source #

Multi-dimensional view wrapper Provides safe indexed access to buffers with automatic offset calculation

Constructors

View1D :: Ptr space (Array n elem) -> Int -> View space (View1D n elem) 
View2D :: Ptr space (Array n elem) -> Int -> Int -> Int -> View space (View2D rows cols elem) 
View3D :: Ptr space (Array n elem) -> Int -> Int -> Int -> Int -> Int -> View space (View3D d1 d2 d3 elem) 

Instances

Instances details
Show (View space a) Source # 
Instance details

Defined in WGSL.AST

Methods

showsPrec :: Int -> View space a -> ShowS #

show :: View space a -> String #

showList :: [View space a] -> ShowS #

data Exp a where Source #

The AST Expression with Phantom Types

Constructors

LitF32 :: Float -> Exp F32 
LitF16 :: Float -> Exp F16 
LitI32 :: Int -> Exp I32 
LitU32 :: Int -> Exp U32 
LitBool :: Bool -> Exp Bool_ 
Var :: String -> Exp a 
Add :: Exp a -> Exp a -> Exp a 
Sub :: Exp a -> Exp a -> Exp a 
Mul :: Exp a -> Exp a -> Exp a 
Div :: Exp a -> Exp a -> Exp a 
Mod :: Exp a -> Exp a -> Exp a 
Neg :: Exp a -> Exp a 
Eq :: Exp a -> Exp a -> Exp Bool_ 
Ne :: Exp a -> Exp a -> Exp Bool_ 
Lt :: Exp a -> Exp a -> Exp Bool_ 
Le :: Exp a -> Exp a -> Exp Bool_ 
Gt :: Exp a -> Exp a -> Exp Bool_ 
Ge :: Exp a -> Exp a -> Exp Bool_ 
And :: Exp Bool_ -> Exp Bool_ -> Exp Bool_ 
Or :: Exp Bool_ -> Exp Bool_ -> Exp Bool_ 
Not :: Exp Bool_ -> Exp Bool_ 
Index :: Exp (Array n a) -> Exp I32 -> Exp a 
PtrIndex :: Ptr s (Array n a) -> Exp I32 -> Exp a 
Deref :: Ptr s a -> Exp a 
VecX :: Exp (Vec3 a) -> Exp a 
VecY :: Exp (Vec3 a) -> Exp a 
VecZ :: Exp (Vec3 a) -> Exp a 
FieldAccess :: Exp (Struct s) -> String -> Exp a 
Sqrt :: Exp F32 -> Exp F32 
Abs :: Exp a -> Exp a 
Min :: Exp a -> Exp a -> Exp a 
Max :: Exp a -> Exp a -> Exp a 
Exp :: Exp F32 -> Exp F32 
Cos :: Exp a -> Exp a 
Sin :: Exp a -> Exp a 
Pow :: Exp a -> Exp a -> Exp a 
Tanh :: Exp a -> Exp a 
Clamp :: Exp a -> Exp a -> Exp a -> Exp a 
F32ToI32 :: Exp F32 -> Exp I32 
I32ToF32 :: Exp I32 -> Exp F32 
U32ToI32 :: Exp U32 -> Exp I32 
I32ToU32 :: Exp I32 -> Exp U32 
F16ToF32 :: Exp F16 -> Exp F32 
F32ToF16 :: Exp F32 -> Exp F16 
I32ToF16 :: Exp I32 -> Exp F16 
ShiftLeft :: Exp U32 -> Exp U32 -> Exp U32 
ShiftRight :: Exp U32 -> Exp U32 -> Exp U32 
BitAnd :: Exp U32 -> Exp U32 -> Exp U32 
BitOr :: Exp U32 -> Exp U32 -> Exp U32 
BitXor :: Exp U32 -> Exp U32 -> Exp U32 
SubgroupMatrixLoad :: TypeRep -> Ptr s a -> Exp U32 -> Exp Bool_ -> Exp U32 -> Exp b 
SubgroupMatrixMultiplyAccumulate :: Exp a -> Exp b -> Exp c -> Exp c 
TextureSample :: Exp (Texture2D format) -> Exp Sampler -> Exp (Vec2 F32) -> Exp (Vec4 F32) 
TextureLoad :: Exp (Texture2D format) -> Exp (Vec2 I32) -> Exp I32 -> Exp (Vec4 F32) 
AtomicAdd :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 
AtomicAddU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 
AtomicSub :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 
AtomicSubU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 
AtomicMin :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 
AtomicMinU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 
AtomicMax :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 
AtomicMaxU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 
AtomicExchange :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 
AtomicExchangeU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 
AtomicCompareExchangeWeak :: Ptr space AtomicI32 -> Exp I32 -> Exp I32 -> Exp I32 
AtomicCompareExchangeWeakU :: Ptr space AtomicU32 -> Exp U32 -> Exp U32 -> Exp U32 

Instances

Instances details
Num (Exp F16) Source #

Numeric operations for F16

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp F16 -> Exp F16 -> Exp F16 #

(-) :: Exp F16 -> Exp F16 -> Exp F16 #

(*) :: Exp F16 -> Exp F16 -> Exp F16 #

negate :: Exp F16 -> Exp F16 #

abs :: Exp F16 -> Exp F16 #

signum :: Exp F16 -> Exp F16 #

fromInteger :: Integer -> Exp F16 #

Num (Exp F32) Source #

Numeric operations for F32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp F32 -> Exp F32 -> Exp F32 #

(-) :: Exp F32 -> Exp F32 -> Exp F32 #

(*) :: Exp F32 -> Exp F32 -> Exp F32 #

negate :: Exp F32 -> Exp F32 #

abs :: Exp F32 -> Exp F32 #

signum :: Exp F32 -> Exp F32 #

fromInteger :: Integer -> Exp F32 #

Num (Exp I32) Source #

Numeric operations for I32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp I32 -> Exp I32 -> Exp I32 #

(-) :: Exp I32 -> Exp I32 -> Exp I32 #

(*) :: Exp I32 -> Exp I32 -> Exp I32 #

negate :: Exp I32 -> Exp I32 #

abs :: Exp I32 -> Exp I32 #

signum :: Exp I32 -> Exp I32 #

fromInteger :: Integer -> Exp I32 #

Num (Exp U32) Source #

Numeric operations for U32

Instance details

Defined in WGSL.DSL

Methods

(+) :: Exp U32 -> Exp U32 -> Exp U32 #

(-) :: Exp U32 -> Exp U32 -> Exp U32 #

(*) :: Exp U32 -> Exp U32 -> Exp U32 #

negate :: Exp U32 -> Exp U32 #

abs :: Exp U32 -> Exp U32 #

signum :: Exp U32 -> Exp U32 #

fromInteger :: Integer -> Exp U32 #

Fractional (Exp F16) Source #

Fractional for F16

Instance details

Defined in WGSL.DSL

Fractional (Exp F32) Source #

Fractional for F32

Instance details

Defined in WGSL.DSL

Show (Exp a) Source # 
Instance details

Defined in WGSL.AST

Methods

showsPrec :: Int -> Exp a -> ShowS #

show :: Exp a -> String #

showList :: [Exp a] -> ShowS #

Eq' (Exp F16) Source # 
Instance details

Defined in WGSL.DSL

Eq' (Exp F32) Source # 
Instance details

Defined in WGSL.DSL

Eq' (Exp I32) Source # 
Instance details

Defined in WGSL.DSL

Eq' (Exp U32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp F16) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp F32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp I32) Source # 
Instance details

Defined in WGSL.DSL

Ord' (Exp U32) Source # 
Instance details

Defined in WGSL.DSL

data Stmt where Source #

Statements (Imperative Actions)

Constructors

DeclVar :: String -> TypeRep -> Maybe ExpSome -> Stmt 
Assign :: String -> ExpSome -> Stmt 
PtrAssign :: Ptr s a -> Exp a -> Stmt 
If :: Exp Bool_ -> [Stmt] -> [Stmt] -> Stmt 
While :: Exp Bool_ -> [Stmt] -> Stmt 
For :: String -> Exp I32 -> Exp I32 -> Maybe (Exp I32) -> [Stmt] -> Stmt 
Barrier :: Stmt 
SubgroupMatrixStore :: Ptr s a -> Exp U32 -> Exp b -> Exp Bool_ -> Exp U32 -> Stmt 
TextureStore :: Exp (Texture2D format) -> Exp (Vec2 I32) -> Exp (Vec4 F32) -> Stmt 
Return :: ExpSome -> Stmt 
Comment :: String -> Stmt 
RawStmt :: String -> Stmt 

Instances

Instances details
Show Stmt Source # 
Instance details

Defined in WGSL.AST

Methods

showsPrec :: Int -> Stmt -> ShowS #

show :: Stmt -> String #

showList :: [Stmt] -> ShowS #

data ExpSome where Source #

Type-erased expression for heterogeneous lists

Constructors

SomeExp :: Exp a -> ExpSome 

Instances

Instances details
Show ExpSome Source # 
Instance details

Defined in WGSL.AST

data TypeRep Source #

WGSL Type Representation (for code generation)

Instances

Instances details
Show TypeRep Source # 
Instance details

Defined in WGSL.AST

Eq TypeRep Source # 
Instance details

Defined in WGSL.AST

Methods

(==) :: TypeRep -> TypeRep -> Bool #

(/=) :: TypeRep -> TypeRep -> Bool #

WGSLLayout TypeRep Source #

TypeRep layout implementation

Instance details

Defined in WGSL.Layout

data MemorySpace Source #

Constructors

MStorage 
MWorkgroup 
MPrivate 

Instances

Instances details
Show MemorySpace Source # 
Instance details

Defined in WGSL.AST

Eq MemorySpace Source # 
Instance details

Defined in WGSL.AST

data StructDef Source #

Struct Definition

Constructors

StructDef 

Instances

Instances details
Show StructDef Source # 
Instance details

Defined in WGSL.AST

Eq StructDef Source # 
Instance details

Defined in WGSL.AST

data FunctionDecl Source #

Function Declaration

Instances

Instances details
Show FunctionDecl Source # 
Instance details

Defined in WGSL.AST

data ShaderModule Source #

Shader Module (Top-level)

Instances

Instances details
Show ShaderModule Source # 
Instance details

Defined in WGSL.AST

class WGSLType a where Source #

WGSLType typeclass for automatic struct generation from Haskell types Use GHC.Generics to derive WGSL struct definitions automatically

Minimal complete definition

wgslTypeRep

Methods

wgslTypeName :: Proxy a -> String Source #

Get the WGSL type name for this type

default wgslTypeName :: (Generic a, GWGSLType (Rep a)) => Proxy a -> String Source #

wgslTypeRep :: Proxy a -> TypeRep Source #

Get the TypeRep for this type

wgslStructDef :: Proxy a -> Maybe StructDef Source #

Generate a struct definition for this type (if it's a struct) Returns Nothing for primitive types, Just StructDef for user-defined structs

Instances

Instances details
WGSLType Bool_ Source # 
Instance details

Defined in WGSL.AST

WGSLType F16 Source # 
Instance details

Defined in WGSL.AST

WGSLType F32 Source #

Primitive type instances

Instance details

Defined in WGSL.AST

WGSLType I32 Source # 
Instance details

Defined in WGSL.AST

WGSLType U32 Source # 
Instance details

Defined in WGSL.AST

WGSLType a => WGSLType (Vec2 a) Source #

Vec instances

Instance details

Defined in WGSL.AST

WGSLType a => WGSLType (Vec3 a) Source # 
Instance details

Defined in WGSL.AST

class GWGSLType f where Source #

Generic typeclass for deriving WGSLType instances

Instances

Instances details
(GWGSLType f, GWGSLType g) => GWGSLType (f :*: g) Source #

Instance for product (multiple fields)

Instance details

Defined in WGSL.AST

Methods

gwgslTypeName :: Proxy ((f :*: g) a) -> String Source #

gwgslStructFields :: Proxy ((f :*: g) a) -> [(String, TypeRep)] Source #

GWGSLType f => GWGSLType (C1 c f) Source #

Instance for constructor metadata

Instance details

Defined in WGSL.AST

(Datatype d, GWGSLType f) => GWGSLType (D1 d f) Source #

Instance for datatype metadata (constructor name)

Instance details

Defined in WGSL.AST

(Selector s, WGSLType t) => GWGSLType (S1 s (K1 i t :: Type -> Type)) Source #

Instance for selector (field)

Instance details

Defined in WGSL.AST

Methods

gwgslTypeName :: Proxy (S1 s (K1 i t) a) -> String Source #

gwgslStructFields :: Proxy (S1 s (K1 i t) a) -> [(String, TypeRep)] Source #