Rule 6.6
On this page

Rule 6.6

Chapter 6, Declarations and resources Test

An entry point’s inputs and outputs are explicit parameters and return values; every parameter and every field of an entry I/O struct must carry @builtin("...") or @location(n), and the builtin name must be one WGSL defines for that stage and direction.

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

Rationale

an implicit stage input hides a dependency, and WGSL refuses an entry I/O member with no attribute.

Derives from

  • Shader Interface;
  • Inter-stage Input and Output Interface, whose definition of a stage input reads “each datum is either a built-in input value, or a user-defined input”;
  • its subsection Input-output Locations, which carries the two requirements (“each user-defined input and output must have an explicitly specified IO location”; “each structure member in the entry point IO must be one of either a built-in value, or assigned a location”, each a shader-creation error);
  • builtin and location;
  • surface §3.

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:

  • TS8024 BUILTIN_NAME and TS8025 BUILTIN_STAGE for the builtin name and its stage;
  • TS8029 STRUCT_FIELD_MISSING_ATTR for a field of an entry I/O struct;
  • nothing at the front end for a bare parameter: @fragment export function fs(p: vec4): vec4 compiles and reaches the WGSL text as fn fs(p: vec4<f32>) with no attribute, which WGSL refuses;
  • the GLSL writer alone, which reports it as a TS8015 warning on a render module (entry 'fs' input 'p' has neither @location nor @builtin) and not at all on a compute-only module (Appendix B).

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:

TS8015 BACKEND
A backend that refused to emit a module the front end accepted. The message is the backend's own.
TS8024 BUILTIN_NAME
@builtin("...") names an id outside WGSL's builtin vocabulary (WgslBuiltinName in core/sot.ts).
TS8025 BUILTIN_STAGE
A @builtin(...) id used as the wrong stage's input or output, e.g. frag_depth on a vertex return, or front_facing on a vertex parameter.
TS8029 STRUCT_FIELD_MISSING_ATTR
A field of a struct used as an entry function's parameter or return type carries neither @builtin(...) nor @location(...): WGSL rejects an entry-IO struct member with no attribute, so this is caught at the front end instead of reaching the backend as invalid emitted WGSL.

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem