Skip to content

Commit

Permalink
Fixed main memory type selection algorithm for Raspberry Pi
Browse files Browse the repository at this point in the history
In function FindMemoryPreferences, not requiring HOST_CACHED memory, as some platforms may not have it. See #362 - thanks @cos-public
  • Loading branch information
adam-sawicki-a committed Aug 22, 2023
1 parent 6cc9fcf commit e88fff9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/vk_mem_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3704,18 +3704,21 @@ static bool FindMemoryPreferences(
// CPU random access - e.g. a buffer written to or transferred from GPU to read back on CPU.
if(hostAccessRandom)
{
if(!isIntegratedGPU && deviceAccess && hostAccessAllowTransferInstead && !preferHost)
// Prefer cached. Cannot require it, because some platforms don't have it (e.g. Raspberry Pi - see #362)!
outPreferredFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;

if (!isIntegratedGPU && deviceAccess && hostAccessAllowTransferInstead && !preferHost)
{
// Nice if it will end up in HOST_VISIBLE, but more importantly prefer DEVICE_LOCAL.
// Omitting HOST_VISIBLE here is intentional.
// In case there is DEVICE_LOCAL | HOST_VISIBLE | HOST_CACHED, it will pick that one.
// Otherwise, this will give same weight to DEVICE_LOCAL as HOST_VISIBLE | HOST_CACHED and select the former if occurs first on the list.
outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
else
{
// Always CPU memory, cached.
outRequiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
// Always CPU memory.
outRequiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
}
}
// CPU sequential write - may be CPU or host-visible GPU memory, uncached and write-combined.
Expand Down

0 comments on commit e88fff9

Please sign in to comment.