5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_POOL_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_COMMAND_POOL_VK_H_
15#include "vulkan/vulkan_handles.hpp"
20class CommandPoolRecyclerVK;
42 std::vector<vk::UniqueCommandBuffer>&& buffers,
43 std::weak_ptr<ContextVK> context,
44 std::weak_ptr<DeviceHolderVK> device_holder)
45 : pool_(
std::move(pool)),
46 unused_command_buffers_(
std::move(buffers)),
47 context_(
std::move(context)),
48 device_holder_(
std::move(device_holder)) {}
76 std::vector<vk::UniqueCommandBuffer> unused_command_buffers_;
77 std::weak_ptr<ContextVK> context_;
78 std::weak_ptr<DeviceHolderVK> device_holder_;
81 std::vector<vk::UniqueCommandBuffer> collected_buffers_
110 :
public std::enable_shared_from_this<CommandPoolRecyclerVK> {
130 std::shared_ptr<CommandPoolVK>
Get();
137 void Reclaim(vk::UniqueCommandPool&& pool,
138 std::vector<vk::UniqueCommandBuffer>&& buffers,
139 bool should_trim =
false);
148 std::weak_ptr<ContextVK> context_;
149 uint64_t context_hash_;
151 Mutex recycled_mutex_;
157 std::optional<CommandPoolRecyclerVK::RecycledData> Create();
162 std::optional<RecycledData> Reuse();
Creates and manages the lifecycle of |vk::CommandPool| objects.
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, std::weak_ptr< DeviceHolderVK > device_holder)
Creates a resource that manages the life of a command pool.
void CollectCommandBuffer(vk::UniqueCommandBuffer &&buffer)
Collects the given |vk::CommandBuffer| to be retained.
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
#define IPLR_GUARDED_BY(x)