internal

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package internal holds helpers shared by the four backend shader emitters (emit/wgsl, emit/glsl, emit/metal, emit/gles). It is importable only by packages under emit/.

The emitters differ in stage scaffolding and surface spelling, but the IR->gputype mapping, the binding-name set, and the ir.Dialect Ref/TypeName/ Call/Sample plumbing are identical (or cleanly parameterizable) across them. This package is where that shared machinery lives so each emitter does not carry its own copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameSet

func NameSet(bs []ir.Binding) map[string]bool

NameSet collects the names of bs into a lookup set.

func TypeToGPU

func TypeToGPU(t ir.Type) gputype.Type

TypeToGPU maps a Selena ir.Type to a prism gputype.Type.

Types

type Resolver

type Resolver struct {
	Dialect    dialect.Dialect
	Uniforms   map[string]bool
	Attributes map[string]bool
	Varyings   map[string]bool
	Fragment   bool
	Qualified  bool
	// SceneSampleFn renders a SceneSample expression. When nil, SceneSample
	// falls back to a dummy expression. Each post-emitter sets this.
	SceneSampleFn func(name, uv string) string
}

Resolver implements ir.Dialect for one emitter stage by delegating the surface spelling (TypeName/Call/Sample) to a prism dialect.Dialect and resolving references per the backend's reference model:

  • Qualified backends (WGSL, Metal) address a uniform as u.x and a stage input as in.x, falling back to a bare name for stage-locals.
  • Bare backends (GLSL, GLES) address everything through bare globals, so Ref returns the name unchanged.

The name sets and Fragment flag drive the qualified case and are ignored when Qualified is false.

func NewBare

func NewBare(d dialect.Dialect) Resolver

NewBare builds a bare-global resolver (GLSL/GLES).

func NewQualified

func NewQualified(d dialect.Dialect, m ir.Module, fragment bool) Resolver

NewQualified builds a struct-qualified resolver (WGSL/Metal) for one stage.

func (Resolver) Call

func (r Resolver) Call(name string, args []string) string

Call renders a builtin/function call.

func (Resolver) Ref

func (r Resolver) Ref(name string) string

Ref resolves a reference in the current stage scope.

func (Resolver) Sample

func (r Resolver) Sample(tex, uv string) string

Sample renders a texture sample.

func (Resolver) SceneSample

func (r Resolver) SceneSample(name, uv string) string

SceneSample renders a post-pass engine scene texture sample.

func (Resolver) TypeName

func (r Resolver) TypeName(t ir.Type) string

TypeName spells an ir.Type for the backend.

Jump to

Keyboard shortcuts

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