pixi.js
    Preparing search index...

    Class BufferResourceAdvanced

    A resource that can be bound to a bind group and used in a shader. Whilst a buffer can be used as a resource, this class allows you to specify an offset and size of the buffer to use. This is useful if you have a large buffer and only part of it is used in a shader.

    This resource listens for changes on the underlying buffer and emits a change itself if the buffer changes shape, unless it is created with watch: false.

    const buffer = new Buffer({
    data: new Float32Array(1000),
    usage: BufferUsage.UNIFORM,
    });
    // Create a buffer resource that uses the first 100 bytes of a buffer
    const bufferResource = new BufferResource({
    buffer,
    offset: 0,
    size: 100,
    });

    Hierarchy

    Implements

    Index
    • Create a new Buffer Resource.

      Parameters

      • options: { buffer: Buffer; offset?: number; size?: number; watch?: boolean }

        The options for the buffer resource

        • buffer: Buffer

          The underlying buffer that this resource is using

        • Optionaloffset?: number

          The byte offset into the buffer this resource starts at, defaulting to 0. Must be a multiple of renderer.limits.minUniformBufferOffsetAlignment.

        • Optionalsize?: number

          The number of bytes this resource covers. If not provided, it covers the rest of the buffer after offset.

        • Optionalwatch?: boolean

          Listen to the buffer, defaulting to true. A watched resource changes its id and emits change when the buffer resizes, unloads or is destroyed, so the bind groups holding it rebuild. Pass false when many resources share one buffer and every bind group holds them with BindGroup.setResourceUnwatched, as thousands of listeners on one buffer cost memory and time to add and remove. An unwatched resource keeps its id through those changes, so whoever owns it must replace it with a new resource once the buffer changes, or bind groups keep using the old GPU buffer.

      Returns BufferResource

    buffer: Buffer

    the underlying buffer that this resource is using

    destroyed: boolean = false

    Has the Buffer resource been destroyed?

    offset: number

    the byte offset into the buffer this resource starts at, defaulting to 0. Must be a multiple of renderer.limits.minUniformBufferOffsetAlignment.

    size: number

    the number of bytes this resource covers. If not provided, it covers the rest of the buffer after offset.

    uid: number = ...

    a unique id for this uniform group used through the renderer

    watch: boolean

    Whether this resource listens to its buffer. See the watch constructor option.

    • set _gcLastUsed(value: number): void

      Parameters

      • value: number

      Returns void

    • Destroys this resource. Make sure the underlying buffer is not used anywhere else if you want to destroy it as well, or code will explode

      Parameters

      • destroyBuffer: boolean = false

        Should the underlying buffer be destroyed as well?

      Returns void