sync primative handles

This commit is contained in:
Greg Wells
2025-06-05 22:19:38 -04:00
parent 4349f76ede
commit d5d339105d
17 changed files with 78 additions and 69 deletions

View File

@@ -8,9 +8,9 @@
#include "core/texture/metal_texture.h" #include "core/texture/metal_texture.h"
#import <QuartzCore/CAMetalLayer.h> #import <QuartzCore/CAMetalLayer.h>
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) { gnReturnCode gnPresentFn(gnOutputDeviceHandle device, struct gnPresentInfo_t info) {
for (int i = 0; i < info.waitCount; i++) { for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i].semaphore->eventTriggered) {} while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
} }
for (int i =0 ; i < info.presentationQueueCount; i++) { for (int i =0 ; i < info.presentationQueueCount; i++) {

View File

@@ -6,19 +6,19 @@
gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) { gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
for (int i = 0; i < info.waitCount; i++) { for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i].semaphore->eventTriggered) {} while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
} }
__block gnSemaphore* semsToSignal = info.signalSemaphores; __block gnSemaphore* semsToSignal = info.signalSemaphores;
__block int semsToSignalCount = info.signalCount; __block int semsToSignalCount = info.signalCount;
__block gnFence* fenceToSignal = info.fence; __block gnFence fenceToSignal = info.fence;
for (int i = 0; i < info.commandBufferCount; i++) { for (int i = 0; i < info.commandBufferCount; i++) {
id<MTLCommandBuffer> commandBuffer = info.commandBuffers[i]->commandBuffer->commandBuffer; id<MTLCommandBuffer> commandBuffer = info.commandBuffers[i]->commandBuffer->commandBuffer;
[info.commandBuffers[i]->commandBuffer->commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) { [info.commandBuffers[i]->commandBuffer->commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
for (int c = 0; c < semsToSignalCount; c++) { for (int c = 0; c < semsToSignalCount; c++) {
semsToSignal[c].semaphore->eventTriggered = gnTrue; semsToSignal[c]->semaphore->eventTriggered = gnTrue;
} }
}]; }];
fenceToSignal->signaled = gnTrue; fenceToSignal->signaled = gnTrue;

View File

@@ -4,5 +4,5 @@
typedef struct gnPlatformSemaphore_t { typedef struct gnPlatformSemaphore_t {
id<MTLEvent> event; id<MTLEvent> event;
gnBool eventTriggered; bool eventTriggered;
} gnPlatformSemaphore; } gnPlatformSemaphore;

View File

@@ -7,7 +7,7 @@
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) { gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount); VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore; for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount); VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain; for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain;

View File

