---
title: "TS8052 UNIFORMITY: TypeShade 컴파일러가 진단에 붙이는 오류 코드와 그 뜻, 고치는 법"
description: "TS8052 UNIFORMITY, TypeShade 컴파일러의 오류 코드입니다. 배리어, workgroupUniformLoad, 그리고 컴파일러의 재작성이 닿지 못하는 도함수나 암묵적 LOD 샘플이 균일하지 않은 값에 대한 조건 아래에 있거나…"
url: https://typeshade.dev/ko/reference/errors/ts8052/
language: ko
---

# `TS8052`

프런트엔드 코드 `UNIFORMITY`

배리어, `workgroupUniformLoad`, 그리고 컴파일러의 재작성이 닿지 못하는 도함수나 암묵적 LOD 샘플이 균일하지 않은 값에 대한 조건 아래에 있거나, 그런 조건 아래에서 실행한 `return`, `break`, `continue` 뒤에 있습니다([규칙 8.5](https://typeshade.dev/ko/reference/rules/8-5/)). 메시지가 작성자가 쓴 그대로의 값과 그 문장을 알려 줍니다.

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 예제

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
}
```

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

**TS8052** error, 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.

## 고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

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
}
```

## 이 코드가 적용하는 규칙

**[규칙 8.3](https://typeshade.dev/ko/reference/rules/8-3/) 테스트**

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.

**[규칙 8.5](https://typeshade.dev/ko/reference/rules/8-5/) 테스트**

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

## 함께 보기

- [제어 흐름](https://typeshade.dev/ko/guide/language/control-flow/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

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