Authoring

Authoring

48 members

The builder a shader is written with: modules, functions, variables and control flow.

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Break Function
Push a break; onto the innermost scope, exiting the nearest enclosing Loop outright, under the same nesting rule as Continue: an If nested inside the loop is not itself a break boundary.
Builder Class
The statement collector every fn() body writes into.
Call Function
Push a call as a statement onto the innermost scope, kept for its effect and nothing else.
compile Function
Compile TypeShade TypeScript source into the module and generated shader outputs.
CompileOptions Interface
How one compile() call is set up.
CompileResult Interface
What compile() returns.
compileTsSource Function
Compile a TypeScript source string through the TypeShade authoring pipeline.
CompileTsSourceOptions Interface
Options controlling compilation of a TypeShade TypeScript source string.
CompileTsSourceResult Interface
The result of compiling a TypeShade TypeScript source string, including IR and optional WGSL.
condExpr Function
N-arm value dispatch on conditions, the first true condition winning: condExpr([[c0, () => e0], [c1, () => e1]], () => eN).
constExpr Function
Author a module-level constant from an IR value expression: the form for a constant that is not a plain scalar.
ConstExprDecl Interface
What constExpr returns: the ConstDecl itself, so it drops straight into module, carrying node, the typed reference to read the constant through at call sites.
Continue Function
Push a continue; onto the innermost scope, skipping to the next iteration of the nearest enclosing loop.
Discard Function
Push a discard; onto the innermost scope.
externFn Function
Forward-declare a callable whose real definition (fn(...)) is authored somewhere else, or built later than the caller's own module-load time (see ExternFn).
ExternFn Type
A typed call-only handle for a function whose definition is provided elsewhere: the forward-declaration counterpart to fn().
externVar Function
Declare a host-provided global: the variable counterpart of externFn.
ExternVarHandle Interface
The pair externVar returns: the read node, and the declaration to hand module().
findUseTypeshadeDirective Function
Scan the top-level statements of a SourceFile and return the first "use typeshade"; directive, or undefined if none is present.
fn Function
Author a function. One call covers a plain helper and a @vertex, @fragment or @compute entry point.
FnHandle Type
The type fn() returns: a typed, callable handle that is also a FuncDecl.
FnParamSpec Type
The parameter record fn() accepts.
hasUseTypeshadeDirective Function
True when the SourceFile contains at least one top-level "use typeshade".
If Function
Author if (cond) { body } over the innermost active scope.
IfChain Class
The chain object Builder.if and If(/api/if/) return, so .elif(...) and .else(...) read top to bottom in authored order.
ifExpr Function
Two-arm value dispatch on a condition: ifExpr(cond, () => a, () => b).
isTypeshadeSource Function
Return whether a TypeScript source string opts into TypeShade with the "use typeshade" directive.
isUseTypeshadeDirective Function
Returns true when node is a top-level "use typeshade"; statement.
Let Function
Bind a value to an immutable local, emitting let name = expr; into the innermost active scope.
Loop Function
Author a C-style for loop over the innermost active scope.
matchEnum Function
Exhaustive integer dispatch over an enumU32: matchEnum(kind, Kind, { Line: () => …, Fill: () => …, … }).
matchExpr Function
A typed multi-arm dispatch over a scalar scrutinee, the expression form of switch (scrutinee) { case v0: r0; …; default: dflt }.
module Function
Assemble a module from its declarations.
ModuleParts Interface
The input shape module accepts: a Partial<ModuleDecl> whose funcs also takes a key-named record as an alternative to the array, and whose uses derives structs, bindings and consts from declarator handles.
overrideConst Function
Declare a pipeline specialization constant: one value that is fixed when a pipeline is created, later than module build and earlier than the draw.
OverrideHandle Interface
The pair overrideConst returns for a pipeline specialization constant: .node reads the value, opaque to the optimizer, in any expression or branch condition, and .decl goes into module.
ParamSpec Type
The parameter record externFn takes: a plain map from parameter name to ShaderType, in declaration order.
rawStmt Function
Author a raw statement, the escape hatch that splices verbatim text into a function body.
reduce Function
Fold a value over a C-style loop: the value-returning spelling of the var acc = init; for (...) { acc = f(acc, i) } accumulator.
Return Function
Push an explicit return value; onto the innermost scope.
ReturnIf Function
Guard clause: if (cond) { return value; }, the explicit early return that reads as "return value if cond".
Switch Function
Open a switch (scrut) chain: Switch(scrut).case(n, body)….default(body).
SwitchChain Class
switch (scrut) { case n: …; default: … } as a chainable statement builder, mirroring the If(…).elif(…).else(…) surface so integer dispatch reads the familiar imperative way: declare a Var(/api/var/) holding the default, then assign it inside the case arms.
TsCompilerDiagnostic Interface
A source diagnostic produced while TypeShade analyzes or compiles TypeScript shader code.
USE_TYPESHADE Constant
The exact string the directive must carry.
UsesHandle Type
A declarator handle accepted by module({ uses }): anything that carries its own declaration or binding.
Var Function
Declare a mutable local and return the node that reads and writes it.
when Function
Dispatch a value on a condition, returning the value instead of mutating a var.

Edit this page Report a problem