Fix some random crashes when using metal argument buffers #2340
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.
Commit should fix a bug with the loop iteration in
enumerateEnabledBits()
. It would jump to the first set bit, then iterate over EVERY subsequent bit, instead of only iterating over bits that were setDiscovered this after a lot of time debugging random crashes in MoltenVK 1.2.11, that would only happen with
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS
enabledWhat seemed to be happening was:
MVKDescriptorPool::allocateDescriptorSet()
would iterate over_descriptorSetAvailablility
to find an empty set, but it would check sets that weren't freed yet.If one of those got picked, the new set is initialized on top of an existing one, essentially corrupting it. Odd behavior would happen after that, and the app would eventually crash trying to use the corrupted set
These crashes could only happen when using Metal Argument buffers, and using a pool with
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT
This is a pretty simple change, so hopefully it doesn't break anything 😃