vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.45k stars 435 forks source link

Use `f64` in vulkano-util to avoid precision loss #2506

Closed Rua closed 4 months ago

Rua commented 5 months ago

Changelog:

### Breaking changes
Changes to vulkano-util:
- `f64` is now used instead of casting to `f32` whenever manipulating `u32` or `f64` values received from the window library.

Winit uses u32 or f64 to represent sizes, positions, etc. Casting either of those to f32 results in precision loss. By using f64 throughout, the user is given the choice of losing precision instead of having it forced on them by Vulkano.

marc0246 commented 4 months ago

The values you get from winit don't have any precision to speak of, and everything in graphics revolves around f32 since f64 is horribly slow on consumer GPUs. Therefore using f64 in APIs is counter-productive. Instead I would #[allow] the clippy lints. They are overly conservative and supposed to be #[allow]ed when it makes sense.