Commit aafcb504 by Courtney Goeltzenleuchter Committed by Commit Bot

Vulkan: Add ensureSubmission to queueSubmitOneOff

Some callers of queueSubmitOneOff require that the command being queued to have been sent to the GPU. The new ensureSubmission parameter indicates that behavior and when running with threaded worker will wait for the worker queue to empty before returning. Bug: b/170312581 Change-Id: Ib620fb37f4b9b4431451ccbd10807c0dff1842af Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2579041Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
parent b1f094eb
......@@ -432,7 +432,7 @@ angle::Result CommandProcessor::processTask(CommandProcessorTask *task)
ANGLE_TRY(mCommandQueue.queueSubmitOneOff(
this, task->getPriority(), task->getOneOffCommandBufferVk(), task->getOneOffFence(),
task->getQueueSerial()));
SubmitPolicy::EnsureSubmitted, task->getQueueSerial()));
ANGLE_TRY(mCommandQueue.checkCompletedCommands(this));
break;
}
......@@ -652,6 +652,7 @@ angle::Result CommandProcessor::queueSubmitOneOff(Context *context,
egl::ContextPriority contextPriority,
VkCommandBuffer commandBufferHandle,
const Fence *fence,
SubmitPolicy submitPolicy,
Serial submitQueueSerial)
{
ANGLE_TRY(checkAndPopPendingError(context));
......@@ -659,6 +660,12 @@ angle::Result CommandProcessor::queueSubmitOneOff(Context *context,
CommandProcessorTask task;
task.initOneOffQueueSubmit(commandBufferHandle, contextPriority, fence, submitQueueSerial);
queueCommand(std::move(task));
if (submitPolicy == SubmitPolicy::EnsureSubmitted)
{
// Caller has synchronization requirement to have work in GPU pipe when returning from this
// function.
ANGLE_TRY(waitForWorkComplete(context));
}
return angle::Result::Continue;
}
......@@ -1091,6 +1098,7 @@ angle::Result CommandQueue::queueSubmitOneOff(Context *context,
egl::ContextPriority contextPriority,
VkCommandBuffer commandBufferHandle,
const Fence *fence,
SubmitPolicy submitPolicy,
Serial submitQueueSerial)
{
VkSubmitInfo submitInfo = {};
......
......@@ -27,6 +27,12 @@ class CommandProcessor;
namespace vk
{
enum class SubmitPolicy
{
AllowDeferred,
EnsureSubmitted,
};
class FenceRecycler
{
public:
......@@ -201,6 +207,7 @@ class CommandQueueInterface : angle::NonCopyable
egl::ContextPriority contextPriority,
VkCommandBuffer commandBufferHandle,
const Fence *fence,
SubmitPolicy submitPolicy,
Serial submitQueueSerial) = 0;
virtual VkResult queuePresent(egl::ContextPriority contextPriority,
const VkPresentInfoKHR &presentInfo) = 0;
......@@ -255,6 +262,7 @@ class CommandQueue final : public CommandQueueInterface
egl::ContextPriority contextPriority,
VkCommandBuffer commandBufferHandle,
const Fence *fence,
SubmitPolicy submitPolicy,
Serial submitQueueSerial) override;
VkResult queuePresent(egl::ContextPriority contextPriority,
......@@ -363,6 +371,7 @@ class CommandProcessor : public Context, public CommandQueueInterface
egl::ContextPriority contextPriority,
VkCommandBuffer commandBufferHandle,
const Fence *fence,
SubmitPolicy submitPolicy,
Serial submitQueueSerial) override;
VkResult queuePresent(egl::ContextPriority contextPriority,
const VkPresentInfoKHR &presentInfo) override;
......
......@@ -1695,8 +1695,11 @@ angle::Result ContextVk::synchronizeCpuGpuTime()
ANGLE_VK_TRY(this, commandBuffer.end());
Serial throwAwaySerial;
// vkEvent's are externally synchronized, therefore need work to be submitted before calling
// vkGetEventStatus
ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
nullptr, &throwAwaySerial));
nullptr, vk::SubmitPolicy::EnsureSubmitted,
&throwAwaySerial));
scratchResourceUseList.releaseResourceUsesAndUpdateSerials(throwAwaySerial);
// Wait for GPU to be ready. This is a short busy wait.
......@@ -4375,7 +4378,8 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
Serial throwAwaySerial;
ANGLE_TRY(mRenderer->queueSubmitOneOff(this, std::move(commandBuffer), mContextPriority,
&fence.get(), &throwAwaySerial));
&fence.get(), vk::SubmitPolicy::EnsureSubmitted,
&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.
......
......@@ -2293,6 +2293,7 @@ angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority,
const vk::Fence *fence,
vk::SubmitPolicy submitPolicy,
Serial *serialOut)
{
ANGLE_TRACE_EVENT0("gpu.angle", "RendererVk::queueSubmitOneOff");
......@@ -2304,13 +2305,13 @@ angle::Result RendererVk::queueSubmitOneOff(vk::Context *context,
{
submitQueueSerial = mCommandProcessor.reserveSubmitSerial();
ANGLE_TRY(mCommandProcessor.queueSubmitOneOff(context, priority, primary.getHandle(), fence,
submitQueueSerial));
submitPolicy, submitQueueSerial));
}
else
{
submitQueueSerial = mCommandQueue.reserveSubmitSerial();
ANGLE_TRY(mCommandQueue.queueSubmitOneOff(context, priority, primary.getHandle(), fence,
submitQueueSerial));
submitPolicy, submitQueueSerial));
}
*serialOut = submitQueueSerial;
......
......@@ -209,6 +209,7 @@ class RendererVk : angle::NonCopyable
vk::PrimaryCommandBuffer &&primary,
egl::ContextPriority priority,
const vk::Fence *fence,
vk::SubmitPolicy submitPolicy,
Serial *serialOut);
template <typename... ArgsT>
......
......@@ -205,8 +205,13 @@ angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int
retain(&contextVk->getResourceUseList());
Serial serialOut;
// exportFd is exporting VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR type handle which
// obeys copy semantics. This means that the fence must already be signaled or the work to
// signal in the graphics pipeline at the time we export the fd. Thus we need to
// ensureSubmission here.
ANGLE_TRY(renderer->queueSubmitOneOff(contextVk, vk::PrimaryCommandBuffer(),
contextVk->getPriority(), &fence.get(), &serialOut));
contextVk->getPriority(), &fence.get(),
vk::SubmitPolicy::EnsureSubmitted, &serialOut));
VkFenceGetFdInfoKHR fenceGetFdInfo = {};
fenceGetFdInfo.sType = VK_STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR;
......@@ -219,7 +224,7 @@ angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int
// descriptor from the application to the Vulkan implementation. The application must not
// perform any operations on the file descriptor after a successful import.
// Make a dup of importFenceFd before tranfering ownership to created fence.
// Make a dup of importFenceFd before transferring ownership to created fence.
mNativeFenceFd = dup(importFenceFd);
// Import FD - after creating fence.
......
......@@ -3226,7 +3226,8 @@ angle::Result BufferHelper::initializeNonZeroMemory(Context *context, VkDeviceSi
Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, nullptr, &serial));
egl::ContextPriority::Medium, nullptr,
vk::SubmitPolicy::AllowDeferred, &serial));
stagingBuffer.collectGarbage(renderer, serial);
mUse.updateSerialOneOff(serial);
......@@ -3764,7 +3765,8 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context, VkDeviceSiz
Serial serial;
ANGLE_TRY(renderer->queueSubmitOneOff(context, std::move(commandBuffer),
egl::ContextPriority::Medium, nullptr, &serial));
egl::ContextPriority::Medium, nullptr,
vk::SubmitPolicy::AllowDeferred, &serial));
if (isCompressedFormat)
{
......
......@@ -479,14 +479,4 @@ TEST_P(EGLSyncTest, AndroidNativeFence_withFences)
EXPECT_EGL_TRUE(eglDestroySyncKHR(display, syncWithGeneratedFD));
}
ANGLE_INSTANTIATE_TEST(EGLSyncTest,
ES2_D3D9(),
ES2_D3D11(),
ES2_METAL(),
ES3_D3D11(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES(),
ES2_VULKAN(),
ES3_VULKAN());
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(EGLSyncTest);
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