Documentation

Hesper.WGSL.Shader

Statement-level DSL for complete WGSL shaders. Supports variable declarations, assignments, loops, conditionals, and shader structure.

WGSL Statements

Instances For

    Storage buffer binding

    Instances For

      Workgroup size specification

      Instances For

        Built-in variable bindings in compute shader

        Instances For
          Instances For

            Shader function parameter

            Instances For

              Workgroup variable declaration (shared memory)

              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Equations
                  Instances For

                    Complete compute shader structure

                    Instances For
                      partial def Hesper.WGSL.Stmt.toWGSL (indent : Nat := 0) :

                      Convert statement to WGSL string with indentation

                      Generate WGSL struct definition

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Generate complete WGSL shader code from ComputeShader

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def Hesper.WGSL.declareVar (name : String) (ty : WGSLType) (init : Option ((t : WGSLType) × Exp t) := none) :

                          Declare a variable with optional initial value

                          Equations
                          Instances For
                            def Hesper.WGSL.assign {ty : WGSLType} (name : String) (value : Exp ty) :

                            Assign to a variable

                            Equations
                            Instances For
                              def Hesper.WGSL.assignAt {ty : WGSLType} (arrName : String) (index : Exp (WGSLType.scalar ScalarType.u32)) (value : Exp ty) :

                              Assign to array element

                              Equations
                              Instances For

                                For loop statement

                                Equations
                                Instances For
                                  def Hesper.WGSL.expr {t : WGSLType} (e : Exp t) :

                                  Expression statement (e.g., function calls)

                                  Equations
                                  Instances For
                                    def Hesper.WGSL.initArray {ty : WGSLType} (arrName : String) (count : Nat) (gen : NatExp ty) :

                                    Initialize array elements with a generator function

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      def Hesper.WGSL.nestedMap2D {α : Type} (rows cols : Nat) (f : NatNatα) :
                                      List α

                                      Nested loops for 2D iteration

                                      Equations
                                      Instances For

                                        HOAS-style loop construct. Instead of requiring a string variable name, takes a function that receives the loop variable as an Exp and returns the loop body.

                                        Example: loop "i" 0 n 1 (fun i => [...statements using i...])

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          def Hesper.WGSL.staticFor {α : Type} (items : List α) (f : αList Stmt) :

                                          Compile-time iteration over a list, generating statements for each element. Similar to Haskell's staticFor - unrolls the loop at DSL compile time.

                                          Example: staticFor [0, 1, 2, 3] (fun i => assignAt "arr" i someValue)

                                          Equations
                                          Instances For
                                            def Hesper.WGSL.staticForRange (start end_ : Nat) (f : NatList Stmt) :

                                            Helper to iterate over a range with a body function

                                            Equations
                                            Instances For
                                              def Hesper.WGSL.staticForIndexed {α : Type} (items : List α) (f : NatαList Stmt) :

                                              Helper to iterate with index and value from a list

                                              Equations
                                              Instances For
                                                def Hesper.WGSL.loadMatricesLeft {st : ScalarType} {m k : Nat} (arrName : String) (count : Nat) (bufferRef : String) (getOffset : NatExp (WGSLType.scalar ScalarType.u32)) (stride : Exp (WGSLType.scalar ScalarType.u32)) :

                                                Load multiple matrices into an array variable

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  def Hesper.WGSL.loadMatricesRight {st : ScalarType} {k n : Nat} (arrName : String) (count : Nat) (bufferRef : String) (getOffset : NatExp (WGSLType.scalar ScalarType.u32)) (stride : Exp (WGSLType.scalar ScalarType.u32)) :

                                                  Load multiple matrices (right operand) into an array variable

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    def Hesper.WGSL.matrixMulAccGrid {st : ScalarType} {m k n tm tn : Nat} (axArrName bxArrName accArrName : String) :

                                                    Perform multiply-accumulate on 2D grid of matrices

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      def Hesper.WGSL.storeMatricesResult {st : ScalarType} {m n tm tn : Nat} (arrName bufferRef : String) (getOffset : NatNatExp (WGSLType.scalar ScalarType.u32)) (stride : Exp (WGSLType.scalar ScalarType.u32)) :

                                                      Store multiple result matrices from array to buffer

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For