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

@@ -14,6 +14,8 @@
#include "command/command_pool/gryphn_command_pool.h"
#include "command/command_buffer/gryphn_command_buffer.h"
#include "renderpass/gryphn_render_pass.h"
#include "sync/fence/gryphn_fence.h"
#include "sync/semaphore/gryphn_semaphore.h"
typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
@@ -72,6 +74,15 @@ typedef struct gnDeviceFunctions_t {
gnReturnCode (*_gnCreateCommandPool)(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info);
void (*_gnDestroyCommandPool)(struct gnCommandPool_t* commandPool);
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device);
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore);
gnReturnCode (*_gnCreateFence)(struct gnFence_t* fence, struct gnOutputDevice_t* device);
void (*_gnSignalFence)(struct gnFence_t* fence);
void (*_gnWaitForFence)(struct gnFence_t* fence, uint64_t timeout);
void (*_gnResetFence)(struct gnFence_t* fence);
void (*_gnDestroyFence)(struct gnFence_t* fence);
} gnDeviceFunctions;
typedef struct gnCommandFunctions_t {

View File

@@ -81,6 +81,13 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn");
gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn");
gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn");
gnLoadDLLFunction(lib, functions->_gnCreateSemaphore, "gnCreateSemaphoreFn");
gnLoadDLLFunction(lib, functions->_gnDestroySemaphore, "gnDestroySemaphoreFn");
gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn");
gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn");
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn");
gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn");
}
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {

View File

@@ -0,0 +1,24 @@
#include "gryphn_fence.h"
#include "core/gryphn_platform_functions.h"
#include "stdio.h"
gnReturnCode gnCreateFence(struct gnFence_t* fence, struct gnOutputDevice_t* device) {
fence->device = device;
fence->signaled = gnFalse;
return device->deviceFunctions->_gnCreateFence(fence, device);
}
void gnSignalFence(struct gnFence_t* fence) {
fence->signaled = gnTrue;
// fence->device->deviceFunctions->_gnSignalFence(fence);
}
void gnWaitForFence(struct gnFence_t* fence, uint64_t timeout) {
if (fence->signaled == gnTrue) return;
fence->device->deviceFunctions->_gnWaitForFence(fence, timeout);
}
void gnResetFence(struct gnFence_t* fence) {
fence->signaled = gnFalse;
fence->device->deviceFunctions->_gnResetFence(fence);
}
void gnDestroyFence(struct gnFence_t* fence) {
fence->device->deviceFunctions->_gnDestroyFence(fence);
}

View File

@@ -4,6 +4,8 @@
typedef struct gnFence_t {
struct gnPlatformFence_t* fence;
struct gnOutputDevice_t* device;
gnBool signaled;
} gnFence;
gnReturnCode gnCreateFence(struct gnFence_t* fence, struct gnOutputDevice_t* device);

View File

@@ -0,0 +1,10 @@
#include "gryphn_semaphore.h"
#include "core/gryphn_platform_functions.h"
gnReturnCode gnCreateSemaphore(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device) {
semaphore->device = device;
return device->deviceFunctions->_gnCreateSemaphore(semaphore, device);
}
void gnDestroySemaphore(struct gnSemaphore_t* semaphore) {
semaphore->device->deviceFunctions->_gnDestroySemaphore(semaphore);
}

View File

@@ -3,6 +3,7 @@
typedef struct gnSemaphore_t {
struct gnPlatformSemaphore_t* semaphore;
struct gnOutputDevice_t* device;
} gnSemaphore;
gnReturnCode gnCreateSemaphore(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device);

View File

@@ -30,7 +30,9 @@ typedef enum gnReturnCode_t {
GN_FAILED_TO_CREATE_COMMAND_POOL,
GN_FAILED_TO_BEGIN_RECORDING,
GN_FAIELD_TO_END_RECORDING,
GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS
GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS,
GN_FAILED_TO_CREATE_FENCE,
GN_FAILED_TO_CREATE_SEMAPHORE
} gnReturnCode;
typedef gnReturnCode gnErrorCode;
@@ -66,5 +68,7 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
case GN_FAILED_TO_BEGIN_RECORDING: return "GN_FAILED_TO_BEGIN_RECORDING";
case GN_FAIELD_TO_END_RECORDING: return "GN_FAIELD_TO_END_RECORDING";
case GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS: return "GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS";
case GN_FAILED_TO_CREATE_FENCE: return "GN_FAILED_TO_CREATE_FENCE";
case GN_FAILED_TO_CREATE_SEMAPHORE: return "GN_FAILED_TO_CREATE_SEMAPHORE";
}
}