@@ -5555,23 +5555,24 @@ angle::Result BufferHelper::initializeNonZeroMemory(Context *context,
55555555 StagingBuffer stagingBuffer;
55565556 ANGLE_TRY(stagingBuffer.init(context, size, StagingUsage::Both));
55575557
5558- PrimaryCommandBuffer commandBuffer;
5559- ANGLE_TRY(
5560- renderer->getCommandBufferOneOff(context, ProtectionType::Unprotected, &commandBuffer));
5561-
55625558 // Queue a DMA copy.
55635559 VkBufferCopy copyRegion = {};
55645560 copyRegion.srcOffset = 0;
55655561 copyRegion.dstOffset = getOffset();
55665562 copyRegion.size = size;
55675563
5564+ ScopedPrimaryCommandBuffer scopedCommandBuffer(renderer->getDevice());
5565+ ANGLE_TRY(renderer->getCommandBufferOneOff(context, ProtectionType::Unprotected,
5566+ &scopedCommandBuffer));
5567+ PrimaryCommandBuffer &commandBuffer = scopedCommandBuffer.get();
5568+
55685569 commandBuffer.copyBuffer(stagingBuffer.getBuffer(), getBuffer(), 1, ©Region);
55695570
55705571 ANGLE_VK_TRY(context, commandBuffer.end());
55715572
55725573 QueueSerial queueSerial;
55735574 ANGLE_TRY(renderer->queueSubmitOneOff(
5574- context, std::move(commandBuffer ), ProtectionType::Unprotected,
5575+ context, std::move(scopedCommandBuffer ), ProtectionType::Unprotected,
55755576 egl::ContextPriority::Medium, VK_NULL_HANDLE, 0, &queueSerial));
55765577
55775578 stagingBuffer.collectGarbage(renderer, queueSerial);
@@ -6172,9 +6173,10 @@ angle::Result ImageHelper::copyToBufferOneOff(Context *context,
61726173 VkBufferImageCopy copyRegion)
61736174{
61746175 Renderer *renderer = context->getRenderer();
6175- PrimaryCommandBuffer commandBuffer;
6176- ANGLE_TRY(
6177- renderer->getCommandBufferOneOff(context, ProtectionType::Unprotected, &commandBuffer));
6176+ ScopedPrimaryCommandBuffer scopedCommandBuffer(renderer->getDevice());
6177+ ANGLE_TRY(renderer->getCommandBufferOneOff(context, ProtectionType::Unprotected,
6178+ &scopedCommandBuffer));
6179+ PrimaryCommandBuffer &commandBuffer = scopedCommandBuffer.get();
61786180
61796181 VkSemaphore acquireNextImageSemaphore;
61806182 barrierImpl(context, getAspectFlags(), ImageLayout::TransferDst,
@@ -6185,10 +6187,10 @@ angle::Result ImageHelper::copyToBufferOneOff(Context *context,
61856187 ANGLE_VK_TRY(context, commandBuffer.end());
61866188
61876189 QueueSerial submitQueueSerial;
6188- ANGLE_TRY(
6189- renderer->queueSubmitOneOff( context, std::move(commandBuffer ), ProtectionType::Unprotected,
6190- egl::ContextPriority::Medium, acquireNextImageSemaphore,
6191- kSwapchainAcquireImageWaitStageFlags, &submitQueueSerial));
6190+ ANGLE_TRY(renderer->queueSubmitOneOff(
6191+ context, std::move(scopedCommandBuffer ), ProtectionType::Unprotected,
6192+ egl::ContextPriority::Medium, acquireNextImageSemaphore,
6193+ kSwapchainAcquireImageWaitStageFlags, &submitQueueSerial));
61926194
61936195 return renderer->finishQueueSerial(context, submitQueueSerial);
61946196}
@@ -6605,9 +6607,10 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context,
66056607 // setEvent.
66066608 ASSERT(!mCurrentEvent.valid());
66076609
6608- PrimaryCommandBuffer commandBuffer ;
6610+ ScopedPrimaryCommandBuffer scopedCommandBuffer(renderer->getDevice()) ;
66096611 auto protectionType = ConvertProtectionBoolToType(hasProtectedContent);
6610- ANGLE_TRY(renderer->getCommandBufferOneOff(context, protectionType, &commandBuffer));
6612+ ANGLE_TRY(renderer->getCommandBufferOneOff(context, protectionType, &scopedCommandBuffer));
6613+ PrimaryCommandBuffer &commandBuffer = scopedCommandBuffer.get();
66116614
66126615 // Queue a DMA copy.
66136616 VkSemaphore acquireNextImageSemaphore;
@@ -6693,7 +6696,7 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context,
66936696 ANGLE_VK_TRY(context, commandBuffer.end());
66946697
66956698 QueueSerial queueSerial;
6696- ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer ), protectionType,
6699+ ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(scopedCommandBuffer ), protectionType,
66976700 egl::ContextPriority::Medium, VK_NULL_HANDLE, 0,
66986701 &queueSerial));
66996702
@@ -10856,11 +10859,12 @@ angle::Result ImageHelper::copySurfaceImageToBuffer(DisplayVk *displayVk,
1085610859
1085710860 // We may have a valid event here but we do not have a collector to collect it. Release the
1085810861 // event here to force pipelineBarrier.
10859- mCurrentEvent.release(displayVk->getRenderer() );
10862+ mCurrentEvent.release(renderer );
1086010863
10861- PrimaryCommandBuffer primaryCommandBuffer ;
10864+ ScopedPrimaryCommandBuffer scopedCommandBuffer(renderer->getDevice()) ;
1086210865 ANGLE_TRY(renderer->getCommandBufferOneOff(displayVk, ProtectionType::Unprotected,
10863- &primaryCommandBuffer));
10866+ &scopedCommandBuffer));
10867+ PrimaryCommandBuffer &primaryCommandBuffer = scopedCommandBuffer.get();
1086410868
1086510869 VkSemaphore acquireNextImageSemaphore;
1086610870 barrierImpl(displayVk, getAspectFlags(), ImageLayout::TransferSrc,
@@ -10873,7 +10877,7 @@ angle::Result ImageHelper::copySurfaceImageToBuffer(DisplayVk *displayVk,
1087310877
1087410878 QueueSerial submitQueueSerial;
1087510879 ANGLE_TRY(renderer->queueSubmitOneOff(
10876- displayVk, std::move(primaryCommandBuffer ), ProtectionType::Unprotected,
10880+ displayVk, std::move(scopedCommandBuffer ), ProtectionType::Unprotected,
1087710881 egl::ContextPriority::Medium, acquireNextImageSemaphore,
1087810882 kSwapchainAcquireImageWaitStageFlags, &submitQueueSerial));
1087910883
@@ -10910,9 +10914,10 @@ angle::Result ImageHelper::copyBufferToSurfaceImage(DisplayVk *displayVk,
1091010914 // event here to force pipelineBarrier.
1091110915 mCurrentEvent.release(displayVk->getRenderer());
1091210916
10913- PrimaryCommandBuffer commandBuffer;
10914- ANGLE_TRY(
10915- renderer->getCommandBufferOneOff(displayVk, ProtectionType::Unprotected, &commandBuffer));
10917+ ScopedPrimaryCommandBuffer scopedCommandBuffer(renderer->getDevice());
10918+ ANGLE_TRY(renderer->getCommandBufferOneOff(displayVk, ProtectionType::Unprotected,
10919+ &scopedCommandBuffer));
10920+ PrimaryCommandBuffer &commandBuffer = scopedCommandBuffer.get();
1091610921
1091710922 VkSemaphore acquireNextImageSemaphore;
1091810923 barrierImpl(displayVk, getAspectFlags(), ImageLayout::TransferDst,
@@ -10925,7 +10930,7 @@ angle::Result ImageHelper::copyBufferToSurfaceImage(DisplayVk *displayVk,
1092510930
1092610931 QueueSerial submitQueueSerial;
1092710932 ANGLE_TRY(renderer->queueSubmitOneOff(
10928- displayVk, std::move(commandBuffer ), ProtectionType::Unprotected,
10933+ displayVk, std::move(scopedCommandBuffer ), ProtectionType::Unprotected,
1092910934 egl::ContextPriority::Medium, acquireNextImageSemaphore,
1093010935 kSwapchainAcquireImageWaitStageFlags, &submitQueueSerial));
1093110936
0 commit comments