Crate mew

Source
Expand description

Maybe Easier wgpu, a thin (?) abstraction to hopefully help organize your 3 buffers, 20 bind groups, and 7 pipelines.

wgpu is a 1:1 API for the WebGPU standard. While that makes it very portable, versatile, and well-documented, since I’m not a hardcore graphics chud, I don’t find it very intuitive to use.

My main problem with it is how many bloody times you need to define the same thing, and quadruple-check that all the layouts line up with each other: first the BindGroupLayoutDescriptor, which turns into a BindGroupLayout, which is then used in a PipelineLayoutDescriptor by putting it into a BindGroupLayoutEntry
Wait, crap, I think I forgot a struct somewhere along the line.

§The point of this

This library aims to, at least a little bit, make it easier to define all the related information in one place (in wrapper structs). It primarily uses like 10 macro_rules! to write boilerplate that generates buffer, bind group, and pipeline layouts. It also stores them in a convenient “render context” struct.

My original goal wasn’t to simplify the wgpu API, rather just to follow a programming pattern I used, but with the amount of boilerplate this let me cut down on, it did kind of end up as a “simplification wrapper”. However, it still should be possible to lobotomize my code and mix-and-match your own custom handlers, so you can do the same funky lower-level stuff as you could if you use wgpu directly.

§Not the point of this

As I mentioned, this isn’t supposed to dumb down the wgpu API, but rather make it easier to define everything. This library is for people who have already used wgpu at least once, so if you’re brand-new to graphics programming, this likely isn’t the super-simple graphics toolkit you’re looking for.

I should also point out, this doesn’t handle making windows. You can use winit for that, its API is actually quite usable directly, especially when comparing to wgpu. The example highlights integrating this and winit in practice, because, well, what else would an example do if not drawing to the screen?

§Final note

Because I’m not a graphics programming chud (my only “graphical” programming experience prior to wgpu is Processing, ShaderToy, a 3D wireframe demo in the terminal, and Bevy), I don’t know the normal way to do proper graphics. All my knowledge of wgpu came from the docs, experimentation, and this tutorial, which is really handy though ever-so-slightly outdated.

You’ll also need to excuse my weird code, using both really verbose traits in combination with macros where traits would be too painful (trust me, I tried). I use lots of type wrappers and generics to (maybe) make it easier to integrate your own types if you need any functionality that I missed.

Re-exports§

pub use wgpu;
pub use pollster;

Modules§

primitives
vertexprimitive

Macros§

bind_group
Define a bind group, with internal buffer types (and their field names), and their shader visibility (see [wgpu::ShaderStages]).
buffer
Define a storage buffer, with an optional internal type to align its size with.
pipeline
Define a pipeline, with internal bind group types.
render_context
sampler
shader_struct
shader_struct2
texture
usage: variants of wgpu::TextureUsages format: variant of wgpu::TextureFormat dimension: variant of wgpu::TextureViewDimension sample_type: FLOAT or DEPTH
typemap
A really bad way to genericize struct fields.
vertex_struct

Structs§

Float32
Float64
Float16x2
Float16x4
Float32x2
Float32x3
Float32x4
Float64x2
Float64x3
Float64x4
MewBindGroupLayout
Wrapper for the layout of some bind group, so that the compiler will scream at you if you mix up layouts.
MewPipelineLayout
Wrapper for the layout of some pipeline, so that the compiler will scream at you if you mix up pipelines.
Sint8x2
Sint8x4
Sint32
Sint16x2
Sint16x4
Sint32x2
Sint32x3
Sint32x4
Snorm8x2
Snorm8x4
Snorm16x2
Snorm16x4
Uint8x2
Uint8x4
Uint32
Uint16x2
Uint16x4
Uint32x2
Uint32x3
Uint32x4
Unorm8x2
Unorm8x4
Unorm10_10_2
Unorm16x2
Unorm16x4

Traits§

MewBindGroup
Trait for bind group wrapper types, to get layouts and descriptors about the inner bind group.
MewBuffer
Trait for buffer wrapper types, to get layouts and descriptors about the inner buffer.
MewPipeline
Trait for pipeline wrapper types, to get layouts and descriptors about the inner pipeline.
MewSampler
MewShaderStruct
MewTexture
MewVertexPrimitive
MewVertexStruct