Commit 087f1384 by Jamie Madill Committed by Commit Bot

Vulkan: Introduce CommandQueue helper class.

Wraps the functionality of managing monitoring workloads of commands being sent to the VkQueue. In the future this will likely move to the RendererVk class. This refactor allows the move to be easier to manage and will let us more easily change ownership in the future if we have to again. Bug: angleproject:2464 Change-Id: I061bc2ba939d7004d74d00b976a753a53c96445c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1804884Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 2e80cf9d
...@@ -42,11 +42,13 @@ angle::Result PersistentCommandPool::init(vk::Context *context, uint32_t queueFa ...@@ -42,11 +42,13 @@ angle::Result PersistentCommandPool::init(vk::Context *context, uint32_t queueFa
return angle::Result::Continue; return angle::Result::Continue;
} }
void PersistentCommandPool::destroy(const vk::Context *context) void PersistentCommandPool::destroy(VkDevice device)
{ {
if (!valid())
return;
ASSERT(mCommandPool.valid()); ASSERT(mCommandPool.valid());
VkDevice device = context->getDevice();
for (vk::PrimaryCommandBuffer &cmdBuf : mFreeBuffers) for (vk::PrimaryCommandBuffer &cmdBuf : mFreeBuffers)
{ {
cmdBuf.destroy(device, mCommandPool); cmdBuf.destroy(device, mCommandPool);
...@@ -56,8 +58,8 @@ void PersistentCommandPool::destroy(const vk::Context *context) ...@@ -56,8 +58,8 @@ void PersistentCommandPool::destroy(const vk::Context *context)
mCommandPool.destroy(device); mCommandPool.destroy(device);
} }
angle::Result PersistentCommandPool::alloc(vk::Context *context, angle::Result PersistentCommandPool::allocate(vk::Context *context,
vk::PrimaryCommandBuffer *bufferOutput) vk::PrimaryCommandBuffer *commandBufferOut)
{ {
if (mFreeBuffers.empty()) if (mFreeBuffers.empty())
{ {
...@@ -65,7 +67,7 @@ angle::Result PersistentCommandPool::alloc(vk::Context *context, ...@@ -65,7 +67,7 @@ angle::Result PersistentCommandPool::alloc(vk::Context *context,
ASSERT(!mFreeBuffers.empty()); ASSERT(!mFreeBuffers.empty());
} }
*bufferOutput = std::move(mFreeBuffers.back()); *commandBufferOut = std::move(mFreeBuffers.back());
mFreeBuffers.pop_back(); mFreeBuffers.pop_back();
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -27,10 +27,10 @@ class PersistentCommandPool final ...@@ -27,10 +27,10 @@ class PersistentCommandPool final
PersistentCommandPool(); PersistentCommandPool();
~PersistentCommandPool(); ~PersistentCommandPool();
void destroy(const vk::Context *context); void destroy(VkDevice device);
angle::Result init(vk::Context *context, uint32_t queueFamilyIndex); angle::Result init(vk::Context *context, uint32_t queueFamilyIndex);
angle::Result alloc(vk::Context *context, vk::PrimaryCommandBuffer *bufferOutput); angle::Result allocate(vk::Context *context, vk::PrimaryCommandBuffer *commandBufferOut);
angle::Result collect(vk::Context *context, vk::PrimaryCommandBuffer &&buffer); angle::Result collect(vk::Context *context, vk::PrimaryCommandBuffer &&buffer);
bool valid() const { return mCommandPool.valid(); } bool valid() const { return mCommandPool.valid(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment