From 662723ec7b4f7cbb74700c282a2b06054a457b83 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 14 Feb 2024 14:49:40 -0800 Subject: [PATCH] Add a comment explaining the lifecycle of `tls_command_pool_map`. (flutter/engine#50623) Partial work towards https://github.com/flutter/flutter/issues/142083. Still investigating a fix. --- .../impeller/renderer/backend/vulkan/command_pool_vk.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc index 7bcbb0ae1c..9bb3d9d898 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc @@ -158,6 +158,15 @@ void CommandPoolVK::Destroy() { // Associates a resource with a thread and context. using CommandPoolMap = std::unordered_map>; + +// CommandPoolVK Lifecycle: +// 1. End of frame will reset the command pool (clearing this on a thread). +// There will still be references to the command pool from the uncompleted +// command buffers. +// 2. The last reference to the command pool will be released from the fence +// waiter thread, which will schedule a task on the resource +// manager thread, which in turn will reset the command pool and make it +// available for reuse ("recycle"). static thread_local std::unique_ptr tls_command_pool_map; // Map each context to a list of all thread-local command pools associated