@@ -17,14 +17,14 @@ gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t i
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount); VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount); VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore; for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]); for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]);
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount); VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer; for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount); VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i].semaphore->semaphore; for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i]->semaphore->semaphore;
VkSubmitInfo submitInfo = { VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,

View File

@@ -15,3 +15,5 @@ GN_HANDLE(gnShaderModule);
GN_HANDLE(gnGraphicsPipeline); GN_HANDLE(gnGraphicsPipeline);
GN_HANDLE(gnCommandPool); GN_HANDLE(gnCommandPool);
GN_HANDLE(gnCommandBuffer); GN_HANDLE(gnCommandBuffer);
GN_HANDLE(gnSemaphore);
GN_HANDLE(gnFence);

View File

@@ -20,14 +20,14 @@
#include "core/present/gryphn_present.h" #include "core/present/gryphn_present.h"
typedef struct gnFunctions_t { typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, struct gnInstanceInfo_t info); gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
void (*_gnDestroyInstance)(gnInstanceHandle instance); void (*_gnDestroyInstance)(gnInstanceHandle instance);
gnReturnCode (*_gnCreateDebugger)(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info); gnReturnCode (*_gnCreateDebugger)(gnDebuggerHandle debugger, gnInstanceHandle instance, const gnDebuggerInfo info);
void (*_gnDestroyDebugger)(gnDebuggerHandle debugger); void (*_gnDestroyDebugger)(gnDebuggerHandle debugger);
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count); gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const gnWindowSurfaceHandle windowSurface); gnBool (*_gnQueueCanPresentToSurface)(const gnPhysicalDevice device, uint32_t queueIndex, const gnWindowSurfaceHandle windowSurface);
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDeviceHandle device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo); gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDeviceHandle device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
@@ -59,33 +59,33 @@ typedef struct gnFunctions_t {
#include "core/presentation_queue/gryphn_presentation_queue.h" #include "core/presentation_queue/gryphn_presentation_queue.h"
typedef struct gnDeviceFunctions_t { typedef struct gnDeviceFunctions_t {
gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo); gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, gnPresentationQueueInfo presentationInfo);
gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex); gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphoreHandle semaphore, uint32_t* imageIndex);
void (*_gnDestroyPresentationQueue)(gnPresentationQueueHandle presentationQueue); void (*_gnDestroyPresentationQueue)(gnPresentationQueueHandle presentationQueue);
gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo); gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, gnShaderModuleInfo shaderModuleInfo);
void (*_gnDestroyShaderModule)(gnShaderModuleHandle module); void (*_gnDestroyShaderModule)(gnShaderModuleHandle module);
gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info); gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info);
void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass); void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass);
gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t pipelineInfo); gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo pipelineInfo);
void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline); void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline);
gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, struct gnFramebufferInfo_t framebufferInfo); gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo);
void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer); void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer);
gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info); gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info);
void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool); void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool);
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, gnOutputDeviceHandle device); gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore); void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
gnReturnCode (*_gnCreateFence)(struct gnFence_t* fence, gnOutputDeviceHandle device); gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
void (*_gnSignalFence)(struct gnFence_t* fence); void (*_gnSignalFence)(gnFenceHandle fence);
void (*_gnWaitForFence)(struct gnFence_t* fence, uint64_t timeout); void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
void (*_gnResetFence)(struct gnFence_t* fence); void (*_gnResetFence)(gnFenceHandle fence);
void (*_gnDestroyFence)(struct gnFence_t* fence); void (*_gnDestroyFence)(gnFenceHandle fence);
gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit); gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info); gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
@@ -99,7 +99,7 @@ typedef struct gnCommandFunctions_t {
void (*_gnResetCommandBuffer)(gnCommandBufferHandle commandBuffer); void (*_gnResetCommandBuffer)(gnCommandBufferHandle commandBuffer);
gnReturnCode (*_gnEndCommandBuffer)(gnCommandBufferHandle commandBuffer); gnReturnCode (*_gnEndCommandBuffer)(gnCommandBufferHandle commandBuffer);
void (*_gnCommandBeginRenderPass)(gnCommandBufferHandle buffer, struct gnRenderPassInfo_t passInfo); void (*_gnCommandBeginRenderPass)(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo);
void (*_gnCommandEndRenderPass)(gnCommandBufferHandle buffer); void (*_gnCommandEndRenderPass)(gnCommandBufferHandle buffer);
void (*_gnCommandBindGraphicsPipeline)(gnCommandBufferHandle buffer, gnGraphicsPipelineHandle graphicsPipeline); void (*_gnCommandBindGraphicsPipeline)(gnCommandBufferHandle buffer, gnGraphicsPipelineHandle graphicsPipeline);

View File

@@ -1,6 +1,6 @@
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
#include "gryphn_present.h" #include "gryphn_present.h"
gnReturnCode gnPresent(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) { gnReturnCode gnPresent(gnOutputDeviceHandle device, gnPresentInfo info) {
return device->deviceFunctions->_gnPresent(device, info); return device->deviceFunctions->_gnPresent(device, info);
} }

View File

@@ -1,14 +1,15 @@
#pragma once #pragma once
#include "core/sync/semaphore/gryphn_semaphore.h" #include "utils/gryphn_error_code.h"
#include "core/presentation_queue/gryphn_presentation_queue.h" #include "stdint.h"
#include "core/gryphn_handles.h"
typedef struct gnPresentInfo_t { typedef struct gnPresentInfo_t {
uint32_t waitCount; uint32_t waitCount;
struct gnSemaphore_t* waitSemaphores; gnSemaphoreHandle* waitSemaphores;
uint32_t presentationQueueCount; uint32_t presentationQueueCount;
gnPresentationQueueHandle* presentationQueues; gnPresentationQueueHandle* presentationQueues;
uint32_t* imageIndices; uint32_t* imageIndices;
uint32_t queueIndex; uint32_t queueIndex;
} gnPresentInfo; } gnPresentInfo;
gnReturnCode gnPresent(struct gnOutputDevice_t* device, struct gnPresentInfo_t info); gnReturnCode gnPresent(gnOutputDeviceHandle device, gnPresentInfo info);

View File

@@ -1,14 +1,14 @@
#include "gryphn_presentation_queue.h" #include "gryphn_presentation_queue.h"
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
gnReturnCode gnCreatePresentationQueue(gnPresentationQueueHandle* presentationQueue, struct gnOutputDevice_t* device, struct gnPresentationQueueInfo_t presentationInfo){ gnReturnCode gnCreatePresentationQueue(gnPresentationQueueHandle* presentationQueue, gnOutputDeviceHandle device, gnPresentationQueueInfo presentationInfo){
*presentationQueue = malloc(sizeof(struct gnPresentationQueue_t)); *presentationQueue = malloc(sizeof(struct gnPresentationQueue_t));
(*presentationQueue)->outputDevice = device; (*presentationQueue)->outputDevice = device;
(*presentationQueue)->info = presentationInfo; (*presentationQueue)->info = presentationInfo;
return device->deviceFunctions->_gnCreatePresentationQueue(*presentationQueue, device, presentationInfo); return device->deviceFunctions->_gnCreatePresentationQueue(*presentationQueue, device, presentationInfo);
} }
gnReturnCode gnPresentationQueueGetImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex) { gnReturnCode gnPresentationQueueGetImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphoreHandle semaphore, uint32_t* imageIndex) {
return presentationQueue->outputDevice->deviceFunctions->_gnPresentationQueueGetImage(presentationQueue, timeout, semaphore, imageIndex); return presentationQueue->outputDevice->deviceFunctions->_gnPresentationQueueGetImage(presentationQueue, timeout, semaphore, imageIndex);
} }
uint32_t gnGetPresentationQueueImageCount(gnPresentationQueueHandle presentationQueue) { return presentationQueue->imageCount; } uint32_t gnGetPresentationQueueImageCount(gnPresentationQueueHandle presentationQueue) { return presentationQueue->imageCount; }

