GPUFrame

interface GPUFrame extends HybridObject

A GPUFrame represents a texture on the GPU, often the result of a Frame that has been resized with the Resizer.

The GPUFrame exposes its underlying pixel buffer to the CPU via getPixelBuffer().

Discussion

It is recommended to dispose() the GPUFrame once it is no longer used to free up resources as early as possible.

Properties

channelOrder?

readonly optional channelOrder: ChannelOrder

Represents the channel ordering of the GPUFrame.

Note

If the GPUFrame has already been disposed, this returns undefined.


dataType?

readonly optional dataType: DataType

Represents the scalar data type of the GPUFrame.

Note

If the GPUFrame has already been disposed, this returns undefined.


height

readonly height: number

Represents the height of the GPUFrame, in pixels.

Note

If the GPUFrame has already been disposed, this returns 0.


pixelLayout?

readonly optional pixelLayout: PixelLayout

Represents how the GPUFrame's channels are laid out in memory.

  • 'interleaved' corresponds to HWC / NHWC.
  • 'planar' corresponds to CHW / NCHW.

Note

If the GPUFrame has already been disposed, this returns undefined.


width

readonly width: number

Represents the width of the GPUFrame, in pixels.

Note

If the GPUFrame has already been disposed, this returns 0.

Methods

getPixelBuffer()

getPixelBuffer(): ArrayBuffer

Get an ArrayBuffer representing the shared memory of this GPUFrame.

While the ArrayBuffer allows reading pixels in JS, it is a GPU buffer, and reads are expected to be performed on the GPU for better performance.

Discussion

The returned ArrayBuffer is only valid as long as this GPUFrame is valid - once the GPUFrame has been dispose()'d, the returned ArrayBuffer is no longer safe to access and may return "garbage data".