Implement new locking for UnsafeBuffer
and UnsafeImage
#1860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog:
This adds new and better resource locking for buffers and images. Locking is performed in
UnsafeBuffer
andUnsafeImage
instead of in the individual "safe" types, so if multiple safe types share a common buffer/image, the locking still works properly. The locks for buffers are now granular at the byte level, so it is possible to lock one range of a buffer while leaving other ranges untouched. For images the same thing applies, but it is granular at the level of aspect/mip level/array layer.To make this possible, I've had to use an existing crate,
rangemap
, and make changes to it so that it would fit Vulkano's needs. This PR uses a fork ofrangemap
on my personal repository, which is probably ok for now but needs a better solution in the long term (before 0.30 is released anyway). It could be merged fully into Vulkano, but then its git history will be lost. @AustinJ235 proposed making it a repository under the Vulkano project, which is also a possibility.This PR is the first in what will be a series of PRs tackling different parts of Vulkano's synchronization. For that reason, I have not included all changes in the changelog entries: things are not yet in the final state and will probably change again before the next release. It is also quite likely that some things don't work properly at the moment. The
texture_array
example crashes, but I know what the cause is and it should be fixed in one of the followup PRs.