mgpuWaitForSubmittedWork function

Future<void> mgpuWaitForSubmittedWork()

Resolves only after work already submitted to minigpu's own device queue has completed. The device comes from Emscripten's handle table, so a host page's unrelated WebGPU device cannot acknowledge this work early.

Implementation

Future<void> mgpuWaitForSubmittedWork() async {
  final object = getWebGpuJsObject(mgpuGetWGPUDeviceHandle());
  if (object == null) {
    throw StateError('minigpu has no initialized WebGPU device');
  }
  final device = object as GPUDevice;
  await (device.queue as _GPUQueue).onSubmittedWorkDone().toDart;
}