TS8051
프런트엔드 코드 LAYOUT
A buffer binding's store type breaks one of WGSL's host-shareable rules (§51), which a struct hides from the type map and the backend only meets as emitted text: a bool, alone or in a vector, in a uniform or storage binding, as a field, a runtime array's element or the whole type (type 'bool' cannot be used in address space 'uniform' as it is non-host-shareable, and the same of vec3<bool>), a runtime-sized array<T> that is not its struct's last member, or a runtime-sized array in a uniform, whose type must be constructible.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
A buffer binding's store type breaks one of WGSL's host-shareable rules (§51), which a struct hides from the type map and the backend only meets as emitted text: a bool, alone or in a vector, in a uniform or storage binding, as a field, a runtime array's element or the whole type (type 'bool' cannot be used in address space 'uniform' as it is non-host-shareable, and the same of vec3<bool>), a runtime-sized array<T> that is not its struct's last member, or a runtime-sized array in a uniform, whose type must be constructible. Also a two-row matrix (mat2x2, mat3x2, mat4x2) in a uniform, which WGSL and std140 lay out at different offsets (Rule 4.8, surface §40).
예제
"use typeshade"
class Uniforms { on: bool gain: f32}
declare const u: uniform<Uniforms>
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv * u.gain, 0., 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8051 error, 8행: "Uniforms.on" is a bool; a uniform struct holds numeric scalars only (WGSL's host-shareable rule). Use u32.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
class Uniforms { on: u32 gain: f32}
declare const u: uniform<Uniforms>
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv * u.gain, 0., 1.)}이 코드가 적용하는 규칙
- 규칙 4.8 테스트
- Every
matCxRwithCandRin 2, 3, 4 must be a type, and a square one must also answer tomatN. - 규칙 6.8 테스트
- The byte layout the emitted module assumes for a resource and the layout
reflect()reports must agree byte for byte, under WGSL’s uniform and storage layout rules, and so must the layout the manifest carries (Rule 11.10); a vertex entry’s vertex buffer is one layout, its@locationinputs tightly packed in the order written, whichreflect().vertexand the manifest both report.
함께 보기
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.