Reland "Update VMA to latest version."

This is a reland of commit f33cf451a2

Original change's description:
> Update VMA to latest version.
>
> This is needed so that we can use non skia supplied vk_mem_alloc.h on
> clients that have already updated to newest version. As we transition
> to Bazel builds this helps to make it so we can set the rules for
> specific clients around VMA without things breaking
>
> Bug: skia:13211
> Change-Id: I5d38a3a91a44f6b3fdf75894a3248ee3991dd5d9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531157
> Reviewed-by: Kevin Lubick <kjlubick@google.com>

Bug: skia:13211
Change-Id: Ia4a863819a7d0bb4763f1b516acfa1cc76c47a8a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531548
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2022-04-19 17:22:28 -04:00
parent 163a7eaf10
commit 2cf8e9b602
3 changed files with 19622 additions and 19042 deletions

View File

@ -36,6 +36,10 @@ sk_sp<GrVkMemoryAllocator> GrVkAMDMemoryAllocator::Make(VkInstance instance,
#define GR_COPY_FUNCTION_KHR(NAME) functions.vk##NAME##KHR = interface->fFunctions.f##NAME
VmaVulkanFunctions functions;
// We don't use dynamic function getting in the allocator so we set the getProc functions to
// null.
functions.vkGetInstanceProcAddr = nullptr;
functions.vkGetDeviceProcAddr = nullptr;
GR_COPY_FUNCTION(GetPhysicalDeviceProperties);
GR_COPY_FUNCTION(GetPhysicalDeviceMemoryProperties);
GR_COPY_FUNCTION(AllocateMemory);
@ -76,12 +80,13 @@ sk_sp<GrVkMemoryAllocator> GrVkAMDMemoryAllocator::Make(VkInstance instance,
info.preferredLargeHeapBlockSize = 4*1024*1024;
info.pAllocationCallbacks = nullptr;
info.pDeviceMemoryCallbacks = nullptr;
info.frameInUseCount = 0;
info.pHeapSizeLimit = nullptr;
info.pVulkanFunctions = &functions;
info.pRecordSettings = nullptr;
info.instance = instance;
info.vulkanApiVersion = physicalDeviceVersion;
// TODO: Update our interface and headers to support vulkan 1.3 and add in the new required
// functions for 1.3 that the allocator needs. Until then we just clamp the version to 1.1.
info.vulkanApiVersion = std::min(physicalDeviceVersion, VK_MAKE_VERSION(1, 1, 0));
info.pTypeExternalMemoryHandleTypes = nullptr;
VmaAllocator allocator;
vmaCreateAllocator(&info, &allocator);
@ -265,15 +270,15 @@ VkResult GrVkAMDMemoryAllocator::invalidateMemory(const GrVkBackendMemory& memor
}
uint64_t GrVkAMDMemoryAllocator::totalUsedMemory() const {
VmaStats stats;
vmaCalculateStats(fAllocator, &stats);
return stats.total.usedBytes;
VmaTotalStatistics stats;
vmaCalculateStatistics(fAllocator, &stats);
return stats.total.statistics.allocationBytes;
}
uint64_t GrVkAMDMemoryAllocator::totalAllocatedMemory() const {
VmaStats stats;
vmaCalculateStats(fAllocator, &stats);
return stats.total.usedBytes + stats.total.unusedBytes;
VmaTotalStatistics stats;
vmaCalculateStatistics(fAllocator, &stats);
return stats.total.statistics.blockBytes;
}
#endif // SK_USE_VMA

View File

@ -16,6 +16,19 @@
#ifndef VULKAN_CORE_H_
#error "vulkan_core.h has not been included before trying to include the GrVulkanMemoryAllocator"
#endif
// vk_mem_alloc.h checks to see if VULKAN_H_ has been included before trying to include vulkan.h.
// However, some builds of Skia may not have access to vulkan.h and just have access to
// vulkan_core.h. So we pretend we've already included vulkan.h (if it already hasn't been) which
// will be fine for building internal skia files. If we do fake it out by defining VULKAN_H_ we
// need to make sure to undefine it incase outside client code does later try to include the
// real vulkan.h
#ifndef VULKAN_H_
#define VULKAN_H_
#define GR_NEEDED_TO_DEFINE_VULKAN_H
#endif
#include "include/vk_mem_alloc.h"
#ifdef GR_NEEDED_TO_DEFINE_VULKAN_H
#undef VULKAN_H_
#endif
#endif

File diff suppressed because it is too large Load Diff