Hash :
e24f4519
Author :
Date :
2023-01-19T02:30:39
Vulkan: Add externalFence into submitCommands() Currently one-off fence in the `queueSubmitOneOff()` is used only in `SyncHelperNativeFence::initializeWithFd()` to submit external fence. Other `queueSubmitOneOff()` calls may use `QueueSerial` instead of a fence. Providing `fence` into `queueSubmitOneOff()` prevents tracking that submission with `QueueSerial`. Therefore using `mUse` to collecting `mFenceWithFd` as garbage will not work as intended. This CL removes `fence` from `queueSubmitOneOff()` and adds optional `externalFence` into `submitCommands()` instead. Providing `externalFence` will cause additional `vkQueueSubmit()` call: - first submission will submit everything as usual except using the `externalFence`. - second, will only submit internal `CommandQueue` fence for `QueueSerial` tracking. As the result of this CL, call to `initializeWithFd()` will always produce two (2) `vkQueueSubmit()` calls. Previously it may be one (1) or two (2) submissions. Future CL will reduce submission count to one (1). If add additional submission into `queueSubmitOneOff()` instead of `submitCommands()`, then maximum number of submissions will be three (3). Bug: angleproject:8117 Change-Id: I6f1ec12682aaab71bfc871e665fec2659df96b26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4392877 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Resource:
// Resource lifetime tracking in the Vulkan back-end.
//
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
namespace rx
{
namespace vk
{
// Resource implementation.
angle::Result Resource::waitForIdle(ContextVk *contextVk,
const char *debugMessage,
RenderPassClosureReason reason)
{
// If there are pending commands for the resource, flush them.
if (contextVk->hasUnsubmittedUse(mUse))
{
ANGLE_TRY(contextVk->flushImpl(nullptr, nullptr, reason));
}
RendererVk *renderer = contextVk->getRenderer();
// Make sure the driver is done with the resource.
if (!renderer->hasResourceUseFinished(mUse))
{
if (debugMessage)
{
ANGLE_VK_PERF_WARNING(contextVk, GL_DEBUG_SEVERITY_HIGH, "%s", debugMessage);
}
ANGLE_TRY(renderer->finishResourceUse(contextVk, mUse));
}
ASSERT(renderer->hasResourceUseFinished(mUse));
return angle::Result::Continue;
}
std::ostream &operator<<(std::ostream &os, const ResourceUse &use)
{
const Serials &serials = use.getSerials();
os << '{';
for (size_t i = 0; i < serials.size(); i++)
{
os << serials[i].getValue();
if (i < serials.size() - 1)
{
os << ",";
}
}
os << '}';
return os;
}
// SharedGarbage implementation.
SharedGarbage::SharedGarbage() = default;
SharedGarbage::SharedGarbage(SharedGarbage &&other)
{
*this = std::move(other);
}
SharedGarbage::SharedGarbage(const ResourceUse &use, GarbageList &&garbage)
: mLifetime(use), mGarbage(std::move(garbage))
{}
SharedGarbage::~SharedGarbage() = default;
SharedGarbage &SharedGarbage::operator=(SharedGarbage &&rhs)
{
std::swap(mLifetime, rhs.mLifetime);
std::swap(mGarbage, rhs.mGarbage);
return *this;
}
bool SharedGarbage::destroyIfComplete(RendererVk *renderer)
{
if (renderer->hasResourceUseFinished(mLifetime))
{
for (GarbageObject &object : mGarbage)
{
object.destroy(renderer);
}
return true;
}
return false;
}
bool SharedGarbage::hasResourceUseSubmitted(RendererVk *renderer) const
{
return renderer->hasResourceUseSubmitted(mLifetime);
}
// ReleasableResource implementation.
template <class T>
void ReleasableResource<T>::release(RendererVk *renderer)
{
renderer->collectGarbage(mUse, &mObject);
}
template class ReleasableResource<Semaphore>;
} // namespace vk
} // namespace rx