diff --git a/rendering_api/metal/src/core/debugger/metal_debugger.m b/rendering_api/metal/src/core/debugger/metal_debugger.m index 77dc534..eec1f25 100644 --- a/rendering_api/metal/src/core/debugger/metal_debugger.m +++ b/rendering_api/metal/src/core/debugger/metal_debugger.m @@ -1,9 +1,9 @@ #include // these do nothing because I am too lazy to write a debugger for metal at this point in time -gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) { +gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) { return GN_SUCCESS; } -void gnDestroyDebuggerFn(gnDebugger* instance) { +void gnDestroyDebuggerFn(gnDebuggerHandle instance) { } diff --git a/rendering_api/vulkan/src/debugger/vulkan_debugger.c b/rendering_api/vulkan/src/debugger/vulkan_debugger.c index dbef784..f0d2bdf 100644 --- a/rendering_api/vulkan/src/debugger/vulkan_debugger.c +++ b/rendering_api/vulkan/src/debugger/vulkan_debugger.c @@ -90,7 +90,7 @@ void vk_destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessenger } } -gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) { +gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) { debugger->debugger = malloc(sizeof(gnPlatformDebugger)); if (instance->valid == gnFalse) { @@ -156,6 +156,6 @@ gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstanceHandle instance, return GN_SUCCESS; } -void gnDestroyDebuggerFn(gnDebugger* debugger) { +void gnDestroyDebuggerFn(gnDebuggerHandle debugger) { vk_destroyDebugUtilsMessengerEXT(debugger->instance->instance->vk_instance, debugger->debugger->debugMessenger, NULL); } diff --git a/src/core/debugger/gryphn_debugger.c b/src/core/debugger/gryphn_debugger.c index 79d04e8..1568e2f 100644 --- a/src/core/debugger/gryphn_debugger.c +++ b/src/core/debugger/gryphn_debugger.c @@ -2,10 +2,11 @@ #include #include "stdio.h" -gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info) { - debugger->info = info; +gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info) { + *debugger = malloc(sizeof(struct gnDebugger_t)); + (*debugger)->info = info; return GN_SUCCESS; } -void gnDestroyDebugger(gnDebugger* debugger) { - // debugger->instance->functions->_gnDestroyDebugger(debugger); +void gnDestroyDebugger(gnDebuggerHandle debugger) { + free(debugger); } diff --git a/src/core/debugger/gryphn_debugger.h b/src/core/debugger/gryphn_debugger.h index 90e00c7..8b6131a 100644 --- a/src/core/debugger/gryphn_debugger.h +++ b/src/core/debugger/gryphn_debugger.h @@ -44,16 +44,23 @@ typedef struct gnDebuggerInfo_t { void* userData; } gnDebuggerInfo; -typedef struct gnDebugger_t { +#ifdef GN_REVEAL_IMPL +struct gnDebugger_t { struct gnPlatformDebugger_t* debugger; struct gnDebuggerInfo_t info; gnInstanceHandle instance; -} gnDebugger; +}; +#endif +typedef struct gnDebugger_t* gnDebuggerHandle; +typedef gnDebuggerHandle gnDebugger; -gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info); -void gnDestroyDebugger(gnDebugger* debugger); +gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info); +void gnDestroyDebugger(gnDebuggerHandle debugger); + +#ifdef GN_REVEAL_IMPL +static void gnDebuggerSetErrorMessage(gnDebuggerHandle debugger, gnMessageData data) { + if (debugger == NULL) return; -static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) { debugger->info.callback( GN_MESSAGE_ERROR, GN_DEBUG_MESSAGE_VALIDATION, @@ -61,3 +68,4 @@ static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) debugger->info.userData ); } +#endif diff --git a/src/core/gryphn_platform_functions.h b/src/core/gryphn_platform_functions.h index c887338..abb5e8b 100644 --- a/src/core/gryphn_platform_functions.h +++ b/src/core/gryphn_platform_functions.h @@ -23,8 +23,8 @@ typedef struct gnFunctions_t { gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, struct gnInstanceInfo_t info); void (*_gnDestroyInstance)(gnInstanceHandle instance); - gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info); - void (*_gnDestroyDebugger)(gnDebugger* debugger); + gnReturnCode (*_gnCreateDebugger)(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info); + void (*_gnDestroyDebugger)(gnDebuggerHandle debugger); gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count); gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface); diff --git a/src/core/instance/gryphn_instance.c b/src/core/instance/gryphn_instance.c index f3154a7..f1f848f 100644 --- a/src/core/instance/gryphn_instance.c +++ b/src/core/instance/gryphn_instance.c @@ -2,6 +2,7 @@ #include "init/gryphn_init.h" #include #include "core/debugger/gryphn_debugger.h" +#include "core/instance/gryphn_instance.h" gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) { *instanceHandlePtr = malloc(sizeof(struct gnInstance_t)); @@ -42,4 +43,5 @@ void gnDestroyInstance(gnInstanceHandle instance) { void gnInstanceReleaseDebugger(gnInstanceHandle instance) { instance->debugger = NULL; + free(instance); } diff --git a/src/core/instance/gryphn_instance.h b/src/core/instance/gryphn_instance.h index 6e77981..72d0c30 100644 --- a/src/core/instance/gryphn_instance.h +++ b/src/core/instance/gryphn_instance.h @@ -5,7 +5,7 @@ struct gnPlatformInstance_t; struct gnFunctions_t; struct gnDynamicLibrary_t; -struct gnDebugger_t; +typedef struct gnDebugger_t* gnDebuggerHandle; typedef struct gnInstanceInfo_t { gnString applicationName; @@ -17,6 +17,7 @@ typedef struct gnInstanceInfo_t { gnRenderingAPI renderingAPI; } gnInstanceInfo; +#ifdef GN_REVEAL_IMPL struct gnInstance_t { struct gnPlatformInstance_t* instance; gnBool valid, @@ -29,12 +30,13 @@ struct gnInstance_t { struct gnDeviceFunctions_t* deviceFunctions; struct gnCommandFunctions_t* commandFunctions; - struct gnDebugger_t* debugger; -} gnInstance_t; - + gnDebuggerHandle debugger; +}; +#endif typedef struct gnInstance_t* gnInstanceHandle; +typedef struct gnInstance_t* gnInstance; gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info); -void gnInstanceAttachDebugger(gnInstanceHandle istance, struct gnDebugger_t* debugger); +void gnInstanceAttachDebugger(gnInstanceHandle istance, gnDebuggerHandle debugger); void gnInstanceReleaseDebugger(gnInstanceHandle instance); void gnDestroyInstance(gnInstanceHandle instance);