Commit ce7bdd0b by Jamie Madill Committed by Commit Bot

Vulkan: Merge CommandQueue and TaskProcessor.

Bug: b/172704839 Change-Id: I43a40e6a3e1eb00a7ddebfba6e915437aa69aeb6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2525141 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent 0c3d0b21
...@@ -337,12 +337,11 @@ struct FeaturesVk : FeatureSetBase ...@@ -337,12 +337,11 @@ struct FeaturesVk : FeatureSetBase
// Tell Vulkan back-end to use CommandProcessor class to dispatch work to the GPU. The work will // Tell Vulkan back-end to use CommandProcessor class to dispatch work to the GPU. The work will
// happen asynchronously in a different thread if asynchronousCommandProcessing is true. // happen asynchronously in a different thread if asynchronousCommandProcessing is true.
// Otherwise use Renderer::CommandQueue to dispatch work. // Otherwise use Renderer::CommandQueue to dispatch work.
// TODO(jmadill): Merge these two features. b/172704839
Feature commandProcessor = {"commandProcessor", FeatureCategory::VulkanFeatures, Feature commandProcessor = {"commandProcessor", FeatureCategory::VulkanFeatures,
"Use CommandProcessor class to dispatch work to GPU.", &members, "Use CommandProcessor class to dispatch work to GPU.", &members,
"http://anglebug.com/4324"}; "http://anglebug.com/4324"};
// Enable parallel thread execution when commandProcessor is enabled.
// Currently off by default.
Feature asynchronousCommandProcessing = {"asynchronousCommandProcessing", Feature asynchronousCommandProcessing = {"asynchronousCommandProcessing",
FeatureCategory::VulkanFeatures, FeatureCategory::VulkanFeatures,
"Enable/Disable parallel processing of worker thread", "Enable/Disable parallel processing of worker thread",
......
...@@ -236,71 +236,6 @@ class CommandQueue final : angle::NonCopyable ...@@ -236,71 +236,6 @@ class CommandQueue final : angle::NonCopyable
Serial mCurrentQueueSerial; Serial mCurrentQueueSerial;
}; };
class TaskProcessor : angle::NonCopyable
{
public:
TaskProcessor();
~TaskProcessor();
angle::Result init(Context *context, std::thread::id threadId);
void destroy(VkDevice device);
angle::Result finishToSerial(Context *context, Serial serial);
angle::Result submitFrame(Context *context,
egl::ContextPriority priority,
const std::vector<VkSemaphore> &waitSemaphores,
const std::vector<VkPipelineStageFlags> &waitSemaphoreStageMasks,
const Semaphore *signalSemaphore,
Shared<Fence> &&sharedFence,
GarbageList *currentGarbage,
CommandPool *commandPool,
Serial submitQueueSerial);
angle::Result queueSubmit(Context *context,
egl::ContextPriority priority,
const VkSubmitInfo &submitInfo,
const Fence *fence,
Serial submitQueueSerial);
void handleDeviceLost(Context *context);
angle::Result checkCompletedCommands(Context *context);
angle::Result flushOutsideRPCommands(Context *context, CommandBufferHelper *outsideRPCommands);
angle::Result flushRenderPassCommands(Context *context,
const RenderPass &renderPass,
CommandBufferHelper *renderPassCommands);
Serial reserveSubmitSerial();
ANGLE_INLINE Serial getLastSubmittedQueueSerial() const { return mLastSubmittedQueueSerial; }
ANGLE_INLINE Serial getLastCompletedQueueSerial() const { return mLastCompletedQueueSerial; }
ANGLE_INLINE Serial getCurrentQueueSerial() const { return mCurrentQueueSerial; }
private:
bool isValidWorkerThread(Context *context) const;
angle::Result releaseToCommandBatch(Context *context,
PrimaryCommandBuffer &&commandBuffer,
CommandPool *commandPool,
CommandBatch *batch);
angle::Result ensurePrimaryCommandBufferValid(Context *context);
GarbageQueue mGarbageQueue;
std::vector<CommandBatch> mInFlightCommands;
// Keeps a free list of reusable primary command buffers.
PrimaryCommandBuffer mPrimaryCommandBuffer;
PersistentCommandPool mPrimaryCommandPool;
std::thread::id mThreadId;
// Queue serial management.
AtomicSerialFactory mQueueSerialFactory;
Serial mLastCompletedQueueSerial;
Serial mLastSubmittedQueueSerial;
Serial mCurrentQueueSerial;
};
// TODO(jmadill): Give this the same API as CommandQueue. b/172704839 // TODO(jmadill): Give this the same API as CommandQueue. b/172704839
class CommandProcessor : public Context class CommandProcessor : public Context
{ {
...@@ -308,8 +243,6 @@ class CommandProcessor : public Context ...@@ -308,8 +243,6 @@ class CommandProcessor : public Context
CommandProcessor(RendererVk *renderer); CommandProcessor(RendererVk *renderer);
~CommandProcessor() override; ~CommandProcessor() override;
angle::Result initTaskProcessor(Context *context);
void handleError(VkResult result, void handleError(VkResult result,
const char *file, const char *file,
const char *function, const char *function,
...@@ -376,7 +309,7 @@ class CommandProcessor : public Context ...@@ -376,7 +309,7 @@ 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;
TaskProcessor mTaskProcessor; CommandQueue mCommandQueue;
std::mutex mQueueSerialMutex; std::mutex mQueueSerialMutex;
......
...@@ -911,17 +911,11 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -911,17 +911,11 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
if (getFeatures().commandProcessor.enabled) if (getFeatures().commandProcessor.enabled)
{ {
if (getFeatures().asynchronousCommandProcessing.enabled) // TODO(jmadill): Clean up. b/172704839
{ ASSERT(mFeatures.asynchronousCommandProcessing.enabled);
ASSERT(getFeatures().commandProcessor.enabled); mCommandProcessorThread =
mCommandProcessorThread = std::thread(&vk::CommandProcessor::processTasks, &mCommandProcessor);
std::thread(&vk::CommandProcessor::processTasks, &mCommandProcessor); waitForCommandProcessorIdle(displayVk);
waitForCommandProcessorIdle(displayVk);
}
else
{
ANGLE_TRY(mCommandProcessor.initTaskProcessor(displayVk));
}
} }
else else
{ {
......
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