1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! OxiCUDA WebGPU backend — cross-platform GPU compute via `wgpu` and WGSL.
//!
//! Provides a [`WebGpuBackend`] that implements the [`oxicuda_backend::ComputeBackend`] trait
//! from `oxicuda-backend`, using `wgpu` to target Vulkan, Metal, Direct3D 12,
//! and the browser WebGPU API from a single Rust crate.
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use oxicuda_webgpu::WebGpuBackend;
//! use oxicuda_backend::ComputeBackend;
//!
//! let mut backend = WebGpuBackend::new();
//! backend.init().expect("WebGPU init failed");
//!
//! // Allocate 1 KiB on the GPU.
//! let ptr = backend.alloc(1024).expect("alloc failed");
//! backend.free(ptr).expect("free failed");
//! ```
//!
//! # Architecture
//!
//! ```text
//! ┌──────────────────────────────────────────┐
//! │ WebGpuBackend │
//! │ (implements ComputeBackend) │
//! └──────────────┬───────────────────────────┘
//! │
//! ┌────────▼────────┐
//! │ WebGpuDevice │ ← wgpu Instance + Adapter + Device + Queue
//! └────────┬────────┘
//! │
//! ┌───────────▼────────────┐
//! │ WebGpuMemoryManager │ ← buffer pool (u64 handle → wgpu::Buffer)
//! └────────────────────────┘
//! ```
//!
//! # WGSL Shader Generation
//!
//! The [`shader`] module provides helpers that produce WGSL source strings for
//! common kernels (GEMM, element-wise ops, reductions).
// WASM target support — compiled on wasm32 or when the `wasm` feature is
// enabled (so that native tests can exercise the module).
pub use WebGpuBackend;
pub use ;