<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ComputeGraphComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit",
      "ComputeGraph"
    ],
    "preciseIdentifier" : "s:24_RealityKit_ComputeGraph0cD9ComponentV"
  },
  "title" : "ComputeGraphComponent"
}
-->

# ComputeGraphComponent

A component that drives a compute graph–based particle simulation on an entity.

```
struct ComputeGraphComponent
```

## Overview

Attach this component to any `Entity` to with a loaded `ComputeGraphResource`
and execute it each frame using Metal compute pipelines. The system
automatically creates and manages child entities for each graph output,
each carrying its own `ModelComponent` and material.

```swift
var component = ComputeGraphComponent(resource: resource)
entity.components.set(component)
```

## Topics

### Structures

[`struct UniformHandle`](/documentation/RealityKit/ComputeGraphComponent/UniformHandle)

### Initializers

[`init()`](/documentation/RealityKit/ComputeGraphComponent/init())

Creates a `ComputeGraphComponent` with no resource attached.

[`init(resource: ComputeGraphResource)`](/documentation/RealityKit/ComputeGraphComponent/init(resource:))

Creates a `ComputeGraphComponent` and immediately attaches the given resource.

### Instance Properties

[`var materials: [ComputeNodeGraph.NodeID : any Material]`](/documentation/RealityKit/ComputeGraphComponent/materials)

The material used to render each graph output, keyed by output node identifier.

[`var models: [ComputeNodeGraph.NodeID : ModelComponent]`](/documentation/RealityKit/ComputeGraphComponent/models)

The model component used to render each graph output, keyed by output node identifier.

[`var pipelines: ComputeNodeGraph.Pipelines?`](/documentation/RealityKit/ComputeGraphComponent/pipelines)

The compiled pipelines used to execute the simulation.

[`var randomSeed: UInt32?`](/documentation/RealityKit/ComputeGraphComponent/randomSeed)

An optional fixed random seed for the simulation.

[`var resource: ComputeGraphResource?`](/documentation/RealityKit/ComputeGraphComponent/resource)

The compute graph resource that defines the simulation.

[`var simulationRate: ComputeGraphSimulation.SimulationRate`](/documentation/RealityKit/ComputeGraphComponent/simulationRate)

The rate at which the simulation updates.

[`var state: ComputeGraphComponent.SimulationState`](/documentation/RealityKit/ComputeGraphComponent/state)

The current playback state of the simulation.

### Instance Methods

[`func fastForward()`](/documentation/RealityKit/ComputeGraphComponent/fastForward())

Fast-forwards the simulation using the default prewarm behavior.

[`func fastForward(stepCount: Int, stepDeltaTime: Float)`](/documentation/RealityKit/ComputeGraphComponent/fastForward(stepCount:stepDeltaTime:))

Advances the particle simulation by multiple steps in a single operation.

[`func findBufferIndex(port: ComputeNodeGraph.Port.Address) -> Int?`](/documentation/RealityKit/ComputeGraphComponent/findBufferIndex(port:))

[`func firstBufferIndex(type: String) -> Int?`](/documentation/RealityKit/ComputeGraphComponent/firstBufferIndex(type:))

[`func isOutputEnabled(ComputeNodeGraph.NodeID) -> Bool`](/documentation/RealityKit/ComputeGraphComponent/isOutputEnabled(_:))

Reads the enabled state of an output identified by ID

[`func pause()`](/documentation/RealityKit/ComputeGraphComponent/pause())

Pauses the simulation, freezing it at its current state.

[`func play()`](/documentation/RealityKit/ComputeGraphComponent/play())

Resumes the simulation from a paused or stepped state.

[`func replaceUniforms(Data)`](/documentation/RealityKit/ComputeGraphComponent/replaceUniforms(_:))

Replaces the entire uniform buffer with the given data.

[`func setBuffer((any MTLBuffer)?, bufferOffset: Int, elementCount: Int?, at: Int)`](/documentation/RealityKit/ComputeGraphComponent/setBuffer(_:bufferOffset:elementCount:at:))

Binds a Metal buffer to a parameter.

[`func setOutputEnabled(ComputeNodeGraph.NodeID, enabled: Bool)`](/documentation/RealityKit/ComputeGraphComponent/setOutputEnabled(_:enabled:))

Sets the enable state of an output identified by ID

[`func setTexture((any MTLTexture)?, at: Int)`](/documentation/RealityKit/ComputeGraphComponent/setTexture(_:at:))

Binds a Metal texture to a parameter at the given index.

[`func setTexture((any MTLTexture)?, port: ComputeNodeGraph.Port.Address) -> Bool`](/documentation/RealityKit/ComputeGraphComponent/setTexture(_:port:))

Binds a Metal texture to a parameter identified by its port address.

[`func setUniformData(RawSpan, for: ComputeGraphComponent.UniformHandle)`](/documentation/RealityKit/ComputeGraphComponent/setUniformData(_:for:))

Sets the value of a uniform to raw bytes.

[`func setUniformValue<V>(V, for: ComputeGraphComponent.UniformHandle)`](/documentation/RealityKit/ComputeGraphComponent/setUniformValue(_:for:))

Sets the value of a uniform to a `BitwiseCopyable` typed value.

[`func setUniformValue<V>(V, named: String) -> Bool`](/documentation/RealityKit/ComputeGraphComponent/setUniformValue(_:named:))

Sets the value of a named uniform to a `BitwiseCopyable` typed value.

[`func spawn(element: ElementSpawnParameters, in: ComputeNodeGraph.NodeID?)`](/documentation/RealityKit/ComputeGraphComponent/spawn(element:in:))

Spawns a new element in the particle simulation.

[`func spawn(elements: [ElementSpawnParameters], in: ComputeNodeGraph.NodeID?)`](/documentation/RealityKit/ComputeGraphComponent/spawn(elements:in:))

Spawns elements into the particle simulation.

[`func step()`](/documentation/RealityKit/ComputeGraphComponent/step())

Advances the simulation by a single frame, then pauses.

[`func uniformHandle(named: String) -> ComputeGraphComponent.UniformHandle?`](/documentation/RealityKit/ComputeGraphComponent/uniformHandle(named:))

Returns a handle for the named uniform.

### Enumerations

[`enum SimulationState`](/documentation/RealityKit/ComputeGraphComponent/SimulationState)

The playback state of a compute graph simulation.

## Relationships

### Conforms To

[`Component`](/documentation/RealityKit/Component)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)