Allow turning a shared lock into an exclusive lock #704
Open
Description
Let's say that you submit a command buffer that reads from buffer A. Then you submit another command buffer that writes to buffer A.
What happens is that vulkano will lock the first command buffer, which is done by locking buffer A for reading.
Then vulkano will try to lock the second command buffer. This is done by asking the first command buffer whether it has exclusive access to that buffer, to which the answer is no as it only has shared access. Therefore vulkano will then try to lock the buffer for writing, which will fail because it is already locked for reading.
Conclusion: this scenario is forbidden by vulkano right now, even though it should be allowed.
I think there should be two changes:
- Add a way for a command buffer to return "I only have shared access to this resource".
- Add an "upgrade_lock" method on buffers and images that turns a shared lock into an exclusive lock if possible. This function only succeeds if there's only one active shared lock.