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

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

View File

@@ -20,14 +20,14 @@
#include "core/present/gryphn_present.h"
typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, struct gnInstanceInfo_t info);
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
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);
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);
@@ -59,33 +59,33 @@ typedef struct gnFunctions_t {
#include "core/presentation_queue/gryphn_presentation_queue.h"
typedef struct gnDeviceFunctions_t {
gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo);
gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex);
gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, gnPresentationQueueInfo presentationInfo);
gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphoreHandle semaphore, uint32_t* imageIndex);
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);
gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info);
gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info);
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);
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);
gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info);
gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info);
void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool);
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, gnOutputDeviceHandle device);
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore);
gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
gnReturnCode (*_gnCreateFence)(struct gnFence_t* fence, gnOutputDeviceHandle 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);
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
void (*_gnSignalFence)(gnFenceHandle fence);
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
void (*_gnResetFence)(gnFenceHandle fence);
void (*_gnDestroyFence)(gnFenceHandle fence);
gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
@@ -99,7 +99,7 @@ typedef struct gnCommandFunctions_t {
void (*_gnResetCommandBuffer)(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 (*_gnCommandBindGraphicsPipeline)(gnCommandBufferHandle buffer, gnGraphicsPipelineHandle graphicsPipeline);

View File

@@ -1,6 +1,6 @@
#include "core/gryphn_platform_functions.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);
}

View File

@@ -1,14 +1,15 @@
#pragma once
#include "core/sync/semaphore/gryphn_semaphore.h"
#include "core/presentation_queue/gryphn_presentation_queue.h"
#include "utils/gryphn_error_code.h"
#include "stdint.h"
#include "core/gryphn_handles.h"
typedef struct gnPresentInfo_t {
uint32_t waitCount;
struct gnSemaphore_t* waitSemaphores;
gnSemaphoreHandle* waitSemaphores;
uint32_t presentationQueueCount;
gnPresentationQueueHandle* presentationQueues;
uint32_t* imageIndices;
uint32_t queueIndex;
} 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 "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)->outputDevice = device;
(*presentationQueue)->info = 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);
}
uint32_t gnGetPresentationQueueImageCount(gnPresentationQueueHandle presentationQueue) { return presentationQueue->imageCount; }

View File

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

View File

@@ -1,6 +1,6 @@
#include "gryphn_submit.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);
}

View File

@@ -1,19 +1,17 @@
#pragma once
#include "stdint.h"
#include "core/sync/semaphore/gryphn_semaphore.h"
#include "core/sync/fence/gryphn_fence.h"
#include "core/output_device/gryphn_output_device.h"
typedef struct gnSubmitInfo_t {
uint32_t waitCount;
enum gnRenderPassStage_e* waitStages;
struct gnSemaphore_t* waitSemaphores;
gnSemaphoreHandle* waitSemaphores;
uint32_t signalCount;
struct gnSemaphore_t* signalSemaphores;
gnSemaphoreHandle* signalSemaphores;
uint32_t commandBufferCount;
gnCommandBufferHandle* commandBuffers;
uint32_t queueIndex;
struct gnFence_t* fence;
} 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 "stdio.h"
gnReturnCode gnCreateFence(struct gnFence_t* fence, struct gnOutputDevice_t* device) {
fence->device = device;
fence->signaled = gnFalse;
return device->deviceFunctions->_gnCreateFence(fence, device);
gnReturnCode gnCreateFence(gnFenceHandle* fence, struct gnOutputDevice_t* device) {
*fence = malloc(sizeof(struct gnFence_t));
(*fence)->device = device;
(*fence)->signaled = gnFalse;
return device->deviceFunctions->_gnCreateFence(*fence, device);
}
void gnSignalFence(struct gnFence_t* fence) {
void gnSignalFence(gnFenceHandle fence) {
fence->signaled = gnTrue;
// 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;
fence->device->deviceFunctions->_gnWaitForFence(fence, timeout);
}
void gnResetFence(struct gnFence_t* fence) {
void gnResetFence(gnFenceHandle fence) {
fence->signaled = gnFalse;
fence->device->deviceFunctions->_gnResetFence(fence);
}
void gnDestroyFence(struct gnFence_t* fence) {
void gnDestroyFence(gnFenceHandle fence) {
fence->device->deviceFunctions->_gnDestroyFence(fence);
}

View File

@@ -1,15 +1,18 @@
#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"
typedef struct gnFence_t {
#ifdef GN_REVEAL_IMPL
struct gnFence_t {
struct gnPlatformFence_t* fence;
struct gnOutputDevice_t* device;
gnOutputDeviceHandle device;
gnBool signaled;
} gnFence;
};
#endif
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);
gnReturnCode gnCreateFence(gnFenceHandle* fence, gnOutputDeviceHandle device);
void gnSignalFence(gnFenceHandle fence);
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout);
void gnResetFence(gnFenceHandle fence);
void gnDestroyFence(gnFenceHandle fence);

View File

@@ -1,9 +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);
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device) {
*semaphore = malloc(sizeof(struct gnSemaphore_t));
(*semaphore)->device = device;
return device->deviceFunctions->_gnCreateSemaphore((*semaphore), device);
}
void gnDestroySemaphore(struct gnSemaphore_t* semaphore) {
semaphore->device->deviceFunctions->_gnDestroySemaphore(semaphore);

View File

@@ -1,10 +1,13 @@
#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 gnOutputDevice_t* device;
} gnSemaphore;
gnOutputDeviceHandle device;
};
#endif
gnReturnCode gnCreateSemaphore(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device);
void gnDestroySemaphore(struct gnSemaphore_t* semaphore);
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device);
void gnDestroySemaphore(gnSemaphore semaphore);