One Logo Pool Ball
ComputeGraph · IOS API REFERENCE

ComputeGraphSimulation

class · iOS 27.0+ · SDK 27.1

final class ComputeGraphSimulation

A simulation of particles, which use a single pipeline. This class is independent of the output, which makes for simpler testing.

Members (27)

method · iOS 27.0+

setBuffers

TypeScript
setBuffers(buffers: Array<(SDKHandle) | null>, bufferOffsets?: (Array<number>) | null): void
Swift declaration
final func setBuffers(_ buffers: [(any MTLBuffer)?], bufferOffsets: [Int]? = nil)
method · iOS 27.0+

setTexture

TypeScript
setTexture(texture: (SDKHandle) | null, index: number): void
Swift declaration
final func setTexture(_ texture: (any MTLTexture)?, at index: Int)

Binds a Metal texture to the texture slot at the given index. - Parameters: - texture: The `MTLTexture` to bind, or `nil` to clear. - index: The zero-based slot index.

method · iOS 27.0+

fastForward

TypeScript
fastForwardStepCountStepDeltaTime(stepCount: number, stepDeltaTime: number): void
Swift declaration
final func fastForward(stepCount: Int, stepDeltaTime: Float)

Advances the particle simulation by multiple steps in a single operation. This method performs batch simulation updates by executing multiple simulation steps consecutively within a single compute command buffer, skipping any non-simulation work such as updating the output buffers. This is useful for: - Parameters: - stepCount: The number of simulation steps to execute. Each step represents one iteration of the simulation update cycle. Must be positive. - stepDeltaTime: The time interval (in seconds) to use for each simulation step. This controls how much simulated time passes with each step. Smaller values provide more accurate simulation at the cost of requiring more steps to advance the same amount of time. - Note: The simulation will be advanced by a total time of `stepCount * stepDeltaTime` seconds.

method · iOS 27.0+

fastForward

TypeScript
fastForward(): void
Swift declaration
final func fastForward()
method · iOS 27.0+

setTextures

TypeScript
setTextures(textures: Array<(SDKHandle) | null>): void
Swift declaration
final func setTextures(_ textures: [(any MTLTexture)?])
get · iOS 27.0+

commandQueue

TypeScript
get commandQueue(): SDKHandle
Swift declaration
final var commandQueue: any MTLCommandQueue { get }
get · iOS 27.0+

graphUniforms

TypeScript
get graphUniforms(): SDKHandle
Swift declaration
final var graphUniforms: any MTLBuffer { get }

Returns a read-only copy of the uniforms buffer. Use `modifyUniforms(_:)` to make modifications.

method · iOS 27.0+

modifyUniforms

TypeScript
modifyUniforms(body: ((arg0: ArrayBuffer) => unknown)): unknown
Swift declaration
final func modifyUniforms<E, R>(_ body: (UnsafeMutableRawBufferPointer) throws(E) -> R) throws(E) -> R where E : Error, R : ~Copyable

Provides read/write access to the entire uniforms buffer for CPU access. ComputeGraph will upload the changes to the GPU before the next simulation.

method · iOS 27.0+

setUniformData

TypeScript
setUniformData(data: ArrayBuffer, location: ComputeNodeGraph_Assembly_Location): void
Swift declaration
final func setUniformData(_ data: Data, at location: ComputeNodeGraph.Assembly.Location)
get · iOS 27.0+

simulationRate

TypeScript
get simulationRate(): ComputeGraphSimulation_SimulationRate
Swift declaration
final var simulationRate: ComputeGraphSimulation.SimulationRate { get set }

Specifies the current simulation rate.

set · iOS 27.0+

simulationRate

TypeScript
set simulationRate(value: ComputeGraphSimulation_SimulationRate)
Swift declaration
final var simulationRate: ComputeGraphSimulation.SimulationRate { get set }

Specifies the current simulation rate.

method · iOS 27.0+

addUserResource

TypeScript
addUserResource(resource: SDKHandle): void
Swift declaration
final func addUserResource(_ resource: any MTLResource)

Registers a resource for residency on all command encoders used by this simulation. Only needed when buffers or textures are passed indirectly through structures using Metal Tier 2 Argument Buffers, since Metal cannot discover those resources automatically.

method · iOS 27.0+

isOutputEnabled

TypeScript
isOutputEnabled(outputID: number): boolean
Swift declaration
final func isOutputEnabled(_ outputID: Int) -> Bool

Returns whether the specified output is currently enabled for simulation. - Parameter outputID: The node identifier of the output to query. - Returns: `true` if the output is simulated; `false` if it is disabled.

method · iOS 27.0+

setOutputEnabled

TypeScript
setOutputEnabled(outputID: number, enabled: boolean): void
Swift declaration
final func setOutputEnabled(_ outputID: Int, enabled: Bool)

Enables or disables execution of the provided output stage, without disabling the system it represents. Disabling an output is useful when you want to switch between multiple outputs for the simulation, for example two outputs with different topologies for the same elements. - Parameters: - outputID: The node identifier of the output to enable or disable. - enabled: `true` to simulate the output; `false` to omit it.

method · iOS 27.0+

setUserResources

TypeScript
setUserResources(resources: Array<SDKHandle>): void
Swift declaration
final func setUserResources(_ resources: [any MTLResource])

