TS8032
프런트엔드 코드 UNSIZED_ARRAY_LENGTH
.length, or arrayLength(x), on an array<T> with no N that is not in storage: a uniform<array<T>>, a local, or a parameter.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
발생 조건
.length, or arrayLength(x), on an array<T> with no N that is not in storage: a uniform<array<T>>, a local, or a parameter. .length once folded to the literal 0, which made gid.x >= xs.length true for every invocation and the kernel a silent no-op in valid WGSL. A runtime-sized storage array now reads its length from the buffer as arrayLength(&x); the shapes that have no runtime length need an explicit size, which is what this says.
예제
"use typeshade"
declare const u: uniform<array<f32>>
function count(): f32 { return f32(u.length)}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, count(), 1.)}빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8051 error, 3행: "u" is a list of no fixed length, which a uniform cannot hold: a uniform buffer has one size. Give it a length, array<T, N>, or declare "u" as storage<T>.
TS8032 error, 6행: ".length" on an array with no size is not known at compile time. Give the type a size: array<f32, 3> rather than array<f32>.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
class UData { items: array<f32, 3>}
declare const u: uniform<UData>
function count(): f32 { return f32(u.items.length)}
@fragmentexport function main(@location(0) uv: vec2): vec4 { return vec4(uv, count(), 1.)}함께 보기
-
TS8051LAYOUT - 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 auniformorstoragebinding, 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 ofvec3<bool>), a runtime-sizedarray<T>that is not its struct's last member, or a runtime-sized array in a uniform, whose type must be constructible.
소스
커밋 c66579bf에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.