gpuGet (Function)

Signature: gpuGet(buffer: GpuBuffer<int> | GpuBuffer<float> | GpuBuffer<bool>, index: int) -> Result<t0, Error>

Description: Bounds-checked read of one element at the buffer's element type. Out of bounds returns Error.

Parameters

  • buffer (GpuBuffer | GpuBuffer | GpuBuffer): The buffer to read
  • index (int): The element index

Returns: Result<t0, Error>

Example

gpuGet(toGpu([10, 20]), 1) ?: 0  // 20
gpuGet (toGpu [10, 20], 1) ?: 0  // 20