Skip to main content

Module wasm

Module wasm 

Source
Expand description

WASM target support for browser-based GPU compute via WebGPU.

This module is conditionally compiled on wasm32 targets (or when the wasm feature is enabled for native testing) and provides browser-friendly wrappers around the wgpu WebGPU backend.

§Architecture

+-------------------------------------------+
|         JavaScript / Browser              |
+-------------------+-----------------------+
                    |
+-------------------v-----------------------+
|   WasmGpuDevice / WasmBackend (wasm32)    |
+-------------------+-----------------------+
                    |  delegates to
+-------------------v-----------------------+
|   WebGpuBackend (wgpu web-sys backend)    |
+-------------------------------------------+

§Usage

The WasmBackend wraps the existing WebGpuBackend and adds browser-specific initialisation methods such as init_from_canvas.

The WasmMemoryManager provides async-friendly buffer staging suited to the browser event loop.

Structs§

WasmBackend
WebGPU compute backend for WASM (browser) targets.
WasmGpuDevice
A WebGPU device obtained from the browser’s navigator.gpu API.
WasmMemoryManager
Browser-side buffer manager that uses async map_async staging.

Functions§

request_adapter
Request a WebGPU adapter from the browser.