writeBuffer method

  1. @override
void writeBuffer(
  1. StorageBuffer target,
  2. int offsetInBytes,
  3. ByteData bytes
)
override

Writes bytes into target at offsetInBytes, in place. Visible starting the next pass, as overwriteGeometry; an offset and length that do not fit throw an ArgumentError before anything is written.

The call a simulation makes every step to feed a compute pass its inputs. Any buffer createBuffer made with BufferUsage.copyDestination. Gated by compute or buffers, whichever made the buffer possible.

Implementation

@override
void writeBuffer(StorageBuffer target, int offsetInBytes, ByteData bytes) {
  features.require(DeviceFeature.buffers, backend: _name);
  if (offsetInBytes < 0 ||
      offsetInBytes + bytes.lengthInBytes > target.lengthInBytes) {
    throw ArgumentError(
      'writeBuffer: $offsetInBytes + ${bytes.lengthInBytes} does not fit '
      'inside a ${target.lengthInBytes}-byte buffer',
    );
  }
  calls.add(
    RecordedCall(
      'writeBuffer',
      arguments: (
        offsetInBytes: offsetInBytes,
        lengthInBytes: bytes.lengthInBytes,
      ),
    ),
  );
}