Commit 6a1fb047 by Jamie Madill Committed by Commit Bot

Vulkan: Align CommandQueue and TaskProcessor.

The intent is to merge these two classes and remove redundant code. Bug: b/172704839 Change-Id: I6eb66d7b4ddea3633b08df99464975cd59773b4e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524550 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent a428487a
...@@ -204,7 +204,6 @@ class CommandQueue final : angle::NonCopyable ...@@ -204,7 +204,6 @@ class CommandQueue final : angle::NonCopyable
angle::Result checkCompletedCommands(Context *context); angle::Result checkCompletedCommands(Context *context);
angle::Result flushOutsideRPCommands(Context *context, CommandBufferHelper *outsideRPCommands); angle::Result flushOutsideRPCommands(Context *context, CommandBufferHelper *outsideRPCommands);
angle::Result flushRenderPassCommands(Context *context, angle::Result flushRenderPassCommands(Context *context,
const RenderPass &renderPass, const RenderPass &renderPass,
CommandBufferHelper *renderPassCommands); CommandBufferHelper *renderPassCommands);
...@@ -220,10 +219,6 @@ class CommandQueue final : angle::NonCopyable ...@@ -220,10 +219,6 @@ class CommandQueue final : angle::NonCopyable
CommandBatch *batch); CommandBatch *batch);
angle::Result retireFinishedCommands(Context *context, size_t finishedCount); angle::Result retireFinishedCommands(Context *context, size_t finishedCount);
angle::Result ensurePrimaryCommandBufferValid(Context *context); angle::Result ensurePrimaryCommandBufferValid(Context *context);
angle::Result allocatePrimaryCommandBuffer(Context *context,
PrimaryCommandBuffer *commandBufferOut);
angle::Result releasePrimaryCommandBuffer(Context *context,
PrimaryCommandBuffer &&commandBuffer);
bool allInFlightCommandsAreAfterSerial(Serial serial) const; bool allInFlightCommandsAreAfterSerial(Serial serial) const;
...@@ -250,25 +245,19 @@ class TaskProcessor : angle::NonCopyable ...@@ -250,25 +245,19 @@ class TaskProcessor : angle::NonCopyable
angle::Result init(Context *context, std::thread::id threadId); angle::Result init(Context *context, std::thread::id threadId);
void destroy(VkDevice device); void destroy(VkDevice device);
angle::Result allocatePrimaryCommandBuffer(Context *context,
PrimaryCommandBuffer *commandBufferOut);
angle::Result releasePrimaryCommandBuffer(Context *context,
PrimaryCommandBuffer &&commandBuffer);
angle::Result finishToSerial(Context *context, Serial serial); angle::Result finishToSerial(Context *context, Serial serial);
VkResult present(VkQueue queue, const VkPresentInfoKHR &presentInfo);
angle::Result submitFrame(Context *context, angle::Result submitFrame(Context *context,
VkQueue queue, egl::ContextPriority priority,
const VkSubmitInfo &submitInfo, const std::vector<VkSemaphore> &waitSemaphores,
const Shared<Fence> &sharedFence, const std::vector<VkPipelineStageFlags> &waitSemaphoreStageMasks,
const Semaphore *signalSemaphore,
Shared<Fence> &&sharedFence,
GarbageList *currentGarbage, GarbageList *currentGarbage,
CommandPool *commandPool, CommandPool *commandPool,
PrimaryCommandBuffer &&commandBuffer,
Serial submitQueueSerial); Serial submitQueueSerial);
angle::Result queueSubmit(Context *context, angle::Result queueSubmit(Context *context,
VkQueue queue, egl::ContextPriority priority,
const VkSubmitInfo &submitInfo, const VkSubmitInfo &submitInfo,
const Fence *fence, const Fence *fence,
Serial submitQueueSerial); Serial submitQueueSerial);
...@@ -277,7 +266,10 @@ class TaskProcessor : angle::NonCopyable ...@@ -277,7 +266,10 @@ class TaskProcessor : angle::NonCopyable
angle::Result checkCompletedCommands(Context *context); angle::Result checkCompletedCommands(Context *context);
VkResult getLastAndClearPresentResult(VkSwapchainKHR swapchain); angle::Result flushOutsideRPCommands(Context *context, CommandBufferHelper *outsideRPCommands);
angle::Result flushRenderPassCommands(Context *context,
const RenderPass &renderPass,
CommandBufferHelper *renderPassCommands);
Serial reserveSubmitSerial(); Serial reserveSubmitSerial();
...@@ -292,11 +284,13 @@ class TaskProcessor : angle::NonCopyable ...@@ -292,11 +284,13 @@ class TaskProcessor : angle::NonCopyable
PrimaryCommandBuffer &&commandBuffer, PrimaryCommandBuffer &&commandBuffer,
CommandPool *commandPool, CommandPool *commandPool,
CommandBatch *batch); CommandBatch *batch);
angle::Result ensurePrimaryCommandBufferValid(Context *context);
GarbageQueue mGarbageQueue; GarbageQueue mGarbageQueue;
std::vector<CommandBatch> mInFlightCommands; std::vector<CommandBatch> mInFlightCommands;
// Keeps a free list of reusable primary command buffers. // Keeps a free list of reusable primary command buffers.
PrimaryCommandBuffer mPrimaryCommandBuffer;
PersistentCommandPool mPrimaryCommandPool; PersistentCommandPool mPrimaryCommandPool;
std::thread::id mThreadId; std::thread::id mThreadId;
...@@ -305,11 +299,6 @@ class TaskProcessor : angle::NonCopyable ...@@ -305,11 +299,6 @@ class TaskProcessor : angle::NonCopyable
Serial mLastCompletedQueueSerial; Serial mLastCompletedQueueSerial;
Serial mLastSubmittedQueueSerial; Serial mLastSubmittedQueueSerial;
Serial mCurrentQueueSerial; Serial mCurrentQueueSerial;
// Track present info
std::mutex mSwapchainStatusMutex;
std::condition_variable mSwapchainStatusCondition;
std::map<VkSwapchainKHR, VkResult> mSwapchainStatus;
}; };
// TODO(jmadill): Give this the same API as CommandQueue. b/172704839 // TODO(jmadill): Give this the same API as CommandQueue. b/172704839
...@@ -363,7 +352,7 @@ class CommandProcessor : public Context ...@@ -363,7 +352,7 @@ class CommandProcessor : public Context
VkResult getLastPresentResult(VkSwapchainKHR swapchain) VkResult getLastPresentResult(VkSwapchainKHR swapchain)
{ {
return mTaskProcessor.getLastAndClearPresentResult(swapchain); return getLastAndClearPresentResult(swapchain);
} }
private: private:
...@@ -372,7 +361,10 @@ class CommandProcessor : public Context ...@@ -372,7 +361,10 @@ class CommandProcessor : public Context
angle::Result processTasksImpl(bool *exitThread); angle::Result processTasksImpl(bool *exitThread);
// Command processor thread, process a task // Command processor thread, process a task
angle::Result processTask(Context *context, CommandProcessorTask *task); angle::Result processTask(CommandProcessorTask *task);
VkResult getLastAndClearPresentResult(VkSwapchainKHR swapchain);
VkResult present(VkQueue queue, const VkPresentInfoKHR &presentInfo);
std::queue<CommandProcessorTask> mTasks; std::queue<CommandProcessorTask> mTasks;
mutable std::mutex mWorkerMutex; mutable std::mutex mWorkerMutex;
...@@ -384,13 +376,17 @@ class CommandProcessor : public Context ...@@ -384,13 +376,17 @@ class CommandProcessor : public Context
bool mWorkerThreadIdle; bool mWorkerThreadIdle;
// Command pool to allocate processor thread primary command buffers from // Command pool to allocate processor thread primary command buffers from
CommandPool mCommandPool; CommandPool mCommandPool;
PrimaryCommandBuffer mPrimaryCommandBuffer;
TaskProcessor mTaskProcessor; TaskProcessor mTaskProcessor;
std::mutex mQueueSerialMutex; std::mutex mQueueSerialMutex;
mutable std::mutex mErrorMutex; mutable std::mutex mErrorMutex;
std::queue<Error> mErrors; std::queue<Error> mErrors;
// Track present info
std::mutex mSwapchainStatusMutex;
std::condition_variable mSwapchainStatusCondition;
std::map<VkSwapchainKHR, VkResult> mSwapchainStatus;
}; };
} // namespace vk } // namespace vk
......
...@@ -154,10 +154,10 @@ void SyncHelperNativeFence::releaseToRenderer(RendererVk *renderer) ...@@ -154,10 +154,10 @@ void SyncHelperNativeFence::releaseToRenderer(RendererVk *renderer)
renderer->collectGarbageAndReinit(&mUse, &mFenceWithFd); renderer->collectGarbageAndReinit(&mUse, &mFenceWithFd);
} }
// Note: Having mFenceWithFd hold the FD, so that ownership is with ICD. Meanwhile store a dup // Note: We have mFenceWithFd hold the FD, so that ownership is with ICD. Meanwhile we store a dup
// of FD in SyncHelperNativeFence for further reference, i.e. dup of FD. Any call to clientWait // of FD in SyncHelperNativeFence for further reference, i.e. dup of FD. Any call to clientWait
// or serverWait will ensure the FD or dup of FD goes to application or ICD. At release, above // or serverWait will ensure the FD or dup of FD goes to application or ICD. At release, above
// it's Garbage collected/destroyed. Otherwise can't time when to close(fd); // it's Garbage collected/destroyed. Otherwise we can't time when to close(fd);
angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int inFd) angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int inFd)
{ {
ASSERT(inFd >= kInvalidFenceFd); ASSERT(inFd >= kInvalidFenceFd);
......
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