ModuleVarDecl
On this page

ModuleVarDecl

Interface in IR

One entry of ModuleDecl.vars: a module-scope variable that is not a resource.

import type { ModuleVarDecl } from 'typeshade'

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

Syntax

interface ModuleVarDecl {
readonly name: string;
readonly space: 'workgroup' | 'private';
readonly type: ShaderType;
readonly init?: Expr;
}

Description

workgroup is WGSL’s var<workgroup>, memory one workgroup’s invocations share, zero at the start of each workgroup and never initialised. private is WGSL’s var<private>, a value each invocation owns for its lifetime, init or zero at its start. Neither has a group, a binding or a byte layout, so reflect reports nothing for one; a host never binds it.

Instance properties

nameread only string
spaceread only 'workgroup' | 'private'
typeread only ShaderType
initoptionalread only Expr

The initial value, a constant expression over literals and module consts. Only a private variable carries one; WGSL forbids an initializer on workgroup memory.

See also

Source

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

Edit this page Report a problem