Skip to content

WgslGenerator

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

new WgslGenerator(): WgslGenerator

WgslGenerator

_block(__namedParameters, externalMap?): string

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

Block

ExternalMap

string


_expression(expression): Snippet

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

Expression

Snippet


_identifier(id): Snippet

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

string

Snippet


_statement(statement): string

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

Statement

string


_typedExpression(expression, expectedType): Snippet

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

A wrapper for generateExpression that updates ctx.expectedType and tries to convert the result when it does not match the expected type.

Expression

BaseData | BaseData[]

Snippet


blockVariable(varType, id, dataType, origin): Snippet

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

"let" | "const" | "var"

string

BaseData | typeof UnknownData

Origin

Snippet


functionDefinition(body): string

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

Block

string

ShaderGenerator.functionDefinition


initGenerator(ctx): void

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

GenerationCtx

void

ShaderGenerator.initGenerator


refVariable(id, dataType): string

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

string

StorableData

string


typeAnnotation(data): string

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

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.typeAnnotation


typeInstantiation(schema, args): ResolvedSnippet

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

BaseData

readonly Snippet[]

ResolvedSnippet

ShaderGenerator.typeInstantiation