WgslGenerator
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:269
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.).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WgslGenerator():
WgslGenerator
Returns
Section titled “Returns”WgslGenerator
Properties
Section titled “Properties”languageKey
Section titled “languageKey”languageKey:
string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:276
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”call()
Section titled “call()”call(
_callee,args,calleeSnippet?):Snippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:547
Parameters
Section titled “Parameters”_callee
Section titled “_callee”AnyFn
readonly Snippet[]
calleeSnippet?
Section titled “calleeSnippet?”Snippet
The snippet the callee was produced from, used for more descriptive errors.
Returns
Section titled “Returns”Snippet
Implementation of
Section titled “Implementation of”declareGlobalConst()
Section titled “declareGlobalConst()”declareGlobalConst(
options):ResolvedSnippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1063
Parameters
Section titled “Parameters”options
Section titled “options”ConstantDefinitionOptions
Returns
Section titled “Returns”ResolvedSnippet
Implementation of
Section titled “Implementation of”ShaderGenerator.declareGlobalConst
declareGlobalVar()
Section titled “declareGlobalVar()”declareGlobalVar(
options):ResolvedSnippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1075
Parameters
Section titled “Parameters”options
Section titled “options”VariableDefinitionOptions
Returns
Section titled “Returns”ResolvedSnippet
Implementation of
Section titled “Implementation of”ShaderGenerator.declareGlobalVar
emitBinaryOp()
Section titled “emitBinaryOp()”emitBinaryOp(
lhs,op,rhs):string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1392
Parameters
Section titled “Parameters”Snippet
BinaryOperator
Snippet
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”emitCall()
Section titled “emitCall()”emitCall(
name,templateParams,args):string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1217
Parameters
Section titled “Parameters”string
templateParams
Section titled “templateParams”readonly Snippet[]
readonly Snippet[]
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”emitTypeAnnotation()
Section titled “emitTypeAnnotation()”emitTypeAnnotation(
data):string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1161
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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”ShaderGenerator.emitTypeAnnotation
functionDefinition()
Section titled “functionDefinition()”functionDefinition(
options):string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1102
Parameters
Section titled “Parameters”options
Section titled “options”FunctionDefinitionOptions
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”ShaderGenerator.functionDefinition
initGenerator()
Section titled “initGenerator()”initGenerator(
ctx):void
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:282
Parameters
Section titled “Parameters”ResolutionCtx
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”numericLiteral()
Section titled “numericLiteral()”numericLiteral(
value,schema):ResolvedSnippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1185
Parameters
Section titled “Parameters”number
schema
Section titled “schema”Returns
Section titled “Returns”ResolvedSnippet
Implementation of
Section titled “Implementation of”ShaderGenerator.numericLiteral
refVariable()
Section titled “refVariable()”refVariable(
id,dataType):string
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:377
Parameters
Section titled “Parameters”string
dataType
Section titled “dataType”Returns
Section titled “Returns”string
typeInstantiation()
Section titled “typeInstantiation()”typeInstantiation(
schema,args):ResolvedSnippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1165
Parameters
Section titled “Parameters”schema
Section titled “schema”readonly Snippet[]
Returns
Section titled “Returns”ResolvedSnippet
Implementation of
Section titled “Implementation of”© Software Mansion 2026. All trademarks and copyrights belong to their respective owners. Read about our Privacy Policy.