readBufferSync method

  1. @override
ByteData readBufferSync(
  1. StorageBuffer buffer, {
  2. int offsetInBytes = 0,
  3. int? sizeInBytes,
})
override

The bytes of buffer (a range of them), read back in the calling turn.

A stall, on purpose. The call waits for every pass submitted before it, which is the price WebGL2's getBufferSubData charges and the reason WebGPU has no such call. For a tool or a test that would rather block than restructure; a frame loop wants GraphicsDevice.readBuffer or GraphicsDevice.mapBuffer. buffer must be BufferUsage.hostReadable.

Implementation

@override
ByteData readBufferSync(
  StorageBuffer buffer, {
  int offsetInBytes = 0,
  int? sizeInBytes,
}) {
  _unrecorded('readBufferSync');
  final inner = this.inner;
  if (inner is! SynchronousBufferReadback) {
    throw refuse(DeviceFeature.synchronousReadback);
  }
  return inner.readBufferSync(
    buffer,
    offsetInBytes: offsetInBytes,
    sizeInBytes: sizeInBytes,
  );
}