class new in Git master
#include <Magnum/Vk/Fence.h>
Fence Fence.
Wraps a VkFence, which is used for synchronizing the CPU to a queue execution done on a Vulkan device.
Fence creation
A fence doesn't need any extra parameters for construction and can be constructed directly using Fence(Device&, const FenceCreateInfo&), leaving the info
parameter at its default. If you want to pass additional parameters to it, include the FenceCreateInfo class as usual:
#include <Magnum/Vk/FenceCreateInfo.h> … Vk::Fence fence{device, Vk::FenceCreateInfo{Vk::FenceCreateInfo::Flag::Signaled}};
Basic usage
By default a fence is created unsignaled. It can be created in a signaled state using FenceCreateInfo::
See Command buffer recording and submit for an example usage in command buffer submission.
Public static functions
- static auto wrap(Device& device, VkFence handle, HandleFlags flags = {}) -> Fence
- Wrap existing Vulkan handle.
Constructors, destructors, conversion operators
- Fence(Device& device, const FenceCreateInfo& info = FenceCreateInfo{}) explicit
- Constructor.
- Fence(NoCreateT) explicit
- Construct without creating the fence.
- Fence(const Fence&) deleted
- Copying is not allowed.
- Fence(Fence&& other) noexcept
- Move constructor.
- ~Fence()
- Destructor.
- operator VkFence()
Public functions
- auto operator=(const Fence&) -> Fence& deleted
- Copying is not allowed.
- auto operator=(Fence&& other) -> Fence& noexcept
- Move assignment.
- auto handle() -> VkFence
- Underlying VkFence handle.
- auto handleFlags() const -> HandleFlags
- Handle flags.
- void reset()
- Reset the fence.
- auto status() -> bool
- Fence status.
-
auto wait(std::
chrono:: nanoseconds timeout) -> bool - Wait for the fence to become signaled.
- void wait()
- Wait indefinitely for the fence to become signaled.
- auto release() -> VkFence
- Release the underlying Vulkan fence.
Function documentation
static Fence Magnum:: Vk:: Fence:: wrap(Device& device,
VkFence handle,
HandleFlags flags = {})
Wrap existing Vulkan handle.
Parameters | |
---|---|
device | Vulkan device the fence is created on |
handle | The VkFence handle |
flags | Handle flags |
The handle
is expected to be originating from device
. Unlike a fence created using a constructor, the Vulkan fence is by default not deleted on destruction, use flags
for different behavior.
Magnum:: Vk:: Fence:: Fence(Device& device,
const FenceCreateInfo& info = FenceCreateInfo{}) explicit
Constructor.
Parameters | |
---|---|
device | Vulkan device to create the fence on |
info | Fence creation info |
Magnum:: Vk:: Fence:: ~Fence()
Destructor.
Destroys associated VkFence handle, unless the instance was created using wrap() without HandleFlag::
Magnum:: Vk:: Fence:: operator VkFence()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: Vk:: Fence:: reset()
Reset the fence.
Sets the state of a fence to unsignaled from the host.
bool Magnum:: Vk:: Fence:: status()
Fence status.
Returns true
if the fence is signaled and false
if unsignaled.
bool Magnum:: Vk:: Fence:: wait(std:: chrono:: nanoseconds timeout)
Wait for the fence to become signaled.
Blocks until the fence becomes signaled or timeout
is elapsed, whichever happens sooner, returning true
is the fence became signaled. If the fence is already signaled, the function returns immediately, if the timeout happens before the fence becomes signaled, false
is returned.
Calling this function with zero timeout
is equivalent to calling status().
void Magnum:: Vk:: Fence:: wait()
Wait indefinitely for the fence to become signaled.
Equivalent to calling wait(std::
VkFence Magnum:: Vk:: Fence:: release()
Release the underlying Vulkan fence.
Releases ownership of the Vulkan fence and returns its handle so vkDestroyFence() is not called on destruction. The internal state is then equivalent to moved-from state.