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"
19class CommandPoolRecyclerVK;
41 std::vector<vk::UniqueCommandBuffer>&& buffers,
42 std::weak_ptr<ContextVK>& context)
44 unused_command_buffers_(
std::move(buffers)),
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 : context_(
std::move(context)) {}
129 std::shared_ptr<CommandPoolVK>
Get();
135 std::vector<vk::UniqueCommandBuffer>&& buffers);
141 std::weak_ptr<ContextVK> context_;
143 Mutex recycled_mutex_;
149 std::optional<CommandPoolRecyclerVK::RecycledData> Create();
154 std::optional<RecycledData> Reuse();
Creates and manages the lifecycle of |vk::CommandPool| objects.
void Dispose()
Clears all recycled command pools to let them be reclaimed.
std::shared_ptr< CommandPoolVK > Get()
Gets a command pool for the current thread.
CommandPoolRecyclerVK(std::weak_ptr< ContextVK > context)
Creates a recycler for the given |ContextVK|.
static void DestroyThreadLocalPools(const ContextVK *context)
Clean up resources held by all per-thread command pools associated with the given context.
void Reclaim(vk::UniqueCommandPool &&pool, std::vector< vk::UniqueCommandBuffer > &&buffers)
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|.
static const uint8_t buffer[]
A unique command pool and zero or more recycled command buffers.
vk::UniqueCommandPool pool
std::vector< vk::UniqueCommandBuffer > buffers
#define IPLR_GUARDED_BY(x)