BufferID
Unique identifier to a memory buffer in device.
Read time 1 minuteLast updated 5 days ago
Definition
- Type: Struct
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEngine.CoreModule
- Implements: IEquatable<BufferID>
public struct BufferID : IEquatable<BufferID>
Remarks
BufferID serves as an opaque handle to memory buffers allocated through IDeviceContext.CreateBuffer. The buffer can reside in CPU memory, GPU memory, or unified memory, depending on the implementation.
The BufferID abstracts the underlying memory management details and provides a unified interface for:
- Cross-platform memory allocation.
- Memory lifetime management.
- Type-safe buffer operations through BufferSlice.
BufferIDs must be explicitly destroyed using IDeviceContext.DestroyBuffer to prevent memory leaks.
Examples
// Create buffers for different data typesBufferID vertexBuffer = context.CreateBuffer(1000, 12); // 1000 Vector3sBufferID resultBuffer = context.CreateBuffer(64, 108); // 64 SphericalHarmonicsL2// Create typed slices for safe operationsvar vertices = new BufferSlice<Vector3>(vertexBuffer, 0);var results = new BufferSlice<SphericalHarmonicsL2>(resultBuffer, 0);// Use buffers with integrator operationsintegrator.Prepare(context, world, vertices, 0.1f, 2);var result = integrator.IntegrateDirectRadiance( context, 0, 64, 1024, false, results);// Cleanup - important to prevent memory leakscontext.DestroyBuffer(vertexBuffer);context.DestroyBuffer(resultBuffer);
Fields
Value | Description |
|---|---|
| Value | The underlying buffer identifier value. |
Constructors
Constructor | Description |
|---|---|
| BufferID(System.UInt64) | Create a new BufferID. |
Methods
Method | Description |
|---|---|
| Slice | Constructs a typed slice from the BufferID. |