TS8033
프런트엔드 코드 MODULE_VAR
A module variable (let x: workgroup<T>, let y: T = init, §24) declared or used where its address space forbids: a const with an address-space wrapper, a workgroup variable with an initializer, a type the space cannot hold (a texture, a runtime-sized array, an atomic in a per-invocation variable), an initializer that is not a constant, or a workgroup variable reached from a vertex or fragment entry (roadmap 0.2 item 5).
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
A module variable (let x: workgroup<T>, let y: T = init, §24) declared or used where its address space forbids: a const with an address-space wrapper, a workgroup variable with an initializer, a type the space cannot hold (a texture, a runtime-sized array, an atomic in a per-invocation variable), an initializer that is not a constant, or a workgroup variable reached from a vertex or fragment entry (roadmap 0.2 item 5). Also the retired perInvocation<T> wrapper, which a plain top-level let replaced and whose refusal names that let.
예제
"use typeshade"
let tile: workgroup<array<f32, 64>>
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, tile[0], 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8033 error, 7행: "tile" is workgroup memory, which only a compute entry has; a fragment entry cannot read or write it.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
let tile: array<f32, 64>
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, tile[0], 1.)}이 코드가 적용하는 규칙
- 규칙 6.1 테스트
- A resource must be written
declare const x: uniform<T>,declare const x: storage<T>,declare const x: storage<T, "read_write">, ordeclare const x: <texture or sampler type>. - 규칙 6.5 테스트
- A top-level
letis a module variable in the per-invocation (private) address space; workgroup memory must be writtenlet x: workgroup<T>; a module variable must take nodeclare. - 규칙 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.
함께 보기
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.