TS8052
이 페이지에서

TS8052

프런트엔드 코드 UNIFORMITY

A call that needs uniform control flow — textureSample and the other implicit-LOD forms, the derivatives, a barrier, or workgroupUniformLoad — reached under a condition that is not uniform across the invocations that run together (an if, a switch, a loop's condition, the left side of && or ||, the condition of a ?: WGSL writes as an if), or after a return, break or continue taken under one (§54).

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

예제

example.shade.ts
"use typeshade"
declare const tex: texture_2d<f32>
declare const smp: sampler
@fragment
export function main(@location(0) uv: vec2): vec4 {
if (uv.x > 0.5) {
return textureSample(tex, smp, uv)
}
return vec4(0., 0., 0., 1.)
}

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

TS8052 error, 9행: textureSample() is reached 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. Hoist the call above the branch, or use textureSampleLevel or textureSampleGrad, whose level of detail is the one you wrote, or write @diagnostic("off", "derivative_uniformity") on the entry to take the module as written.

고치는 법

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

example.shade.ts
"use typeshade"
declare const tex: texture_2d<f32>
declare const smp: sampler
@fragment
export function main(@location(0) uv: vec2): vec4 {
const c = textureSample(tex, smp, uv)
if (uv.x > 0.5) {
return c
}
return vec4(0., 0., 0., 1.)
}

이 코드가 적용하는 규칙

규칙 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 테스트
A collective operation (a derivative, an implicit-LOD texture sample, a barrier) must be in uniform control flow.

함께 보기

소스

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

이 페이지 편집 문제 보고