Fix: Out-of-boounds memory type index allocation for discrete GPUs#84
Merged
Conversation
…ory heaps; updated vulkan-cpp version to 6.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue Overview
The way vulkan-cpp allows for specifying for memory allocations is managed by the
vk::physical_deviceto retrieve the bit masks of the available memory properties. The physical device to determine the capabilities themask to determine where resources should live in.On
integratedphysical device types, these masks overlap. Whereas on discrete physical device types have a varied different memory type and heap configurations.Which caused cases where the buffers memory requirements and the requested device property mask had no common bits.
std::countr_zerocaused to return 32.32to the VulkanvkAllocateMemoryAPIs.Fixes
To fix this, I added a fallback to handle such edge case for specifying
std::countr_zeroand passing in the memoryTypeBits provided by the buffer memory requirements.The fallback will evaluate the supported memory indexes and choose the first bit that represents the available supported memory index for allocation for the specific device type.