Skip to content

Wgpu

wgpu

介绍 | 学习 wgpu

wgpu  是基于  WebGPU API 规范的、跨平台的、安全的、纯 Rust 图形 API。它是 Firefox、Servo 和 Deno 中 WebGPU 整合的核心。

wgpu  不仅可以在 Web 环境运行,还可以在 macOS / iOS、Android、Window 和 Linux 等系统上原生运行。

GPU 实例 Instance 用于创建适配器 Adapter 和展示平面 Surface

适配器

适配器固定在特定图形后端,用于获取关联显卡的信息,创建逻辑设备和命令队列

let adapter = instance.request_adapter(
    &wgpu::RequestAdapterOptions {
        power_preference: wgpu::PowerPreference::default(),
        compatible_surface: Some(&surface),
        force_fallback_adapter: false,
    },
).await.unwrap();

展示平面

展示平面是绘制到窗口的部分,用于展示绘制结果到屏幕上

其它

GitHub - gfx-rs/gfx: [maintenance mode] A low-overhead Vulkan-like GPU API for Rust. > GitHub - grovesNL/glow: GL on Whatever: a set of bindings to run GL anywhere and avoid target-specific code

big picture

run native with glutin

cargo run --features=glutin