WGSL_BUILTIN_TYPES
On this page

WGSL_BUILTIN_TYPES

Constant in Layout

The type each @builtin(<name>) supplies, for every id WGSL gives one fixed type.

import { WGSL_BUILTIN_TYPES } from 'typeshade'

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

Syntax

const WGSL_BUILTIN_TYPES: { readonly vertex_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly instance_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly position: { readonly kind: "vec"; readonly n: 4; readonly elem: "f32"; }; readonly front_facing: { readonly kind: "scalar"; readonly scalar: "bool"; }; readonly frag_depth: { readonly kind: "scalar"; readonly scalar: "f32"; }; readonly sample_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly sample_mask: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly primitive_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly local_invocation_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly local_invocation_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly global_invocation_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly workgroup_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly num_workgroups: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly subgroup_invocation_id: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly subgroup_size: { readonly kind: "scalar"; readonly scalar: "u32"; }; }

Description

Read it to check a declared field against what the pipeline will actually hand the shader, or to render the vocabulary in a tool. builtin resolves its own token from this table when the call omits one, so the table and the authoring surface cannot disagree.

clip_distances is absent on purpose: it is an array<f32, N> whose N the author picks, so it has no single type and its builtin call still names one.

Examples

Example

import { WGSL_BUILTIN_TYPES, typeKey } from 'typeshade'
typeKey(WGSL_BUILTIN_TYPES.global_invocation_id) // 'vec3<u32>'

See also

Source

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

Edit this page Report a problem