Manages the lifecycle of a single |vk::CommandPool|.
More...
#include <command_pool_vk.h>
|
| | ~CommandPoolVK () |
| |
| | 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.
|
| |
| vk::UniqueCommandBuffer | CreateCommandBuffer () |
| | Creates and returns a new |vk::CommandBuffer|.
|
| |
| void | CollectCommandBuffer (vk::UniqueCommandBuffer &&buffer) |
| | Collects the given |vk::CommandBuffer| to be retained.
|
| |
| void | Destroy () |
| | Delete all Vulkan objects in this command pool.
|
| |
Manages the lifecycle of a single |vk::CommandPool|.
A |vk::CommandPool| is expensive to create and reset. This class manages the lifecycle of a single |vk::CommandPool| by returning to the origin (|CommandPoolRecyclerVK|) when it is destroyed to be reused.
- Warning
- This class is not thread-safe.
- See also
- |CommandPoolRecyclerVK|
Definition at line 31 of file command_pool_vk.h.
◆ ~CommandPoolVK()
| impeller::CommandPoolVK::~CommandPoolVK |
( |
| ) |
|
Definition at line 72 of file command_pool_vk.cc.
72 {
73 if (!pool_) {
74 return;
75 }
76
77 auto const context = context_.lock();
78 if (!context) {
79 return;
80 }
81 auto const recycler = context->GetCommandPoolRecycler();
82 if (!recycler) {
83 return;
84 }
85
86
87 size_t unused_count = unused_command_buffers_.size();
88 for (
auto i = 0u;
i < unused_command_buffers_.size();
i++) {
89 collected_buffers_.push_back(std::move(unused_command_buffers_[
i]));
90 }
91 unused_command_buffers_.clear();
92
93 auto reset_pool_when_dropped = BackgroundCommandPoolVK(
94 std::move(pool_), std::move(collected_buffers_), unused_count, recycler);
95
96 UniqueResourceVKT<BackgroundCommandPoolVK> pool(
97 context->GetResourceManager(), std::move(reset_pool_when_dropped));
98}
References i.
◆ CommandPoolVK()
| impeller::CommandPoolVK::CommandPoolVK |
( |
vk::UniqueCommandPool |
pool, |
|
|
std::vector< vk::UniqueCommandBuffer > && |
buffers, |
|
|
std::weak_ptr< ContextVK > & |
context |
|
) |
| |
|
inline |
Creates a resource that manages the life of a command pool.
- Parameters
-
| [in] | pool | The command pool to manage. |
| [in] | buffers | Zero or more command buffers in an initial state. |
| [in] | recycler | The context that will be notified on destruction. |
Definition at line 40 of file command_pool_vk.h.
43 : pool_(std::move(pool)),
44 unused_command_buffers_(std::move(buffers)),
45 context_(context) {}
◆ CollectCommandBuffer()
| void impeller::CommandPoolVK::CollectCommandBuffer |
( |
vk::UniqueCommandBuffer && |
buffer | ) |
|
Collects the given |vk::CommandBuffer| to be retained.
- Parameters
-
| [in] | buffer | The |vk::CommandBuffer| to collect. |
- See also
- |GarbageCollectBuffersIfAble|
Definition at line 129 of file command_pool_vk.cc.
129 {
130 Lock lock(pool_mutex_);
131 if (!pool_) {
132
133
135 return;
136 }
137 collected_buffers_.push_back(std::move(buffer));
138}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
◆ CreateCommandBuffer()
| vk::UniqueCommandBuffer impeller::CommandPoolVK::CreateCommandBuffer |
( |
| ) |
|
Creates and returns a new |vk::CommandBuffer|.
- Returns
- Always returns a new |vk::CommandBuffer|, but if for any reason a valid command buffer could not be created, it will be a
{} default instance (i.e. while being torn down).
Definition at line 101 of file command_pool_vk.cc.
101 {
102 auto const context = context_.lock();
103 if (!context) {
104 return {};
105 }
106
107 Lock lock(pool_mutex_);
108 if (!pool_) {
109 return {};
110 }
111 if (!unused_command_buffers_.empty()) {
112 vk::UniqueCommandBuffer
buffer = std::move(unused_command_buffers_.back());
113 unused_command_buffers_.pop_back();
115 }
116
117 auto const device = context->GetDevice();
118 vk::CommandBufferAllocateInfo info;
119 info.setCommandPool(pool_.get());
120 info.setCommandBufferCount(1u);
121 info.setLevel(vk::CommandBufferLevel::ePrimary);
122 auto [result, buffers] =
device.allocateCommandBuffersUnique(info);
123 if (result != vk::Result::eSuccess) {
124 return {};
125 }
126 return std::move(buffers[0]);
127}
References device.
◆ Destroy()
| void impeller::CommandPoolVK::Destroy |
( |
| ) |
|
Delete all Vulkan objects in this command pool.
Definition at line 140 of file command_pool_vk.cc.
140 {
141 Lock lock(pool_mutex_);
142 pool_.reset();
143
144
145
146 for (auto& buffer : collected_buffers_) {
148 }
149 for (auto& buffer : unused_command_buffers_) {
151 }
152 unused_command_buffers_.clear();
153 collected_buffers_.clear();
154}
The documentation for this class was generated from the following files: