synchronisation.cpp

1
2
3
4
#include <planet/vk/device.hpp>
#include <planet/vk/synchronisation.hpp>

#include <array>

planet::vk::fence

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
planet::vk::fence::fence(vk::device &d) : device{d} {
    VkFenceCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
    info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
    handle.create<vkCreateFence>(device.get(), info);
}


bool planet::vk::fence::is_ready() const {
    auto const result = vkGetFenceStatus(device.get(), get());
    if (result == VK_NOT_READY) {
        return false;
    } else {
        return planet::vk::worked(result) == VK_SUCCESS;
    }
}


void planet::vk::fence::reset() {
    std::array fences{get()};
    planet::vk::worked(
            vkResetFences(device.get(), fences.size(), fences.data()));
}

planet::vk::semaphore

38
39
40
41
42
planet::vk::semaphore::semaphore(vk::device &d) : device{d} {
    VkSemaphoreCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
    handle.create<vkCreateSemaphore>(device.get(), info);
}