Documentation

Hesper.WGSL.CodeGen

WGSL Code Generation #

Complete code generation from ShaderM monad to WGSL modules.

Features:

Usage:

def myShader : ShaderM Unit := do
  -- ... shader code ...

let module := generateModule "myKernel" {x := 256, y := 1, z := 1} [] myShader
IO.println module.toWGSL

Function parameter with optional built-in binding

Instances For

    Generate WGSL parameter declaration

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

      Function declaration with attributes, parameters, and body

      Instances For

        Generate complete WGSL function

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

          Complete shader module with all declarations

          Instances For

            Generate storage buffer declaration with binding

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

              Generate workgroup variable declaration

              Equations
              Instances For

                Generate struct definition

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

                  Generate complete WGSL module

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Hesper.WGSL.CodeGen.generateComputeModule (funcName : String) (workgroupSize : WorkgroupSize) (extensions : List String := []) (computation : Monad.ShaderM Unit) :

                    Generate a compute shader module from ShaderM monad

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Hesper.WGSL.CodeGen.generateComputeModuleWithDiagnostics (funcName : String := "main") (workgroupSize : WorkgroupSize := { x := 256 }) (extensions : List String := []) (diagnostics : List (String × String) := []) (computation : Monad.ShaderM Unit) :

                      Generate compute shader module with diagnostics support

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Hesper.WGSL.CodeGen.generateWGSL (funcName : String := "main") (workgroupSize : WorkgroupSize := { x := 256 }) (extensions : List String := []) (diagnostics : List (String × String) := []) (computation : Monad.ShaderM Unit) :

                        Convenience function: Generate WGSL string from ShaderM computation

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

                          Generate WGSL with default parameters

                          Equations
                          Instances For