dialect

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 3 Imported by: 0

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

func (GLES) Builtin(name string, args []string) string

Builtin renders a builtin call. Unknown names fall back to the canonical name. Lifted from selena/emit/internal/spell/spell.go:10-16.

func (GLES) Sample

func (GLES) Sample(tex, uv string) string

Sample renders: texture(tex, uv) Lifted from selena/emit/gles/gles.go:74.

func (GLES) Swizzle

func (GLES) Swizzle(expr, components string) string

func (GLES) TypeName

func (GLES) TypeName(t gputype.Type) string

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

func (GLSL) Builtin(name string, args []string) string

Builtin renders a builtin call. Unknown names fall back to the canonical name. Lifted from selena/emit/internal/spell/spell.go:10-16.

func (GLSL) Sample

func (GLSL) Sample(tex, uv string) string

Sample renders: texture2D(tex, uv) Lifted from selena/emit/glsl/glsl.go:74.

func (GLSL) Swizzle

func (GLSL) Swizzle(expr, components string) string

func (GLSL) TypeName

func (GLSL) TypeName(t gputype.Type) string

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

func (Metal) Builtin(name string, args []string) string

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).

func (Metal) Sample

func (Metal) Sample(tex, uv string) string

Sample renders: tex.sample(texSampler, uv) Lifted from selena/emit/metal/metal.go:108-110.

func (Metal) Swizzle

func (Metal) Swizzle(expr, components string) string

func (Metal) TypeName

func (Metal) TypeName(t gputype.Type) string

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

func (WGSL) Builtin(name string, args []string) string

Builtin renders a builtin call. Unknown names fall back to the canonical name (lifted from selena/emit/internal/spell/spell.go:10-16).

func (WGSL) Sample

func (WGSL) Sample(tex, uv string) string

Sample renders: textureSample(tex, texSampler, uv) Lifted from selena/emit/wgsl/wgsl.go:106-108.

func (WGSL) Swizzle

func (WGSL) Swizzle(expr, components string) string

func (WGSL) TypeName

func (WGSL) TypeName(t gputype.Type) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL