Engine API Reference - v2.15.1
    Preparing search index...

    Class StorageBuffer

    A storage buffer represents a memory which both the CPU and the GPU can access. Typically it is used to provide data for compute shader, and to store the result of the computation. Note that this class is only supported on the WebGPU platform.

    Index

    Constructors

    Methods

    Constructors

    • Create a new StorageBuffer instance.

      Parameters

      • graphicsDevice: GraphicsDevice

        The graphics device used to manage this storage buffer.

      • byteSize: number

        The size of the storage buffer in bytes.

      • OptionalbufferUsage: number = 0

        The usage type of the storage buffer. Can be a combination of BUFFERUSAGE_READ, BUFFERUSAGE_WRITE, BUFFERUSAGE_COPY_SRC and BUFFERUSAGE_COPY_DST flags. This parameter can be omitted if no special usage is required.

      • OptionaladdStorageUsage: boolean = true

        If true, automatically adds BUFFERUSAGE_STORAGE flag. Set to false for staging buffers that use BUFFERUSAGE_WRITE. Defaults to true.

      Returns StorageBuffer

    Methods

    • Clear the content of a storage buffer to 0.

      Parameters

      • Optionaloffset: number = 0

        The byte offset of data to clear. Defaults to 0.

      • Optionalsize: number = ...

        The byte size of data to clear. Defaults to the full size of the buffer minus the offset.

      Returns void

    • Copy data from another storage buffer into this storage buffer.

      Parameters

      • srcBuffer: StorageBuffer

        The source storage buffer to copy from.

      • OptionalsrcOffset: number = 0

        The byte offset in the source buffer. Defaults to 0.

      • OptionaldstOffset: number = 0

        The byte offset in this buffer. Defaults to 0.

      • Optionalsize: number = ...

        The byte size of data to copy. Defaults to the full size of the source buffer minus the source offset.

      Returns void

    • Issues a write operation of the provided data into a storage buffer.

      Parameters

      • bufferOffset: number = 0

        The offset in bytes to start writing to the storage buffer.

      • data: ArrayBufferView<ArrayBufferLike>

        The data to write to the storage buffer.

      • dataOffset: number = 0

        Offset in data to begin writing from. Given in elements if data is a TypedArray and bytes otherwise.

      • size: number

        Size of content to write from data to buffer. Given in elements if data is a TypedArray and bytes otherwise.

      Returns void