Sets additional resources for residency on all command buffers used by this simulation, replacing any previously added resources. Only needed when buffers or textures are passed indirectly through structures using Metal Tier 2 Argument Buffers, since Metal cannot discover those resources automatically.

method · iOS 27.0+

reset

TypeScript
reset(encoder: SDKHandle): void
Swift declaration
final func reset(encoder: any MTLComputeCommandEncoder)

Resets the simulation to its initial state, clearing all live elements and accumulated time. The reset is encoded as a compute dispatch into `encoder`. You must commit the enclosing command buffer for the reset to take effect on the GPU. - Parameter encoder: The compute command encoder to encode the reset operation with.

method · iOS 27.0+

spawn

TypeScript
spawn(elements: Array<ElementSpawnParameters>, systemID: (number) | null, encoder: SDKHandle): void
Swift declaration
final func spawn(elements: borrowing [ElementSpawnParameters], in systemID: Int?, using encoder: any MTLComputeCommandEncoder)

Spawns new elements into the simulation with the given initial parameters. Each entry in `elements` produces one new element. The initialization stage of the simulation graph runs on the newly spawned elements before they participate in subsequent simulation steps, and may read or overwrite the values supplied here. - Parameters: - elements: The initial state for each element to spawn. - systemID: The index of the particle simulation stage to spawn into, or `nil` to spawn into all simulations. - encoder: The compute command encoder to encode the spawn operation with.

method · iOS 27.0+

buffer

TypeScript
buffer(index: number): ([SDKHandle, number]) | null
Swift declaration
final func buffer(at index: Int) -> (any MTLBuffer, bufferOffset: Int)?
method · iOS 27.0+

advance

TypeScript
advance(params: ComputeGraphSimulation_AdvanceParams): void
Swift declaration
final func advance(_ params: ComputeGraphSimulation.AdvanceParams)

Advances the simulation by one time step, encoding all simulation stage dispatches into the command buffer and encoder provided by `params`. Call this once per frame from your render loop. The simulation reads ``AdvanceParams/deltaTime`` to determine how much simulated time to consume, subject to ``simulationRate``. Spatial transforms and optional viewer information in `params` are forwarded to the simulation graph. - Parameter params: The advance parameters, including the time delta, command buffer, compute encoder, and spatial transforms for this frame.

method · iOS 27.0+

texture

TypeScript
texture(index: number): (SDKHandle) | null
Swift declaration
final func texture(at index: Int) -> (any MTLTexture)?
init · iOS 27.0+

init

TypeScript
static initPipelinesCommandQueue(pipelines: ComputeNodeGraph_Pipelines, commandQueue: SDKHandle): ComputeGraphSimulation
Swift declaration
convenience init(pipelines: ComputeNodeGraph.Pipelines, commandQueue: any MTLCommandQueue)

Initialize a ComputeGraphSimulation for the given pipelines The simulation will use the provided command queue for operations such as ``fastForward()`` and resetting the system.

get · iOS 27.0+

pipelines

TypeScript
get pipelines(): ComputeNodeGraph_Pipelines
Swift declaration
final var pipelines: ComputeNodeGraph.Pipelines { get set }
set · iOS 27.0+

pipelines

TypeScript
set pipelines(value: ComputeNodeGraph_Pipelines)
Swift declaration
final var pipelines: ComputeNodeGraph.Pipelines { get set }
init · iOS 27.0+

init

TypeScript
static initPipelines(pipelines?: (ComputeNodeGraph_Pipelines) | null): ComputeGraphSimulation
Swift declaration
convenience init(pipelines: ComputeNodeGraph.Pipelines?)

Initialize a ComputeGraphSimulation for the given pipelines, or a default pipeline if not specified. The simulation will use the ComputeGraphFramework's default queue for operations such as ``fastForward()`` and resetting after setting the pipeline. Prefer ``init(pipeline:commandQueue:)`` to this method.

method · iOS 27.0+

setBuffer

TypeScript
setBufferBufferOffsetElementCountAt(buffer: SDKHandle, bufferOffset: number, elementCount: number, location: ComputeNodeGraph_Assembly_Location): void
Swift declaration
final func setBuffer(_ buffer: any MTLBuffer, bufferOffset: Int = 0, elementCount: Int, at location: ComputeNodeGraph.Assembly.Location)
method · iOS 27.0+

setBuffer

TypeScript
setBufferBufferOffsetAt(buffer: (SDKHandle) | null, bufferOffset: number, index: number): void
Swift declaration
final func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, at index: Int)
method · iOS 27.0+

setBuffer

TypeScript
setBufferBufferOffsetAt35335(buffer: (SDKHandle) | null, bufferOffset: number, location: ComputeNodeGraph_Assembly_Location): void
Swift declaration
final func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, at location: ComputeNodeGraph.Assembly.Location)

Skipped declarations

3 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ComputeGraphSimulation.resetRandomSeeds(using:)

callback cannot propagate synchronous failure

ComputeGraphSimulation.setUniform(_:named:)

This declaration needs Swift generic type arguments. (no canonical witness for V)

ComputeGraphSimulation.setUniformValue(_:at:)

This declaration needs Swift generic type arguments. (no canonical witness for V)

All ComputeGraph types →