diff options
| author | Robin Kertels <robin.kertels@gmail.com> | 2022-10-08 00:01:42 +0200 |
|---|---|---|
| committer | Robin Kertels <robin.kertels@gmail.com> | 2022-10-23 03:21:29 +0200 |
| commit | aa1679f2c7428720d6ded0c69668311b552c60d4 (patch) | |
| tree | 11b9a5fb596eba6447d67753ba923f16854019cd /Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | |
| parent | 1ba58e83cafaeefee8cb968ad6789ac7d3fc3060 (diff) | |
VideoBackends:Vulkan: Clean up unused memory allocation code
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/VulkanContext.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 6df7ed3414..4d6b5c8903 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -792,109 +792,6 @@ void VulkanContext::DisableDebugReports() } } -std::optional<u32> VulkanContext::GetMemoryType(u32 bits, VkMemoryPropertyFlags properties, - bool strict, bool* is_coherent) -{ - static constexpr u32 ALL_MEMORY_PROPERTY_FLAGS = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - VK_MEMORY_PROPERTY_HOST_CACHED_BIT; - - const u32 mask = strict ? ALL_MEMORY_PROPERTY_FLAGS : properties; - - for (u32 i = 0; i < VK_MAX_MEMORY_TYPES; i++) - { - if ((bits & (1 << i)) != 0) - { - const VkMemoryPropertyFlags type_flags = - m_device_memory_properties.memoryTypes[i].propertyFlags; - const VkMemoryPropertyFlags supported = type_flags & mask; - if (supported == properties) - { - if (is_coherent) - *is_coherent = (type_flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0; - return i; - } - } - } - - return std::nullopt; -} - -u32 VulkanContext::GetUploadMemoryType(u32 bits, bool* is_coherent) -{ - static constexpr VkMemoryPropertyFlags COHERENT_FLAGS = - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - - // Try for coherent memory. Some drivers (looking at you, Adreno) have the cached type before the - // uncached type, so use a strict check first. - std::optional<u32> type_index = GetMemoryType(bits, COHERENT_FLAGS, true, is_coherent); - if (type_index) - return type_index.value(); - - // Try for coherent memory, with any other bits set. - type_index = GetMemoryType(bits, COHERENT_FLAGS, false, is_coherent); - if (type_index) - { - WARN_LOG_FMT(VIDEO, - "Strict check for upload memory properties failed, this may affect performance"); - return type_index.value(); - } - - // Fall back to non-coherent memory. - WARN_LOG_FMT( - VIDEO, - "Vulkan: Failed to find a coherent memory type for uploads, this will affect performance."); - type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent); - if (type_index) - return type_index.value(); - - // Shouldn't happen, there should be at least one host-visible heap. - PanicAlertFmt("Unable to get memory type for upload."); - return 0; -} - -u32 VulkanContext::GetReadbackMemoryType(u32 bits, bool* is_coherent) -{ - std::optional<u32> type_index; - - // Mali driver appears to be significantly slower for readbacks when using cached memory. - if (DriverDetails::HasBug(DriverDetails::BUG_SLOW_CACHED_READBACK_MEMORY)) - { - type_index = GetMemoryType( - bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, true, - is_coherent); - if (type_index) - return type_index.value(); - } - - // Optimal config uses cached+coherent. - type_index = - GetMemoryType(bits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, - true, is_coherent); - if (type_index) - return type_index.value(); - - // Otherwise, prefer cached over coherent if we must choose one. - type_index = - GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, - false, is_coherent); - if (type_index) - return type_index.value(); - - WARN_LOG_FMT(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect " - "performance."); - type_index = GetMemoryType(bits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, false, is_coherent); - *is_coherent = false; - if (type_index) - return type_index.value(); - - // We should have at least one host visible memory type... - PanicAlertFmt("Unable to get memory type for upload."); - return 0; -} - bool VulkanContext::SupportsDeviceExtension(const char* name) const { return std::any_of(m_device_extensions.begin(), m_device_extensions.end(), |
