| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
WGSL.AST
Synopsis
- data F32
- data F16
- data I32
- data U32
- data Bool_
- data AtomicI32
- data AtomicU32
- data Vec2 a
- data Vec3 a
- data Vec4 a
- data Array (n :: Nat) a
- data Struct a
- data Texture2D format
- data Sampler
- data View1D (size :: Nat) a
- data View2D (rows :: Nat) (cols :: Nat) a
- data View3D (d1 :: Nat) (d2 :: Nat) (d3 :: Nat) a
- data SubgroupMatrixLeft (precision :: *) (m :: Nat) (n :: Nat)
- data SubgroupMatrixRight (precision :: *) (m :: Nat) (n :: Nat)
- data SubgroupMatrixResult (precision :: *) (m :: Nat) (n :: Nat)
- data Storage
- data Workgroup
- data Private
- newtype Ptr space a = Ptr String
- data View space a where
- data Exp a where
- 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
- data Stmt where
- 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
- data ExpSome where
- data TypeRep
- = TF32
- | TF16
- | TI32
- | TU32
- | TBool
- | TVec2 TypeRep
- | TVec3 TypeRep
- | TVec4 TypeRep
- | TArray Int TypeRep
- | TPtr MemorySpace TypeRep
- | TSubgroupMatrixLeft TypeRep Int Int
- | TSubgroupMatrixRight TypeRep Int Int
- | TSubgroupMatrixResult TypeRep Int Int
- | TStruct String
- | TTexture2D String
- | TSampler
- | TAtomicI32
- | TAtomicU32
- data MemorySpace
- data StructDef = StructDef {
- structName :: String
- structFields :: [(String, TypeRep)]
- data FunctionDecl = FunctionDecl {
- funcName :: String
- funcParams :: [(Maybe String, String, TypeRep)]
- funcReturnType :: Maybe TypeRep
- funcBody :: [Stmt]
- funcAttributes :: [String]
- data ShaderModule = ShaderModule {
- moduleFunctions :: [FunctionDecl]
- moduleGlobals :: [(String, TypeRep, MemorySpace)]
- moduleStructs :: [StructDef]
- moduleExtensions :: [String]
- moduleDiagnostics :: [String]
- moduleBindings :: [(String, Int)]
- class WGSLType a where
- wgslTypeName :: Proxy a -> String
- wgslTypeRep :: Proxy a -> TypeRep
- wgslStructDef :: Proxy a -> Maybe StructDef
- class GWGSLType f where
- gwgslTypeName :: Proxy (f a) -> String
- gwgslStructFields :: Proxy (f a) -> [(String, TypeRep)]
Documentation
Phantom Types for WGSL types
Atomic types (for atomic operations) These are distinct from I32/U32 to prevent use in regular arithmetic
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 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 View space a where Source #
Multi-dimensional view wrapper Provides safe indexed access to buffers with automatic offset calculation
The AST Expression with Phantom Types
Constructors
Instances
| Num (Exp F16) Source # | Numeric operations for F16 |
| Num (Exp F32) Source # | Numeric operations for F32 |
| Num (Exp I32) Source # | Numeric operations for I32 |
| Num (Exp U32) Source # | Numeric operations for U32 |
| Fractional (Exp F16) Source # | Fractional for F16 |
| Fractional (Exp F32) Source # | Fractional for F32 |
| Show (Exp a) Source # | |
| Eq' (Exp F16) Source # | |
| Eq' (Exp F32) Source # | |
| Eq' (Exp I32) Source # | |
| Eq' (Exp U32) Source # | |
| Ord' (Exp F16) Source # | |
| Ord' (Exp F32) Source # | |
| Ord' (Exp I32) Source # | |
| Ord' (Exp U32) 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 |
Type-erased expression for heterogeneous lists
WGSL Type Representation (for code generation)
Constructors
Instances
| Show TypeRep Source # | |
| Eq TypeRep Source # | |
| WGSLLayout TypeRep Source # | TypeRep layout implementation |
Defined in WGSL.Layout Methods wgslSize :: LayoutMode -> TypeRep -> Int Source # wgslAlignment :: LayoutMode -> TypeRep -> Int Source # | |
data MemorySpace Source #
Constructors
| MStorage | |
| MWorkgroup | |
| MPrivate |
Instances
| Show MemorySpace Source # | |
Defined in WGSL.AST Methods showsPrec :: Int -> MemorySpace -> ShowS # show :: MemorySpace -> String # showList :: [MemorySpace] -> ShowS # | |
| Eq MemorySpace Source # | |
Defined in WGSL.AST | |
Struct Definition
Constructors
| StructDef | |
Fields
| |
data FunctionDecl Source #
Function Declaration
Constructors
| FunctionDecl | |
Fields
| |
Instances
| Show FunctionDecl Source # | |
Defined in WGSL.AST Methods showsPrec :: Int -> FunctionDecl -> ShowS # show :: FunctionDecl -> String # showList :: [FunctionDecl] -> ShowS # | |
data ShaderModule Source #
Shader Module (Top-level)
Constructors
| ShaderModule | |
Fields
| |
Instances
| Show ShaderModule Source # | |
Defined in WGSL.AST Methods showsPrec :: Int -> ShaderModule -> ShowS # show :: ShaderModule -> String # showList :: [ShaderModule] -> ShowS # | |
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
Methods
wgslTypeName :: Proxy a -> String Source #
Get the WGSL type name for this type
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
class GWGSLType f where Source #
Generic typeclass for deriving WGSLType instances
Methods
gwgslTypeName :: Proxy (f a) -> String Source #
gwgslStructFields :: Proxy (f a) -> [(String, TypeRep)] Source #
Instances
| (GWGSLType f, GWGSLType g) => GWGSLType (f :*: g) Source # | Instance for product (multiple fields) |
| GWGSLType f => GWGSLType (C1 c f) Source # | Instance for constructor metadata |
| (Datatype d, GWGSLType f) => GWGSLType (D1 d f) Source # | Instance for datatype metadata (constructor name) |
| (Selector s, WGSLType t) => GWGSLType (S1 s (K1 i t :: Type -> Type)) Source # | Instance for selector (field) |