attackgoat / screen-13

Screen 13 is an easy-to-use Vulkan rendering engine in the spirit of QBasic.
Apache License 2.0
264 stars 13 forks source link

Swapchain continuously recreated due to timeouts #52

Open trevex opened 1 year ago

trevex commented 1 year ago

When running any example under Linux with both winit wayland and x11 backend the swapchain is continuously recreated:

2023-01-13T09:45:13.584538Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1
2023-01-13T09:45:13.688318Z  INFO screen_13::driver: OK
2023-01-13T09:45:13.688668Z  INFO screen_13::event_loop: Window dimensions: 512x512 (1x scale)
2023-01-13T09:45:13.779842Z  WARN screen_13::driver::device: waited for 1 ms
2023-01-13T09:45:13.787303Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 512x512
2023-01-13T09:45:13.864767Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:13.930116Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:13.995836Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.063075Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.137871Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.206030Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.271837Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.340159Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.389876Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.456287Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.522417Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.588928Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.655721Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.723229Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.789725Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.855235Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.921972Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:14.990189Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.055567Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.120868Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.187700Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.254177Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.321913Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.389837Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.456553Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.523543Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.589954Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.656752Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.723625Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.790263Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.855268Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.905441Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:15.955310Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.021748Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.073016Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.138395Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.189387Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.239198Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.289671Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.355784Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.405375Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.456047Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.520965Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.571319Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.621476Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.671121Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.721137Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.772319Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.821298Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.872013Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.922745Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:16.987211Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.038794Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.088699Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.138603Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.188176Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.238700Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.305035Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.354474Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.404871Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.454995Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.504336Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.555529Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475
2023-01-13T09:45:17.619889Z  INFO screen_13::driver::swapchain: Swapchain dimensions: 470x475

I tried fixing it locally by handling the timeout here: https://github.com/attackgoat/screen-13/blob/master/src/driver/swapchain.rs#L109

But then no frame is rendered after the initial frame. I am currently traveling and using an integrated AMD GPU I suspect the reason for the timeouts is similar to the following workaround in bevy for integrated GPUs on Linux: https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/view/window.rs#L230

I tried to quickly restructure the EventLoop code to handle the timeout similar to bevy, but without much avail. Most likely due to a lack of understanding Screen 13.

trevex commented 1 year ago

Just re-confirming the above only happens on AMD integrated GPU for me. Just tested on desktop PC with NVIDIA GPU without any issues.