Documentation
¶
Overview ¶
Package dialect provides the per-backend spelling layer for GPU shader codegen. It is IR-agnostic: it knows only gputype.Type and produces the correct surface string for each target shading language.
Lifted from Selena's per-backend dialects so that Selena (Task 3) and Elio (Task 4) can delete their copies and import this package instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect interface {
TypeName(gputype.Type) string // WGSL vec3<f32> · GLSL vec3 · Metal float3
Builtin(name string, args []string) string // a builtin call, e.g. dot(a, b) (Metal may rename)
Swizzle(expr, components string) string // expr.xyz (same on all backends today)
Sample(tex, uv string) string // WGSL textureSample(...) · GLSL texture(...) · Metal t.sample(...)
}
Dialect spells the backend-specific, IR-agnostic parts of shader codegen.
type GLES ¶
type GLES struct{}
GLES implements Dialect for GLSL ES 3.00 (Android / GLES 3.1). TypeName spellings lifted from selena/emit/gles/gles.go:76-93 — identical to GLSL; the difference is only the Sample call form and shader IO keywords. Builtin spellings lifted from selena/emit/gles/gles.go:103-130. Sample lifted from selena/emit/gles/gles.go:74.
func (GLES) Builtin ¶
Builtin renders a builtin call. Unknown names fall back to the canonical name. Lifted from selena/emit/internal/spell/spell.go:10-16.
type GLSL ¶
type GLSL struct{}
GLSL implements Dialect for GLSL ES 1.00 (WebGL / desktop GL). TypeName spellings lifted from selena/emit/glsl/glsl.go:76-93 and elio/emit/glsl/glsl.go:442-480 (i32/u32 vectors, non-square mats). Builtin spellings lifted from selena/emit/glsl/glsl.go:103-130. Sample lifted from selena/emit/glsl/glsl.go:74.
func (GLSL) Builtin ¶
Builtin renders a builtin call. Unknown names fall back to the canonical name. Lifted from selena/emit/internal/spell/spell.go:10-16.
type Metal ¶
type Metal struct{}
Metal implements Dialect for Metal Shading Language (iOS / macOS). TypeName spellings lifted from selena/emit/metal/metal.go:112-129 and elio/emit/metal/metal.go:316-347 (i32/u32/bool scalars, Array). Builtin spellings lifted from selena/emit/metal/metal.go:139-166 (all identity). Sample lifted from selena/emit/metal/metal.go:108-110.
func (Metal) Builtin ¶
Builtin renders a builtin call. Unknown names fall back to the canonical name. Lifted from selena/emit/internal/spell/spell.go:10-16. Note: Selena's Metal builtins map has all-identity spellings (no renames).
type WGSL ¶
type WGSL struct{}
WGSL implements Dialect for the WebGPU Shading Language. TypeName spellings lifted from selena/emit/wgsl/wgsl.go:110-127 and elio/emit/wgsl/wgsl.go:199-217 (Array). Builtin spellings lifted from selena/emit/wgsl/wgsl.go:137-164. Sample lifted from selena/emit/wgsl/wgsl.go:106-108.
func (WGSL) Builtin ¶
Builtin renders a builtin call. Unknown names fall back to the canonical name (lifted from selena/emit/internal/spell/spell.go:10-16).