attackgoat / screen-13

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

Window resizing lags in v0.9.2 #69

Closed KSchala closed 7 months ago

KSchala commented 7 months ago

I wanted to say thank you first. After dealing with Ash and Vulkano, Screen-13 is just pure fun to experiment with. However, there is an issue when resizing the window in the latest version that results in freezes.

Just tried the triangle example and it happens here also. In 0.9.1 i had no such behavior.

OS: Windows 11

attackgoat commented 7 months ago

One of the things updated in 0.9.2 was the gpu-allocator crate, I suspect but have not yet confirmed that this may be related to the issue. The main issue is that the HashPool and LazyPool types have no way to manage memory and so allocating new images to support a new swapchain size as you resize creates lots of new resources that are not reused or freed - they remain in the pool for any other request to use.

I've been putting off this work because everything works fine for regular games and programs which request very similar resources each frame. Resize breaks this. Also a lot of the toys I've been making are resolution independent and don't have this issue during resize.

I think the Pool types work well because they're much more efficient than creating new resources each time one is needed, but there should be some new API that manages the total supply of resources within given limits. ~Right now only an individual bucket of resources (of the same dimensions/settings) is kept to a reasonable number.~

I will create a PR soon with some ideas, and I am glad you enjoy Screen-13!

attackgoat commented 7 months ago

I wasn't able to repro on Ubuntu but I finally got to a Windows machine and it repro'd right away. The issue is that Swapchain::destroy is hanging for about 500ms. The previous version does not exhibit the issue.

I used OpTick profiler to debug the issue:

cargo run --example triangle --features profile-with-optick

Once I upgraded the Nvidia driver from 546.33 -> 551.23 the issue went away.

If you are on Nvidia hardware is this something you can try?

KSchala commented 7 months ago

Oh damn, should have come up with updating my drivers myself.. Now its working fine.

Sorry for wasting your time and thank you very much!