update pool

This commit is contained in:
ouczbs 2024-03-14 12:10:37 +08:00
parent 5e9b0bb305
commit df8e818ac5
4 changed files with 8 additions and 7 deletions

View File

@ -41,7 +41,7 @@ namespace zstd {
};
T acquire() {
if (m_tail == m_head) {
return std::move(newT());
return newT();
}
int tail = m_tail % m_size;
m_tail++;

View File

@ -6,9 +6,9 @@ namespace vulkanapi {
:mName(name)
,mDevice(device)
,mQueue(queue)
,mCommandPool(CommandPool(device, queueFlags, queue.QueueFamilyIndex()))
,mWork(CommandThreadWorker(name, 64))
,mImmediateExeCmd(CommandBuffer(mCommandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY))
,mCommandPool(device, queueFlags, queue.QueueFamilyIndex())
,mWork(name, 64)
,mImmediateExeCmd(mCommandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY)
{
}
@ -22,6 +22,7 @@ namespace vulkanapi {
mWork.Invoke([=]() {
CommandBuffer cmd = mCommandPool.Pop();
Buffer(cmd, fn, callback);
mCommandPool.Push(cmd);
});
}
@ -32,7 +33,6 @@ namespace vulkanapi {
cmd.EndRecord();
cmd.Submit(mQueue.Ptr());
cmd.WaitFofFence(mDevice.Ptr());
mCommandPool.Push(cmd);
callback();
}

View File

@ -11,6 +11,7 @@ namespace vulkanapi {
public:
CommandBuffer(CommandPool& commandPool, VkCommandBufferLevel level);
~CommandBuffer();
CommandBuffer(CommandBuffer* other)noexcept:CommandBuffer(std::forward<CommandBuffer>(*other)) {};
CommandBuffer(CommandBuffer&& other)noexcept;
VkCommandBuffer& Ptr() {
return mPtr;

View File

@ -23,11 +23,11 @@ namespace vulkanapi {
};
CommandBuffer Pop()
{
return std::move(mPool.acquire());
return mPool.acquire();
}
void Push(CommandBuffer& cmd)
{
mPool.release(std::forward<CommandBuffer>(cmd));
mPool.release(&cmd);
}
};
}