OverrideDecl
On this page

OverrideDecl

Interface in IR

A pipeline specialization constant, the declaration behind overrideConst.

import type { OverrideDecl } from 'typeshade'

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

Syntax

interface OverrideDecl {
readonly name: string;
readonly type: ShaderType;
readonly default: number | boolean;
}

Description

On WGSL it emits a module-scope override name: type = default;, which the host specializes through createRenderPipeline({ constants: { name } }). On GLSL ES 3.00 it emits #define name default after the #version line, and the host specializes it by emitting again with emitGlslModule(m, stage, { overrideValues }). The value is chosen when the pipeline is created, so a single authored module yields as many driver-specialized variants as the host needs, and the driver eliminates the branches a constant turns dead. Only WGSL scalar types are allowed (bool, i32, u32, f32); a vector, matrix, array or struct type is rejected at authoring with SD0014.

Instance properties

nameread only string
typeread only ShaderType
defaultread only number | boolean

The default value emitted into the override declaration or #define: the value a pipeline gets when the host supplies nothing for this constant.

See also

Source

src/core/ir/nodes.ts, line 406, at commit 26de7be8

Edit this page Report a problem