Skip to content

Commit a5518f0

Browse files
cclaoAngle LUCI CQ
authored andcommitted
Vulkan: Remove mWaitSemaphores from ContextVk
With per context command buffer in earlier CL, we no longer needs to store mWaitSemaphores in ContextVk any more, they could be stored in CommandState directly. flushWaitSemaphores() API is completely removed in this CL since there is no need for such flush any more. Bug: b/447633563 Change-Id: Ifa73657cd6bd9ca76a764db1b49cac11cdfec0f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7132482 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 parent 4121f4e commit a5518f0

File tree

4 files changed

+20
-60
lines changed

4 files changed

+20
-60
lines changed

src/libANGLE/renderer/vulkan/CommandQueue.cpp

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -574,25 +574,10 @@ void CommandsState::destroy(VkDevice device)
574574
mSecondaryCommands.releaseCommandBuffers();
575575
}
576576

577-
void CommandsState::flushWaitSemaphores(ProtectionType protectionType,
578-
std::vector<VkSemaphore> &&waitSemaphores,
579-
std::vector<VkPipelineStageFlags> &&waitSemaphoreStageMasks)
580-
{
581-
ANGLE_TRACE_EVENT0("gpu.angle", "Renderer::flushWaitSemaphores");
582-
ASSERT(!waitSemaphores.empty());
583-
ASSERT(waitSemaphores.size() == waitSemaphoreStageMasks.size());
584-
std::lock_guard<angle::SimpleMutex> lock(mCmdPoolMutex);
585-
586-
mWaitSemaphores.insert(mWaitSemaphores.end(), waitSemaphores.begin(), waitSemaphores.end());
587-
mWaitSemaphoreStageMasks.insert(mWaitSemaphoreStageMasks.end(), waitSemaphoreStageMasks.begin(),
588-
waitSemaphoreStageMasks.end());
589-
590-
waitSemaphores.clear();
591-
waitSemaphoreStageMasks.clear();
592-
}
593-
594577
angle::Result CommandsState::getCommandsAndWaitSemaphores(
595578
ErrorContext *context,
579+
CommandPoolAccess *commandPoolAccess,
580+
CommandBatch *batch,
596581
std::vector<VkSemaphore> *waitSemaphoresOut,
597582
std::vector<VkPipelineStageFlags> *waitSemaphoreStageMasksOut)
598583
{
@@ -606,6 +591,10 @@ angle::Result CommandsState::getCommandsAndWaitSemaphores(
606591
ANGLE_VK_TRY(context, mPrimaryCommands.end());
607592
}
608593

594+
batch->setPrimaryCommands(std::move(mPrimaryCommands), commandPoolAccess);
595+
// Store secondary Command Buffers.
596+
batch->setSecondaryCommands(std::move(mSecondaryCommands));
597+
609598
// Store wait semaphores.
610599
*waitSemaphoresOut = std::move(mWaitSemaphores);
611600
*waitSemaphoreStageMasksOut = std::move(mWaitSemaphoreStageMasks);
@@ -876,12 +865,8 @@ angle::Result CommandQueue::submitCommands(ErrorContext *context,
876865
std::vector<VkSemaphore> waitSemaphores;
877866
std::vector<VkPipelineStageFlags> waitSemaphoreStageMasks;
878867

879-
ANGLE_TRY(commandsState.getCommandsAndWaitSemaphores(context, &waitSemaphores,
880-
&waitSemaphoreStageMasks));
881-
882-
batch.setPrimaryCommands(std::move(*commandsState.getPrimaryCommands()), &mCommandPoolAccess);
883-
// Store secondary Command Buffers.
884-
batch.setSecondaryCommands(std::move(*commandsState.getSecondaryCommands()));
868+
ANGLE_TRY(commandsState.getCommandsAndWaitSemaphores(
869+
context, &mCommandPoolAccess, &batch, &waitSemaphores, &waitSemaphoreStageMasks));
885870

886871
mPerfCounters.commandQueueWaitSemaphoresTotal += waitSemaphores.size();
887872

src/libANGLE/renderer/vulkan/CommandQueue.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ class CommandsState : angle::NonCopyable
223223
VkFramebuffer framebufferOverride,
224224
RenderPassCommandBufferHelper **renderPassCommands);
225225

226-
void flushWaitSemaphores(ProtectionType protectionType,
227-
std::vector<VkSemaphore> &&waitSemaphores,
228-
std::vector<VkPipelineStageFlags> &&waitSemaphoreStageMasks);
229-
230226
void flushImagesTransitionToForeign(
231227
std::vector<VkImageMemoryBarrier> &&imagesToTransitionToForeign)
232228
{
@@ -244,6 +240,8 @@ class CommandsState : angle::NonCopyable
244240

245241
angle::Result getCommandsAndWaitSemaphores(
246242
ErrorContext *context,
243+
CommandPoolAccess *commandPoolAccess,
244+
CommandBatch *batch,
247245
std::vector<VkSemaphore> *waitSemaphoresOut,
248246
std::vector<VkPipelineStageFlags> *waitSemaphoreStageMasksOut);
249247

@@ -256,6 +254,8 @@ class CommandsState : angle::NonCopyable
256254
PrimaryCommandBuffer *getPrimaryCommands() { return &mPrimaryCommands; }
257255
SecondaryCommandBufferCollector *getSecondaryCommands() { return &mSecondaryCommands; }
258256

257+
bool hasWaitSemaphoresPendingSubmission() const { return !mWaitSemaphores.empty(); }
258+
259259
private:
260260
angle::Result ensurePrimaryCommandBufferValidLocked(ErrorContext *context,
261261
const ProtectionType &protectionType);

src/libANGLE/renderer/vulkan/ContextVk.cpp

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, vk::Rendere
862862
mTotalBufferToImageCopySize(0),
863863
mEstimatedPendingImageGarbageSize(0),
864864
mRenderPassCountSinceSubmit(0),
865-
mHasWaitSemaphoresPendingSubmission(false),
866865
mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()},
867866
mGpuEventTimestampOrigin(0),
868867
mInitialContextPriority(renderer->getDriverPriority(GetContextPriority(state))),
@@ -6272,8 +6271,7 @@ angle::Result ContextVk::onSurfaceUnMakeCurrent(WindowSurfaceVk *surface)
62726271
// Everything must be flushed and submitted.
62736272
ASSERT(mOutsideRenderPassCommands->empty());
62746273
ASSERT(!mRenderPassCommands->started());
6275-
ASSERT(mWaitSemaphores.empty());
6276-
ASSERT(!mHasWaitSemaphoresPendingSubmission);
6274+
ASSERT(!mCommandState.hasWaitSemaphoresPendingSubmission());
62776275
ASSERT(mLastSubmittedQueueSerial == mLastFlushedQueueSerial);
62786276
return angle::Result::Continue;
62796277
}
@@ -6300,7 +6298,7 @@ angle::Result ContextVk::onSurfaceUnMakeCurrent(OffscreenSurfaceVk *surface)
63006298
// Everything must be flushed but may be pending submission.
63016299
ASSERT(mOutsideRenderPassCommands->empty());
63026300
ASSERT(!mRenderPassCommands->started());
6303-
ASSERT(mWaitSemaphores.empty());
6301+
ASSERT(!mCommandState.hasWaitSemaphoresPendingSubmission());
63046302
return angle::Result::Continue;
63056303
}
63066304

