vulkan+gryphn sync impl

This commit is contained in:
Greg Wells
2025-05-30 11:00:20 -04:00
parent 7ffae404bb
commit 014b315faa
11 changed files with 114 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
#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);
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include <vulkan/vulkan.h>
#include "core/sync/fence/gryphn_fence.h"
typedef struct gnPlatformFence_t {
VkFence fence;
} gnPlatformFence;

View File

@@ -0,0 +1,17 @@
#include "vulkan_semaphore.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateSemaphoreFn(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device) {
semaphore->semaphore = malloc(sizeof(gnPlatformSemaphore));
VkSemaphoreCreateInfo semaphoreInfo = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
};
if (vkCreateSemaphore(device->outputDevice->device, &semaphoreInfo, NULL, &semaphore->semaphore->semaphore))
return GN_FAILED_TO_CREATE_SEMAPHORE;
return GN_SUCCESS;
}
void gnDestroySemaphoreFn(struct gnSemaphore_t* semaphore) {
vkDestroySemaphore(semaphore->device->outputDevice->device, semaphore->semaphore->semaphore, NULL);
free(semaphore->semaphore);
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include <vulkan/vulkan.h>
#include "core/sync/semaphore/gryphn_semaphore.h"
typedef struct gnPlatformSemaphore_t {
VkSemaphore semaphore;
} gnPlatformSemaphore;