Creates and manages the lifecycle of |vk::CommandPool| objects. More...
#include <command_pool_vk.h>
Classes | |
struct | RecycledData |
A unique command pool and zero or more recycled command buffers. More... | |
Public Member Functions | |
void | DestroyThreadLocalPools () |
Clean up resources held by all per-thread command pools associated with the context. More... | |
CommandPoolRecyclerVK (const std::shared_ptr< ContextVK > &context) | |
Creates a recycler for the given |ContextVK|. More... | |
std::shared_ptr< CommandPoolVK > | Get () |
Gets a command pool for the current thread. More... | |
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. More... | |
void | Dispose () |
Clears this context's thread-local command pool. More... | |
Static Public Member Functions | |
static int | GetGlobalPoolCount (const ContextVK &context) |
Creates and manages the lifecycle of |vk::CommandPool| objects.
A |vk::CommandPool| is expensive to create and reset. This class manages the lifecycle of |vk::CommandPool| objects by creating and recycling them; or in other words, a pool for command pools.
A single instance should be created per |ContextVK|.
Every "frame", a single |CommandPoolResourceVk| is made available for each thread that calls |Get|. After calling |Dispose|, the current thread's pool is moved to a background thread, reset, and made available for the next time |Get| is called and needs to create a command pool.
Commands in the command pool are not necessarily done executing when the pool is recycled, when all references are dropped to the pool, they are reset and returned to the pool of available pools.
Definition at line 103 of file command_pool_vk.h.
|
explicit |
Creates a recycler for the given |ContextVK|.
[in] | context | The context to create the recycler for. |
Definition at line 179 of file command_pool_vk.cc.
void impeller::CommandPoolRecyclerVK::DestroyThreadLocalPools | ( | ) |
Clean up resources held by all per-thread command pools associated with the context.
Definition at line 305 of file command_pool_vk.cc.
References impeller::g_all_pools_map_mutex, and impeller::tls_command_pool_map.
void impeller::CommandPoolRecyclerVK::Dispose | ( | ) |
Clears this context's thread-local command pool.
Definition at line 290 of file command_pool_vk.cc.
References impeller::g_all_pools_map_mutex, and impeller::tls_command_pool_map.
std::shared_ptr< CommandPoolVK > impeller::CommandPoolRecyclerVK::Get | ( | ) |
Gets a command pool for the current thread.
Definition at line 192 of file command_pool_vk.cc.
References data, impeller::g_all_pools_map_mutex, and impeller::tls_command_pool_map.
|
static |
Definition at line 185 of file command_pool_vk.cc.
References impeller::g_all_pools_map_mutex, and impeller::ContextVK::GetHash().
Referenced by impeller::testing::TEST().
void impeller::CommandPoolRecyclerVK::Reclaim | ( | vk::UniqueCommandPool && | pool, |
std::vector< vk::UniqueCommandBuffer > && | buffers, | ||
bool | should_trim = false |
||
) |
Returns a command pool to be reset on a background thread.
[in] | pool | The pool to recycle. |
[in] | should_trim | whether to trim command pool memory before reseting. |
Definition at line 266 of file command_pool_vk.cc.
References impeller::CommandPoolRecyclerVK::RecycledData::pool.