Rule 11.12
On this page

Rule 11.12

Chapter 11, Targets and the oracle Test

An integer division, remainder and shift, and a float’s conversion to an integer, must give WGSL’s answer on GLSL ES 3.00 for every input WGSL settles: the GLSL writer spells each through a helper that settles the inputs GLSL ES 3.00 leaves undefined, and uses the bare operator only where the operands cannot reach one.

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

Rationale

GLSL ES 3.00 gives a zero divisor, the least int over -1, a negative operand of %, a shift amount past the width and a float the integer cannot hold no result (its §5.9, §4.1.3 and §5.4.1), and a WebGL2 driver answers otherwise than WGSL on all but the shift (#382); the oracle follows WGSL (Rule 11.5), so without the helpers a program means one thing on WebGPU and on the CPU tier and another on WebGL2, a kernel function’s WebGL2 tier included.

Derives from

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/core/backends/glsl-int.ts, which the GLSL writer’s intBinop and floatToInt spellings call; pinned by src/core/backends/glsl-int-answers.test.ts on both halves; the compile gate for every example’s GLSL; and the WebGL2 arm of scripts/gpu-differential.ts, which holds these operations to the oracle over generated programs and requires the corpus to reach the inputs GLSL leaves undefined.

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:

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem