---
title: "WGSL entry points and attributes in TypeShade"
description: "Stage attributes, workgroup size, what a vertex entry has to return, the builtin ids the pipeline supplies, and the names WGSL does not have."
url: https://typeshade.dev/guide/language/from-wgsl/entries/
language: en
---

# Entry points and attributes

A stage is an attribute on a function declaration, `@vertex`, `@fragment` or `@compute([…])`. A function with no stage attribute is a helper. `@compute` takes dimensions as a list of numbers or named overrides, and numeric dimensions remain valid.

WGSL TypeShade Note

```wgsl
@vertex
```

```ts
@vertex
```

One stage attribute per entry point, on its function declaration.

```wgsl
@fragment
```

```ts
@fragment
```

A fragment entry may also return nothing, which is what a program that only writes to a storage binding does.

```wgsl
@compute @workgroup_size(64)
```

```ts
@compute([64, 1, 1])
```

The list is the workgroup size, one to three extents.

```wgsl
@location(0) uv: vec2<f32>
```

```ts
uv: location<0, vec2>
```

A location sits on an entry parameter, on a class field and on the return.

```wgsl
-> @builtin(position) vec4<f32>
```

```ts
: vec4
```

A return typed `vec4` carries the position builtin on its own, so the smallest vertex shader needs no struct and no parameters.

```wgsl
@builtin(position) pos: vec4<f32>
```

```ts
pos: builtin<"position">
```

A struct return carries the position in a field and adds as many varyings beside it as the program wants.

```wgsl
-> @location(0) vec4<f32>
```

```ts
: vec4
```

A bare fragment return takes location 0 at any width, so `f32`, `vec2`, `vec3` and `vec4` are all draw-buffer formats. A struct return is the multiple-render-target form.

A vertex entry has to produce a position. A return typed `vec4` carries the position builtin on its own, and a struct return carries it in a field and adds as many `location<n, T>` varyings as the program wants. A struct return with no position field, a `void` return and a bare type that is not a `vec4` are each refused, naming the field or the type to write.

WGSL declares the value with a module-level `override`, and `@workgroup_size` can use its name. TypeShade can use the same override for the outer length of a workgroup array.

The vocabulary of `builtin<N>` is WGSL's, 18 names passed through as a string, so the WGSL attribute is the same id with no quotes around it. A typo is an error at the line the author wrote, since the type argument is a closed union of them. WGSL fixes the type of every id but one, so the type column shows the type each value has; only `clip_distances` takes a written type.

TypeShade Type

```ts
builtin<"vertex_index", T>
```

```wgsl
u32
```

```ts
builtin<"instance_index", T>
```

```wgsl
u32
```

```ts
builtin<"position", T>
```

```wgsl
vec4<f32>
```

```ts
builtin<"front_facing", T>
```

```wgsl
bool
```

```ts
builtin<"frag_depth", T>
```

```wgsl
f32
```

```ts
builtin<"sample_index", T>
```

```wgsl
u32
```

```ts
builtin<"sample_mask", T>
```

```wgsl
u32
```

```ts
builtin<"primitive_index", T>
```

```wgsl
u32
```

```ts
builtin<"local_invocation_id", T>
```

```wgsl
vec3<u32>
```

```ts
builtin<"local_invocation_index", T>
```

```wgsl
u32
```

```ts
builtin<"global_invocation_id", T>
```

```wgsl
vec3<u32>
```

```ts
builtin<"workgroup_id", T>
```

```wgsl
vec3<u32>
```

```ts
builtin<"num_workgroups", T>
```

```wgsl
vec3<u32>
```

```ts
builtin<"subgroup_invocation_id", T>
```

```wgsl
u32
```

```ts
builtin<"subgroup_size", T>
```

```wgsl
u32
```

```ts
builtin<"subgroup_id", T>
```

```wgsl
u32
```

```ts
builtin<"num_subgroups", T>
```

```wgsl
u32
```

```ts
builtin<"clip_distances", T>
```

The one id with no fixed type. The array length is the author's.

Three names a GLSL author reaches for have no WGSL builtin behind them. The front end refuses each one at the declaration and lists the names it does take. The right column is the sentence the backends print after the attribute name, which says what to reach for instead.

WGSL What to write

```wgsl
@builtin(point_size)
```

does not exist in WGSL — WebGPU point-list primitives are always 1px. Expand an instanced quad in the vertex stage instead

```wgsl
@builtin(point_coord)
```

does not exist in WGSL — there is no point-sprite coordinate. Interpolate a `@location(n)` corner uv from the expanded quad instead

```wgsl
@builtin(frag_coord)
```

does not exist in WGSL — the fragment-stage framebuffer coordinate (GLSL gl\_FragCoord) is `@builtin(position)` on a fragment entry parameter.
