Skip to content

bluescreen10/wesl-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wesl-go

logo

Go Reference Tests codecov Go Report Card Go Version

A Go implementation of the WESL compiler — a superset of WGSL that adds a module system with cross-file imports and compile-time @if conditionals. It takes one or more WESL source files and produces a single, flat WGSL output suitable for use with the WebGPU API.

Usage

import "github.com/bluescreen10/wesl-go"

// Create a compiler instance.
c := wesl.New()

// Register source files. Paths are stored relative to the FS root so that
// package:: imports resolve correctly.
c.ParseFS(os.DirFS("./shaders"), "**/*.wesl")

// Compile an entry-point file, optionally passing compile-time feature flags.
wgsl, err := c.Compile("main.wesl", map[string]bool{"MY_FEATURE": true})
if err != nil {
    log.Fatal(err)
}
fmt.Println(wgsl)

Credits

Test cases are adapted from the WESL Test Suite maintained by the WebGPU Shading Language tooling working group.

About

Pure Go WGSL Extension Language Compiler

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages