setBuffers
TypeScriptsetBuffers(buffers: Array<(SDKHandle) | null>, bufferOffsets?: (Array<number>) | null): voidSwift declarationfinal func setBuffers(_ buffers: [(any MTLBuffer)?], bufferOffsets: [Int]? = nil)class · iOS 27.0+ · SDK 27.1
final class ComputeGraphSimulationA simulation of particles, which use a single pipeline. This class is independent of the output, which makes for simpler testing.
setBuffers(buffers: Array<(SDKHandle) | null>, bufferOffsets?: (Array<number>) | null): voidSwift declarationfinal func setBuffers(_ buffers: [(any MTLBuffer)?], bufferOffsets: [Int]? = nil)setTexture(texture: (SDKHandle) | null, index: number): voidSwift declarationfinal 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.
fastForwardStepCountStepDeltaTime(stepCount: number, stepDeltaTime: number): voidSwift declarationfinal 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.
fastForward(): voidSwift declarationfinal func fastForward()setTextures(textures: Array<(SDKHandle) | null>): voidSwift declarationfinal func setTextures(_ textures: [(any MTLTexture)?])get commandQueue(): SDKHandleSwift declarationfinal var commandQueue: any MTLCommandQueue { get }get graphUniforms(): SDKHandleSwift declarationfinal var graphUniforms: any MTLBuffer { get }Returns a read-only copy of the uniforms buffer. Use `modifyUniforms(_:)` to make modifications.
modifyUniforms(body: ((arg0: ArrayBuffer) => unknown)): unknownSwift declarationfinal func modifyUniforms<E, R>(_ body: (UnsafeMutableRawBufferPointer) throws(E) -> R) throws(E) -> R where E : Error, R : ~CopyableProvides read/write access to the entire uniforms buffer for CPU access. ComputeGraph will upload the changes to the GPU before the next simulation.
setUniformData(data: ArrayBuffer, location: ComputeNodeGraph_Assembly_Location): voidSwift declarationfinal func setUniformData(_ data: Data, at location: ComputeNodeGraph.Assembly.Location)get simulationRate(): ComputeGraphSimulation_SimulationRateSwift declarationfinal var simulationRate: ComputeGraphSimulation.SimulationRate { get set }Specifies the current simulation rate.
set simulationRate(value: ComputeGraphSimulation_SimulationRate)Swift declarationfinal var simulationRate: ComputeGraphSimulation.SimulationRate { get set }Specifies the current simulation rate.
addUserResource(resource: SDKHandle): voidSwift declarationfinal 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.
isOutputEnabled(outputID: number): booleanSwift declarationfinal func isOutputEnabled(_ outputID: Int) -> BoolReturns 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.
setOutputEnabled(outputID: number, enabled: boolean): voidSwift declarationfinal 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.
setUserResources(resources: Array<SDKHandle>): voidSwift declarationfinal 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.
reset(encoder: SDKHandle): voidSwift declarationfinal 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.
spawn(elements: Array<ElementSpawnParameters>, systemID: (number) | null, encoder: SDKHandle): voidSwift declarationfinal 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.
buffer(index: number): ([SDKHandle, number]) | nullSwift declarationfinal func buffer(at index: Int) -> (any MTLBuffer, bufferOffset: Int)?advance(params: ComputeGraphSimulation_AdvanceParams): voidSwift declarationfinal 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.
texture(index: number): (SDKHandle) | nullSwift declarationfinal func texture(at index: Int) -> (any MTLTexture)?static initPipelinesCommandQueue(pipelines: ComputeNodeGraph_Pipelines, commandQueue: SDKHandle): ComputeGraphSimulationSwift declarationconvenience 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 pipelines(): ComputeNodeGraph_PipelinesSwift declarationfinal var pipelines: ComputeNodeGraph.Pipelines { get set }set pipelines(value: ComputeNodeGraph_Pipelines)Swift declarationfinal var pipelines: ComputeNodeGraph.Pipelines { get set }static initPipelines(pipelines?: (ComputeNodeGraph_Pipelines) | null): ComputeGraphSimulationSwift declarationconvenience 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.
setBufferBufferOffsetElementCountAt(buffer: SDKHandle, bufferOffset: number, elementCount: number, location: ComputeNodeGraph_Assembly_Location): voidSwift declarationfinal func setBuffer(_ buffer: any MTLBuffer, bufferOffset: Int = 0, elementCount: Int, at location: ComputeNodeGraph.Assembly.Location)setBufferBufferOffsetAt(buffer: (SDKHandle) | null, bufferOffset: number, index: number): voidSwift declarationfinal func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, at index: Int)setBufferBufferOffsetAt35335(buffer: (SDKHandle) | null, bufferOffset: number, location: ComputeNodeGraph_Assembly_Location): voidSwift declarationfinal func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, at location: ComputeNodeGraph.Assembly.Location)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)