From 8d476781a852d4cea016d1a2f010d42cadcf5913 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Tue, 15 Jul 2025 09:18:53 -0400 Subject: [PATCH] remove gnCreateDebugger function --- include/gryphn/gryphn.h | 1 - .../command_buffer/metal_command_buffer.m | 1 - .../apis/metal/src/debugger/metal_debugger.m | 9 -------- .../metal/src/devices/metal_output_device.m | 1 - .../src/framebuffers/metal_framebuffer.m | 1 - .../metal_graphics_pipeline.m | 1 - .../apis/metal/src/present/metal_present.h | 1 - .../metal_presentation_queue.m | 1 - .../src/shader_module/metal_shader_module.m | 6 ++--- projects/apis/metal/src/submit/metal_submit.h | 1 - .../vulkan/src/debugger/vulkan_debugger.c | 4 ++-- .../vulkan/src/debugger/vulkan_debugger.h | 12 +++++----- .../vulkan/src/instance/vulkan_instance.c | 8 +++---- .../src/output_device/vulkan_output_device.c | 2 +- projects/core/src/debugger/gryphn_debugger.c | 8 ------- .../{debugger => instance}/gryphn_debugger.h | 22 +++++-------------- projects/core/src/instance/gryphn_instance.c | 11 ++++++---- projects/core/src/instance/gryphn_instance.h | 6 +++-- .../extensions/sync_functions.c | 2 +- .../function_loader/src/command_functions.c | 2 +- .../function_loader/src/device_functions.c | 2 +- .../function_loader/src/instance_functions.c | 2 +- 22 files changed, 36 insertions(+), 68 deletions(-) delete mode 100644 projects/apis/metal/src/debugger/metal_debugger.m delete mode 100644 projects/core/src/debugger/gryphn_debugger.c rename projects/core/src/{debugger => instance}/gryphn_debugger.h (72%) diff --git a/include/gryphn/gryphn.h b/include/gryphn/gryphn.h index 0c0e3fc..9752e46 100644 --- a/include/gryphn/gryphn.h +++ b/include/gryphn/gryphn.h @@ -3,7 +3,6 @@ // core functionality #include -#include #include #include #include diff --git a/projects/apis/metal/src/commands/command_buffer/metal_command_buffer.m b/projects/apis/metal/src/commands/command_buffer/metal_command_buffer.m index 4fcf198..4e571cb 100644 --- a/projects/apis/metal/src/commands/command_buffer/metal_command_buffer.m +++ b/projects/apis/metal/src/commands/command_buffer/metal_command_buffer.m @@ -1,6 +1,5 @@ #include "metal_command_buffer.h" #include "commands/command_pool/metal_command_pool.h" -#include "debugger/gryphn_debugger.h" #include "instance/gryphn_instance.h" #import diff --git a/projects/apis/metal/src/debugger/metal_debugger.m b/projects/apis/metal/src/debugger/metal_debugger.m deleted file mode 100644 index e8830f3..0000000 --- a/projects/apis/metal/src/debugger/metal_debugger.m +++ /dev/null @@ -1,9 +0,0 @@ -#include - -// these do nothing because I am too lazy to write a debugger for metal at this point in time -gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const gnDebuggerInfo info) { - return GN_SUCCESS; -} -void gnDestroyDebuggerFn(gnDebuggerHandle instance) { - -} diff --git a/projects/apis/metal/src/devices/metal_output_device.m b/projects/apis/metal/src/devices/metal_output_device.m index 820131a..560a662 100644 --- a/projects/apis/metal/src/devices/metal_output_device.m +++ b/projects/apis/metal/src/devices/metal_output_device.m @@ -3,7 +3,6 @@ #include "metal_output_devices.h" #include "instance/metal_instance.h" #include "instance/gryphn_instance.h" -#include gnReturnCode createMetalOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) { outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice)); diff --git a/projects/apis/metal/src/framebuffers/metal_framebuffer.m b/projects/apis/metal/src/framebuffers/metal_framebuffer.m index 2866908..276c591 100644 --- a/projects/apis/metal/src/framebuffers/metal_framebuffer.m +++ b/projects/apis/metal/src/framebuffers/metal_framebuffer.m @@ -1,5 +1,4 @@ #include "metal_framebuffer.h" -#include "debugger/gryphn_debugger.h" #include "texture/metal_texture.h" #include "renderpass/gryphn_render_pass_descriptor.h" #include "instance/gryphn_instance.h" diff --git a/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m b/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m index f5cb12c..97d1270 100644 --- a/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m +++ b/projects/apis/metal/src/pipelines/graphics_pipeline/metal_graphics_pipeline.m @@ -1,6 +1,5 @@ #include "metal_graphics_pipeline.h" #include "devices/metal_output_devices.h" -#include "debugger/gryphn_debugger.h" #include "shader_module/metal_shader_module.h" #include "surface/metal_surface.h" #include "texture/metal_texture.h" diff --git a/projects/apis/metal/src/present/metal_present.h b/projects/apis/metal/src/present/metal_present.h index 84e93e3..a6f5975 100644 --- a/projects/apis/metal/src/present/metal_present.h +++ b/projects/apis/metal/src/present/metal_present.h @@ -4,7 +4,6 @@ #include "devices/metal_output_devices.h" #include "sync/semaphore/metal_semaphore.h" #include "presentation_queue/metal_presentation_queue.h" -#include "debugger/gryphn_debugger.h" #include "texture/metal_texture.h" #import diff --git a/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m b/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m index d512a90..5894ae1 100644 --- a/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m +++ b/projects/apis/metal/src/presentation_queue/metal_presentation_queue.m @@ -1,7 +1,6 @@ #include "metal_presentation_queue.h" #include "surface/metal_surface.h" #include "devices/metal_output_devices.h" -#include "debugger/gryphn_debugger.h" #include "texture/metal_texture.h" #include "sync/semaphore/metal_semaphore.h" diff --git a/projects/apis/metal/src/shader_module/metal_shader_module.m b/projects/apis/metal/src/shader_module/metal_shader_module.m index 8831637..2f24384 100644 --- a/projects/apis/metal/src/shader_module/metal_shader_module.m +++ b/projects/apis/metal/src/shader_module/metal_shader_module.m @@ -1,12 +1,12 @@ #include "metal_shader_module.h" #include "spirv_cross_c.h" -#include "debugger/gryphn_debugger.h" +#include "instance/gryphn_debugger.h" #include "devices/metal_output_devices.h" #import #import void mtlSpirVErrorCallback(void *userdata, const char *error) { - gnDebugger debugger = (gnDebugger)userdata; + gnDebuggerInfo debugger = *((gnDebuggerInfo*)userdata); gnDebuggerSetErrorMessage(debugger, (gnMessageData){ .message = gnCombineStrings(gnCreateString("shader compilation error MSL "), gnCreateString(error)) }); @@ -25,7 +25,7 @@ gnReturnCode createMetalShaderModule(gnShaderModule module, gnDevice device, gnS size_t count; spvc_context_create(&context); - spvc_context_set_error_callback(context, mtlSpirVErrorCallback, module->device->instance->debugger); + spvc_context_set_error_callback(context, mtlSpirVErrorCallback, &module->device->instance->debugger); spvc_context_parse_spirv(context, shaderModuleInfo.code, shaderModuleInfo.size / 4, &ir); spvc_context_create_compiler(context, SPVC_BACKEND_MSL, ir, SPVC_CAPTURE_MODE_COPY, &compiler); diff --git a/projects/apis/metal/src/submit/metal_submit.h b/projects/apis/metal/src/submit/metal_submit.h index cfaed85..f5b9e56 100644 --- a/projects/apis/metal/src/submit/metal_submit.h +++ b/projects/apis/metal/src/submit/metal_submit.h @@ -1,7 +1,6 @@ #include "submit/gryphn_submit.h" #include "sync/semaphore/metal_semaphore.h" #include "commands/command_buffer/metal_command_buffer.h" -#include "debugger/gryphn_debugger.h" #include "commands/command_pool/metal_command_pool.h" #include "synchronization/commands/gryphn_sync_submit.h" diff --git a/projects/apis/vulkan/src/debugger/vulkan_debugger.c b/projects/apis/vulkan/src/debugger/vulkan_debugger.c index 2a160ac..ca31464 100644 --- a/projects/apis/vulkan/src/debugger/vulkan_debugger.c +++ b/projects/apis/vulkan/src/debugger/vulkan_debugger.c @@ -1,2 +1,2 @@ -#include "vulkan_debugger.h" -#include +// #include "vulkan_debugger.h" +// #include diff --git a/projects/apis/vulkan/src/debugger/vulkan_debugger.h b/projects/apis/vulkan/src/debugger/vulkan_debugger.h index eaba276..cccc917 100644 --- a/projects/apis/vulkan/src/debugger/vulkan_debugger.h +++ b/projects/apis/vulkan/src/debugger/vulkan_debugger.h @@ -1,7 +1,7 @@ -#pragma once -#include -#include +// #pragma once +// #include +// #include -typedef struct gnPlatformDebugger_t { - VkDebugUtilsMessengerEXT debugMessenger; -} gnPlatformDebugger; +// typedef struct gnPlatformDebugger_t { +// VkDebugUtilsMessengerEXT debugMessenger; +// } gnPlatformDebugger; diff --git a/projects/apis/vulkan/src/instance/vulkan_instance.c b/projects/apis/vulkan/src/instance/vulkan_instance.c index a2f7c32..43580cb 100644 --- a/projects/apis/vulkan/src/instance/vulkan_instance.c +++ b/projects/apis/vulkan/src/instance/vulkan_instance.c @@ -80,8 +80,8 @@ gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceInfo instanceIn #endif if (instanceInfo.debugger != NULL) { - for (int i = 0; i < instanceInfo.debugger->info.layerCount; i++) { - if (instanceInfo.debugger->info.layers[i] == GN_DEBUGGER_LAYER_PLATFORM) { + for (int i = 0; i < instanceInfo.debugger->layerCount; i++) { + if (instanceInfo.debugger->layers[i] == GN_DEBUGGER_LAYER_PLATFORM) { vkStringArrayListAdd(&extensions, VK_EXT_DEBUG_UTILS_EXTENSION_NAME); const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" }; @@ -89,8 +89,8 @@ gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceInfo instanceIn createInfo.ppEnabledLayerNames = (const char*[]){ "VK_LAYER_KHRONOS_validation" }; vkUserData* userData = malloc(sizeof(vkUserData)); - userData->debuggerCallback = instanceInfo.debugger->info.callback; - userData->userData = instanceInfo.debugger->info.userData; + userData->debuggerCallback = instanceInfo.debugger->callback; + userData->userData = instanceInfo.debugger->userData; VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo = { .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, diff --git a/projects/apis/vulkan/src/output_device/vulkan_output_device.c b/projects/apis/vulkan/src/output_device/vulkan_output_device.c index 4707358..f6aa2ea 100644 --- a/projects/apis/vulkan/src/output_device/vulkan_output_device.c +++ b/projects/apis/vulkan/src/output_device/vulkan_output_device.c @@ -34,7 +34,7 @@ gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHan for (int i = 0; i < deviceCreateInfo.enabledExtensionCount; i++) if (strcmp(deviceCreateInfo.ppEnabledExtensionNames[i], VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME) == 0) outputDevice->outputDevice->enabledOversizedDescriptorPools = gnTrue; - if (instance->debugger == NULL) + if (instance->hasDebugger) deviceCreateInfo.enabledLayerCount = 0; else { const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" }; diff --git a/projects/core/src/debugger/gryphn_debugger.c b/projects/core/src/debugger/gryphn_debugger.c deleted file mode 100644 index eb65535..0000000 --- a/projects/core/src/debugger/gryphn_debugger.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "gryphn_debugger.h" - -gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info) { - *debugger = malloc(sizeof(struct gnDebugger_t)); - (*debugger)->info = info; - return GN_SUCCESS; -} -void gnDestroyDebugger(gnDebuggerHandle debugger) {} diff --git a/projects/core/src/debugger/gryphn_debugger.h b/projects/core/src/instance/gryphn_debugger.h similarity index 72% rename from projects/core/src/debugger/gryphn_debugger.h rename to projects/core/src/instance/gryphn_debugger.h index b829fb1..eaf659a 100644 --- a/projects/core/src/debugger/gryphn_debugger.h +++ b/projects/core/src/instance/gryphn_debugger.h @@ -1,8 +1,6 @@ #pragma once #include "stdint.h" #include "utils/gryphn_string.h" -#include "utils/gryphn_error_code.h" -#include "gryphn_handles.h" struct gnPlatformDebugger_t; @@ -43,24 +41,14 @@ typedef struct gnDebuggerInfo { } gnDebuggerInfo; #ifdef GN_REVEAL_IMPL - -struct gnDebugger_t { - gnDebuggerInfo info; -}; -#endif - -gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info); -void gnDestroyDebugger(gnDebuggerHandle debugger); - -#ifdef GN_REVEAL_IMPL -static void gnDebuggerSetErrorMessage(gnDebuggerHandle debugger, gnMessageData data) { - if (debugger == NULL) return; - - debugger->info.callback( +// struct gnDebugger_t { gnDebuggerInfo info; }; +static void gnDebuggerSetErrorMessage(gnDebuggerInfo debugger, gnMessageData data) { + // if (debugger == NULL) return; + debugger.callback( GN_MESSAGE_ERROR, GN_DEBUG_MESSAGE_VALIDATION, data, - debugger->info.userData + debugger.userData ); } #endif diff --git a/projects/core/src/instance/gryphn_instance.c b/projects/core/src/instance/gryphn_instance.c index 19b061f..d9f2d46 100644 --- a/projects/core/src/instance/gryphn_instance.c +++ b/projects/core/src/instance/gryphn_instance.c @@ -2,11 +2,11 @@ #include "instance/gryphn_instance.h" #include #include "loader/src/gryphn_loader.h" -#include "debugger/gryphn_debugger.h" #include "loader/src/gryphn_loader.h" gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) { *instance = malloc(sizeof(struct gnInstance_t)); + (*instance)->hasDebugger = gnFalse; (*instance)->layers = loaderLayerArrayListCreate(); loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){ @@ -20,8 +20,12 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) { } gnBool loaderFunctionChecker = gnFalse; - for (int i = 0; i < info.debugger->info.layerCount; i++) { - if (info.debugger->info.layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) loaderFunctionChecker = gnTrue; + if (info.debugger != NULL) { + for (int i = 0; i < info.debugger->layerCount; i++) { + if (info.debugger->layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) loaderFunctionChecker = gnTrue; + } + (*instance)->debugger = *info.debugger; + (*instance)->hasDebugger = gnTrue; } if (loaderFunctionChecker) { @@ -36,7 +40,6 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) { // i hate this line of code but im not fixing it (*instance)->callingLayer = &(*instance)->layers.data[(*instance)->layers.count - 1]; - (*instance)->debugger = info.debugger; return (*instance)->callingLayer->instanceFunctions._gnCreateInstance((*instance), info); } diff --git a/projects/core/src/instance/gryphn_instance.h b/projects/core/src/instance/gryphn_instance.h index fb3712f..96f0d51 100644 --- a/projects/core/src/instance/gryphn_instance.h +++ b/projects/core/src/instance/gryphn_instance.h @@ -3,6 +3,7 @@ #include "core/src/gryphn_handles.h" #include "utils/gryphn_version.h" #include "utils/gryphn_error_code.h" +#include "core/src/instance/gryphn_debugger.h" #include typedef struct gnInstanceInfo { @@ -13,7 +14,7 @@ typedef struct gnInstanceInfo { gnVersion engineVersion; gnRenderingAPI renderingAPI; - gnDebuggerHandle debugger; + gnDebuggerInfo* debugger; uint32_t extensionCount; gnExtension* extensions; @@ -29,7 +30,8 @@ struct gnInstance_t { loaderLayer* callingLayer; uint32_t currentLayer; - gnDebuggerHandle debugger; + gnBool hasDebugger; + gnDebuggerInfo debugger; }; #endif diff --git a/projects/validation_layers/function_loader/extensions/sync_functions.c b/projects/validation_layers/function_loader/extensions/sync_functions.c index f8b4c60..bead1c6 100644 --- a/projects/validation_layers/function_loader/extensions/sync_functions.c +++ b/projects/validation_layers/function_loader/extensions/sync_functions.c @@ -1,7 +1,7 @@ #include "sync_functions.h" #include "loader_utils.h" #include "core/src/presentation_queue/gryphn_presentation_queue.h" -#include +#include #include "synchronization/semaphore/gryphn_semaphore.h" #include "synchronization/fence/gryphn_fence.h" #include "synchronization/commands/gryphn_sync_submit.h" diff --git a/projects/validation_layers/function_loader/src/command_functions.c b/projects/validation_layers/function_loader/src/command_functions.c index 07c9290..97bdd23 100644 --- a/projects/validation_layers/function_loader/src/command_functions.c +++ b/projects/validation_layers/function_loader/src/command_functions.c @@ -2,7 +2,7 @@ #include "core/src/command/command_pool/gryphn_command_pool.h" #include "core/src/command/command_buffer/gryphn_command_buffer.h" #include "core/src/output_device/gryphn_output_device.h" -#include +#include #include #include "core/src/renderpass/gryphn_render_pass.h" #include "core/src/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h" diff --git a/projects/validation_layers/function_loader/src/device_functions.c b/projects/validation_layers/function_loader/src/device_functions.c index ed82dcf..c13b54b 100644 --- a/projects/validation_layers/function_loader/src/device_functions.c +++ b/projects/validation_layers/function_loader/src/device_functions.c @@ -1,6 +1,6 @@ #include "device_functions.h" #include "loader_utils.h" -#include +#include #include "core/src/presentation_queue/gryphn_presentation_queue.h" #include "core/src/shader_module/gryphn_shader_module.h" #include "core/src/renderpass/gryphn_render_pass_descriptor.h" diff --git a/projects/validation_layers/function_loader/src/instance_functions.c b/projects/validation_layers/function_loader/src/instance_functions.c index b3f3459..078df78 100644 --- a/projects/validation_layers/function_loader/src/instance_functions.c +++ b/projects/validation_layers/function_loader/src/instance_functions.c @@ -1,6 +1,6 @@ #include "instance_functions.h" #include "../loader_utils.h" -#include +#include #include "core/src/output_device/gryphn_output_device.h" #include "core/src/window_surface/gryphn_surface.h"