2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
// VulkanFence.cpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2019/01/31.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "backend/vulkan/component/VulkanFence.hpp"
|
2019-04-17 10:49:11 +08:00
|
|
|
#if VK_FENCE_WAIT_FD_IF_SUPPORT
|
|
|
|
#include <errno.h>
|
|
|
|
#include <poll.h>
|
|
|
|
#include <string.h>
|
2019-12-27 22:16:57 +08:00
|
|
|
#include <MNN/MNNDefine.h>
|
2019-04-17 10:49:11 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace MNN {
|
|
|
|
VulkanFence::VulkanFence(const VulkanDevice& dev) : mDevice(dev) {
|
|
|
|
CALL_VK(mDevice.createFence(mFence));
|
|
|
|
}
|
|
|
|
VulkanFence::~VulkanFence() {
|
|
|
|
mDevice.destroyFence(mFence);
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult VulkanFence::rawWait() const {
|
|
|
|
auto status = VK_TIMEOUT;
|
|
|
|
do {
|
|
|
|
status = mDevice.waitForFence(mFence, 5000000000);
|
|
|
|
} while (status == VK_TIMEOUT);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult VulkanFence::wait() const {
|
|
|
|
return rawWait();
|
|
|
|
}
|
|
|
|
VkResult VulkanFence::reset() const {
|
|
|
|
return mDevice.resetFence(mFence);
|
|
|
|
}
|
|
|
|
} // namespace MNN
|