Add new safe Buffer
and Image
types containing bound memory
#2050
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 is another step towards reducing the number of buffer and image types that are needed, and also makes binding memory mostly safe. Type safety is used to ensure that
Buffer
andImage
always have memory bound to them. Once sparse binding is introduced, this will not fully be the case, since bindings can be made and unmade at any time; sparse resources will therefore require runtime checks.@marc0246 There are some considerations in this PR that may affect your memory allocator code:
disjoint
flag is added, which never allows dedicated allocations (VUID-VkMemoryDedicatedAllocateInfo-image-01797). Images that were created with this flag don't have one singleMemoryRequirements
, but rather two or three (for each plane). Thememory_requirements
method for images therefore now returns a slice. The newly introducedImageMemory
type also has a vector to hold all the allocations.MemoryRequirements
was missing therequires_dedicated_allocation
flag, which this PR adds. The allocator needs to ensure that when this flag is set, either a dedicated allocation is made or it errors out.