Documentation

Hesper.WGSL.DSL

High-level DSL with operator overloading for natural syntax. Provides literals, arithmetic, comparison, and other operators that compile to type-safe WGSL expressions.

Convenience function: Create f32 literal (most common type)

Equations
Instances For
    def Hesper.WGSL.var {t : WGSLType} (name : String) :
    Exp t

    Create a variable reference

    Equations
    Instances For
      instance Hesper.WGSL.instHAddExp_1 {t : WGSLType} :
      HAdd (Exp t) (Exp t) (Exp t)

      Addition operator for WGSL expressions

      Equations
      instance Hesper.WGSL.instHSubExp_1 {t : WGSLType} :
      HSub (Exp t) (Exp t) (Exp t)

      Subtraction operator for WGSL expressions

      Equations
      instance Hesper.WGSL.instHMulExp_1 {t : WGSLType} :
      HMul (Exp t) (Exp t) (Exp t)

      Multiplication operator for WGSL expressions

      Equations
      instance Hesper.WGSL.instHDivExp_1 {t : WGSLType} :
      HDiv (Exp t) (Exp t) (Exp t)

      Division operator for WGSL expressions

      Equations
      instance Hesper.WGSL.instHModExp_1 {t : WGSLType} :
      HMod (Exp t) (Exp t) (Exp t)

      Modulo operator for WGSL expressions

      Equations

      Negation operator for WGSL expressions

      Equations
      def Hesper.WGSL.divExp {t : WGSLType} (a b : Exp t) :
      Exp t

      Integer division for WGSL expressions (./.)

      Equations
      Instances For
        def Hesper.WGSL.modExp {t : WGSLType} (a b : Exp t) :
        Exp t

        Modulo for WGSL expressions (./.)

        Equations
        Instances For

          Custom equality class for WGSL expressions

          Instances

            Custom ordering class for WGSL expressions

            Instances

              Bitwise right shift

              Equations
              Instances For

                Convert to f32

                Equations
                Instances For

                  Convert to f16

                  Equations
                  Instances For

                    Convert to i32

                    Equations
                    Instances For

                      Convert to u32

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

                                Array indexing operator

                                Equations
                                Instances For

                                  Vector component accessors

                                  Equations
                                  Instances For
                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        Equations
                                        Instances For

                                          Create vec2

                                          Equations
                                          Instances For

                                            Create vec3

                                            Equations
                                            Instances For

                                              Create vec4

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

                                                Square root

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

                                                  Absolute value

                                                  Equations
                                                  Instances For
                                                    def Hesper.WGSL.min' {t : WGSLType} (a b : Exp t) :
                                                    Exp t

                                                    Minimum of two values

                                                    Equations
                                                    Instances For
                                                      def Hesper.WGSL.max' {t : WGSLType} (a b : Exp t) :
                                                      Exp t

                                                      Maximum of two values

                                                      Equations
                                                      Instances For
                                                        def Hesper.WGSL.clamp' {t : WGSLType} (e lo hi : Exp t) :
                                                        Exp t

                                                        Clamp value between min and max

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

                                                          Exponential function

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

                                                            Sine function

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

                                                              Cosine function

                                                              Equations
                                                              Instances For
                                                                def Hesper.WGSL.pow' {t : WGSLType} (base exponent : Exp t) :
                                                                Exp t

                                                                Power function

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

                                                                  Hyperbolic tangent

                                                                  Equations
                                                                  Instances For
                                                                    def Hesper.WGSL.select' {t : WGSLType} (cond : Exp (WGSLType.scalar ScalarType.bool)) (ifTrue ifFalse : Exp t) :
                                                                    Exp t

                                                                    Select between two values based on condition (WGSL select function)

                                                                    Equations
                                                                    Instances For

                                                                      Example Usage #

                                                                      -- Create variables
                                                                      def x : Exp (.scalar .f32) := Exp.var "x"
                                                                      def y : Exp (.scalar .f32) := Exp.var "y"
                                                                      
                                                                      -- Natural arithmetic syntax
                                                                      def expr1 := x + y * 2.0  -- Multiplication binds tighter
                                                                      
                                                                      -- Comparisons
                                                                      def cond := x .>. 0.0 .&&. y .<. 10.0
                                                                      
                                                                      -- Type conversions
                                                                      def asInt := i32(x)
                                                                      
                                                                      -- Math functions
                                                                      def length := sqrt'(x * x + y * y)
                                                                      
                                                                      -- Conditional
                                                                      def result := select' (x .>. 0.0) x (-x)  -- absolute value
                                                                      

                                                                      Minimum of two values

                                                                      Equations
                                                                      Instances For

                                                                        Maximum of two values

                                                                        Equations
                                                                        Instances For

                                                                          Clamp value to range

                                                                          Equations
                                                                          Instances For
                                                                            def Hesper.WGSL.select {t : WGSLType} (cond : Exp (WGSLType.scalar ScalarType.bool)) (trueVal falseVal : Exp t) :
                                                                            Exp t

                                                                            Select (ternary operator): select(cond, trueVal, falseVal)

                                                                            Equations
                                                                            Instances For

                                                                              Load subgroup matrix (left operand) from buffer

                                                                              Equations
                                                                              Instances For

                                                                                Load subgroup matrix (right operand) from buffer

                                                                                Equations
                                                                                Instances For

                                                                                  Multiply-accumulate for subgroup matrices

                                                                                  Equations
                                                                                  Instances For

                                                                                    Store subgroup matrix result to buffer

                                                                                    Equations
                                                                                    Instances For

                                                                                      Zero-initialized subgroup matrix (left)

                                                                                      Equations
                                                                                      Instances For

                                                                                        Zero-initialized subgroup matrix (right)

                                                                                        Equations
                                                                                        Instances For

                                                                                          Zero-initialized subgroup matrix (result)

                                                                                          Equations
                                                                                          Instances For
                                                                                            def Hesper.WGSL.get {elemTy : WGSLType} {n : Nat} (arr : Exp (elemTy.array n)) (idx : Exp (WGSLType.scalar ScalarType.u32)) :
                                                                                            Exp elemTy

                                                                                            Index into an array

                                                                                            Equations
                                                                                            • arr[idx] = arr ! idx
                                                                                            Instances For
                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For

                                                                                                Atomically add to i32, returns old value

                                                                                                Equations
                                                                                                Instances For

                                                                                                  Atomically add to u32, returns old value

                                                                                                  Equations
                                                                                                  Instances For

                                                                                                    Atomically subtract from i32, returns old value

                                                                                                    Equations
                                                                                                    Instances For

                                                                                                      Atomically subtract from u32, returns old value

                                                                                                      Equations
                                                                                                      Instances For

                                                                                                        Atomically compute minimum with i32, returns old value

                                                                                                        Equations
                                                                                                        Instances For

                                                                                                          Atomically compute minimum with u32, returns old value

                                                                                                          Equations
                                                                                                          Instances For

                                                                                                            Atomically compute maximum with i32, returns old value

                                                                                                            Equations
                                                                                                            Instances For

                                                                                                              Atomically compute maximum with u32, returns old value

                                                                                                              Equations
                                                                                                              Instances For

                                                                                                                Atomically exchange (swap) i32 value, returns old value

                                                                                                                Equations
                                                                                                                Instances For

                                                                                                                  Atomically exchange (swap) u32 value, returns old value

                                                                                                                  Equations
                                                                                                                  Instances For

                                                                                                                    Atomically compare-and-exchange i32 (weak version), returns old value

                                                                                                                    Equations
                                                                                                                    Instances For

                                                                                                                      Atomically compare-and-exchange u32 (weak version), returns old value

                                                                                                                      Equations
                                                                                                                      Instances For