14TEST(CommandPoolRecyclerVKTest, GetsACommandPoolPerThread) {
23 std::shared_ptr<CommandPoolVK> pool1;
24 std::shared_ptr<CommandPoolVK> pool2;
28 [&]() { pool1 = context->GetCommandPoolRecycler()->Get(); });
31 [&]() { pool2 = context->GetCommandPoolRecycler()->Get(); });
37 EXPECT_NE(pool1, pool2);
107TEST(CommandPoolRecyclerVKTest, ReclaimMakesCommandPoolAvailable) {
112 auto const recycler = context->GetCommandPoolRecycler();
113 auto const pool = recycler->Get();
119 WaitForReclaim(context);
122 std::thread thread([&]() {
123 auto const pool = context->GetCommandPoolRecycler()->Get();
124 EXPECT_NE(pool.get(),
nullptr);
130 auto const called = ReclaimAndGetMockVulkanFunctions(context);
131 EXPECT_EQ(std::count(called->begin(), called->end(),
"vkCreateCommandPool"),
137TEST(CommandPoolRecyclerVKTest, CommandBuffersAreRecycled) {
142 auto const recycler = context->GetCommandPoolRecycler();
143 auto pool = recycler->Get();
145 auto buffer = pool->CreateCommandBuffer();
146 pool->CollectCommandBuffer(std::move(
buffer));
152 WaitForReclaim(context);
157 auto const recycler = context->GetCommandPoolRecycler();
158 auto pool = recycler->Get();
160 auto buffer = pool->CreateCommandBuffer();
161 pool->CollectCommandBuffer(std::move(
buffer));
168 auto const called = ReclaimAndGetMockVulkanFunctions(context);
169 EXPECT_EQ(std::count(called->begin(), called->end(),
"vkCreateCommandPool"),
172 std::count(called->begin(), called->end(),
"vkAllocateCommandBuffers"),
178TEST(CommandPoolRecyclerVKTest, ExtraCommandBufferAllocationsTriggerTrim) {
183 auto const recycler = context->GetCommandPoolRecycler();
184 auto pool = recycler->Get();
187 for (
auto i = 0;
i < 64;
i++) {
188 auto buffer = pool->CreateCommandBuffer();
189 pool->CollectCommandBuffer(std::move(
buffer));
197 auto called = ReclaimAndGetMockVulkanFunctions(context);
198 EXPECT_EQ(std::count(called->begin(), called->end(),
"vkResetCommandPool"),
204 auto const recycler = context->GetCommandPoolRecycler();
205 auto pool = recycler->Get();
214 called = ReclaimAndGetMockVulkanFunctions(context);
215 EXPECT_EQ(std::count(called->begin(), called->end(),
216 "vkResetCommandPoolReleaseResources"),
std::shared_ptr< ContextVK > Build()
Create a Vulkan context with Vulkan functions mocked. The caller is given a chance to tinker on the s...