Fixed main memory type selection algorithm for Raspberry Pi

In function FindMemoryPreferences, not requiring HOST_CACHED memory, as some platforms may not have it. See #362 - thanks @cos-public
This commit is contained in:
Adam Sawicki 2023-08-22 13:13:09 +02:00
parent 6cc9fcf66b
commit e88fff957b

View File

@ -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. // CPU random access - e.g. a buffer written to or transferred from GPU to read back on CPU.
if(hostAccessRandom) if(hostAccessRandom)
{ {
// 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) if (!isIntegratedGPU && deviceAccess && hostAccessAllowTransferInstead && !preferHost)
{ {
// Nice if it will end up in HOST_VISIBLE, but more importantly prefer DEVICE_LOCAL. // Nice if it will end up in HOST_VISIBLE, but more importantly prefer DEVICE_LOCAL.
// Omitting HOST_VISIBLE here is intentional. // Omitting HOST_VISIBLE here is intentional.
// In case there is DEVICE_LOCAL | HOST_VISIBLE | HOST_CACHED, it will pick that one. // 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. // 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 else
{ {
// Always CPU memory, cached. // Always CPU memory.
outRequiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; outRequiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
} }
} }
// CPU sequential write - may be CPU or host-visible GPU memory, uncached and write-combined. // CPU sequential write - may be CPU or host-visible GPU memory, uncached and write-combined.