Hash :
b540da89
Author :
Date :
2019-09-19T14:19:12
Vulkan: Use ResourceUse to track object lifetime. With the new resource tracking scheme the CommandGraph, tracking a "Context serial" aka "current" serial is no longer necessary for CommandGraphResources. Serial tracking has been moved to the shared ResourceUse struct that gets updated on a command submission. Thus we don't need to store the serial as a current separate piece of info in BufferHelper/ImageHelper. Will lead to further redesign for the multi-threading support for Vulkan. Bug: angleproject:2464 Change-Id: I1ae4bcc27fcfb93422b4ab4c9682a458e482f295 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785990 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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
// Copyright 2019 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.
//
// SemaphoreVk.cpp: Defines the class interface for SemaphoreVk, implementing
// SemaphoreImpl.
#include "libANGLE/renderer/vulkan/SemaphoreVk.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
namespace rx
{
SemaphoreVk::SemaphoreVk() = default;
SemaphoreVk::~SemaphoreVk() = default;
void SemaphoreVk::onDestroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
contextVk->addGarbage(&mSemaphore);
}
angle::Result SemaphoreVk::importFd(gl::Context *context, gl::HandleType handleType, GLint fd)
{
switch (handleType)
{
case gl::HandleType::OpaqueFd:
return importOpaqueFd(context, fd);
default:
ANGLE_VK_UNREACHABLE(vk::GetImpl(context));
return angle::Result::Stop;
}
}
angle::Result SemaphoreVk::wait(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers)
{
ContextVk *contextVk = vk::GetImpl(context);
if (!bufferBarriers.empty())
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (!textureBarriers.empty())
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
contextVk->insertWaitSemaphore(&mSemaphore);
return angle::Result::Continue;
}
angle::Result SemaphoreVk::signal(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers)
{
ContextVk *contextVk = vk::GetImpl(context);
if (!bufferBarriers.empty())
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (!textureBarriers.empty())
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
return contextVk->flushImpl(&mSemaphore);
}
angle::Result SemaphoreVk::importOpaqueFd(gl::Context *context, GLint fd)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
if (!mSemaphore.valid())
{
mSemaphore.init(renderer->getDevice());
}
ASSERT(mSemaphore.valid());
VkImportSemaphoreFdInfoKHR importSemaphoreFdInfo = {};
importSemaphoreFdInfo.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR;
importSemaphoreFdInfo.semaphore = mSemaphore.getHandle();
importSemaphoreFdInfo.flags = 0;
importSemaphoreFdInfo.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
importSemaphoreFdInfo.fd = fd;
ANGLE_VK_TRY(contextVk, vkImportSemaphoreFdKHR(renderer->getDevice(), &importSemaphoreFdInfo));
return angle::Result::Continue;
}
} // namespace rx