---
title: "WGSL_BUILTIN_TYPES: constant in Layout, TypeShade API"
description: "WGSL_BUILTIN_TYPES, a constant in Layout. The type each @builtin(<name>) supplies, for every id WGSL gives one fixed type."
url: https://typeshade.dev/api/wgslbuiltintypes/
language: en
---

# `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/core/ir'`

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

## Syntax

```ts
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"; }; readonly subgroup_id: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly num_subgroups: { 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`](https://typeshade.dev/api/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

```ts
import { typeKey } from 'typeshade'
import { WGSL_BUILTIN_TYPES } from 'typeshade/core/ir'

typeKey(WGSL_BUILTIN_TYPES.global_invocation_id) // 'vec3<u32>'
```

## See also

- [`builtin`](https://typeshade.dev/api/builtin/)

## Source

[`src/core/sot.ts`, line 278](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/sot.ts#L278), at commit af54ddad5
