TS8052
Front-end code UNIFORMITY
A barrier, a workgroupUniformLoad, or a derivative or implicit-LOD sample that the compiler's rewrite cannot reach, reached under a condition on a non-uniform value, or after a return, break or continue taken under one (Rule 8.5). The message names the value as the author wrote it and the statement.
The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.
The registry text and every compiler message on these pages are the compiler's own English.
Example
"use typeshade"
declare const tex: texture_2d<f32>declare const smp: sampler
@fragmentexport function main(uv: location<0, vec2>): vec4 { let c = vec4(0.) let p = uv for (let i = 0; i < 4; i++) { if (p.x > 0.5) { break } p = p * 1.5 c += textureSample(tex, smp, p) } return c}Compiled at build time against the pinned compiler, this program gets:
TS8052 error, line 13: textureSample() is reached in a loop some invocations leave by a break taken under "uv" (a fragment input at @location(0)), which WGSL's derivative_uniformity rule refuses: the implicit level of detail is a difference between neighbouring invocations, and one that did not run has no value to difference against. The compiler could not compute the gradients before the loop: its operand changes on each iteration of a loop that not every invocation runs. Move the call above the loop and select from its result, or call textureSampleLevel or textureSampleGrad with the level or the gradients you want.
How to fix it
The same program, corrected. It compiles with no diagnostic.
"use typeshade"
declare const tex: texture_2d<f32>declare const smp: sampler
@fragmentexport function main(uv: location<0, vec2>): vec4 { let c = vec4(0.) let p = uv for (let i = 0; i < 4; i++) { if (p.x > 0.5) { break } p = p * 1.5 c += textureSampleLevel(tex, smp, p, 0.) } return c}The rules this enforces
See also
Source
Where the compiler raises this code at commit af54ddad5, one line per file: