TS8033
On this page

TS8033

Front-end code MODULE_VAR

A module variable (let x: workgroup<T>, let y: T = init, §24) declared or used where its address space forbids: a const with an address-space wrapper, a workgroup variable with an initializer, a type the space cannot hold (a texture, a runtime-sized array, an atomic in a per-invocation variable), an initializer that is not a constant, or a workgroup variable reached from a vertex or fragment entry (roadmap 0.2 item 5).

The registry text and every compiler message on these pages are the compiler's own English.

When it fires

A module variable (let x: workgroup<T>, let y: T = init, §24) declared or used where its address space forbids: a const with an address-space wrapper, a workgroup variable with an initializer, a type the space cannot hold (a texture, a runtime-sized array, an atomic in a per-invocation variable), an initializer that is not a constant, or a workgroup variable reached from a vertex or fragment entry (roadmap 0.2 item 5). Also the retired perInvocation<T> wrapper, which a plain top-level let replaced and whose refusal names that let.

Example

example.shade.ts
"use typeshade"
let tile: workgroup<array<f32, 64>>
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv, tile[0], 1.)
}

Compiled at build time against the pinned compiler, this program gets:

TS8033 error, line 7: "tile" is workgroup memory, which only a compute entry has; a fragment entry cannot read or write it.

How to fix it

The same program, corrected. It compiles with no diagnostic.

example.shade.ts
"use typeshade"
let tile: array<f32, 64>
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv, tile[0], 1.)
}

The rules this enforces

Rule 6.1 Test
A resource must be written declare const x: uniform<T>, declare const x: storage<T>, declare const x: storage<T, "read_write">, or declare const x: <texture or sampler type>.
Rule 6.5 Test
A top-level let is a module variable in the per-invocation (private) address space; workgroup memory must be written let x: workgroup<T>; a module variable must take no declare.
Rule 8.3 Test
A builtin WGSL confines by stage may be used in an entry of a permitted stage, and in a helper that no entry of an excluded stage can reach.

See also

Source

Where the compiler raises this code at commit 26de7be8, one line per file:

Edit this page Report a problem