Files
Gryphn/projects/apis/vulkan/src/sync/fence/vulkan_fence.c
2025-06-24 12:04:16 -04:00

24 lines
995 B
C

#include "vulkan_fence.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateFenceFn(struct gnFence_t* fence, struct gnOutputDevice_t* device) {
fence->fence = malloc(sizeof(gnPlatformFence));
VkFenceCreateInfo fenceInfo = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
};
if (vkCreateFence(device->outputDevice->device, &fenceInfo, NULL, &fence->fence->fence) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_FENCE;
return GN_SUCCESS;
}
void gnSignalFenceFn(struct gnFence_t* fence) {}
void gnWaitForFenceFn(struct gnFence_t* fence, uint64_t timeout) {
vkWaitForFences(fence->device->outputDevice->device, 1, &fence->fence->fence, VK_TRUE, timeout);
}
void gnResetFenceFn(struct gnFence_t* fence) {
vkResetFences(fence->device->outputDevice->device, 1, &fence->fence->fence);
}
void gnDestroyFenceFn(struct gnFence_t* fence) {
vkDestroyFence(fence->device->outputDevice->device, fence->fence->fence, NULL);
free(fence->fence);
}