Commit 9a0284e8 by Jamie Madill Committed by Commit Bot

Vulkan: Merge command paths in submitFrame.

This makes the CommandQueue and CommandProcessor paths nearly the same in submitFrame. The end goal is to make them take identical input parameters. Bug: b/172704839 Change-Id: If3ef2752534de1c3dcaefa5730b308aea46e549e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524545 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 a391674c
...@@ -1904,27 +1904,49 @@ void ContextVk::commandProcessorSyncErrorsAndQueueCommand(vk::CommandProcessorTa ...@@ -1904,27 +1904,49 @@ void ContextVk::commandProcessorSyncErrorsAndQueueCommand(vk::CommandProcessorTa
mRenderer->queueCommand(this, command); mRenderer->queueCommand(this, command);
} }
angle::Result ContextVk::submitFrame(const vk::Semaphore *signalSemaphore, angle::Result ContextVk::submitFrame(const vk::Semaphore *signalSemaphore)
vk::ResourceUseList *resourceList)
{ {
ASSERT(!getRenderer()->getFeatures().commandProcessor.enabled); if (mCurrentWindowSurface)
{
vk::Semaphore waitSemaphore = mCurrentWindowSurface->getAcquireImageSemaphore();
if (waitSemaphore.valid())
{
addWaitSemaphore(waitSemaphore.getHandle(),
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
addGarbage(&waitSemaphore);
}
}
if (vk::CommandBufferHelper::kEnableCommandStreamDiagnostics) if (vk::CommandBufferHelper::kEnableCommandStreamDiagnostics)
{ {
dumpCommandStreamDiagnostics(); dumpCommandStreamDiagnostics();
} }
ANGLE_TRY(ensureSubmitFenceInitialized()); if (mRenderer->getFeatures().commandProcessor.enabled)
ANGLE_TRY(mCommandQueue.submitFrame(this, mContextPriority, mWaitSemaphores, {
mWaitSemaphoreStageMasks, signalSemaphore, mSubmitFence, vk::CommandProcessorTask flushAndQueueSubmit;
resourceList, &mCurrentGarbage, &mCommandPool)); flushAndQueueSubmit.initFlushAndQueueSubmit(
std::move(mWaitSemaphores), std::move(mWaitSemaphoreStageMasks), signalSemaphore,
mContextPriority, std::move(mCurrentGarbage), std::move(mResourceUseList));
commandProcessorSyncErrorsAndQueueCommand(&flushAndQueueSubmit);
}
else
{
ANGLE_TRY(ensureSubmitFenceInitialized());
ANGLE_TRY(mCommandQueue.submitFrame(this, mContextPriority, mWaitSemaphores,
mWaitSemaphoreStageMasks, signalSemaphore, mSubmitFence,
&mResourceUseList, &mCurrentGarbage, &mCommandPool));
// Make sure a new fence is created for the next submission.
mRenderer->resetSharedFence(&mSubmitFence);
mWaitSemaphores.clear();
mWaitSemaphoreStageMasks.clear();
}
onRenderPassFinished(); onRenderPassFinished();
mComputeDirtyBits |= mNewComputeCommandBufferDirtyBits; mComputeDirtyBits |= mNewComputeCommandBufferDirtyBits;
// Make sure a new fence is created for the next submission.
mRenderer->resetSharedFence(&mSubmitFence);
if (mGpuEventsEnabled) if (mGpuEventsEnabled)
{ {
ANGLE_TRY(checkCompletedGpuEvents()); ANGLE_TRY(checkCompletedGpuEvents());
...@@ -4472,48 +4494,7 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore) ...@@ -4472,48 +4494,7 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
mDefaultUniformStorage.releaseInFlightBuffersToResourceUseList(this); mDefaultUniformStorage.releaseInFlightBuffersToResourceUseList(this);
mStagingBuffer.releaseInFlightBuffersToResourceUseList(this); mStagingBuffer.releaseInFlightBuffersToResourceUseList(this);
waitForSwapchainImageIfNecessary(); ANGLE_TRY(submitFrame(signalSemaphore));
if (mRenderer->getFeatures().commandProcessor.enabled)
{
// Some tasks from ContextVk::submitFrame() that run before CommandQueue::submitFrame()
gl::RunningGraphWidget *renderPassCount =
mState.getOverlay()->getRunningGraphWidget(gl::WidgetId::VulkanRenderPassCount);
renderPassCount->add(mRenderPassCommands->getAndResetCounter());
renderPassCount->next();
if (vk::CommandBufferHelper::kEnableCommandStreamDiagnostics)
{
dumpCommandStreamDiagnostics();
}
// Send a flush command to worker thread that will:
// 1. Create submitInfo
// 2. Call submitFrame()
// 3. Allocate new primary command buffer
vk::CommandProcessorTask flushAndQueueSubmit;
flushAndQueueSubmit.initFlushAndQueueSubmit(
std::move(mWaitSemaphores), std::move(mWaitSemaphoreStageMasks), signalSemaphore,
mContextPriority, std::move(mCurrentGarbage), std::move(mResourceUseList));
commandProcessorSyncErrorsAndQueueCommand(&flushAndQueueSubmit);
// Some tasks from ContextVk::submitFrame() that run after CommandQueue::submitFrame()
onRenderPassFinished();
mComputeDirtyBits |= mNewComputeCommandBufferDirtyBits;
if (mGpuEventsEnabled)
{
ANGLE_TRY(checkCompletedGpuEvents());
}
}
else
{
ANGLE_TRY(submitFrame(signalSemaphore, &mResourceUseList));
mWaitSemaphores.clear();
mWaitSemaphoreStageMasks.clear();
}
mPerfCounters.renderPasses = 0; mPerfCounters.renderPasses = 0;
mPerfCounters.writeDescriptorSets = 0; mPerfCounters.writeDescriptorSets = 0;
...@@ -4773,20 +4754,6 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex) ...@@ -4773,20 +4754,6 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex)
static_cast<uint32_t>(offset)); static_cast<uint32_t>(offset));
} }
void ContextVk::waitForSwapchainImageIfNecessary()
{
if (mCurrentWindowSurface)
{
vk::Semaphore waitSemaphore = mCurrentWindowSurface->getAcquireImageSemaphore();
if (waitSemaphore.valid())
{
addWaitSemaphore(waitSemaphore.getHandle(),
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
addGarbage(&waitSemaphore);
}
}
}
vk::DescriptorSetLayoutDesc ContextVk::getDriverUniformsDescriptorSetDesc( vk::DescriptorSetLayoutDesc ContextVk::getDriverUniformsDescriptorSetDesc(
VkShaderStageFlags shaderStages) const VkShaderStageFlags shaderStages) const
{ {
......
...@@ -934,8 +934,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -934,8 +934,7 @@ class ContextVk : public ContextImpl, public vk::Context
void writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut, size_t offsetsSize); void writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut, size_t offsetsSize);
angle::Result submitFrame(const vk::Semaphore *signalSemaphore, angle::Result submitFrame(const vk::Semaphore *signalSemaphore);
vk::ResourceUseList *resourceList);
angle::Result memoryBarrierImpl(GLbitfield barriers, VkPipelineStageFlags stageMask); angle::Result memoryBarrierImpl(GLbitfield barriers, VkPipelineStageFlags stageMask);
angle::Result synchronizeCpuGpuTime(); angle::Result synchronizeCpuGpuTime();
...@@ -945,7 +944,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -945,7 +944,6 @@ class ContextVk : public ContextImpl, public vk::Context
angle::Result checkCompletedGpuEvents(); angle::Result checkCompletedGpuEvents();
void flushGpuEvents(double nextSyncGpuTimestampS, double nextSyncCpuTimestampS); void flushGpuEvents(double nextSyncGpuTimestampS, double nextSyncCpuTimestampS);
void handleDeviceLost(); void handleDeviceLost();
void waitForSwapchainImageIfNecessary();
bool shouldEmulateSeamfulCubeMapSampling() const; bool shouldEmulateSeamfulCubeMapSampling() const;
bool shouldUseOldRewriteStructSamplers() const; bool shouldUseOldRewriteStructSamplers() const;
void clearAllGarbage(); void clearAllGarbage();
......
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