Rule 8.2
Chapter 8, Functions and entry points Test
A vertex entry must return the position, as a bare vec4 or as a struct with a builtin<"position"> field; a fragment entry returns one value at location 0, a struct of render targets, or nothing. The decorated field, @builtin("position"), stays accepted until the release after the migration release (change 0111, D5).
The rule text and the parts under it are the compiler's own English, as the design document writes them.
Rationale
nothing can invent a position, and WGSL says so.
Derives from
Restrictions on Functions (“a vertex shader must return the position built-in output value”); change 0111 in changes/ (D2); change 0135; 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:
src/compiler/ts/entry-io.test.ts; src/compiler/ts/attribute-types.test.ts for the position written as a type.
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:
See also
- Rule 8.1 Test
- Rule 8.3 Test
- Design rules
- Error codes
Source
The rule at commit af54ddad5:
docs/language-design.md:786(the design document)reqs/rules/RULE-0802.md(its traceability item)