# CopyCount

> Copy the counter value of a GraphicsBuffer into another buffer.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## CopyCount(ComputeBuffer, ComputeBuffer, int)

Copy the counter value of a GraphicsBuffer into another buffer.

```csharp
public static void CopyCount(ComputeBuffer src, ComputeBuffer dst, int dstOffsetBytes)
```

### Parameters

**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): The source GraphicsBuffer.**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): The destination GraphicsBuffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The destination buffer offset in bytes.

### Remarks

Append/consume buffers (see [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) and counter buffers [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md)) keep track of the number of elements in them with a special counter variable. CopyCount takes such a buffer as `src`, and copies its counter value into `dst` buffer at given byte offset.

This is most commonly used in conjunction with [Graphics.RenderPrimitivesIndirect](/engine/6000.5/script-reference/unityengine/graphics/renderprimitivesindirect.md), to render an arbitrary number of primitives without reading their count back to the CPU.

The `src` buffer must have been created with a usage target of [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) or [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md).

On DirectX 11 and 12, the `dst` buffer must have been created with a usage target of [GraphicsBuffer.Target.Raw](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/raw.md) or [GraphicsBuffer.Target.IndirectArguments](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/indirectarguments.md). For other graphics APIs, there is no such restriction.

Additional Resources: [GraphicsBuffer.SetCounterValue](/engine/6000.5/script-reference/unityengine/graphicsbuffer/setcountervalue.md).

## CopyCount(GraphicsBuffer, ComputeBuffer, int)

Copy the counter value of a GraphicsBuffer into another buffer.

```csharp
public static void CopyCount(GraphicsBuffer src, ComputeBuffer dst, int dstOffsetBytes)
```

### Parameters

**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): The source GraphicsBuffer.**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): The destination GraphicsBuffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The destination buffer offset in bytes.

### Remarks

Append/consume buffers (see [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) and counter buffers [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md)) keep track of the number of elements in them with a special counter variable. CopyCount takes such a buffer as `src`, and copies its counter value into `dst` buffer at given byte offset.

This is most commonly used in conjunction with [Graphics.RenderPrimitivesIndirect](/engine/6000.5/script-reference/unityengine/graphics/renderprimitivesindirect.md), to render an arbitrary number of primitives without reading their count back to the CPU.

The `src` buffer must have been created with a usage target of [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) or [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md).

On DirectX 11 and 12, the `dst` buffer must have been created with a usage target of [GraphicsBuffer.Target.Raw](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/raw.md) or [GraphicsBuffer.Target.IndirectArguments](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/indirectarguments.md). For other graphics APIs, there is no such restriction.

Additional Resources: [GraphicsBuffer.SetCounterValue](/engine/6000.5/script-reference/unityengine/graphicsbuffer/setcountervalue.md).

## CopyCount(ComputeBuffer, GraphicsBuffer, int)

Copy the counter value of a GraphicsBuffer into another buffer.

```csharp
public static void CopyCount(ComputeBuffer src, GraphicsBuffer dst, int dstOffsetBytes)
```

### Parameters

**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): The source GraphicsBuffer.**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): The destination GraphicsBuffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The destination buffer offset in bytes.

### Remarks

Append/consume buffers (see [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) and counter buffers [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md)) keep track of the number of elements in them with a special counter variable. CopyCount takes such a buffer as `src`, and copies its counter value into `dst` buffer at given byte offset.

This is most commonly used in conjunction with [Graphics.RenderPrimitivesIndirect](/engine/6000.5/script-reference/unityengine/graphics/renderprimitivesindirect.md), to render an arbitrary number of primitives without reading their count back to the CPU.

The `src` buffer must have been created with a usage target of [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) or [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md).

On DirectX 11 and 12, the `dst` buffer must have been created with a usage target of [GraphicsBuffer.Target.Raw](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/raw.md) or [GraphicsBuffer.Target.IndirectArguments](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/indirectarguments.md). For other graphics APIs, there is no such restriction.

Additional Resources: [GraphicsBuffer.SetCounterValue](/engine/6000.5/script-reference/unityengine/graphicsbuffer/setcountervalue.md).

## CopyCount(GraphicsBuffer, GraphicsBuffer, int)

Copy the counter value of a GraphicsBuffer into another buffer.

```csharp
public static void CopyCount(GraphicsBuffer src, GraphicsBuffer dst, int dstOffsetBytes)
```

### Parameters

**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): The source GraphicsBuffer.**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): The destination GraphicsBuffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The destination buffer offset in bytes.

### Remarks

Append/consume buffers (see [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) and counter buffers [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md)) keep track of the number of elements in them with a special counter variable. CopyCount takes such a buffer as `src`, and copies its counter value into `dst` buffer at given byte offset.

This is most commonly used in conjunction with [Graphics.RenderPrimitivesIndirect](/engine/6000.5/script-reference/unityengine/graphics/renderprimitivesindirect.md), to render an arbitrary number of primitives without reading their count back to the CPU.

The `src` buffer must have been created with a usage target of [GraphicsBuffer.Target.Append](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/append.md) or [GraphicsBuffer.Target.Counter](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/counter.md).

On DirectX 11 and 12, the `dst` buffer must have been created with a usage target of [GraphicsBuffer.Target.Raw](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/raw.md) or [GraphicsBuffer.Target.IndirectArguments](/engine/6000.5/script-reference/unityengine/graphicsbuffer/target/indirectarguments.md). For other graphics APIs, there is no such restriction.

Additional Resources: [GraphicsBuffer.SetCounterValue](/engine/6000.5/script-reference/unityengine/graphicsbuffer/setcountervalue.md).
