mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Fix heap flags check in Vulkan Allocator and add heap flags check to VMA Allocator
(cherry picked from commit 488f8d27616570029de9429cf4794886f6d209e1)
This commit is contained in:
parent
e4021513d1
commit
96da1f3eed
2 changed files with 24 additions and 5 deletions
|
@ -78,13 +78,13 @@ uint32 FindMemoryTypeIndex( const uint32 memoryTypeBits, const vulkanMemoryUsage
|
|||
case VULKAN_MEMORY_USAGE_CPU_TO_GPU:
|
||||
required |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
preferred |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
// SRS - Make sure preferred memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
// SRS - Make sure memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
avoid |= VK_MEMORY_HEAP_MULTI_INSTANCE_BIT;
|
||||
break;
|
||||
case VULKAN_MEMORY_USAGE_GPU_TO_CPU:
|
||||
required |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
preferred |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
// SRS - Make sure preferred memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
// SRS - Make sure memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
avoid |= VK_MEMORY_HEAP_MULTI_INSTANCE_BIT;
|
||||
break;
|
||||
default:
|
||||
|
@ -98,14 +98,19 @@ uint32 FindMemoryTypeIndex( const uint32 memoryTypeBits, const vulkanMemoryUsage
|
|||
continue;
|
||||
}
|
||||
|
||||
// SRS - Make sure memory type does not have any avoid heap flags set
|
||||
if( ( physicalMemoryProperties.memoryHeaps[ physicalMemoryProperties.memoryTypes[ i ].heapIndex ].flags & avoid ) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const VkMemoryPropertyFlags properties = physicalMemoryProperties.memoryTypes[ i ].propertyFlags;
|
||||
if( ( properties & required ) != required )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// SRS - Make sure preferred memory type does not have any avoid heap flags set
|
||||
if( ( properties & preferred ) != preferred || ( physicalMemoryProperties.memoryHeaps[ i ].flags & avoid ) != 0 )
|
||||
if( ( properties & preferred ) != preferred )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -120,6 +125,12 @@ uint32 FindMemoryTypeIndex( const uint32 memoryTypeBits, const vulkanMemoryUsage
|
|||
continue;
|
||||
}
|
||||
|
||||
// SRS - Make sure memory type does not have any avoid heap flags set
|
||||
if( ( physicalMemoryProperties.memoryHeaps[ physicalMemoryProperties.memoryTypes[ i ].heapIndex ].flags & avoid ) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const VkMemoryPropertyFlags properties = physicalMemoryProperties.memoryTypes[ i ].propertyFlags;
|
||||
if( ( properties & required ) != required )
|
||||
{
|
||||
|
|
|
@ -5231,6 +5231,7 @@ VkResult vmaFindMemoryTypeIndex(
|
|||
|
||||
uint32_t requiredFlags = pMemoryRequirements->requiredFlags;
|
||||
uint32_t preferredFlags = pMemoryRequirements->preferredFlags;
|
||||
uint32_t avoidFlags = 0;
|
||||
if( preferredFlags == 0 )
|
||||
{
|
||||
preferredFlags = requiredFlags;
|
||||
|
@ -5252,10 +5253,14 @@ VkResult vmaFindMemoryTypeIndex(
|
|||
case VMA_MEMORY_USAGE_CPU_TO_GPU:
|
||||
requiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
preferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
// SRS - Make sure memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
avoidFlags |= VK_MEMORY_HEAP_MULTI_INSTANCE_BIT;
|
||||
break;
|
||||
case VMA_MEMORY_USAGE_GPU_TO_CPU:
|
||||
requiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
preferredFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
// SRS - Make sure memory type does not have VK_MEMORY_HEAP_MULTI_INSTANCE_BIT set, otherwise get validation errors when mapping memory
|
||||
avoidFlags |= VK_MEMORY_HEAP_MULTI_INSTANCE_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -5277,8 +5282,11 @@ VkResult vmaFindMemoryTypeIndex(
|
|||
{
|
||||
const VkMemoryPropertyFlags currFlags =
|
||||
allocator->m_MemProps.memoryTypes[memTypeIndex].propertyFlags;
|
||||
const VkMemoryHeapFlags heapFlags =
|
||||
allocator->m_MemProps.memoryHeaps[allocator->m_MemProps.memoryTypes[memTypeIndex].heapIndex].flags;
|
||||
// This memory type contains requiredFlags.
|
||||
if( ( requiredFlags & ~currFlags ) == 0 )
|
||||
// SRS - and does not contain any heap avoidFlags
|
||||
if( ( requiredFlags & ~currFlags ) == 0 && ( avoidFlags & heapFlags ) == 0 )
|
||||
{
|
||||
// Calculate cost as number of bits from preferredFlags not present in this memory type.
|
||||
uint32_t currCost = CountBitsSet( preferredFlags & ~currFlags );
|
||||
|
|
Loading…
Reference in a new issue