View File

@@ -29,8 +29,8 @@ struct gnPresentationQueue_t {
}; };
#endif #endif
gnReturnCode gnCreatePresentationQueue(gnPresentationQueueHandle* presentationQueue, struct gnOutputDevice_t* device, struct gnPresentationQueueInfo_t presentationInfo); gnReturnCode gnCreatePresentationQueue(gnPresentationQueueHandle* presentationQueue, gnOutputDeviceHandle device, gnPresentationQueueInfo presentationInfo);
gnReturnCode gnPresentationQueueGetImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex); gnReturnCode gnPresentationQueueGetImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphoreHandle semaphore, uint32_t* imageIndex);
uint32_t gnGetPresentationQueueImageCount(gnPresentationQueueHandle presentationQueue); uint32_t gnGetPresentationQueueImageCount(gnPresentationQueueHandle presentationQueue);
gnTextureHandle gnGetPresentationQueueImage(gnPresentationQueueHandle presentationQueue, uint32_t index); gnTextureHandle gnGetPresentationQueueImage(gnPresentationQueueHandle presentationQueue, uint32_t index);
void gnDestroyPresentationQueue(gnPresentationQueueHandle presentationQueue); void gnDestroyPresentationQueue(gnPresentationQueueHandle presentationQueue);

