Skip to content

WgslGenerator

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:243

NOTE: This is an unstable API and may change in the future.

An interface meant to be used by other systems to generate snippets of shader code in the target language (WGSL, GLSL, etc.).

new WgslGenerator(): WgslGenerator

WgslGenerator

languageKey: string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:250

ShaderGenerator.languageKey

declareGlobalConst(options): ResolvedSnippet

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1140

ConstantDefinitionOptions

ResolvedSnippet

ShaderGenerator.declareGlobalConst


declareGlobalVar(options): ResolvedSnippet

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1152

VariableDefinitionOptions

ResolvedSnippet

ShaderGenerator.declareGlobalVar


emitBinaryOp(lhs, op, rhs): string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1310

Snippet

BinaryOperator

Snippet

string

ShaderGenerator.emitBinaryOp


emitCall(name, templateParams, args): string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1294

string

readonly Snippet[]

readonly Snippet[]

string

ShaderGenerator.emitCall


emitTypeAnnotation(data): string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1238

Generates a WGSL type string for the given data type, and adds necessary definitions to the shader preamble. This shouldn’t be called directly, only through ctx.resolve to properly cache the result.

BaseData

string

ShaderGenerator.emitTypeAnnotation


functionDefinition(options): string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1179

FunctionDefinitionOptions

string

ShaderGenerator.functionDefinition


initGenerator(ctx): void

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:256

ResolutionCtx

void

ShaderGenerator.initGenerator


numericLiteral(value, schema): ResolvedSnippet

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1262

number

BaseData

ResolvedSnippet

ShaderGenerator.numericLiteral


refVariable(id, dataType): string

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:351

string

StorableData

string


typeInstantiation(schema, args): ResolvedSnippet

Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1242

BaseData

readonly Snippet[]

ResolvedSnippet

ShaderGenerator.typeInstantiation

© Software Mansion 2026. All trademarks and copyrights belong to their respective owners. Read about our Privacy Policy.