ash
ash copied to clipboard
Examples demonstrate bad patterns
The examples have a few issues that should be corrected to help guide new Vulkan users towards good practice:
- [ ] Window resizes should be handled gracefully rather than panicing
- [ ] Validation layer should not be hardcoded on, as it can be easily enabled via environment variables and will prevent execution when the validation layers are not installed
- [x] Fences should be reused, rather than reconstructed every frame
- [ ] Presentation should be pipelined with rendering, rather than blocked on the CPU until rendering completes
- [ ] The windowing system event queue should be drained independently of frame rendering, rather than rendering one frame per event, as that leads to massive input lag and low framerates.
I can have a go at refactoring this! This will be a bit of a learning exercise for me because apart from some gfx-rs tutorials I'm still new to computer graphics so mightn't have a PR for a while :smile:
Thanks, that would be awesome!
Hi, so I'm pretty much finished with this I think but I just have one question about the second point, do you mean enable the validation layer by passing it in as a feature?...so something like cargo run --bin triangle --features "layer_validation" and then conditionally create the instance with or without it?
No; the user can easily enable the validation layers themselves by setting the VK_LAYER_KHRONOS_validation environment variable or using vkconfig, so there's no need for the examples to enable them explicitly at all.