mgpuWriteTexture2D function
Implementation
int mgpuWriteTexture2D(
MGPUTexture texture,
Uint8List bytes,
int mipLevel,
int arrayLayer,
) {
final pointer = _malloc(bytes.lengthInBytes.toJS);
final start = pointer.toDartInt;
try {
if (start <= 0 || start + bytes.lengthInBytes > _heapU8.length) {
throw StateError('Texture upload allocation failed');
}
HEAPU8.set(Uint8ListToJSUint8Array(bytes).toJS, start);
return _mgpuWriteTexture2D(
texture,
pointer,
bytes.lengthInBytes.toJS,
mipLevel.toJS,
arrayLayer.toJS,
).toDartInt;
} finally {
_free(pointer);
}
}