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()
vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
ANGLE_TRY(mCommandQueue.allocatePrimaryCommandBuffer(this, mCommandPool, &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));
ANGLE_TRY(mRenderer->getCommandBufferOneOff(this, &commandBuffer));
commandBuffer.setEvent(gpuReady.get().getHandle(), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT);
commandBuffer.waitEvents(1, cpuReady.get().ptr(), VK_PIPELINE_STAGE_HOST_BIT,
......@@ -1702,12 +1695,9 @@ angle::Result ContextVk::synchronizeCpuGpuTime()
ANGLE_VK_TRY(this, commandBuffer.end());
// Submit the command buffer
VkSubmitInfo submitInfo = {};
InitializeSubmitInfo(&submitInfo, commandBatch.get(), {}, &mWaitSemaphoreStageMasks,
nullptr);
ANGLE_TRY(submitFrame(submitInfo, commandBatch.release()));
Serial throwAwaySerial;
ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
nullptr, &throwAwaySerial));
// Wait for GPU to be ready. This is a short busy wait.
VkResult result = VK_EVENT_RESET;
......@@ -3896,14 +3886,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
vk::DeviceScoped<vk::PrimaryCommandBuffer> commandBatch(device);
vk::PrimaryCommandBuffer &commandBuffer = commandBatch.get();
ANGLE_TRY(mCommandQueue.allocatePrimaryCommandBuffer(this, mCommandPool, &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_TRY(mRenderer->getCommandBufferOneOff(this, &commandBuffer));
ANGLE_VK_TRY(this, commandBuffer.begin(beginInfo));
timestampQuery.writeTimestamp(this, &commandBuffer);
ANGLE_VK_TRY(this, commandBuffer.end());
......@@ -3927,8 +3911,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
submitInfo.pSignalSemaphores = nullptr;
Serial throwAwaySerial;
ANGLE_TRY(
mRenderer->queueSubmit(this, mContextPriority, submitInfo, &fence.get(), &throwAwaySerial));
ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
&fence.get(), &throwAwaySerial));
// 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.
......@@ -3943,7 +3927,7 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
*timestampOut *
static_cast<double>(getRenderer()->getPhysicalDeviceProperties().limits.timestampPeriod));
return mCommandQueue.releasePrimaryCommandBuffer(this, commandBatch.release());
return angle::Result::Continue;
}
void ContextVk::invalidateDefaultAttribute(size_t attribIndex)
......
......@@ -1943,6 +1943,7 @@ angle::Result RendererVk::queueSubmit(vk::Context *context,
angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority,
const vk::Fence *fence,
Serial *serialOut)
{
VkSubmitInfo submitInfo = {};
......@@ -1950,7 +1951,7 @@ angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
submitInfo.commandBufferCount = 1;
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)});
......
......@@ -189,6 +189,7 @@ class RendererVk : angle::NonCopyable
angle::Result queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority,
const vk::Fence *fence,
Serial *serialOut);
angle::Result newSharedFence(vk::Context *context, vk::Shared<vk::Fence> *sharedFenceOut);
......
......@@ -2197,7 +2197,7 @@ angle::Result BufferHelper::initializeNonZeroMemory(Context *context, VkDeviceSi
Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, &serial));
egl::ContextPriority::Medium, nullptr, &serial));
stagingBuffer.collectGarbage(renderer, serial);
mUse.updateSerialOneOff(serial);
......@@ -2592,7 +2592,7 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context, VkDeviceSiz
Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, &serial));
egl::ContextPriority::Medium, nullptr, &serial));
stagingBuffer.collectGarbage(renderer, 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