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 and numbered in that order where no location<n, T> states the number (Rule 6.6), 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 behind reflect() in src/core/reflect.ts (its code is in the directory src/core/reflect/) 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 af54ddad5, each at the first line that names the rule:

Explained in

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

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. A class with no fields is accepted; this code covers an invalid field declaration, an empty struct that is not a class, an @align on a field, which is not applied, and a user-defined value whose uses give it two locations (Rule 6.6).
TS8028 ATTRIBUTE_NAME
A decorator or an entry form that this surface does not read: an identifier outside the attribute vocabulary (@vertex, @fragment, @compute, @builtin, @location), such as a misspelled @vertx; a WGSL attribute that the surface writes another way or does not borrow, such as a written @diagnostic(…); a stage written as a call, such as vertex(f); an entry that is written in a form that Rule 8.1 refuses, such as export default; or a decorator on a declaration or in a place that takes none (Rule 6.7). Without this code the decorated function or field would silently stop being an entry point or an I/O field.
TS8051 LAYOUT
A buffer binding's store type that breaks one of WGSL's host-shareable rules: a bool, alone or in a vector, in a uniform or storage binding; a runtime-sized array<T> that is not the last member of its struct; a runtime-sized array in a uniform; or a two-row matrix (mat2x2, mat3x2, mat4x2) in a uniform, which WGSL and std140 lay out at different offsets (Rule 4.8).

See also

Source

The rule at commit af54ddad5:

Edit this page Report a problem