typeLayout
On this page

typeLayout()

Function in Reflection

Size + alignment (bytes) of a host-shareable type under a layout.

import { typeLayout } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

function typeLayout(
t: ShaderType,
layout: LayoutKind,
structs: ReadonlyMap<string, StructDecl>,
): { size: number; align: number }

Parameters

t ShaderType
layout LayoutKind
structs ReadonlyMap<string, StructDecl>

Return value

{ size: number; align: number }

Description

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.

Source

src/core/reflect.ts, line 86, at commit 26de7be8

Edit this page Report a problem