New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible invalid synchronization #276
Comments
I do not believe this is a synchronization issue because the fence that is waited on in step 7 guarantees that the rfSem has signaled. The spec line quoted indicates that its fine to use a semaphore if it will be unsignaled by the time it is waited on. The issue is that there is no Vulkan 1.0 mechanism to query whether a swapchain image is finished being presented on except for getting the same swapchain image index again. Since this chapter is trying to introduce synchronization, I wanted it to be as simple as possible. Does the following chapter (where multiple frames in flight are introduced) have the same issue? If so that would be the place to fix it in my opinion. |
And is there a mechanism that ensures it will be unsignaled by that time? At the time of the call to
As far as I can tell, when setting |
From my understanding the reason why it works is because of the use of a single queue. Essentially the queue forward progress guarantees make this synchronization work. However I am not an expert on this subject and don't have a stronger answer for why it works. |
I have only just now looked into this, so I may not understand this fully, but judging from this comment to fix this issue, you need to use |
Yes, that is actually the provably more correct solution. The core of the issue is that this is currently a 'underspecified' part of the spec, or at least without the VK_EXT_present_wait extension that has limited support. So while on most drivers this works just fine, it would be good to improve the text with that change. Not a very satisfactory answer, but WSI in vulkan is not a good API and the people who wrote it know that. |
FYI, I have put up a modified version of the code that fixes this as well. |
It seems to me that the following sequence of events could happen in
15_hello_triangle.cpp
:drawFrame(F1)
[]
wait(fence)
[]
acquire(signal=iaSem)
[]
T1 = submit(F1, wait=iaSem, signal=rfSem,fence
)[T1]
T2 = present(F1, wait=rfSem)
[T1, T2]
drawFrame(F2)
[T1, T2]
wait(fence)
[T1, T2]
T1
(signalrfSem
/fence
)[T2]
acquire(signal=iaSem)
[T2]
T3 = submit(F2, wait=iaSem, signal=rfSem,fence
)[T2, T3]
In step10,
vkQueueSubmit
is called withrenderFinishedSemaphore
to signal which is already in the signaled state (signaled in step 8 and not yet unsignaled by the GPU). This seems illegal according to the spec:Is the some implicit synchronization mechanism that ensures that
T2
already started (and hence waited on/unsignaledrenderFinishedSemaphore
) at this point or is it actually invalid?The text was updated successfully, but these errors were encountered: