Class GPUBuffer

Handles a generic GPU buffer that you may use for storing any kind of sequential data you wish to be accessible to the GPU.

Sim thread only.

Hierarchy

  • FrameworkObject
    • GPUBuffer

Constructors

  • Creates a generic buffer that can be passed as a parameter to a GPU program. This type of buffer can hold various type of data and can be used for various purposes. See GPUBufferType for explanation of different buffer types.

    Parameters

    Returns GPUBuffer

Accessors

  • get elementCount(): number
  • Returns number of elements in the buffer.

    Returns number

  • get elementSize(): number
  • Returns size of a single element in the buffer in bytes.

    Returns number

  • get size(): number
  • Gets the size in bytes

    Returns number

  • get type(): EnumValue<GPUBufferType, number>
  • Returns the type of the GPU buffer. type determines which kind of views (if any) can be created for the buffer, and how is data read or modified in it.

    Returns EnumValue<GPUBufferType, number>

Methods

  • Reads data from a portion of the buffer and copies it to the destination buffer without blocking GPU execution. Caller must ensure destination buffer is large enough.

    Parameters

    • offset: number

      Offset in bytes from which to copy the data.

    • length: number

      Length of the area you want to copy, in bytes.

    Returns UncertainAsyncOp<number[], string>

    Object that will be signaled when the read operation completes.

  • Reads stream data from a portion of the buffer and copies it to the destination buffer without blocking GPU execution. Caller must ensure destination buffer is large enough.

    Parameters

    • offset: number

      Offset in bytes from which to copy the data.

    • length: number

      Length of the area you want to copy, in bytes.

    Returns UncertainAsyncOp<DataStream, string>

    Object that will be signaled when the read operation completes.

  • Writes data into a portion of the buffer from the source memory.

    Parameters

    • offset: number

      Offset in bytes from which to copy the data.

    • length: number

      Length of the area you want to copy, in bytes.

    • source: number[]

      Source buffer containing the data to write. Data is read from the start of the buffer (offset is only applied to the destination).

    • writeType: EnumValue<BufferWriteType, number>

      Write flags that may affect performance.

    Returns UncertainAsyncOp<boolean, string>

  • Writes stream data into a portion of the buffer from the source memory.

    Parameters

    • offset: number

      Offset in bytes from which to copy the data.

    • length: number

      Length of the area you want to copy, in bytes.

    • source: DataStream

      Source buffer containing the data to write. Data is read from the start of the buffer (offset is only applied to the destination).

    • writeType: EnumValue<BufferWriteType, number>

      Write flags that may affect performance.

    Returns UncertainAsyncOp<boolean, string>

  • Returns the size of a single element in the buffer, of the provided format, in bytes.

    Parameters

    Returns number