Skip to content

WgslGenerator

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

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:253

ShaderGenerator.languageKey

declareGlobalConst(options): ResolvedSnippet

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

ConstantDefinitionOptions

ResolvedSnippet

ShaderGenerator.declareGlobalConst


declareGlobalVar(options): ResolvedSnippet

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

VariableDefinitionOptions

ResolvedSnippet

ShaderGenerator.declareGlobalVar


emitBinaryOp(lhs, op, rhs): string

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

Snippet

BinaryOperator

Snippet

string

ShaderGenerator.emitBinaryOp


emitCall(name, templateParams, args): string

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

string

readonly Snippet[]

readonly Snippet[]

string

ShaderGenerator.emitCall


emitTypeAnnotation(data): string

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

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:1260

FunctionDefinitionOptions

string

ShaderGenerator.functionDefinition


initGenerator(ctx): void

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

ResolutionCtx

void

ShaderGenerator.initGenerator


numericLiteral(value, schema): ResolvedSnippet

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

number

BaseData

ResolvedSnippet

ShaderGenerator.numericLiteral


refVariable(id, dataType): string

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

string

StorableData

string


typeInstantiation(schema, args): ResolvedSnippet

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

BaseData

readonly Snippet[]

ResolvedSnippet

ShaderGenerator.typeInstantiation

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