BindingDecl
On this page

BindingDecl

Interface in IR

A ModuleDecl.bindings entry: a resource bound at a slot.

import type { BindingDecl } from 'typeshade'

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

Syntax

interface BindingDecl {
readonly group: number;
readonly binding: number;
readonly name: string;
readonly space: AddressSpace;
readonly access?: 'read' | 'read_write';
readonly type: ShaderType;
readonly owner?: 'module' | 'host';
readonly precision?: 'highp' | 'mediump' | 'lowp';
readonly glsl?: 'std140-block' | 'loose';
}

Description

A ModuleDecl.bindings entry: a resource bound at a (group, binding) slot. It is a uniform buffer, a storage buffer, a texture, or a sampler, keyed by type (a struct, scalar or array type means a buffer; a texture or sampler ShaderType.kind means a handle resource with no address space). WGSL emits both group and binding. GLSL ES 3.00 has a single binding namespace, so its backend reads binding only; group is still used by reflect, which groups resources per WGSL bind group. Use uniformStruct, resource or storageBuffer to derive one instead of constructing it directly.

Instance properties

groupread only number
bindingread only number
nameread only string
spaceread only AddressSpace
accessoptionalread only 'read' | 'read_write'

Storage access, read or read_write. Ignored for uniform.

typeread only ShaderType
owneroptionalread only 'module' | 'host'

Who owns this resource. 'module' (the default) means the module declares it and describes its layout, and a host builds its bind group from reflect. 'host' means the resource belongs to the surrounding host, such as a bind group a host-integrated WebGPU renderer hands the module, so the host’s layout is the authority and reflect reports it under hostResources. Ownership does not change the spelling: a host-owned binding is still declared in the emitted source, which is what makes it type-checkable; it is just not the module’s to allocate. For a symbol the host’s prelude already declares, use externVar, which emits nothing.

precisionoptionalread only 'highp' | 'mediump' | 'lowp'

GLSL ES 3.00 precision qualifier for this declaration. GLSL only; WGSL has no such concept and ignores it. Without it the declaration takes the stage default from the precision preamble, which is right for a module that owns its own header and wrong for a fragment composed into a host program whose preamble the module does not control.

glsloptionalread only 'std140-block' | 'loose'

How a struct-typed uniform binding is spelled on GLSL ES 3.00. Ignored on WGSL, which has exactly one spelling, and ignored for non-struct types.

'std140-block' (the default, and the only choice for a module-owned block) emits layout(std140) uniform Name { … } var;. 'loose' emits one default-block uniform <type> <field>; per member and rewrites every var.field read to the bare field, which is the form a GLSL host prelude provides. Only a host-owned block may choose 'loose': for a module-owned block the two spellings are not interchangeable (std140 is the only one with a defined layout for a host to write into), so the choice would be a silent ABI change.

See also

Source

src/core/ir/nodes.ts, line 517, at commit 26de7be8

Edit this page Report a problem