alan icon indicating copy to clipboard operation
alan copied to clipboard

Bolt some type safety onto the `wgpu` Buffer API

Open dfellis opened this issue 10 months ago • 0 comments

The Rust wgpu API will usually simply panic! on things like invalid shader code, buffers that are too big, using shader features you didn't acquire when initializing wgpu, etc, instead of having all of these fallible APIs return a Result you need to check or unwrap.

I was honestly really surprised by this decision, and I definitely don't want this to be the experience in Alan. I feel like I'm going to end up playing whack-a-mole with issues on this, but at least for the wgpu::Buffer type, I think I can write some logic to wrap some safety onto it pretty cheaply, and make my createBuffer function return a Result<Buffer> instead of just a Buffer.

dfellis avatar Apr 09 '24 22:04 dfellis