GenericMemoryAllocatorCreateInfo set prefers_dedicated_allocation to false if dedicated_allocation is false #2214
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.
If GenericMemoryAllocator was created with dedicated_allocation = false, then the prefers_dedicated_allocation from the buffer memory requirements will be set to false. This seems like expected behavior given the docs for GenericMemoryAllocatorCreateInfo:
"
dedicated_allocation: bool
Whether the allocator should use the dedicated allocation APIs.
This means that when the allocator decides that an allocation should not be suballocated, but rather have its own block of DeviceMemory, that that allocation will be made a dedicated allocation. Otherwise they are still made free-standing (root) allocations, just not dedicated ones.
Dedicated allocations are an optimization which may result in better performance, so there really is no reason to disable this option, unless the restrictions that they bring with them are a problem. Namely, a dedicated allocation must only be used for the resource it was created for. Meaning that reusing the memory for something else is not possible, suballocating it is not possible, and aliasing it is also not possible.
This option is silently ignored (treated as false) if the device API version is below 1.1 and the khr_dedicated_allocation extension is not enabled on the device.
The default value is true.
"
This change keeps current behavior of using a dedicated allocation if required or as a fallback. The docs imply imo that dedicated allocations won't be used if false, so potentially the docs could be clarified or the behavior modified more drastically.
Note that dedicated allocations can be really expensive (because they can't be reused) and undermine the utility of the allocator, so at least allowing the user to opt out can dramatically improve performance when dynamically allocating in a hot loop.