Commit 5891b091 by Charlie Lao Committed by Commit Bot

Vulkan: acquire swapchain image should use COLOR_ATTACHMENT_OUTPUT_BIT

The mAcquireImageSemaphore is for achieving the maximum overlap between display engine and rendering engine. We should only need to block when we write to the swapchain image. Work that doesn't touch the visible buffer can proceed. Bug: b/157916459 Change-Id: Ic9a9a1f2a7648ef7f50f99578a0f0d674ae5e66c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2223826 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 1e9097f5
......@@ -129,24 +129,18 @@ constexpr size_t kInFlightCommandsLimit = 100u;
void InitializeSubmitInfo(VkSubmitInfo *submitInfo,
const vk::PrimaryCommandBuffer &commandBuffer,
const std::vector<VkSemaphore> &waitSemaphores,
std::vector<VkPipelineStageFlags> *waitSemaphoreStageMasks,
const std::vector<VkPipelineStageFlags> &waitSemaphoreStageMasks,
const vk::Semaphore *signalSemaphore)
{
// Verify that the submitInfo has been zero'd out.
ASSERT(submitInfo->signalSemaphoreCount == 0);
ASSERT(waitSemaphores.size() == waitSemaphoreStageMasks.size());
submitInfo->sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo->commandBufferCount = commandBuffer.valid() ? 1 : 0;
submitInfo->pCommandBuffers = commandBuffer.ptr();
if (waitSemaphoreStageMasks->size() < waitSemaphores.size())
{
waitSemaphoreStageMasks->resize(waitSemaphores.size(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
}
submitInfo->waitSemaphoreCount = static_cast<uint32_t>(waitSemaphores.size());
submitInfo->pWaitSemaphores = waitSemaphores.data();
submitInfo->pWaitDstStageMask = waitSemaphoreStageMasks->data();
submitInfo->pWaitDstStageMask = waitSemaphoreStageMasks.data();
if (signalSemaphore)
{
......@@ -3737,12 +3731,6 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context,
return angle::Result::Continue;
}
void ContextVk::insertWaitSemaphore(const vk::Semaphore *waitSemaphore)
{
ASSERT(waitSemaphore);
mWaitSemaphores.push_back(waitSemaphore->getHandle());
}
bool ContextVk::hasRecordedCommands()
{
ASSERT(mOutsideRenderPassCommands && mRenderPassCommands);
......@@ -3801,7 +3789,7 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
waitForSwapchainImageIfNecessary();
VkSubmitInfo submitInfo = {};
InitializeSubmitInfo(&submitInfo, mPrimaryCommands, mWaitSemaphores, &mWaitSemaphoreStageMasks,
InitializeSubmitInfo(&submitInfo, mPrimaryCommands, mWaitSemaphores, mWaitSemaphoreStageMasks,
signalSemaphore);
ANGLE_TRY(submitFrame(submitInfo, std::move(mPrimaryCommands)));
......@@ -3810,6 +3798,7 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
mRenderPassCounter = 0;
mWaitSemaphores.clear();
mWaitSemaphoreStageMasks.clear();
mPrimaryBufferCounter++;
......@@ -3853,9 +3842,10 @@ angle::Result ContextVk::finishImpl()
return angle::Result::Continue;
}
void ContextVk::addWaitSemaphore(VkSemaphore semaphore)
void ContextVk::addWaitSemaphore(VkSemaphore semaphore, VkPipelineStageFlags stageMask)
{
mWaitSemaphores.push_back(semaphore);
mWaitSemaphoreStageMasks.push_back(stageMask);
}
const vk::CommandPool &ContextVk::getCommandPool() const
......@@ -4042,7 +4032,8 @@ void ContextVk::waitForSwapchainImageIfNecessary()
vk::Semaphore waitSemaphore = mCurrentWindowSurface->getAcquireImageSemaphore();
if (waitSemaphore.valid())
{
addWaitSemaphore(waitSemaphore.getHandle());
addWaitSemaphore(waitSemaphore.getHandle(),
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
addGarbage(&waitSemaphore);
}
}
......
......@@ -366,12 +366,10 @@ class ContextVk : public ContextImpl, public vk::Context
mLastIndexBufferOffset = reinterpret_cast<const void *>(angle::DirtyPointer);
}
void insertWaitSemaphore(const vk::Semaphore *waitSemaphore);
angle::Result flushImpl(const vk::Semaphore *semaphore);
angle::Result finishImpl();
void addWaitSemaphore(VkSemaphore semaphore);
void addWaitSemaphore(VkSemaphore semaphore, VkPipelineStageFlags stageMask);
const vk::CommandPool &getCommandPool() const;
......
......@@ -149,7 +149,7 @@ angle::Result SemaphoreVk::wait(gl::Context *context,
}
}
contextVk->insertWaitSemaphore(&mSemaphore);
contextVk->addWaitSemaphore(mSemaphore.getHandle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
return angle::Result::Continue;
}
......
......@@ -279,7 +279,8 @@ angle::Result SyncHelperNativeFence::serverWait(ContextVk *contextVk)
ANGLE_TRY(contextVk->flushImpl(nullptr));
// Add semaphore to next submit job.
contextVk->insertWaitSemaphore(&waitSemaphore.get());
contextVk->addWaitSemaphore(waitSemaphore.get().getHandle(),
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
contextVk->addGarbage(&waitSemaphore.get()); // This releases the handle.
return angle::Result::Continue;
}
......
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