Hash :
89cd8583
Author :
Date :
2022-12-12T11:23:59
Vulkan: Clean up Resource class Resource::retainCommands() API name no longer make sense. This CL removes retainCommands and retainReadOnly and retainReadWrite APIs and replaced with setQueueSerial and setWriteQueueSerial call directly. This CL also merges some of single inline functions to minimize the file, sine the class is small anyway. Bug: b/262048658 Change-Id: I9d16b82c79b27f3285311393601705a4ee7f6d8a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4098005 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.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
//
// 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, reason));
}
RendererVk *renderer = contextVk->getRenderer();
// Make sure the driver is done with the resource.
if (renderer->hasUnfinishedUse(mUse))
{
if (debugMessage)
{
ANGLE_VK_PERF_WARNING(contextVk, GL_DEBUG_SEVERITY_HIGH, "%s", debugMessage);
}
ANGLE_TRY(renderer->finishResourceUse(contextVk, mUse));
}
ASSERT(!renderer->hasUnfinishedUse(mUse));
return angle::Result::Continue;
}
// 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->hasUnfinishedUse(mLifetime))
{
return false;
}
for (GarbageObject &object : mGarbage)
{
object.destroy(renderer);
}
return true;
}
bool SharedGarbage::hasUnsubmittedUse(RendererVk *renderer) const
{
return renderer->hasUnsubmittedUse(mLifetime);
}
} // namespace vk
} // namespace rx