Documentation
¶
Overview ¶
Package selena is the shader & material authoring language for the GoSX ecosystem: author a material once and emit the correct shader for every rendering target (WGSL/GLSL for browser + desktop, Metal/GLSL-ES for mobile via gosx-native).
The pipeline is: .sel source -> grammar (gotreesitter/grammargen) -> AST -> lower -> the neutral Selena IR (package ir) -> per-target emitters (package emit/...). See README.md for the architecture and design notes.
The root Compile APIs are the stable integration point for tools and hosts: parse .sel source, select a material, lower it to IR, compute the binding descriptor, and optionally emit all supported shader targets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artifact ¶
Artifact is the emitted shader source for one target. WGSL and Metal use Source. GLSL and GLES use Vertex and Fragment.
type CompileError ¶
type CompileError struct {
Diagnostics []Diagnostic
Err error
}
CompileError wraps one or more diagnostics while preserving the original error for errors.Is/errors.As callers.
func (*CompileError) Error ¶
func (e *CompileError) Error() string
func (*CompileError) Unwrap ¶
func (e *CompileError) Unwrap() error
type CompileOptions ¶
CompileOptions controls material selection and shader emission.
If Material is empty, Selena compiles the last material in the program. This matches the file-authoring convention where a derived material follows its base material. If Targets is nil, Compile emits every supported target. If Targets is an empty non-nil slice, Compile parses and lowers without emitting shader source.
type Diagnostic ¶
Diagnostic is a structured compiler message. Range is zero when source information is not available, such as when callers hand-build HIR.
type Result ¶
type Result struct {
Program hir.Program
Material hir.Material
Module ir.Module
Layout bindings.Layout
Artifacts []Artifact
}
Result contains the useful artifacts from a Selena compile: parsed HIR, selected material, lowered IR, host binding layout, and emitted shader source.
func Compile ¶
func Compile(source []byte, opts CompileOptions) (Result, error)
Compile parses source, selects a material, lowers it, and emits requested shader targets.
func CompileMaterial ¶
CompileMaterial compiles a named material from an already parsed program.
func CompileProgram ¶
func CompileProgram(p hir.Program, opts CompileOptions) (Result, error)
CompileProgram selects, lowers, and emits one material from p.
type Severity ¶
type Severity string
Severity classifies a compiler diagnostic.
const (
SeverityError Severity = "error"
)
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
gosx
Package gosx adapts a Selena material into a GoSX scene.IRMaterial, filling the custom-shader slots for every backend (GLSL for WebGL, WGSL for WebGPU).
|
Package gosx adapts a Selena material into a GoSX scene.IRMaterial, filling the custom-shader slots for every backend (GLSL for WebGL, WGSL for WebGPU). |
|
Package bindings computes and represents the host-facing binding layout for a material: the std140 uniform-block byte map, vertex attributes, textures, and per-backend binding coordinates.
|
Package bindings computes and represents the host-facing binding layout for a material: the std140 uniform-block byte map, vertex attributes, textures, and per-backend binding coordinates. |
|
cmd
|
|
|
selena
command
Command selena is the CLI for the Selena shader authoring language.
|
Command selena is the CLI for the Selena shader authoring language. |
|
selena-grammar
command
Command selena-grammar regenerates the embedded parser blob used by parse.
|
Command selena-grammar regenerates the embedded parser blob used by parse. |
|
emit
|
|
|
gles
Package gles emits GLSL ES from the Selena IR for the Android GLSurfaceView backend, consumed by gosx-native.
|
Package gles emits GLSL ES from the Selena IR for the Android GLSurfaceView backend, consumed by gosx-native. |
|
glsl
Package glsl emits GLSL from the Selena IR for the WebGL backend (browser + GoSX desktop, via 16-scene-webgl.js running in Chromium).
|
Package glsl emits GLSL from the Selena IR for the WebGL backend (browser + GoSX desktop, via 16-scene-webgl.js running in Chromium). |
|
internal
Package internal holds helpers shared by the four backend shader emitters (emit/wgsl, emit/glsl, emit/metal, emit/gles).
|
Package internal holds helpers shared by the four backend shader emitters (emit/wgsl, emit/glsl, emit/metal, emit/gles). |
|
metal
Package metal emits Metal Shading Language from the Selena IR for the iOS SceneKit backend, consumed by gosx-native.
|
Package metal emits Metal Shading Language from the Selena IR for the iOS SceneKit backend, consumed by gosx-native. |
|
wgsl
Package wgsl emits WGSL from the Selena IR for the WebGPU backend (browser + GoSX desktop, via 16a-scene-webgpu.js running in Chromium).
|
Package wgsl emits WGSL from the Selena IR for the WebGPU backend (browser + GoSX desktop, via 16a-scene-webgpu.js running in Chromium). |
|
Package grammar defines the Selena shader DSL grammar using gotreesitter + grammargen — the same grammar engine behind GoSX's .gsx and gosx-native's .swift.gsx.
|
Package grammar defines the Selena shader DSL grammar using gotreesitter + grammargen — the same grammar engine behind GoSX's .gsx and gosx-native's .swift.gsx. |
|
Package hir is Selena's high-level, author-facing material model — the level a human (or grammar front-end) targets.
|
Package hir is Selena's high-level, author-facing material model — the level a human (or grammar front-end) targets. |
|
Package ir defines the neutral, typed Selena shader IR — the heart of the project and the single source of truth for a material.
|
Package ir defines the neutral, typed Selena shader IR — the heart of the project and the single source of truth for a material. |
|
Package lower translates a parsed Selena AST into the neutral Selena IR (package ir), resolving types, uniform/attribute/sampler/varying bindings, and standard-material composition.
|
Package lower translates a parsed Selena AST into the neutral Selena IR (package ir), resolving types, uniform/attribute/sampler/varying bindings, and standard-material composition. |
|
Package parse turns .sel source into the high-level material model (hir).
|
Package parse turns .sel source into the high-level material model (hir). |