LayoutKind
Type in Reflection
The byte-layout rule a struct's fields are placed under.
import type { LayoutKind } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
type LayoutKind = 'std140' | 'std430';Description
'std140' is the rule WGSL
applies to the uniform address space, and the rule of a GLSL ES 3.00
layout(std140) uniform block: a struct or array base alignment rounds up to 16 bytes, so
a vec3 field costs 16 and an array of f32 uses 16 bytes per element. 'std430' is the
rule WGSL applies to the storage address space: natural alignment with no 16-byte
round-up. Vertex-attribute offsets use the same rule.
Pick the rule from the binding’s address space, on either backend: uniform is std140 and
storage is std430. GLSL ES 3.00 has no storage buffer, so a storage binding is emitted
as a data texture there, but reflect describes the module as authored and reports
its fields under std430 in Reflection.storage.
A two-row field — mat2x2, mat3x2, mat4x2 — under 'std140' throws: WGSL’s uniform
rule gives a two-row matrix a column stride of 8 bytes while GLSL std140 rounds every
column to 16, and this engine reports one number for both backends. The other six shapes
agree byte for byte (measured on Tint and ANGLE). Carry such a field as the matCx4
of the same column count, where both targets stride 16, or as C separate vec2 fields.
See also
Source
src/core/reflect.ts, line 71, at commit 26de7be8