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);
builtinandlocation;- 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_NAMEandTS8025 BUILTIN_STAGEfor the builtin name and its stage;TS8029 STRUCT_FIELD_MISSING_ATTRfor a field of an entry I/O struct;- nothing at the front end for a bare parameter:
@fragment export function fs(p: vec4): vec4compiles and reaches the WGSL text asfn fs(p: vec4<f32>)with no attribute, which WGSL refuses; - the GLSL writer alone, which reports it as a
TS8015warning 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:
-
TS8015BACKEND - A backend that refused to emit a module the front end accepted. The message is the backend's own.
-
TS8024BUILTIN_NAME @builtin("...")names an id outside WGSL's builtin vocabulary (WgslBuiltinNameincore/sot.ts).-
TS8025BUILTIN_STAGE - A
@builtin(...)id used as the wrong stage's input or output, e.g.frag_depthon a vertex return, orfront_facingon a vertex parameter. -
TS8029STRUCT_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
- Rule 6.5 Test
- Rule 6.7 Test
- Design rules
- Error codes
Source
The rule at commit 26de7be8:
docs/language-design.md:433(the design document)reqs/rules/RULE-0606.md(its traceability item)