mgpuWriteUint16 function
Implementation
void mgpuWriteUint16(MGPUBuffer buffer, Uint16List inputData, int size) {
final int byteSize = size * Uint16List.bytesPerElement;
final JSNumber ptr = _malloc(byteSize.toJS);
final int startByteIndex = ptr.toDartInt;
try {
final int startElementIndex = startByteIndex ~/ Uint16List.bytesPerElement;
if (startElementIndex + inputData.length > _heapU16.length) {
throw StateError('Uint16 buffer allocation would exceed heap bounds');
}
_heapU16.setRange(
startElementIndex,
startElementIndex + inputData.length,
inputData,
);
_mgpuWriteUint16(buffer, ptr, byteSize.toJS);
} finally {
_free(ptr);
}
}