# Class: RenderBundle

**`Advanced`**

A recorded WebGPU render bundle, together with a stamp of the pipeline state it baked when it
was recorded.

Recording captures the render target permanently, in two ways:

- the attachment state (color format(s), depth/stencil format, sample count). WebGPU validates
  this when the bundle is executed — replaying it in a pass whose attachments differ rejects the
  whole command buffer.
- the front-face winding baked into every pipeline inside it. WebGPU does *not* validate this —
  replaying after the target's [RenderTarget.flipY](rendering.RenderTarget.html#flipy) parity changed silently renders
  geometry inside out.

[RenderBundle.stateKey](#statekey) stamps both, so [GpuEncoderSystem.isBundleValid](rendering.GpuEncoderSystem.html#isbundlevalid) can answer
whether a cached bundle is still safe to replay against the target that is bound now.

Created by [GpuEncoderSystem.endBundle](rendering.GpuEncoderSystem.html#endbundle) — there is no reason to construct one yourself.

## Example

```ts
const record = () =>
{
    encoder.beginBundle('my-cached-pass');
    encoder.draw({ geometry, shader });

    return encoder.endBundle();
};

// record once, then replay on later frames — re-recording whenever the target it baked
// no longer matches the one bound now
if (!encoder.isBundleValid(bundle)) bundle = record();
encoder.executeBundle(bundle);
```

## Constructors

### Constructor

> **new RenderBundle**(`gpuBundle`, `stateKey`, `device`, `label?`): `RenderBundle`

#### Parameters

##### gpuBundle

[`GPURenderBundle`](https://developer.mozilla.org/docs/Web/API/GPURenderBundle)

The recorded native render bundle.

##### stateKey

`number`

The pipeline state key captured when recording began.

##### device

[`GPUDevice`](https://developer.mozilla.org/docs/Web/API/GPUDevice)

The device the bundle was recorded on.

##### label?

`string`

Optional debug label for the bundle.

#### Returns

`RenderBundle`

## Properties

### device

> `readonly` **device**: [`GPUDevice`](https://developer.mozilla.org/docs/Web/API/GPUDevice)

The device the bundle was recorded on. A bundle cannot be replayed on the device that replaces it after a loss.

***

### gpuBundle

> `readonly` **gpuBundle**: [`GPURenderBundle`](https://developer.mozilla.org/docs/Web/API/GPURenderBundle)

The recorded native bundle, as handed to `GPURenderPassEncoder.executeBundles`.

***

### label?

> `readonly` `optional` **label**: `string`

Optional debug label — names the bundle in GPU captures and in WebGPU validation errors.

***

### stateKey

> `readonly` **stateKey**: `number`

The value [PipelineSystem.bundleStateKey](rendering.PipelineSystem.html#bundlestatekey) had when recording began. Comparing it
against the pipeline's current key tells you whether this bundle still matches the bound
render target — which is exactly what [GpuEncoderSystem.isBundleValid](rendering.GpuEncoderSystem.html#isbundlevalid) does.
