typeLayout()
함수, 리플렉션 분류
Size + alignment (bytes) of a host-shareable type under a layout.
import { typeLayout } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function typeLayout( t: ShaderType, layout: LayoutKind, structs: ReadonlyMap<string, StructDecl>,): { size: number; align: number }매개변수
tShaderTypelayoutLayoutKindstructsReadonlyMap<string, StructDecl>
반환값
{ size: number; align: number }
설명
Throws on a non-host-shareable type (texture/sampler/void are bind resources, not struct fields).
Exported for passes/uniform-layout.ts (§51), which computes the layout of a struct as
emitted — after it has inserted the wrapper structs a uniform array’s 16-byte element
stride needs — and so owns its own struct and array recursion. Its leaves are these: the
scalar, vector and matrix numbers are the same rule read from the same place, and a second
copy of the matrix arm is exactly what’s measurement would have drifted against.
'std430' is WGSL’s own layout; the uniform address space’s extra element rule is what
that pass adds on top.
소스
src/core/reflect.ts, 86행, 커밋 c66579bf 기준