FnParamSpec
Type in Authoring
The parameter record fn() accepts.
import type { FnParamSpec } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
type FnParamSpec = Record<string, ShaderType | ParamAttr | StructParamHandle>;Description
Each key is a parameter name and each value is one
of three things: a plain ShaderType for an ordinary parameter; a builtin
or location spec for an entry-point parameter that carries a stage attribute; or
a structDecl / ioStruct handle, in which case the body receives that
struct’s typed field proxy. One record shape covers plain helpers and @vertex,
@fragment and @compute entries alike. See FnHandle for the call surface a
record produces.
Examples
Example
import { fn, builtin, toF32, vec4, u32T, vec4fT, type FnParamSpec } from 'typeshade'
const vs = fn( 'vs_main', { idx: builtin('vertex_index', u32T) } satisfies FnParamSpec, ({ idx }) => vec4(toF32(idx), 0, 0, 1), { stage: 'vertex', retAttr: builtin('position', vec4fT) },)See also
Source
src/core/ir/builder.ts, line 100, at commit 26de7be8