FieldSpec
On this page

FieldSpec

Interface in Layout

One struct field or entry-point parameter carrying a stage attribute.

import type { FieldSpec } from 'typeshade'

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

Syntax

interface FieldSpec<T extends ShaderType = ShaderType> {
readonly type: T;
readonly attr: string;
readonly location?: number;
readonly builtin?: string;
readonly interpolate?: string;
}

Description

One struct field or entry-point parameter carrying a stage attribute. It is the return type of builtin and location, and the value type of both an ioStruct field map and an fn entry-point parameter record, so a stage-attributed parameter and an IO-struct field are written the same way.

attr is the attribute as WGSL text. location, builtin and interpolate are the structured form the backends read, for capability checks, for the vertex-attribute table reflect produces, and for the GLSL flat qualifier. A field carries either a builtin attribute or a location attribute, never both. Build one with builtin(name, type) or location(n, type, interpolate?).

Instance properties

typeread only T

The field’s shader type.

attrread only string

The attribute as WGSL text. The structured fields below are what the backends read.

locationoptionalread only number

The @location(n) slot, when the field is location-attributed.

builtinoptionalread only string

The @builtin(name) id, when the field is builtin-attributed.

interpolateoptionalread only string

The @interpolate(mode) mode, when one was given.

See also

Source

src/core/sot.ts, line 100, at commit 26de7be8

Edit this page Report a problem