Skip to content

Commit fb7dc55

Browse files
committed
docs: Update WGSL codegen documentation with completion status
Mark parser support as complete in documentation. All features are now fully implemented and working end-to-end.
1 parent 6c3ee57 commit fb7dc55

1 file changed

Lines changed: 28 additions & 32 deletions

File tree

docs/WGSL_CODEGEN.md

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -61,53 +61,49 @@ Guix now supports WGSL (WebGPU Shader Language) code generation alongside Go/WAS
6161
- Type mapping tests
6262
- Go struct generation tests
6363

64-
## Current Limitations
64+
## ✅ Complete Implementation
6565

66-
⚠️ **Parser Integration Not Complete**
66+
**All features are now fully implemented and working!**
6767

68-
The parser **lexer** recognizes GPU decorator tokens, but the **grammar** does not yet parse GPU declarations. This means:
68+
The parser now fully supports GPU/WGSL syntax. You can write GPU shaders directly in `.gx` files and generate WGSL code automatically.
6969

70-
- ❌ Cannot parse `.gx` files with GPU syntax yet
71-
- ❌ Must construct GPU AST nodes programmatically for testing
72-
- ✅ AST structure is complete and ready
73-
- ✅ Code generators work correctly with AST nodes
74-
- ✅ Build pipeline integration is ready
70+
### Parser Support (✅ COMPLETE)
7571

76-
### What Works Now
72+
The parser now handles:
73+
- ✅ GPU struct declarations with `@gpu` decorator
74+
- ✅ GPU binding declarations with `@binding`, `@uniform`, `@storage`
75+
- ✅ GPU function declarations with `@vertex`, `@fragment`, `@compute`
76+
- ✅ Field decorators like `@builtin`, `@location`
77+
- ✅ Parameter decorators for shader inputs
78+
- ✅ Mixed GPU and regular Guix code in the same file
7779

78-
```go
79-
// This works - programmatic AST construction
80-
file := &guixast.File{
81-
Package: "shaders",
82-
GPUStructs: []*guixast.GPUStructDecl{
83-
{
84-
Name: "Uniforms",
85-
Struct: &guixast.GPUStructType{
86-
Fields: []*guixast.GPUField{
87-
{Name: "viewportSize", Type: &guixast.GPUType{Name: "vec2"}},
88-
},
89-
},
90-
},
91-
},
92-
}
93-
94-
gen := codegen.NewWGSLGenerator()
95-
wgslCode, _ := gen.Generate(file) // Generates valid WGSL!
96-
```
97-
98-
### What Doesn't Work Yet
80+
### Quick Example
9981

10082
```go
101-
// This doesn't work yet - parser doesn't support GPU syntax
83+
// Write this in a .gx file
10284
input := `
10385
package shaders
10486
10587
@gpu type Uniforms struct {
10688
viewportSize vec2
89+
color vec4
90+
}
91+
92+
@binding(0, 0) @uniform var uniforms Uniforms
93+
94+
@vertex
95+
func vsMain(@builtin(vertex_index) idx uint32) vec4 {
96+
return vec4(0.0, 0.0, 0.0, 1.0)
10797
}
10898
`
10999

110-
parser.ParseString(input) // Error: unexpected token "@gpu"
100+
// Parse it
101+
parser, _ := parser.New()
102+
file, _ := parser.ParseString(input) // ✅ Works!
103+
104+
// Generate WGSL
105+
wgslGen := codegen.NewWGSLGenerator()
106+
wgslCode, _ := wgslGen.Generate(file) // ✅ Generates valid WGSL!
111107
```
112108

113109
## Next Steps

0 commit comments

Comments
 (0)