Commit 6df1ffdc by Jamie Madill Committed by Commit Bot

Vulkan: Remove in-flight commands lock in TaskProcessor.

This is no longer necessary with the removal of the submit fence. Bug: b/172704839 Change-Id: If8c2795d7e3c73453a235498ed6caac727bdaca5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524549 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 e6a302a0
...@@ -304,14 +304,6 @@ angle::Result TaskProcessor::init(Context *context, std::thread::id threadId) ...@@ -304,14 +304,6 @@ angle::Result TaskProcessor::init(Context *context, std::thread::id threadId)
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result TaskProcessor::lockAndCheckCompletedCommands(Context *context)
{
ASSERT(isValidWorkerThread(context));
std::lock_guard<std::mutex> inFlightLock(mInFlightCommandsMutex);
return checkCompletedCommandsNoLock(context);
}
VkResult TaskProcessor::getLastAndClearPresentResult(VkSwapchainKHR swapchain) VkResult TaskProcessor::getLastAndClearPresentResult(VkSwapchainKHR swapchain)
{ {
std::unique_lock<std::mutex> lock(mSwapchainStatusMutex); std::unique_lock<std::mutex> lock(mSwapchainStatusMutex);
...@@ -327,9 +319,9 @@ VkResult TaskProcessor::getLastAndClearPresentResult(VkSwapchainKHR swapchain) ...@@ -327,9 +319,9 @@ VkResult TaskProcessor::getLastAndClearPresentResult(VkSwapchainKHR swapchain)
return result; return result;
} }
angle::Result TaskProcessor::checkCompletedCommandsNoLock(Context *context) angle::Result TaskProcessor::checkCompletedCommands(Context *context)
{ {
ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::checkCompletedCommandsNoLock"); ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::checkCompletedCommands");
VkDevice device = context->getDevice(); VkDevice device = context->getDevice();
RendererVk *rendererVk = context->getRenderer(); RendererVk *rendererVk = context->getRenderer();
...@@ -434,7 +426,6 @@ void TaskProcessor::handleDeviceLost(Context *context) ...@@ -434,7 +426,6 @@ void TaskProcessor::handleDeviceLost(Context *context)
ASSERT(isValidWorkerThread(context)); ASSERT(isValidWorkerThread(context));
ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::handleDeviceLost"); ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::handleDeviceLost");
VkDevice device = context->getDevice(); VkDevice device = context->getDevice();
std::lock_guard<std::mutex> inFlightLock(mInFlightCommandsMutex);
for (CommandBatch &batch : mInFlightCommands) for (CommandBatch &batch : mInFlightCommands)
{ {
...@@ -466,7 +457,6 @@ angle::Result TaskProcessor::finishToSerial(Context *context, Serial serial) ...@@ -466,7 +457,6 @@ angle::Result TaskProcessor::finishToSerial(Context *context, Serial serial)
ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::finishToSerial"); ANGLE_TRACE_EVENT0("gpu.angle", "TaskProcessor::finishToSerial");
RendererVk *rendererVk = context->getRenderer(); RendererVk *rendererVk = context->getRenderer();
uint64_t timeout = rendererVk->getMaxFenceWaitTimeNs(); uint64_t timeout = rendererVk->getMaxFenceWaitTimeNs();
std::unique_lock<std::mutex> inFlightLock(mInFlightCommandsMutex);
if (mInFlightCommands.empty()) if (mInFlightCommands.empty())
{ {
...@@ -487,15 +477,12 @@ angle::Result TaskProcessor::finishToSerial(Context *context, Serial serial) ...@@ -487,15 +477,12 @@ angle::Result TaskProcessor::finishToSerial(Context *context, Serial serial)
} }
const CommandBatch &batch = mInFlightCommands[batchIndex]; const CommandBatch &batch = mInFlightCommands[batchIndex];
// Don't need to hold the lock while waiting for the fence
inFlightLock.unlock();
// Wait for it finish // Wait for it finish
VkDevice device = context->getDevice(); VkDevice device = context->getDevice();
ANGLE_VK_TRY(context, batch.fence.get().wait(device, timeout)); ANGLE_VK_TRY(context, batch.fence.get().wait(device, timeout));
// Clean up finished batches. // Clean up finished batches.
return lockAndCheckCompletedCommands(context); return checkCompletedCommands(context);
} }
VkResult TaskProcessor::present(VkQueue queue, const VkPresentInfoKHR &presentInfo) VkResult TaskProcessor::present(VkQueue queue, const VkPresentInfoKHR &presentInfo)
...@@ -544,10 +531,9 @@ angle::Result TaskProcessor::submitFrame(Context *context, ...@@ -544,10 +531,9 @@ angle::Result TaskProcessor::submitFrame(Context *context,
// in the in-flight list. // in the in-flight list.
ANGLE_TRY(releaseToCommandBatch(context, std::move(commandBuffer), commandPool, &batch)); ANGLE_TRY(releaseToCommandBatch(context, std::move(commandBuffer), commandPool, &batch));
std::unique_lock<std::mutex> inFlightLock(mInFlightCommandsMutex);
mInFlightCommands.emplace_back(scopedBatch.release()); mInFlightCommands.emplace_back(scopedBatch.release());
ANGLE_TRY(checkCompletedCommandsNoLock(context)); ANGLE_TRY(checkCompletedCommands(context));
// CPU should be throttled to avoid mInFlightCommands from growing too fast. Important for // CPU should be throttled to avoid mInFlightCommands from growing too fast. Important for
// off-screen scenarios. // off-screen scenarios.
...@@ -555,7 +541,6 @@ angle::Result TaskProcessor::submitFrame(Context *context, ...@@ -555,7 +541,6 @@ angle::Result TaskProcessor::submitFrame(Context *context,
{ {
size_t numCommandsToFinish = mInFlightCommands.size() - kInFlightCommandsLimit; size_t numCommandsToFinish = mInFlightCommands.size() - kInFlightCommandsLimit;
Serial finishSerial = mInFlightCommands[numCommandsToFinish].serial; Serial finishSerial = mInFlightCommands[numCommandsToFinish].serial;
inFlightLock.unlock();
return finishToSerial(context, finishSerial); return finishToSerial(context, finishSerial);
} }
...@@ -816,7 +801,7 @@ angle::Result CommandProcessor::processTask(Context *context, CommandProcessorTa ...@@ -816,7 +801,7 @@ angle::Result CommandProcessor::processTask(Context *context, CommandProcessorTa
ANGLE_TRY(mTaskProcessor.queueSubmit(context, ANGLE_TRY(mTaskProcessor.queueSubmit(context,
getRenderer()->getVkQueue(task->getPriority()), getRenderer()->getVkQueue(task->getPriority()),
submitInfo, task->getOneOffFence())); submitInfo, task->getOneOffFence()));
ANGLE_TRY(mTaskProcessor.lockAndCheckCompletedCommands(context)); ANGLE_TRY(mTaskProcessor.checkCompletedCommands(context));
break; break;
} }
case CustomTask::FinishToSerial: case CustomTask::FinishToSerial:
...@@ -853,7 +838,7 @@ angle::Result CommandProcessor::processTask(Context *context, CommandProcessorTa ...@@ -853,7 +838,7 @@ angle::Result CommandProcessor::processTask(Context *context, CommandProcessorTa
} }
case CustomTask::CheckCompletedCommands: case CustomTask::CheckCompletedCommands:
{ {
ANGLE_TRY(mTaskProcessor.lockAndCheckCompletedCommands(this)); ANGLE_TRY(mTaskProcessor.checkCompletedCommands(this));
break; break;
} }
default: default:
......
...@@ -257,8 +257,7 @@ class TaskProcessor : angle::NonCopyable ...@@ -257,8 +257,7 @@ class TaskProcessor : angle::NonCopyable
void handleDeviceLost(Context *context); void handleDeviceLost(Context *context);
// Called by CommandProcessor to process any completed work angle::Result checkCompletedCommands(Context *context);
angle::Result lockAndCheckCompletedCommands(Context *context);
VkResult getLastAndClearPresentResult(VkSwapchainKHR swapchain); VkResult getLastAndClearPresentResult(VkSwapchainKHR swapchain);
...@@ -270,14 +269,7 @@ class TaskProcessor : angle::NonCopyable ...@@ -270,14 +269,7 @@ class TaskProcessor : angle::NonCopyable
CommandPool *commandPool, CommandPool *commandPool,
CommandBatch *batch); CommandBatch *batch);
// Check to see which batches have finished completion (forward progress for
// mLastCompletedQueueSerial, for example for when the application busy waits on a query
// result). It would be nice if we didn't have to expose this for QuerygetResult.
angle::Result checkCompletedCommandsNoLock(Context *context);
GarbageQueue mGarbageQueue; GarbageQueue mGarbageQueue;
mutable std::mutex mInFlightCommandsMutex;
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.
......
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