Rule 6.8
On this page

Rule 6.8

Chapter 6, Declarations and resources 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.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

a buffer the host fills from reflect() and the shader reads by its own offsets is a dynamic error nothing detects.

Derives from

Memory Layout (“it is a dynamic error if buffer producers and consumers do not agree on the memory layout”).

How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

examples/emit-reflection-conformance.test.ts for bindings, locations, and entry points, src/core/manifest.test.ts, which holds every example’s manifest to reflect()’s slots, struct offsets and vertex layout, and the one layout engine in src/core/reflect.ts that the GLSL writer also uses, whose layout checks are the two-row matrix of Rule 4.8 and the uniform-address-space rules of surface §51 (#156): an array in a uniform is padded to a 16-byte stride and reflect() agrees; a bool, alone or in a vector, in a uniform or storage binding (a struct field, a runtime array’s element or the binding’s whole type, "U.b" is a vec3b; a uniform binding holds no bool, alone or in a vector (WGSL's host-shareable rule). Use vec3u.), a runtime-sized array in a uniform, and one that is not a struct’s last field are TS8051 LAYOUT; a field @align is TS8010 (@align on a field is not applied.) and a field @size is TS8028; pinned by src/compiler/ts/uniform-layout.test.ts.

The files that verify it at commit 26de7be8, each at the first line that names the rule:

Explained in

The sections of the surface document that explain this rule, at commit 26de7be8:

Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

TS8010 STRUCT_FIELD
An invalid struct field or declaration shape.
TS8028 ATTRIBUTE_NAME
A decorator identifier outside the attribute vocabulary "use typeshade" defines (@vertex, @fragment, @compute, @builtin, @location), e.g. a misspelled @vertx: without this, the decorated function or field just silently stops being an entry point or an I/O field.
TS8051 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.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem