ash icon indicating copy to clipboard operation
ash copied to clipboard

Examples demonstrate bad patterns

Open Ralith opened this issue 6 years ago • 4 comments

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.

Ralith avatar Mar 02 '19 07:03 Ralith

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:

hgallagher1993 avatar Nov 26 '20 22:11 hgallagher1993

Thanks, that would be awesome!

Ralith avatar Nov 26 '20 23:11 Ralith

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?

hgallagher1993 avatar Jan 11 '21 21:01 hgallagher1993

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.

Ralith avatar Jan 11 '21 22:01 Ralith