bindings/minigpu_bindings
library
Classes
-
GPUDevice
-
-
WebContextRetirement
-
Receipt from the exact loaded module's creation context. Captured functions
cannot accidentally poll a later module whose token numbers happen to match.
Functions
-
allocateUTF8(String str)
→ JSString
-
-
ccall(JSString name, JSString returnType, JSArray<JSAny?> argTypes, JSArray<JSAny?> args, JSObject opts)
→ JSPromise<JSAny?>
-
-
ensureMinigpuModuleLoaded()
→ Future<void>
-
Load (or adopt) the minigpu wasm module once. Safe to await repeatedly.
Throws on fetch/instantiation failure — callers surface that as "no GPU
on this platform" rather than a silent hang — and the next call tries again.
-
mgpuComputeShaderBuildPipeline(MGPUComputeShader shader)
→ bool
-
Compiles
shader's pipeline for its kernel and bindings without
dispatching; true when it exists. A direct export call like mgpuDispatch:
the compile is the one a first dispatch does, and it never suspends.
-
mgpuCreateBuffer(int elements, int dataType)
→ MGPUBuffer
-
-
mgpuCreateBufferWithUsage(int sizeBytes, int usage)
→ MGPUBuffer?
-
-
mgpuCreateComputeShader()
→ MGPUComputeShader
-
-
mgpuCreateRenderPipeline(String code, String vertex, String fragment, List<int> words)
→ MGPURenderPipeline?
-
-
mgpuCreateSampler(int addressU, int addressV, int addressW, int mag, int min, int mip, double lodMin, double lodMax, int compare)
→ MGPUSampler?
-
-
mgpuCreateTexture2D(int width, int height, int format, int usage, int layers, int mipLevels)
→ MGPUTexture?
-
-
mgpuCreateTextureView(MGPUTexture texture, int dimension, int baseMip, int mipCount, int baseLayer, int layerCount)
→ MGPUTextureView?
-
-
mgpuDestroyBuffer(MGPUBuffer buffer)
→ void
-
-
mgpuDestroyComputeShader(MGPUComputeShader shader)
→ void
-
-
mgpuDestroyContext()
→ Future<void>
-
-
mgpuDestroyOwnDevice(JSObject device)
→ void
-
Destroy the retained creation device, never an ambient/replacement device.
Completion of its loss promise is observed separately by the platform owner.
-
mgpuDestroyRenderPipeline(MGPURenderPipeline pipeline)
→ void
-
-
mgpuDestroySampler(MGPUSampler sampler)
→ void
-
-
mgpuDestroyTexture(MGPUTexture texture)
→ void
-
-
mgpuDestroyTextureView(MGPUTextureView view)
→ void
-
-
mgpuDispatch(MGPUComputeShader shader, int groupsX, int groupsY, int groupsZ)
→ Future<void>
-
-
mgpuFlushBatch()
→ void
-
Submits any open fire-and-forget compute batch on minigpu's device.
-
mgpuGetOwnDeviceObject()
→ JSObject?
-
Resolves minigpu's own device. Never uses the host-page gpuDevice global.
-
mgpuGetWGPUBufferHandle(MGPUBuffer buf)
→ int
-
Returns the Emscripten integer handle for a WGPUBuffer inside
buf.
Pass to getWebGpuJsObject from webgpu_interop.dart to get the JS GPUBuffer.
-
mgpuGetWGPUDeviceHandle()
→ int
-
Returns the Emscripten integer handle for the WGPUDevice.
Pass to getWebGpuJsObject from webgpu_interop.dart to get the JS GPUDevice.
-
mgpuHasKernel(MGPUComputeShader shader)
→ bool
-
-
mgpuImportExternalTexture(JSAny videoFrame)
→ JSObject?
-
Import a
VideoFrame (or HTMLVideoElement) as a GPUExternalTexture.
-
mgpuInitializeContext()
→ Future<void>
-
-
mgpuLandExternalTexture({required JSObject externalTexture, required int dstBufferHandle, required int width, required int height, required int downscale})
→ bool
-
Run the external-texture landing pass:
externalTexture -> packed RGBA8
array<u32> in the buffer behind dstBufferHandle, the same destination
layout the native D3D11 path writes.
-
mgpuLoadKernel(MGPUComputeShader shader, String kernelString)
→ void
-
-
mgpuObserveOwnContextRetirement(int deviceHandle)
→ WebContextRetirement?
-
-
mgpuOwnDeviceLost(JSObject device)
→ Future<void>?
-
The loss promise belonging to minigpu's owned device, if readable.
-
mgpuOwnDeviceRequirements(JSObject device)
→ (Set<String>, Map<String, int>)
-
Capture actual device features/limits for browser-selected replacement.
These are compatibility requirements, never a physical adapter identity.
-
mgpuReadAsyncDouble(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncFloat(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncInt16(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncInt32(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncInt64(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncInt8(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
Asynchronous reads, one per element type:
readElements (0: the whole
list) elements from GPU element elementOffset land at the front of
outputData, whatever its list type. See _readAsync.
-
mgpuReadAsyncUint16(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncUint32(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncUint64(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadAsyncUint8(MGPUBuffer buffer, TypedData outputData, {int readElements = 0, int elementOffset = 0})
→ Future<void>
-
-
mgpuReadOwnDeviceBufferLimits(JSObject device)
→ (int, int)?
-
Exact limits on the resolved GPUDevice, or null if any JS surface is absent.
-
mgpuReadOwnDeviceTextureLimits(JSObject device)
→ (int, int)?
-
-
mgpuRenderPipelineBindingStat(MGPURenderPipeline pipeline, int selector)
→ int
-
-
mgpuRenderPipelineDiagnostic(MGPURenderPipeline pipeline)
→ String
-
-
mgpuRenderPipelineStatus(MGPURenderPipeline pipeline)
→ int
-
-
mgpuSetBuffer(MGPUComputeShader shader, int tag, MGPUBuffer buffer)
→ void
-
-
mgpuSetBufferRange(MGPUComputeShader shader, int slot, MGPUBuffer buffer, int kind, int offsetBytes, int sizeBytes)
→ int
-
-
mgpuSetLogLevel(int level)
→ void
-
Minimum native log verbosity (0=DEBUG 1=INFO 2=WARN 3=ERROR, -1 silences
all). The wasm default is INFO, which narrates ~7 buffer ops per encoded
frame straight onto the browser console via stderr
printChar. Callable
only once the module is loaded — MinigpuWeb stages the level and applies
it right after ensureMinigpuModuleLoaded, before context init, so even
the adapter/device bring-up logs honor it.
-
mgpuSetOwnedSampler(MGPUComputeShader shader, int slot, MGPUSampler sampler, int kind)
→ int
-
-
mgpuSetOwnedTexture(MGPUComputeShader shader, int slot, MGPUTextureView view, int kind)
→ int
-
-
mgpuSubmitRender(MGPURenderPipeline pipeline, MGPUTextureView color, MGPUTextureView? depth, List<double> clear, int flags, List<MGPUBuffer> buffers, List<MGPUBuffer> views, List<MGPUBuffer> samplers, List<int> commands)
→ int
-
-
mgpuWaitForSubmittedWork()
→ Future<void>
-
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.
-
mgpuWriteDouble(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteFloat(MGPUBuffer buffer, TypedData inputData, int size)
→ Future<void>
-
-
mgpuWriteInt16(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteInt32(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteInt64(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteInt8(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
Writes
size (0: the whole list) elements from the front of inputData,
whatever its list type; see _writeSync.
-
mgpuWriteRawBytesAt(MGPUBuffer buffer, Uint8List bytes, int offset)
→ void
-
Upload exactly the caller's byte view into minigpu's own device/buffer.
The typed-array overload preserves a subview's offset and length. Flushing
the open compute batch orders earlier work before this queue write.
-
mgpuWriteTexture2D(MGPUTexture texture, Uint8List bytes, int mipLevel, int arrayLayer)
→ int
-
-
mgpuWriteTextureRegion2D(MGPUTexture texture, Uint8List bytes, int x, int y, int width, int height, int mipLevel, int arrayLayer)
→ int
-
-
mgpuWriteUint16(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteUint32(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteUint64(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
mgpuWriteUint8(MGPUBuffer buffer, TypedData inputData, int size)
→ void
-
-
setRenderPipelineSettledHook(void onSettled(int level))
→ void
-
Calls
onSettled with a render pipeline's handle each time one settles
(ready, failed or closed). It may run inside a create or destroy call.
Replaces any earlier hook.