WgslGenerator
Defined in: packages/typegpu/src/tgsl/wgslGenerator.ts:221
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:228
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:1058
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:1070
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:1228
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:1212
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:1156
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:1097
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:234
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:1180
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:329
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:1160
Parameters
Section titled “Parameters”schema
Section titled “schema”readonly Snippet[]
Returns
Section titled “Returns”ResolvedSnippet