TS8051
프런트엔드 코드 LAYOUT
버퍼 바인딩의 저장 타입이 WGSL의 호스트 공유 규칙 하나를 어깁니다. uniform이나 storage 바인딩 안의 bool(단독이든 벡터든), 구조체의 마지막 멤버가 아닌 런타임 크기 array<T>, uniform 안의 런타임 크기 배열, uniform 안의 두 행 행렬(mat2x2, mat3x2, mat4x2)이 그렇습니다. 마지막은 WGSL과 std140이 서로 다른 오프셋에 배치합니다(규칙 4.8).
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
class Uniforms { on: bool gain: f32}
declare const u: uniform<Uniforms>
@fragmentexport function main(uv: location<0, 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(uv: location<0, 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 and numbered in that order where nolocation<n, T>states the number (Rule 6.6), whichreflect().vertexand the manifest both report.
함께 보기
소스
커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.