Crate wde_wgpu

Crate wde_wgpu 

Source
Expand description

WaterDropEngine’s wde-wgpu crate is a lightweight layer over wgpu that keeps the low-level power of WebGPU while offering opinionated building blocks for buffers, textures, render/compute pipelines, and pass orchestration. All submodules are re-exported at the crate root (e.g. wde_wgpu::buffer, wde_wgpu::command_buffer) to keep imports short and examples consistent.

§Architecture

§Core usage patterns

  • Configure a surface once, then react to instance::RenderEvent::Resize with instance::resize.
  • Build resources up-front (Buffer, Texture), then stage per-frame uploads via buffer::Buffer::write or queue.write_texture wrappers.
  • Keep pipeline creation deterministic: set shaders, bind group layouts, push constants, then call init and gate draws/dispatches on is_initialized.
  • Record work inside a CommandBuffer; each render/compute pass enforces that required state (pipeline, vertex/index buffers) is set before issuing commands.

§Modules

§Examples and further reading

  • Minimal WGSL shaders live in res/ (see res/examples for full scenes).
  • Bind group helpers sit in bind_group; pair them with pipeline layouts for material or compute resource binding.
  • For GPU-driven draws, see indirect helpers on render_pass::RenderPassInstance.
  • The examples under res/examples show complete scenes; start with display_texture for a minimal textured quad.

Re-exports§

pub use instance::RenderInstanceData;
pub use passes::command_buffer;
pub use passes::compute_pass;
pub use passes::render_pass;
pub use pipelines::bind_group;
pub use pipelines::compute_pipeline;
pub use pipelines::render_pipeline;
pub use resources::buffer;
pub use resources::texture;
pub use utils::vertex;

Modules§

instance
Device/queue/surface bootstrap utilities used across the renderer.
passes
Render and compute pass helpers built on top of wgpu encoders.
pipelines
Pipeline and bind-group construction utilities.
resources
GPU resources shared across the renderer.
utils
Small utilities shared across the renderer.