규칙 8.3
이 페이지에서

규칙 8.3

8장, 함수와 진입점 테스트

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. The derivatives, implicit-LOD sampling, and discard may be used in the fragment stage only. Barriers and workgroup memory may be used in the compute stage only. The atomic builtins may be used in the compute and fragment stages, and must not be used in the vertex stage.

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

근거

the stage rule is Tint’s, and the call graph is how a helper inherits it.

출처

검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

  • the reachability check in src/compiler/ts/stage-restrictions.ts (TS8099 names the builtin, the helper, and the entry) for the fragment-only builtins;
  • TS8033 for workgroup memory, and TS8034 for a barrier outside a compute entry (a barrier in a branch is Rule 8.5’s TS8052);
  • TS8099 for an atomic builtin in a @vertex entry or in a helper it reaches ("atomicAdd" is only valid in a fragment or compute shader; "vs" is a vertex entry. WGSL allows an atomic built-in in a fragment or compute stage only.), pinned by src/compiler/ts/atomics.test.ts (refuses atomicAdd in a vertex entry).

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

TS8033 MODULE_VAR
주소 공간이 허용하지 않는 곳에서 모듈 변수를 선언하거나 씁니다. 주소 공간 래퍼가 붙은 const, 초기값이 있는 workgroup 변수, 그 공간이 담을 수 없는 타입(텍스처, 런타임 크기 배열, 호출별 변수 안의 atomic), 상수가 아닌 초기값, 정점이나 프래그먼트 진입점이 닿는 workgroup 변수가 그렇습니다. 일반 최상위 let이 대신하게 된 perInvocation<T> 래퍼도 여기에 속합니다.
TS8034 BARRIER_PLACEMENT
배리어가 놓일 수 없는 곳의 workgroupBarrier()나 storageBarrier()입니다. 워크그룹이 없는 정점이나 프래그먼트 진입점 안이거나, 배리어는 문이므로 값으로 쓴 경우입니다. 호출들이 공유하지 않는 제어 흐름 아래의 배리어는 UNIFORMITY입니다.
TS8052 UNIFORMITY
배리어, workgroupUniformLoad, 그리고 컴파일러의 재작성이 닿지 못하는 도함수나 암묵적 LOD 샘플이 균일하지 않은 값에 대한 조건 아래에 있거나, 그런 조건 아래에서 실행한 return, break, continue 뒤에 있습니다(규칙 8.5). 메시지가 작성자가 쓴 그대로의 값과 그 문장을 알려 줍니다.
TS8099 UNSUPPORTED
자기 코드를 받을 만하지 않은 진단을 위한 포괄 코드입니다. 순차 범위 뒤인 TS8099에 따로 둡니다.

함께 보기

소스

커밋 af54ddad5의 규칙 원문:

이 페이지 편집 문제 보고