Class: Computation
Defined in: modules/engine/src/compute/computation.ts:81
v9 Model API A model
- automatically reuses pipelines (programs) when possible
- automatically rebuilds pipelines if necessary to accommodate changed settings shaders integration
- accepts modules and performs shader transpilation
Constructors
Constructor
new Computation(
device,props):Computation
Defined in: modules/engine/src/compute/computation.ts:167
Parameters
device
Device
props
Returns
Computation
Properties
_lastLogTime
_lastLogTime:
number=0
Defined in: modules/engine/src/compute/computation.ts:450
Throttle draw call logging
_logOpen
_logOpen:
boolean=false
Defined in: modules/engine/src/compute/computation.ts:451
_pipelineNeedsUpdate
_pipelineNeedsUpdate:
string|false='newly created'
Defined in: modules/engine/src/compute/computation.ts:159
_uniformStore
_uniformStore:
UniformStore
Defined in: modules/engine/src/compute/computation.ts:157
bindings
bindings:
Record<string,Binding> ={}
Defined in: modules/engine/src/compute/computation.ts:143
Bindings (textures, samplers, uniform buffers)
device
readonlydevice:Device
Defined in: modules/engine/src/compute/computation.ts:134
id
readonlyid:string
Defined in: modules/engine/src/compute/computation.ts:135
pipeline
pipeline:
ComputePipeline
Defined in: modules/engine/src/compute/computation.ts:146
The underlying GPU pipeline.
pipelineFactory
readonlypipelineFactory:PipelineFactory
Defined in: modules/engine/src/compute/computation.ts:137
shader
shader:
Shader
Defined in: modules/engine/src/compute/computation.ts:151
the underlying compiled compute shader
shaderFactory
readonlyshaderFactory:ShaderFactory
Defined in: modules/engine/src/compute/computation.ts:138
shaderInputs
shaderInputs:
ShaderInputs
Defined in: modules/engine/src/compute/computation.ts:154
ShaderInputs instance
source
source:
string
Defined in: modules/engine/src/compute/computation.ts:148
Assembled compute shader source
userData
userData:
object={}
Defined in: modules/engine/src/compute/computation.ts:140
Index Signature
[key: string]: unknown
defaultProps
staticdefaultProps:Required<ComputationProps>
Defined in: modules/engine/src/compute/computation.ts:112
Methods
_getBufferOrConstantValues()
_getBufferOrConstantValues(
attribute,dataType):string
Defined in: modules/engine/src/compute/computation.ts:485
Parameters
attribute
TypedArray | Buffer
dataType
any
Returns
string
_logDrawCallEnd()
_logDrawCallEnd():
void
Defined in: modules/engine/src/compute/computation.ts:466
Returns
void
_logDrawCallStart()
_logDrawCallStart():
void
Defined in: modules/engine/src/compute/computation.ts:453
Returns
void
_setPipelineNeedsUpdate()
_setPipelineNeedsUpdate(
reason):void
Defined in: modules/engine/src/compute/computation.ts:396
Parameters
reason
string
Returns
void
_updatePipeline()
_updatePipeline():
ComputePipeline
Defined in: modules/engine/src/compute/computation.ts:400
Returns
ComputePipeline
_updatePipelineAsync()
_updatePipelineAsync():
Promise<ComputePipeline>
Defined in: modules/engine/src/compute/computation.ts:410
Creates or replaces the pipeline through the backend's asynchronous compilation path.
Returns
Promise<ComputePipeline>
destroy()
destroy():
void
Defined in: modules/engine/src/compute/computation.ts:276
Returns
void
dispatch()
dispatch(
computePass,x,y?,z?):void
Defined in: modules/engine/src/compute/computation.ts:295
Parameters
computePass
ComputePass
x
number
y?
number
z?
number
Returns
void
dispatchIndirect()
dispatchIndirect(
computePass,indirectBuffer,indirectOffset?):void
Defined in: modules/engine/src/compute/computation.ts:306
Dispatches a GPU-written workgroup count from an indirect buffer.
Parameters
computePass
ComputePass
indirectBuffer
Buffer
indirectOffset?
number = 0
Returns
void
predraw()
predraw(
commandEncoder):void
Defined in: modules/engine/src/compute/computation.ts:290
Updates compute shader inputs before opening the compute pass that will consume them.
Parameters
commandEncoder
CommandEncoder
Returns
void
setBindings()
setBindings(
bindings):void
Defined in: modules/engine/src/compute/computation.ts:392
Sets bindings (textures, samplers, uniform buffers)
Parameters
bindings
Record<string, Binding>
Returns
void
setInstanceCount()
setInstanceCount(
instanceCount):void
Defined in: modules/engine/src/compute/computation.ts:344
Updates the instance count (used in draw calls)
Parameters
instanceCount
number
Returns
void
Note
Any attributes with stepMode=instance need to be at least this big
setShaderInputs()
setShaderInputs(
shaderInputs):void
Defined in: modules/engine/src/compute/computation.ts:348
Parameters
shaderInputs
Returns
void
setShaderModuleProps()
setShaderModuleProps(
props):void
Defined in: modules/engine/src/compute/computation.ts:363
Updates shader module settings (which results in uniforms being set)
Parameters
props
Record<string, any>
Returns
void
setVertexCount()
setVertexCount(
vertexCount):void
Defined in: modules/engine/src/compute/computation.ts:336
Updates the vertex count (used in draw calls)
Parameters
vertexCount
number
Returns
void
Note
Any attributes with stepMode=vertex need to be at least this big
updateShaderInputs()
updateShaderInputs(
commandEncoder?):void
Defined in: modules/engine/src/compute/computation.ts:385
Flushes current shader-input values into the internal uniform store.
Parameters
commandEncoder?
CommandEncoder
Optional encoder used to order uniform uploads with subsequent compute commands.
Returns
void
createAsync()
staticcreateAsync(device,props):Promise<Computation>
Defined in: modules/engine/src/compute/computation.ts:88
Creates a computation while allowing the backend to compile its pipeline asynchronously.
Use this factory when several independent computations can be prepared together. Calling the constructor remains the synchronous compatibility path.
Parameters
device
Device
props
Returns
Promise<Computation>