Skip to content

WgslGenerator

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

new WgslGenerator(): WgslGenerator

WgslGenerator

_block(__namedParameters, externalMap?): string

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

Block

ExternalMap

string


_expression(expression): Snippet

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

Expression

Snippet


_identifier(id): Snippet

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

string

Snippet


_return(statement): string

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

Return

string


_statement(statement): string

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

Statement

string


_typedExpression(expression, expectedType): Snippet

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

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

"let" | "const" | "var"

string

BaseData | typeof UnknownData

Origin

Snippet


functionDefinition(options): string

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

FunctionDefinitionOptions

string

ShaderGenerator.functionDefinition


initGenerator(ctx): void

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

GenerationCtx

void

ShaderGenerator.initGenerator


refVariable(id, dataType): string

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

string

StorableData

string


typeAnnotation(data): string

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

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

BaseData

readonly Snippet[]

ResolvedSnippet

ShaderGenerator.typeInstantiation