---
title: "TS8052 UNIFORMITY: an error code of the TypeShade compiler"
description: "TS8052 UNIFORMITY, an error code of the TypeShade compiler. A barrier, a workgroupUniformLoad…"
url: https://typeshade.dev/reference/errors/ts8052/
language: en
---

# `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](https://typeshade.dev/reference/rules/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

example.shade.ts

```ts
"use typeshade"

declare const tex: texture_2d<f32>
declare const smp: sampler

@fragment
export 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.

example.shade.ts

```ts
"use typeshade"

declare const tex: texture_2d<f32>
declare const smp: sampler

@fragment
export 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

**[Rule 8.3](https://typeshade.dev/reference/rules/8-3/) Test**

A builtin WGSL confines by stage may be used in an entry of a permitted stage, and in a helper that no entry of an excluded stage can reach.

**[Rule 8.5](https://typeshade.dev/reference/rules/8-5/) Test**

A collective operation (a derivative, an implicit-LOD texture sample, a barrier) must be in uniform control flow.

## See also

- [Control flow](https://typeshade.dev/guide/language/control-flow/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

Where the compiler raises this code at commit af54ddad5, one line per file:

- [`src/compiler/ts/source-file.ts:412`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L412)
