5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_POOL_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_POOL_VK_H_
14 #include "vulkan/vulkan_handles.hpp"
19 class CommandPoolRecyclerVK;
41 std::vector<vk::UniqueCommandBuffer>&& buffers,
42 std::weak_ptr<ContextVK>& context)
43 : pool_(
std::move(pool)),
44 unused_command_buffers_(
std::move(buffers)),
70 vk::UniqueCommandPool pool_ IPLR_GUARDED_BY(pool_mutex_);
71 std::vector<vk::UniqueCommandBuffer> unused_command_buffers_;
72 std::weak_ptr<ContextVK>& context_;
75 std::vector<vk::UniqueCommandBuffer> collected_buffers_ IPLR_GUARDED_BY(
104 :
public std::enable_shared_from_this<CommandPoolRecyclerVK> {
124 std::shared_ptr<CommandPoolVK>
Get();
131 void Reclaim(vk::UniqueCommandPool&& pool,
132 std::vector<vk::UniqueCommandBuffer>&& buffers,
133 bool should_trim =
false);
142 std::weak_ptr<ContextVK> context_;
143 uint64_t context_hash_;
145 Mutex recycled_mutex_;
146 std::vector<RecycledData> recycled_ IPLR_GUARDED_BY(recycled_mutex_);
151 std::optional<CommandPoolRecyclerVK::RecycledData> Create();
156 std::optional<RecycledData> Reuse();
Creates and manages the lifecycle of |vk::CommandPool| objects.
CommandPoolRecyclerVK(const std::shared_ptr< ContextVK > &context)
Creates a recycler for the given |ContextVK|.
void Dispose()
Clears this context's thread-local command pool.
static int GetGlobalPoolCount(const ContextVK &context)
std::shared_ptr< CommandPoolVK > Get()
Gets a command pool for the current thread.
void DestroyThreadLocalPools()
Clean up resources held by all per-thread command pools associated with the context.
void Reclaim(vk::UniqueCommandPool &&pool, std::vector< vk::UniqueCommandBuffer > &&buffers, bool should_trim=false)
Returns a command pool to be reset on a background thread.
Manages the lifecycle of a single |vk::CommandPool|.
CommandPoolVK(vk::UniqueCommandPool pool, std::vector< vk::UniqueCommandBuffer > &&buffers, std::weak_ptr< ContextVK > &context)
Creates a resource that manages the life of a command pool.
void CollectCommandBuffer(vk::UniqueCommandBuffer &&buffer)
Collects the given |vk::CommandBuffer| to be retained.
void Destroy()
Delete all Vulkan objects in this command pool.
vk::UniqueCommandBuffer CreateCommandBuffer()
Creates and returns a new |vk::CommandBuffer|.
A unique command pool and zero or more recycled command buffers.
vk::UniqueCommandPool pool
std::vector< vk::UniqueCommandBuffer > buffers