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.).
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:250
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”declareGlobalConst()
Section titled “declareGlobalConst()”declareGlobalConst(
options):ResolvedSnippet
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:1140
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:1152
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:1310
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:1294
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: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.
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:1179
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:256
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:1262
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:351
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:1242
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.