TS8051
On this page

TS8051

Front-end code LAYOUT

A buffer binding's store type breaks one of WGSL's host-shareable rules (§51), which a struct hides from the type map and the backend only meets as emitted text: a bool, alone or in a vector, in a uniform or storage binding, as a field, a runtime array's element or the whole type (type 'bool' cannot be used in address space 'uniform' as it is non-host-shareable, and the same of vec3<bool>), a runtime-sized array<T> that is not its struct's last member, or a runtime-sized array in a uniform, whose type must be constructible.

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

When it fires

A buffer binding's store type breaks one of WGSL's host-shareable rules (§51), which a struct hides from the type map and the backend only meets as emitted text: a bool, alone or in a vector, in a uniform or storage binding, as a field, a runtime array's element or the whole type (type 'bool' cannot be used in address space 'uniform' as it is non-host-shareable, and the same of vec3<bool>), a runtime-sized array<T> that is not its struct's last member, or a runtime-sized array in a uniform, whose type must be constructible. Also a two-row matrix (mat2x2, mat3x2, mat4x2) in a uniform, which WGSL and std140 lay out at different offsets (Rule 4.8, surface §40).

Example

example.shade.ts
"use typeshade"
class Uniforms {
on: bool
gain: f32
}
declare const u: uniform<Uniforms>
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv * u.gain, 0., 1.)
}

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

TS8051 error, line 8: "Uniforms.on" is a bool; a uniform struct holds numeric scalars only (WGSL's host-shareable rule). Use u32.

How to fix it

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

example.shade.ts
"use typeshade"
class Uniforms {
on: u32
gain: f32
}
declare const u: uniform<Uniforms>
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv * u.gain, 0., 1.)
}

The rules this enforces

Rule 4.8 Test
Every matCxR with C and R in 2, 3, 4 must be a type, and a square one must also answer to matN.
Rule 6.8 Test
The byte layout the emitted module assumes for a resource and the layout reflect() reports must agree byte for byte, under WGSL’s uniform and storage layout rules, and so must the layout the manifest carries (Rule 11.10); a vertex entry’s vertex buffer is one layout, its @location inputs tightly packed in the order written, which reflect().vertex and the manifest both report.

See also

Source

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

Edit this page Report a problem