Revert "Vulkan: Adding custom pool allocator"
This reverts commit 05459e06fde5047ae8f5f90fe091c3255e6bc88e.
Reason for revert: Clusterfuzz bugs flagged this commit
Original change's description:
> Vulkan: Adding custom pool allocator
>
> Copied pool allocator used by compiler to common and hooking it up as
> custom allocator for CommandPools. Modified it to support reallocation.
>
> RendererVk now has a private poolAllocator and VkAllocationCallbacks
> struct. The allocation callbacks are initialized to static functions
> in RendererVk::initializeDevice() and then passed to CommandPool init()
> and destroy() functions.
>
> Using the pool allocator saves Command Pool/Buffer clean-up time which
> was showing us as a bottleneck is some cases.
>
> Bug: angleproject:2951
> Change-Id: I81aa8a7ec60397676fa722d6435029db27947ef4
> Reviewed-on: https://chromium-review.googlesource.com/c/1409867
> Commit-Queue: Tobin Ehlis <tobine@google.com>
> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>
TBR=jmadill@chromium.org,tobine@google.com,ianelliott@google.com,syoussefi@chromium.org
Change-Id: I363a351667c4dddef79833061790da90de477e70
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: angleproject:2951
Reviewed-on: https://chromium-review.googlesource.com/c/1430679
Reviewed-by: Tobin Ehlis <tobine@google.com>
Commit-Queue: Tobin Ehlis <tobine@google.com>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 8916ad1..912a0dd 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -458,54 +458,6 @@
// Initially dumping the command graphs is disabled.
constexpr bool kEnableCommandGraphDiagnostics = false;
-// Custom allocation functions
-VKAPI_ATTR void *VKAPI_CALL PoolAllocationFunction(void *pUserData,
- size_t size,
- size_t alignment,
- VkSystemAllocationScope allocationScope)
-{
- angle::PoolAllocator *poolAllocator = static_cast<angle::PoolAllocator *>(pUserData);
-
- ASSERT((angle::PoolAllocator::kDefaultAlignment % alignment) == 0);
- return poolAllocator->allocate(size);
-}
-
-VKAPI_ATTR void *VKAPI_CALL PoolReallocationFunction(void *pUserData,
- void *pOriginal,
- size_t size,
- size_t alignment,
- VkSystemAllocationScope allocationScope)
-{
- angle::PoolAllocator *poolAllocator = static_cast<angle::PoolAllocator *>(pUserData);
- return poolAllocator->reallocate(pOriginal, size);
-}
-
-VKAPI_ATTR void VKAPI_CALL PoolFreeFunction(void *pUserData, void *pMemory) {}
-
-VKAPI_ATTR void VKAPI_CALL
-PoolInternalAllocationNotification(void *pUserData,
- size_t size,
- VkInternalAllocationType allocationType,
- VkSystemAllocationScope allocationScope)
-{}
-
-VKAPI_ATTR void VKAPI_CALL PoolInternalFreeNotification(void *pUserData,
- size_t size,
- VkInternalAllocationType allocationType,
- VkSystemAllocationScope allocationScope)
-{}
-
-void InitPoolAllocationCallbacks(angle::PoolAllocator *poolAllocator,
- VkAllocationCallbacks *allocationCallbacks)
-{
- allocationCallbacks->pUserData = static_cast<void *>(poolAllocator);
- allocationCallbacks->pfnAllocation = &PoolAllocationFunction;
- allocationCallbacks->pfnReallocation = &PoolReallocationFunction;
- allocationCallbacks->pfnFree = &PoolFreeFunction;
- allocationCallbacks->pfnInternalAllocation = &PoolInternalAllocationNotification;
- allocationCallbacks->pfnInternalFree = &PoolInternalFreeNotification;
-}
-
} // anonymous namespace
// CommandBatch implementation.
@@ -514,25 +466,20 @@
RendererVk::CommandBatch::~CommandBatch() = default;
RendererVk::CommandBatch::CommandBatch(CommandBatch &&other)
- : commandPool(std::move(other.commandPool)),
- poolAllocator(std::move(other.poolAllocator)),
- fence(std::move(other.fence)),
- serial(other.serial)
+ : commandPool(std::move(other.commandPool)), fence(std::move(other.fence)), serial(other.serial)
{}
RendererVk::CommandBatch &RendererVk::CommandBatch::operator=(CommandBatch &&other)
{
std::swap(commandPool, other.commandPool);
- std::swap(poolAllocator, other.poolAllocator);
std::swap(fence, other.fence);
std::swap(serial, other.serial);
return *this;
}
-void RendererVk::CommandBatch::destroy(VkDevice device,
- const VkAllocationCallbacks *allocationCallbacks)
+void RendererVk::CommandBatch::destroy(VkDevice device)
{
- commandPool.destroy(device, allocationCallbacks);
+ commandPool.destroy(device);
fence.destroy(device);
}
@@ -588,7 +535,7 @@
if (mCommandPool.valid())
{
- mCommandPool.destroy(mDevice, &mAllocationCallbacks);
+ mCommandPool.destroy(mDevice);
}
if (mDevice)
@@ -930,14 +877,13 @@
vkGetDeviceQueue(mDevice, mCurrentQueueFamilyIndex, 0, &mQueue);
- InitPoolAllocationCallbacks(&mPoolAllocator, &mAllocationCallbacks);
// Initialize the command pool now that we know the queue family index.
VkCommandPoolCreateInfo commandPoolInfo = {};
commandPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
commandPoolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
- ANGLE_VK_TRY(displayVk, mCommandPool.init(mDevice, commandPoolInfo, &mAllocationCallbacks));
+ ANGLE_VK_TRY(displayVk, mCommandPool.init(mDevice, commandPoolInfo));
// Initialize the vulkan pipeline cache.
ANGLE_TRY(initPipelineCache(displayVk));
@@ -1290,7 +1236,7 @@
ASSERT(status == VK_SUCCESS || status == VK_ERROR_DEVICE_LOST);
}
batch.fence.destroy(mDevice);
- batch.commandPool.destroy(mDevice, &mAllocationCallbacks);
+ batch.commandPool.destroy(mDevice);
}
mInFlightCommands.clear();
@@ -1320,7 +1266,7 @@
mLastCompletedQueueSerial = batch.serial;
batch.fence.destroy(mDevice);
- batch.commandPool.destroy(mDevice, &mAllocationCallbacks);
+ batch.commandPool.destroy(mDevice);
++finishedCount;
}
@@ -1351,7 +1297,7 @@
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.flags = 0;
- vk::ScopedCustomAllocation<CommandBatch> scopedBatch(mDevice, &mAllocationCallbacks);
+ vk::Scoped<CommandBatch> scopedBatch(mDevice);
CommandBatch &batch = scopedBatch.get();
ANGLE_VK_TRY(context, batch.fence.init(mDevice, fenceInfo));
@@ -1359,7 +1305,6 @@
// Store this command buffer in the in-flight list.
batch.commandPool = std::move(mCommandPool);
- batch.poolAllocator = std::move(mPoolAllocator);
batch.serial = mCurrentQueueSerial;
mInFlightCommands.emplace_back(scopedBatch.release());
@@ -1384,13 +1329,12 @@
// Reallocate the command pool for next frame.
// TODO(jmadill): Consider reusing command pools.
- InitPoolAllocationCallbacks(&mPoolAllocator, &mAllocationCallbacks);
VkCommandPoolCreateInfo poolInfo = {};
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
poolInfo.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
poolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
- ANGLE_VK_TRY(context, mCommandPool.init(mDevice, poolInfo, &mAllocationCallbacks));
+ ANGLE_VK_TRY(context, mCommandPool.init(mDevice, poolInfo));
return angle::Result::Continue;
}
@@ -1733,7 +1677,7 @@
//
// Post-submission work Begin execution
//
- // ???? Write timestamp Tgpu
+ // ???? Write timstamp Tgpu
//
// ???? End execution
//