# BufferID

> Unique identifier to a memory buffer in device.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.7/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<BufferID>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct BufferID : IEquatable<BufferID>
```

## Remarks

BufferID serves as an opaque handle to memory buffers allocated through [IDeviceContext.CreateBuffer](/engine/6000.7/script-reference/unityengine/lighttransport/idevicecontext/createbuffer.md). 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](/engine/6000.7/script-reference/unityengine/lighttransport/bufferslice1.md).

BufferIDs must be explicitly destroyed using [IDeviceContext.DestroyBuffer](/engine/6000.7/script-reference/unityengine/lighttransport/idevicecontext/destroybuffer.md) to prevent memory leaks.

## Examples

```csharp
// Create buffers for different data types
BufferID vertexBuffer = context.CreateBuffer(1000, 12); // 1000 Vector3s
BufferID resultBuffer = context.CreateBuffer(64, 108);  // 64 SphericalHarmonicsL2

// Create typed slices for safe operations
var vertices = new BufferSlice<Vector3>(vertexBuffer, 0);
var results = new BufferSlice<SphericalHarmonicsL2>(resultBuffer, 0);

// Use buffers with integrator operations
integrator.Prepare(context, world, vertices, 0.1f, 2);
var result = integrator.IntegrateDirectRadiance(
    context, 0, 64, 1024, false, results);

// Cleanup - important to prevent memory leaks
context.DestroyBuffer(vertexBuffer);
context.DestroyBuffer(resultBuffer);
```

## Fields

| Value                                                                                 | Description                             |
| ------------------------------------------------------------------------------------- | --------------------------------------- |
| [Value](/engine/6000.7/script-reference/unityengine/lighttransport/bufferid/value.md) | The underlying buffer identifier value. |

## Constructors

| Constructor                                                                                            | Description            |
| ------------------------------------------------------------------------------------------------------ | ---------------------- |
| [BufferID(System.UInt64)](/engine/6000.7/script-reference/unityengine/lighttransport/bufferid/ctor.md) | Create a new BufferID. |

## Methods

| Method                                                                                | Description                                 |
| ------------------------------------------------------------------------------------- | ------------------------------------------- |
| [Slice](/engine/6000.7/script-reference/unityengine/lighttransport/bufferid/slice.md) | Constructs a typed slice from the BufferID. |