@@ -7805,7 +7803,7 @@ angle::Result ContextVk::flushAndSubmitCommands(const vk::Semaphore *signalSemap
78057803
bool someCommandAlreadyFlushedNeedsSubmit =
78067804
mLastFlushedQueueSerial != mLastSubmittedQueueSerial;
78077805
bool someOtherReasonNeedsSubmit = signalSemaphore != nullptr || externalFence != nullptr ||
7808-
mHasWaitSemaphoresPendingSubmission ||
7806+
mCommandState.hasWaitSemaphoresPendingSubmission() ||
78097807
hasForeignImagesToTransition();
78107808

78117809
if (!someCommandsNeedFlush && !someCommandAlreadyFlushedNeedsSubmit &&
@@ -7888,18 +7886,15 @@ angle::Result ContextVk::flushAndSubmitCommands(const vk::Semaphore *signalSemap
78887886
mHasInFlightStreamedVertexBuffers.reset();
78897887
}
78907888

7891-
ASSERT(mWaitSemaphores.empty());
7892-
ASSERT(mWaitSemaphoreStageMasks.empty());
7893-
78947889
prepareToSubmitAllCommands();
78957890
ANGLE_TRY(submitCommands(signalSemaphore, externalFence));
78967891
mCommandsPendingSubmissionCount = 0;
78977892
mRenderPassCountSinceSubmit = 0;
78987893

7894+
ASSERT(!mCommandState.hasWaitSemaphoresPendingSubmission());
78997895
ASSERT(mOutsideRenderPassCommands->getQueueSerial() > mLastSubmittedQueueSerial);
79007896

79017897
mHasAnyCommandsPendingSubmission = false;
7902-
mHasWaitSemaphoresPendingSubmission = false;
79037898
onRenderPassFinished(RenderPassClosureReason::AlreadySpecifiedElsewhere);
79047899

79057900
if (mGpuEventsEnabled)
@@ -7948,13 +7943,6 @@ angle::Result ContextVk::finishImpl(RenderPassClosureReason renderPassClosureRea
79487943
return angle::Result::Continue;
79497944
}
79507945

7951-
void ContextVk::addWaitSemaphore(VkSemaphore semaphore, VkPipelineStageFlags stageMask)
7952-
{
7953-
mWaitSemaphores.push_back(semaphore);
7954-
mWaitSemaphoreStageMasks.push_back(stageMask);
7955-
mHasWaitSemaphoresPendingSubmission = true;
7956-
}
7957-
79587946
angle::Result ContextVk::getCompatibleRenderPass(const vk::RenderPassDesc &desc,
79597947
const vk::RenderPass **renderPassOut)
79607948
{
@@ -8545,15 +8533,6 @@ angle::Result ContextVk::flushAndSubmitOutsideRenderPassCommands()
85458533

85468534
angle::Result ContextVk::flushOutsideRenderPassCommands()
85478535
{
8548-
if (!mWaitSemaphores.empty())
8549-
{
8550-
ASSERT(mHasWaitSemaphoresPendingSubmission);
8551-
mCommandState.flushWaitSemaphores(getProtectionType(), std::move(mWaitSemaphores),
8552-
std::move(mWaitSemaphoreStageMasks));
8553-
}
8554-
ASSERT(mWaitSemaphores.empty());
8555-
ASSERT(mWaitSemaphoreStageMasks.empty());
8556-
85578536
if (mOutsideRenderPassCommands->empty())
85588537
{
85598538
return angle::Result::Continue;

src/libANGLE/renderer/vulkan/ContextVk.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,10 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
479479

480480
angle::Result finishImpl(RenderPassClosureReason renderPassClosureReason);
481481

482-
void addWaitSemaphore(VkSemaphore semaphore, VkPipelineStageFlags stageMask);
482+
void addWaitSemaphore(VkSemaphore semaphore, VkPipelineStageFlags stageMask)
483+
{
484+
mCommandState.addWaitSemaphore(semaphore, stageMask);
485+
}
483486

484487
template <typename T>
485488
void addGarbage(T *object)
@@ -1675,13 +1678,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
16751678
// The number of render passes since the last submission of all commands.
16761679
VkDeviceSize mRenderPassCountSinceSubmit;
16771680

1678-
// Semaphores that must be flushed before the current commands. Flushed semaphores will be
1679-
// waited on in the next submission.
1680-
std::vector<VkSemaphore> mWaitSemaphores;
1681-
std::vector<VkPipelineStageFlags> mWaitSemaphoreStageMasks;
1682-
// Whether this context has wait semaphores (flushed and unflushed) that must be submitted.
1683-
bool mHasWaitSemaphoresPendingSubmission;
1684-
16851681
// Hold information from the last gpu clock sync for future gpu-to-cpu timestamp conversions.
16861682
GpuClockSyncInfo mGpuClockSync;
16871683

0 commit comments

Comments
 (0)