Commit d3d7b95b by Tobin Ehlis Committed by Commit Bot

Vulkan:Migrate timer sync functions to one-off cmd buffer

ContextVk's getTimestamp() and synchronizeCpuGpuTime() were the two places that mCommandQueue was used outside of processing SecondaryCommandBuffers. Migrating those functions to use the one- off command buffer instead. This will allow for the removal of mCommandQueue from ContextVk as we migrate it to RendererVk instead for threading phase2 development. Bug: b/154030730 Change-Id: Ic00ce56739dadcdc4b5a1b1839e0e18603bfe0eb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2209312Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent c9ebf905
...@@ -1684,14 +1684,7 @@ angle::Result ContextVk::synchronizeCpuGpuTime() ...@@ -1684,14 +1684,7 @@ angle::Result ContextVk::synchronizeCpuGpuTime()
vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device); vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get(); vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
ANGLE_TRY(mCommandQueue.allocatePrimaryCommandBuffer(this, mCommandPool, &commandBuffer)); ANGLE_TRY(mRenderer->getCommandBufferOneOff(this, &commandBuffer));
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
beginInfo.pInheritanceInfo = nullptr;
ANGLE_VK_TRY(this, commandBuffer.begin(beginInfo));
commandBuffer.setEvent(gpuReady.get().getHandle(), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT); commandBuffer.setEvent(gpuReady.get().getHandle(), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT);
commandBuffer.waitEvents(1, cpuReady.get().ptr(), VK_PIPELINE_STAGE_HOST_BIT, commandBuffer.waitEvents(1, cpuReady.get().ptr(), VK_PIPELINE_STAGE_HOST_BIT,
...@@ -1702,12 +1695,9 @@ angle::Result ContextVk::synchronizeCpuGpuTime() ...@@ -1702,12 +1695,9 @@ angle::Result ContextVk::synchronizeCpuGpuTime()
ANGLE_VK_TRY(this, commandBuffer.end()); ANGLE_VK_TRY(this, commandBuffer.end());
// Submit the command buffer Serial throwAwaySerial;
VkSubmitInfo submitInfo = {}; ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
InitializeSubmitInfo(&submitInfo, commandBatch.get(), {}, &mWaitSemaphoreStageMasks, nullptr, &throwAwaySerial));
nullptr);
ANGLE_TRY(submitFrame(submitInfo, commandBatch.release()));
// Wait for GPU to be ready. This is a short busy wait. // Wait for GPU to be ready. This is a short busy wait.
VkResult result = VK_EVENT_RESET; VkResult result = VK_EVENT_RESET;
...@@ -3896,14 +3886,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut) ...@@ -3896,14 +3886,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device); vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get(); vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
ANGLE_TRY(mCommandQueue.allocatePrimaryCommandBuffer(this, mCommandPool, &commandBuffer)); ANGLE_TRY(mRenderer->getCommandBufferOneOff(this, &commandBuffer));
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
beginInfo.pInheritanceInfo = nullptr;
ANGLE_VK_TRY(this, commandBuffer.begin(beginInfo));
timestampQuery.writeTimestamp(this, &commandBuffer); timestampQuery.writeTimestamp(this, &commandBuffer);
ANGLE_VK_TRY(this, commandBuffer.end()); ANGLE_VK_TRY(this, commandBuffer.end());
...@@ -3927,8 +3911,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut) ...@@ -3927,8 +3911,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
submitInfo.pSignalSemaphores = nullptr; submitInfo.pSignalSemaphores = nullptr;
Serial throwAwaySerial; Serial throwAwaySerial;
ANGLE_TRY( ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
mRenderer->queueSubmit(this, mContextPriority, submitInfo, &fence.get(), &throwAwaySerial)); &fence.get(), &throwAwaySerial));
// Wait for the submission to finish. Given no semaphores, there is hope that it would execute // Wait for the submission to finish. Given no semaphores, there is hope that it would execute
// in parallel with what's already running on the GPU. // in parallel with what's already running on the GPU.
...@@ -3943,7 +3927,7 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut) ...@@ -3943,7 +3927,7 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
*timestampOut * *timestampOut *
static_cast<double>(getRenderer()->getPhysicalDeviceProperties().limits.timestampPeriod)); static_cast<double>(getRenderer()->getPhysicalDeviceProperties().limits.timestampPeriod));
return mCommandQueue.releasePrimaryCommandBuffer(this, commandBatch.release()); return angle::Result::Continue;
} }
void ContextVk::invalidateDefaultAttribute(size_t attribIndex) void ContextVk::invalidateDefaultAttribute(size_t attribIndex)
......
...@@ -1943,6 +1943,7 @@ angle::Result RendererVk::queueSubmit(vk::Context *context, ...@@ -1943,6 +1943,7 @@ angle::Result RendererVk::queueSubmit(vk::Context *context,
angle::Result RendererVk::queueSubmitOneOff(vk::Context *context, angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary, vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority, egl::ContextPriority priority,
const vk::Fence *fence,
Serial *serialOut) Serial *serialOut)
{ {
VkSubmitInfo submitInfo = {}; VkSubmitInfo submitInfo = {};
...@@ -1950,7 +1951,7 @@ angle::Result RendererVk::queueSubmitOneOff(vk::Context *context, ...@@ -1950,7 +1951,7 @@ angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
submitInfo.commandBufferCount = 1; submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = primary.ptr(); submitInfo.pCommandBuffers = primary.ptr();
ANGLE_TRY(queueSubmit(context, priority, submitInfo, nullptr, serialOut)); ANGLE_TRY(queueSubmit(context, priority, submitInfo, fence, serialOut));
mPendingOneOffCommands.push_back({*serialOut, std::move(primary)}); mPendingOneOffCommands.push_back({*serialOut, std::move(primary)});
......
...@@ -189,6 +189,7 @@ class RendererVk : angle::NonCopyable ...@@ -189,6 +189,7 @@ class RendererVk : angle::NonCopyable
angle::Result queueSubmitOneOff(vk::Context *context, angle::Result queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary, vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority, egl::ContextPriority priority,
const vk::Fence *fence,
Serial *serialOut); Serial *serialOut);
angle::Result newSharedFence(vk::Context *context, vk::Shared<vk::Fence> *sharedFenceOut); angle::Result newSharedFence(vk::Context *context, vk::Shared<vk::Fence> *sharedFenceOut);
......
...@@ -2197,7 +2197,7 @@ angle::Result BufferHelper::initializeNonZeroMemory(Context *context, VkDeviceSi ...@@ -2197,7 +2197,7 @@ angle::Result BufferHelper::initializeNonZeroMemory(Context *context, VkDeviceSi
Serial serial; Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer), ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, &serial)); egl::ContextPriority::Medium, nullptr, &serial));
stagingBuffer.collectGarbage(renderer, serial); stagingBuffer.collectGarbage(renderer, serial);
mUse.updateSerialOneOff(serial); mUse.updateSerialOneOff(serial);
...@@ -2592,7 +2592,7 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context, VkDeviceSiz ...@@ -2592,7 +2592,7 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context, VkDeviceSiz
Serial serial; Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer), ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, &serial)); egl::ContextPriority::Medium, nullptr, &serial));
stagingBuffer.collectGarbage(renderer, serial); stagingBuffer.collectGarbage(renderer, serial);
mUse.updateSerialOneOff(serial); mUse.updateSerialOneOff(serial);
......
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