Expand description
Real wgpu compute backend, enabled only with the wgpu-backend feature.
Provides GPU buffer management, WGSL shader dispatch, and CPU-side readback
using wgpu 29’s cross-platform Vulkan / Metal / DX12 backends.
§Thread safety
wgpu::Device and wgpu::Queue are Send + Sync. The shader cache is
protected by a Mutex, making WgpuBackendReal safe to share across
threads (though individual dispatches are synchronous on the calling thread).
§Usage
ⓘ
// With the wgpu-backend feature enabled:
use oxiphysics_gpu::compute::wgpu_backend::real::WgpuBackendReal;
let mut backend = WgpuBackendReal::try_new()?;
let h = backend.create_buffer_f64(128);
backend.write_buffer_f64(h, &vec![1.0_f64; 128]);
backend.dispatch_wgsl(
WGSL_SPH_DENSITY, "sph_density",
&[(h, wgpu::BufferBindingType::Storage { read_only: false })],
[2, 1, 1],
)?;
let out = backend.read_buffer_f64(h);Structs§
- Wgpu
Backend Real - Real GPU compute backend backed by
wgpu29.