View File

@@ -1,6 +1,6 @@
#include "gryphn_submit.h" #include "gryphn_submit.h"
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
gnReturnCode gnSubmit(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) { gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info) {
return device->deviceFunctions->_gnSubmit(device, info); return device->deviceFunctions->_gnSubmit(device, info);
} }

View File

@@ -1,19 +1,17 @@
#pragma once #pragma once
#include "stdint.h" #include "stdint.h"
#include "core/sync/semaphore/gryphn_semaphore.h"
#include "core/sync/fence/gryphn_fence.h" #include "core/sync/fence/gryphn_fence.h"
#include "core/output_device/gryphn_output_device.h"
typedef struct gnSubmitInfo_t { typedef struct gnSubmitInfo_t {
uint32_t waitCount; uint32_t waitCount;
enum gnRenderPassStage_e* waitStages; enum gnRenderPassStage_e* waitStages;
struct gnSemaphore_t* waitSemaphores; gnSemaphoreHandle* waitSemaphores;
uint32_t signalCount; uint32_t signalCount;
struct gnSemaphore_t* signalSemaphores; gnSemaphoreHandle* signalSemaphores;
uint32_t commandBufferCount; uint32_t commandBufferCount;
gnCommandBufferHandle* commandBuffers; gnCommandBufferHandle* commandBuffers;
uint32_t queueIndex; uint32_t queueIndex;
struct gnFence_t* fence; struct gnFence_t* fence;
} gnSubmitInfo; } gnSubmitInfo;
gnReturnCode gnSubmit(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit); gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info);

View File

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

View File

@@ -1,15 +1,18 @@
#pragma once #pragma once
#include "core/output_device/gryphn_output_device.h" #include "core/gryphn_handles.h"
#include "utils/gryphn_bool.h"
#include "utils/gryphn_error_code.h"
#ifdef GN_REVEAL_IMPL
typedef struct gnFence_t { struct gnFence_t {
struct gnPlatformFence_t* fence; struct gnPlatformFence_t* fence;
struct gnOutputDevice_t* device; gnOutputDeviceHandle device;
gnBool signaled; gnBool signaled;
} gnFence; };
#endif
gnReturnCode gnCreateFence(struct gnFence_t* fence, struct gnOutputDevice_t* device); gnReturnCode gnCreateFence(gnFenceHandle* fence, gnOutputDeviceHandle device);
void gnSignalFence(struct gnFence_t* fence); void gnSignalFence(gnFenceHandle fence);
void gnWaitForFence(struct gnFence_t* fence, uint64_t timeout); void gnWaitForFence(gnFenceHandle fence, uint64_t timeout);
void gnResetFence(struct gnFence_t* fence); void gnResetFence(gnFenceHandle fence);
void gnDestroyFence(struct gnFence_t* fence); void gnDestroyFence(gnFenceHandle fence);

View File

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

View File

@@ -1,10 +1,13 @@
#pragma once #pragma once
#include "core/output_device/gryphn_output_device.h" #include "core/gryphn_handles.h"
#include "utils/gryphn_error_code.h"
typedef struct gnSemaphore_t { #ifdef GN_REVEAL_IMPL
struct gnSemaphore_t {
struct gnPlatformSemaphore_t* semaphore; struct gnPlatformSemaphore_t* semaphore;
struct gnOutputDevice_t* device; gnOutputDeviceHandle device;
} gnSemaphore; };
#endif
gnReturnCode gnCreateSemaphore(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device); gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device);
void gnDestroySemaphore(struct gnSemaphore_t* semaphore); void gnDestroySemaphore(gnSemaphore semaphore);