Interface GPUBuffer

    interface GPUBuffer {
        __brand: "GPUBuffer";
        label: string;
        mapState: GPUBufferMapState;
        size: number;
        usage: number;
        destroy(): undefined;
        getMappedRange(offset?: number, size?: number): ArrayBuffer;
        mapAsync(mode: number, offset?: number, size?: number): Promise<undefined>;
        unmap(): undefined;
    }
    Hierarchy

    Properties

    __brand: "GPUBuffer"
    label: string
    size: number
    usage: number

    Methods

    • Destroys the GPUBuffer. Note: It is valid to destroy a buffer multiple times. Note: Since no further operations can be enqueued using this buffer, implementations can free resource allocations, including mapped memory that was just unmapped.

      Returns undefined

    • Returns an ArrayBuffer with the contents of the GPUBuffer in the given mapped range.

      Parameters

      • Optionaloffset: number

        Offset in bytes into the buffer to return buffer contents from.

      • Optionalsize: number

        Size in bytes of the ArrayBuffer to return.

      Returns ArrayBuffer

    • Maps the given range of the GPUBuffer and resolves the returned Promise when the GPUBuffer's content is ready to be accessed with GPUBuffer#getMappedRange. The resolution of the returned Promise only indicates that the buffer has been mapped. It does not guarantee the completion of any other operations visible to the content timeline, and in particular does not imply that any other Promise returned from () or GPUBuffer#mapAsync on other GPUBuffers have resolved. The resolution of the Promise returned from GPUQueue#onSubmittedWorkDone does imply the completion of GPUBuffer#mapAsync calls made prior to that call, on GPUBuffers last used exclusively on that queue.

      Parameters

      • mode: number

        Whether the buffer should be mapped for reading or writing.

      • Optionaloffset: number

        Offset in bytes into the buffer to the start of the range to map.

      • Optionalsize: number

        Size in bytes of the range to map.

      Returns Promise<undefined>

    • Unmaps the mapped range of the GPUBuffer and makes it's contents available for use by the GPU again.

      Returns undefined