Commit ec73f889 by David Reveman Committed by Geoff Lang

Vulkan: Use 4 MB as preferredLargeHeapBlockSize for allocator.

This reduces preferredLargeHeapBlockSize from the default value of 256 MB to 4 MB, which reduces the initial block size from 32 MB to 512 KB. 4 MB is the same size as used by Chromium and Skia. It seems to be a good compromise of not wasting unused allocated space and not making too many small allocations. This change is limited to non-Qualcomm GPUs as a number of tests are failing on Qualcomm after this change and the initial investigation indicates a potential driver bug. See http://anglebug.com/4995 for more details. Bug: chromium:1122718 Bug: fuchsia:58959 Change-Id: Ifdaf863ef38e72098a04ee57dec46ee71cab6ac3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2376891Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: David Reveman <reveman@chromium.org> (cherry picked from commit 9a19a996) Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2385917Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c060d8d6
...@@ -376,6 +376,13 @@ struct FeaturesVk : FeatureSetBase ...@@ -376,6 +376,13 @@ struct FeaturesVk : FeatureSetBase
Feature enableMultisampledRenderToTexture = { Feature enableMultisampledRenderToTexture = {
"enable_multisampled_render_to_texture", FeatureCategory::VulkanWorkarounds, "enable_multisampled_render_to_texture", FeatureCategory::VulkanWorkarounds,
"Expose EXT_multisampled_render_to_texture", &members, "http://anglebug.com/4937"}; "Expose EXT_multisampled_render_to_texture", &members, "http://anglebug.com/4937"};
// Qualcomm fails some tests when reducing the preferred block size to 4M.
// http://anglebug.com/4995
Feature preferredLargeHeapBlockSize4MB = {
"preferred_large_heap_block_size_4M", FeatureCategory::VulkanWorkarounds,
"Use 4 MB preferred large heap block size with AMD allocator", &members,
"http://anglebug.com/4995"};
}; };
inline FeaturesVk::FeaturesVk() = default; inline FeaturesVk::FeaturesVk() = default;
......
...@@ -852,9 +852,19 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -852,9 +852,19 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
ANGLE_TRY(initializeDevice(displayVk, firstGraphicsQueueFamily)); ANGLE_TRY(initializeDevice(displayVk, firstGraphicsQueueFamily));
} }
VkDeviceSize preferredLargeHeapBlockSize = 0;
if (mFeatures.preferredLargeHeapBlockSize4MB.enabled)
{
// This number matches Chromium and was picked by looking at memory usage of
// Android apps. The allocator will start making blocks at 1/8 the max size
// and builds up block size as needed before capping at the max set here.
preferredLargeHeapBlockSize = 4 * 1024 * 1024;
}
// Create VMA allocator // Create VMA allocator
ANGLE_VK_TRY(displayVk, ANGLE_VK_TRY(displayVk,
mAllocator.init(mPhysicalDevice, mDevice, mInstance, applicationInfo.apiVersion)); mAllocator.init(mPhysicalDevice, mDevice, mInstance, applicationInfo.apiVersion,
preferredLargeHeapBlockSize));
// Store the physical device memory properties so we can find the right memory pools. // Store the physical device memory properties so we can find the right memory pools.
mMemoryProperties.init(mPhysicalDevice); mMemoryProperties.init(mPhysicalDevice);
...@@ -1855,6 +1865,8 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev ...@@ -1855,6 +1865,8 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
ANGLE_FEATURE_CONDITION(&mFeatures, enableMultisampledRenderToTexture, ANGLE_FEATURE_CONDITION(&mFeatures, enableMultisampledRenderToTexture,
!(IsApple() && isSwiftShader)); !(IsApple() && isSwiftShader));
ANGLE_FEATURE_CONDITION(&mFeatures, preferredLargeHeapBlockSize4MB, !isQualcomm);
angle::PlatformMethods *platform = ANGLEPlatformCurrent(); angle::PlatformMethods *platform = ANGLEPlatformCurrent();
platform->overrideFeaturesVk(platform, &mFeatures); platform->overrideFeaturesVk(platform, &mFeatures);
......
...@@ -17,6 +17,7 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice, ...@@ -17,6 +17,7 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice,
VkDevice device, VkDevice device,
VkInstance instance, VkInstance instance,
uint32_t apiVersion, uint32_t apiVersion,
VkDeviceSize preferredLargeHeapBlockSize,
VmaAllocator *pAllocator) VmaAllocator *pAllocator)
{ {
VmaVulkanFunctions funcs = {}; VmaVulkanFunctions funcs = {};
...@@ -55,12 +56,13 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice, ...@@ -55,12 +56,13 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice,
funcs.vkGetPhysicalDeviceMemoryProperties2KHR = vkGetPhysicalDeviceMemoryProperties2KHR; funcs.vkGetPhysicalDeviceMemoryProperties2KHR = vkGetPhysicalDeviceMemoryProperties2KHR;
} }
VmaAllocatorCreateInfo allocatorInfo = {}; VmaAllocatorCreateInfo allocatorInfo = {};
allocatorInfo.physicalDevice = physicalDevice; allocatorInfo.physicalDevice = physicalDevice;
allocatorInfo.device = device; allocatorInfo.device = device;
allocatorInfo.instance = instance; allocatorInfo.instance = instance;
allocatorInfo.pVulkanFunctions = &funcs; allocatorInfo.pVulkanFunctions = &funcs;
allocatorInfo.vulkanApiVersion = apiVersion; allocatorInfo.vulkanApiVersion = apiVersion;
allocatorInfo.preferredLargeHeapBlockSize = preferredLargeHeapBlockSize;
return vmaCreateAllocator(&allocatorInfo, pAllocator); return vmaCreateAllocator(&allocatorInfo, pAllocator);
} }
......
...@@ -21,6 +21,7 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice, ...@@ -21,6 +21,7 @@ VkResult InitAllocator(VkPhysicalDevice physicalDevice,
VkDevice device, VkDevice device,
VkInstance instance, VkInstance instance,
uint32_t apiVersion, uint32_t apiVersion,
VkDeviceSize preferredLargeHeapBlockSize,
VmaAllocator *pAllocator); VmaAllocator *pAllocator);
void DestroyAllocator(VmaAllocator allocator); void DestroyAllocator(VmaAllocator allocator);
......
...@@ -469,7 +469,8 @@ class Allocator : public WrappedObject<Allocator, VmaAllocator> ...@@ -469,7 +469,8 @@ class Allocator : public WrappedObject<Allocator, VmaAllocator>
VkResult init(VkPhysicalDevice physicalDevice, VkResult init(VkPhysicalDevice physicalDevice,
VkDevice device, VkDevice device,
VkInstance instance, VkInstance instance,
uint32_t apiVersion); uint32_t apiVersion,
VkDeviceSize preferredLargeHeapBlockSize);
// Initializes the buffer handle and memory allocation. // Initializes the buffer handle and memory allocation.
VkResult createBuffer(const VkBufferCreateInfo &bufferCreateInfo, VkResult createBuffer(const VkBufferCreateInfo &bufferCreateInfo,
...@@ -1394,10 +1395,12 @@ ANGLE_INLINE void Allocator::destroy() ...@@ -1394,10 +1395,12 @@ ANGLE_INLINE void Allocator::destroy()
ANGLE_INLINE VkResult Allocator::init(VkPhysicalDevice physicalDevice, ANGLE_INLINE VkResult Allocator::init(VkPhysicalDevice physicalDevice,
VkDevice device, VkDevice device,
VkInstance instance, VkInstance instance,
uint32_t apiVersion) uint32_t apiVersion,
VkDeviceSize preferredLargeHeapBlockSize)
{ {
ASSERT(!valid()); ASSERT(!valid());
return vma::InitAllocator(physicalDevice, device, instance, apiVersion, &mHandle); return vma::InitAllocator(physicalDevice, device, instance, apiVersion,
preferredLargeHeapBlockSize, &mHandle);
} }
ANGLE_INLINE VkResult Allocator::createBuffer(const VkBufferCreateInfo &bufferCreateInfo, ANGLE_INLINE VkResult Allocator::createBuffer(const VkBufferCreateInfo &bufferCreateInfo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment