Fix deadlock on swapchain recreation#250
Conversation
|
Not sure about this. I don't think the code does deadlock, also see #246, which is reworking the fence setup. |
I was able to reproduce the deadlock (on a linux build) in the original attachment examples (e.g. attachments/17_swap_chain_recreation.cpp) The deadlock occurs when you resize the window, as explained in the documentation.
I wonder in your rework @SaschaWillems if you resize the window, does it hang until the timeout is reached then throws an exception? (Not a deadlock, but still not the idea case?) since It may appear like a deadock if the timeout is |
|
Nope. Not seeing that issue here on windows. |
I can reproduce in the following case only, and it is entirely dependent on the Build attachments Run 17_swap_chain_recreation If GPU device is discrete GPU, the hang occurs If GPU is not discrete device (I modified For me, this means: So the case seems driver dependent (maybe not necessarily platform e.g. Linux vs. Windows) |
|
In either case, the changes match the tutorial documentation - unless I misunderstand it?
|
|
That's one of the biggest problems with the tutorial right now. The documentation and the code aren't matching in many places, and fixing that is kinda hard. Pinging @gpx1000, as he might have ideas on how to fix all of this. |
|
Thanks @SaschaWillems Agreed - I haven't updated the literal code in the docs, but at least the instruction to not call |
|
Taking a second look I think I can see how the current code can lead to such a deadlock and I think your PR is correct. We'll merge #246 first, as that also contains other fixes and changes to the documentation. Will review your PR afterwards. |
|
#246 has been merged. Can you fix the merge conflicts? Will review afterwards. |
195264d to
5be959d
Compare
|
@SaschaWillems I have now rebased and resolved the conflicts |
SaschaWillems
left a comment
There was a problem hiding this comment.
Thanks. Very much appreciated.
Can't provoke out of date on Windows, but code looks good and matches the documentation.
Thanks for your help @SaschaWillems I found the tutorials very useful in general. I don't have a lot of spare time, but I'd like to keep contributing where I can, especially updating some of the written sections. I don't have permissions to merge, if someone could do that please :) |
I'm working through the Vulkan tutorial and noticed the following.
In the deadlock section: https://docs.vulkan.org/tutorial/latest/03_Drawing_a_triangle/04_Swap_chain_recreation.html#_fixing_a_deadlock
It gives the example of a deadlock where the device fence is reset and the
drawFramefunction is exited early. On the next call todrawFrame, the call towaitForFencesnever returns, as the fence is left in an unsignaled state without anything to signal it.The tutorial docs seem correct in that explanation, but the C++ code attachment still has the deadlock condition.
This fixes the C++ attachments where I was able to find the deadlocking code still present.
Now we reset the fence when we are ready to use it. The location was chosen to match attachments where the deadlock does not appear, or was already in the right location.