From 5f298554fdbde2c4d8466fa9cd0f089f05554f46 Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Sun, 3 Aug 2025 15:08:01 -0400 Subject: [PATCH] more error hunting --- .../vulkan/src/instance/vulkan_instance.c | 34 ++++++++++++------- .../vulkan/src/instance/vulkan_instance.h | 2 +- projects/core/src/buffers/gryphn_buffer.c | 3 ++ projects/core/src/buffers/gryphn_buffer.h | 4 +-- .../command_buffer/gryphn_command_buffer.c | 17 +++++----- .../command_buffer/gryphn_command_buffer.h | 3 +- projects/core/src/instance/gryphn_debugger.h | 3 +- .../src/output_device/gryphn_output_device.h | 2 +- projects/core/src/uniforms/gryphn_uniform.c | 3 ++ projects/core/src/uniforms/gryphn_uniform.h | 2 +- .../synchronization/fence/gryphn_fence.c | 4 +-- .../synchronization/fence/gryphn_fence.h | 4 ++- .../semaphore/gryphn_semaphore.c | 3 +- .../semaphore/gryphn_semaphore.h | 2 +- .../loader/src/gryphn_command_functions.h | 4 +-- projects/loader/src/gryphn_loader.c | 3 ++ projects/loader/src/gryphn_loader.h | 2 +- projects/utils | 2 +- .../function_loader/loader/function_loader.c | 12 +++---- 19 files changed, 61 insertions(+), 48 deletions(-) diff --git a/projects/apis/vulkan/src/instance/vulkan_instance.c b/projects/apis/vulkan/src/instance/vulkan_instance.c index 94b42fc..2e85e6c 100644 --- a/projects/apis/vulkan/src/instance/vulkan_instance.c +++ b/projects/apis/vulkan/src/instance/vulkan_instance.c @@ -1,5 +1,7 @@ #include "vulkan_instance.h" #include "vulkan_result_converter.h" +GN_ARRAY_LIST_DEFINITION(vkString) + static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback( VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, @@ -14,18 +16,24 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback( }; switch (messageSeverity) { - default: break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break; case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT: { + VkDebugUtilsMessengerCallbackDataEXT callbackData = { + .pMessage = "Error triggered with VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT, this indicates a big within vulkan" + }; + vk_debuggerDebugCallback(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, &callbackData, pUserData); + severity = GN_MESSAGE_ERROR; + } } switch (messageType) { - default: break; case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break; case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break; case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break; + case VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break; } vkUserData* userData = (vkUserData*)pUserData; @@ -36,20 +44,21 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback( } gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next) { + if (next != NULL) { return GN_SUCCESS; } instance->instance = malloc(sizeof(gnPlatformInstance)); vkStringArrayList extensions = vkStringArrayListCreate(); - vkStringArrayListAdd(&extensions, "VK_KHR_surface"); - vkStringArrayListReserve(&extensions, 5); + vkStringArrayListAdd(extensions, "VK_KHR_surface"); + vkStringArrayListReserve(extensions, 5); #ifdef GN_PLATFORM_MACOS - vkStringArrayListAdd(&extensions, "VK_EXT_metal_surface"); - vkStringArrayListAdd(&extensions, "VK_KHR_portability_enumeration"); + vkStringArrayListAdd(extensions, "VK_EXT_metal_surface"); + vkStringArrayListAdd(extensions, "VK_KHR_portability_enumeration"); #elif GN_PLATFORM_WINDOWS - vkStringArrayListAdd(&extensions, "VK_KHR_win32_surface"); + vkStringArrayListAdd(extensions, "VK_KHR_win32_surface"); #elif GN_PLATFORM_LINUX #ifdef GN_WINDOW_X11 - vkStringArrayListAdd(&extensions, "VK_KHR_xlib_surface"); + vkStringArrayListAdd(extensions, "VK_KHR_xlib_surface"); #endif #endif @@ -74,9 +83,7 @@ gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInf #endif if (instance->enabledLayerCounts[GN_DEBUGGER_LAYER_PLATFORM] > 0) { - vkStringArrayListAdd(&extensions, VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - - const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" }; + vkStringArrayListAdd(extensions, VK_EXT_DEBUG_UTILS_EXTENSION_NAME); createInfo.enabledLayerCount = 1; createInfo.ppEnabledLayerNames = (const char*[]){ "VK_LAYER_KHRONOS_validation" }; @@ -94,11 +101,12 @@ gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInf } - createInfo.enabledExtensionCount = extensions.count; - createInfo.ppEnabledExtensionNames = extensions.data; + createInfo.enabledExtensionCount = vkStringArrayListCount(extensions); + createInfo.ppEnabledExtensionNames = vkStringArrayListData(extensions); return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance)); } void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next) { + if (next != NULL) { return; } vkDestroyInstance(instance->instance->vk_instance, NULL); } diff --git a/projects/apis/vulkan/src/instance/vulkan_instance.h b/projects/apis/vulkan/src/instance/vulkan_instance.h index 12e6241..833ae1f 100644 --- a/projects/apis/vulkan/src/instance/vulkan_instance.h +++ b/projects/apis/vulkan/src/instance/vulkan_instance.h @@ -18,4 +18,4 @@ gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInf void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next); typedef const char* vkString; -GN_ARRAY_LIST(vkString); +GN_ARRAY_LIST_HEADER(vkString); diff --git a/projects/core/src/buffers/gryphn_buffer.c b/projects/core/src/buffers/gryphn_buffer.c index d422a9e..7649c8f 100644 --- a/projects/core/src/buffers/gryphn_buffer.c +++ b/projects/core/src/buffers/gryphn_buffer.c @@ -2,6 +2,9 @@ #include "output_device/gryphn_output_device.h" #include "instance/gryphn_instance.h" +GN_ARRAY_LIST_DEFINITION(gnBuffer) +GN_ARRAY_LIST_DEFINITION(gnBufferMemory) + gnReturnCode gnCreateBuffer(gnBufferHandle* buffer, gnOutputDeviceHandle device, gnBufferInfo info) { *buffer = malloc(sizeof(struct gnBuffer_t)); (*buffer)->device = device; diff --git a/projects/core/src/buffers/gryphn_buffer.h b/projects/core/src/buffers/gryphn_buffer.h index 516dce8..fa93a15 100644 --- a/projects/core/src/buffers/gryphn_buffer.h +++ b/projects/core/src/buffers/gryphn_buffer.h @@ -37,8 +37,8 @@ struct gnBuffer_t { }; #endif typedef void* gnBufferMemory; -GN_ARRAY_LIST(gnBuffer); -GN_ARRAY_LIST(gnBufferMemory); +GN_ARRAY_LIST_HEADER(gnBuffer); +GN_ARRAY_LIST_HEADER(gnBufferMemory); gnReturnCode gnCreateBuffer(gnBufferHandle* buffer, gnOutputDeviceHandle device, gnBufferInfo info); void gnBufferData(gnBufferHandle buffer, size_t dataSize, gnBufferMemory data); diff --git a/projects/core/src/command/command_buffer/gryphn_command_buffer.c b/projects/core/src/command/command_buffer/gryphn_command_buffer.c index adda95d..4fabff3 100644 --- a/projects/core/src/command/command_buffer/gryphn_command_buffer.c +++ b/projects/core/src/command/command_buffer/gryphn_command_buffer.c @@ -3,7 +3,7 @@ #include "instance/gryphn_instance.h" gnReturnCode gnCommandPoolAllocateCommandBuffersFromPointer(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool) { - for (int i = 0; i < count; i++) { + for (uint32_t i = 0; i < count; i++) { buffers[i] = malloc(sizeof(struct gnCommandBuffer_t)); buffers[i]->commandPool = commandPool; buffers[i]->instance = commandPool->instance; @@ -12,15 +12,11 @@ gnReturnCode gnCommandPoolAllocateCommandBuffersFromPointer(gnCommandBufferHandl } gnReturnCode gnCommandPoolAllocateCommandBuffersFromList(gnCommandBufferArrayList buffers, uint32_t count, gnCommandPoolHandle commandPool) { - // if (buffers.count < count) { - // gnCommandBufferArrayListExpand(&buffers, buffers.count - count); - // } - - for (int i = 0; i < count; i++) { - buffers.data[i] = malloc(sizeof(struct gnCommandBuffer_t)); - buffers.data[i]->commandPool = commandPool; + for (uint32_t i = 0; i < count; i++) { + gnCommandBufferArrayListAt(buffers, i)->commandBuffer = malloc(sizeof(struct gnCommandBuffer_t)); + gnCommandBufferArrayListAt(buffers, i)->commandPool = commandPool; } - return gnCommandPoolAllocateCommandBuffersFromPointer(buffers.data, count, commandPool); + return gnCommandPoolAllocateCommandBuffersFromPointer(gnCommandBufferArrayListData(buffers), count, commandPool); } void gnResetCommandBuffer(gnCommandBufferHandle commandBuffer) { @@ -38,3 +34,6 @@ gnReturnCode gnEndCommandBuffer(gnCommandBufferHandle commandBuffer) { void gnDestroyCommandBuffer(gnCommandBufferHandle commandBuffer) { commandBuffer->commandPool->instance->callingLayer->commandFunctions._gnDestroyCommandBuffer(commandBuffer); } + + +GN_ARRAY_LIST_DEFINITION(gnCommandBuffer) diff --git a/projects/core/src/command/command_buffer/gryphn_command_buffer.h b/projects/core/src/command/command_buffer/gryphn_command_buffer.h index a54f881..0ec0a8c 100644 --- a/projects/core/src/command/command_buffer/gryphn_command_buffer.h +++ b/projects/core/src/command/command_buffer/gryphn_command_buffer.h @@ -12,10 +12,9 @@ struct gnCommandBuffer_t { }; #endif -GN_ARRAY_LIST(gnCommandBuffer); +GN_ARRAY_LIST_HEADER(gnCommandBuffer); gnReturnCode gnCommandPoolAllocateCommandBuffersFromPointer(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool); -// will reserve the space for ${count} number of elements gnReturnCode gnCommandPoolAllocateCommandBuffersFromList(gnCommandBufferArrayList buffers, uint32_t count, gnCommandPoolHandle commandPool); #define gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool) \ diff --git a/projects/core/src/instance/gryphn_debugger.h b/projects/core/src/instance/gryphn_debugger.h index 55bcd69..cca1829 100644 --- a/projects/core/src/instance/gryphn_debugger.h +++ b/projects/core/src/instance/gryphn_debugger.h @@ -42,8 +42,7 @@ typedef struct gnDebuggerCreateInfo { } gnDebuggerCreateInfo; #ifdef GN_REVEAL_IMPL -// struct gnDebugger_t { gnDebuggerInfo info; }; -static void gnDebuggerSetErrorMessage(gnDebuggerCreateInfo debugger, gnMessageData data) { +static inline void gnDebuggerSetErrorMessage(gnDebuggerCreateInfo debugger, gnMessageData data) { // if (debugger == NULL) return; debugger.callback( GN_MESSAGE_ERROR, diff --git a/projects/core/src/output_device/gryphn_output_device.h b/projects/core/src/output_device/gryphn_output_device.h index 529fc14..ae13c54 100644 --- a/projects/core/src/output_device/gryphn_output_device.h +++ b/projects/core/src/output_device/gryphn_output_device.h @@ -3,7 +3,7 @@ #include typedef struct gnOutputDeviceEnabledFeatures { - + gnBool warningAvioder; // this is here just to stop this from producing a warning } gnOutputDeviceEnabledFeatures; typedef struct gnDeviceQueueInfo { diff --git a/projects/core/src/uniforms/gryphn_uniform.c b/projects/core/src/uniforms/gryphn_uniform.c index e2c1c87..8707d0d 100644 --- a/projects/core/src/uniforms/gryphn_uniform.c +++ b/projects/core/src/uniforms/gryphn_uniform.c @@ -14,3 +14,6 @@ void gnUpdateStorageUniform(gnUniform uniform, gnStorageUniformInfo storageInfo) void gnUpdateImageUniform(gnUniform uniform, gnImageUniformInfo imageInfo) { uniform->pool->device->instance->callingLayer->deviceFunctions._gnUpdateImageUniform(uniform, &imageInfo); } + + +GN_ARRAY_LIST_DEFINITION(gnUniform) diff --git a/projects/core/src/uniforms/gryphn_uniform.h b/projects/core/src/uniforms/gryphn_uniform.h index 22260c1..1ab931d 100644 --- a/projects/core/src/uniforms/gryphn_uniform.h +++ b/projects/core/src/uniforms/gryphn_uniform.h @@ -30,7 +30,7 @@ struct gnUniform_t { gnUniformPool pool; }; #endif -GN_ARRAY_LIST(gnUniform); +GN_ARRAY_LIST_HEADER(gnUniform); void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo); void gnUpdateStorageUniform(gnUniform uniform, gnStorageUniformInfo storageInfo); diff --git a/projects/extensions/synchronization/fence/gryphn_fence.c b/projects/extensions/synchronization/fence/gryphn_fence.c index b2ef360..ad6c685 100644 --- a/projects/extensions/synchronization/fence/gryphn_fence.c +++ b/projects/extensions/synchronization/fence/gryphn_fence.c @@ -1,5 +1,3 @@ -// #ifdef GN_EXT_GN_EXT_SYNCHRONIZATION - #include "gryphn_fence.h" #include "output_device/gryphn_output_device.h" #include "instance/gryphn_instance.h" @@ -25,4 +23,4 @@ void gnDestroyFence(gnFenceHandle fence) { fence->device->instance->callingLayer->syncFunctions._gnDestroyFence(fence); } -// #endif +GN_ARRAY_LIST_DEFINITION(gnFence) diff --git a/projects/extensions/synchronization/fence/gryphn_fence.h b/projects/extensions/synchronization/fence/gryphn_fence.h index 63d931a..72bb171 100644 --- a/projects/extensions/synchronization/fence/gryphn_fence.h +++ b/projects/extensions/synchronization/fence/gryphn_fence.h @@ -11,10 +11,12 @@ struct gnFence_t { gnBool signaled; }; #endif -GN_ARRAY_LIST(gnFence); 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); + + +GN_ARRAY_LIST_HEADER(gnFence); diff --git a/projects/extensions/synchronization/semaphore/gryphn_semaphore.c b/projects/extensions/synchronization/semaphore/gryphn_semaphore.c index 2310675..882c25a 100644 --- a/projects/extensions/synchronization/semaphore/gryphn_semaphore.c +++ b/projects/extensions/synchronization/semaphore/gryphn_semaphore.c @@ -12,5 +12,4 @@ gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* void gnDestroySemaphore(struct gnSemaphore_t* semaphore) { semaphore->device->instance->callingLayer->syncFunctions._gnDestroySemaphore(semaphore); } - -// #endif +GN_ARRAY_LIST_DEFINITION(gnSemaphore) diff --git a/projects/extensions/synchronization/semaphore/gryphn_semaphore.h b/projects/extensions/synchronization/semaphore/gryphn_semaphore.h index 1ccfb17..b4eea53 100644 --- a/projects/extensions/synchronization/semaphore/gryphn_semaphore.h +++ b/projects/extensions/synchronization/semaphore/gryphn_semaphore.h @@ -9,7 +9,7 @@ struct gnSemaphore_t { gnOutputDeviceHandle device; }; #endif -GN_ARRAY_LIST(gnSemaphore); gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device); void gnDestroySemaphore(gnSemaphore semaphore); +GN_ARRAY_LIST_HEADER(gnSemaphore); diff --git a/projects/loader/src/gryphn_command_functions.h b/projects/loader/src/gryphn_command_functions.h index e926687..971398e 100644 --- a/projects/loader/src/gryphn_command_functions.h +++ b/projects/loader/src/gryphn_command_functions.h @@ -3,12 +3,12 @@ #include "core/gryphn_return_code.h" #include "gryphn_handles.h" +#include + typedef struct gnRenderPassInfo gnRenderPassInfo; typedef struct gnViewport gnViewport; typedef struct gnScissor gnScissor; typedef struct gnPushConstantLayout gnPushConstantLayout; -typedef enum gnBufferType gnBufferType; -typedef enum gnIndexType gnIndexType; typedef struct gnCommandFunctions_t { gnReturnCode (*_gnCommandPoolAllocateCommandBuffers)(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPoolHandle pool); diff --git a/projects/loader/src/gryphn_loader.c b/projects/loader/src/gryphn_loader.c index 6370c2a..bb8523e 100644 --- a/projects/loader/src/gryphn_loader.c +++ b/projects/loader/src/gryphn_loader.c @@ -175,3 +175,6 @@ loaderLayer* loaderGetNextLayer(gnInstance instance) { void resetLayer(gnInstance instance) { instance->currentLayer = (instance->layers.count - 1); } + + +GN_ARRAY_LIST_DEFINITION(loaderLayer) diff --git a/projects/loader/src/gryphn_loader.h b/projects/loader/src/gryphn_loader.h index 92732a4..606ec3e 100644 --- a/projects/loader/src/gryphn_loader.h +++ b/projects/loader/src/gryphn_loader.h @@ -38,7 +38,7 @@ typedef struct loaderLayer { } loaderLayer; loaderLayer loadLayer(loaderInfo info); -GN_ARRAY_LIST(loaderLayer); +GN_ARRAY_LIST_HEADER(loaderLayer); loaderLayer* loaderGetNextLayer(gnInstance instance); void resetLayer(gnInstance instance); diff --git a/projects/utils b/projects/utils index a9aa97b..203928a 160000 --- a/projects/utils +++ b/projects/utils @@ -1 +1 @@ -Subproject commit a9aa97be63e2b2e3541d685a314b1f9abb2f201d +Subproject commit 203928aa81efcb4a2dda743f4a551b54eb4b236a diff --git a/projects/validation_layers/function_loader/loader/function_loader.c b/projects/validation_layers/function_loader/loader/function_loader.c index 00a12c7..39d35aa 100644 --- a/projects/validation_layers/function_loader/loader/function_loader.c +++ b/projects/validation_layers/function_loader/loader/function_loader.c @@ -5,14 +5,14 @@ #include "extensions/sync_functions.h" #include "extensions/queue_functions.h" -gryphnInstanceFunctionLayers checkerLoadInstanceFunctions() { +gryphnInstanceFunctionLayers checkerLoadInstanceFunctions(void) { return (gryphnInstanceFunctionLayers) { .createInstance = checkCreateInstance, .destroyInstance = checkDestroyInstance }; } -gnInstanceFunctions loadFunctionLoaderInstanceFunctions() { +gnInstanceFunctions loadFunctionLoaderInstanceFunctions(void) { return (gnInstanceFunctions){ ._gnGetPhysicalDevices = checkGetPhysicalDevices, ._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent, @@ -43,7 +43,7 @@ gnInstanceFunctions loadFunctionLoaderInstanceFunctions() { ._gnGetSurfaceDetails = checkGetSurfaceDetails }; } -gnDeviceFunctions loadFunctionLoaderDeviceFunctions() { +gnDeviceFunctions loadFunctionLoaderDeviceFunctions(void) { return (gnDeviceFunctions){ ._gnCreatePresentationQueue = checkCreatePresentationQueue, ._gnPresentationQueueGetImage = checkPresentationQueueGetImage, @@ -88,7 +88,7 @@ gnDeviceFunctions loadFunctionLoaderDeviceFunctions() { ._gnWaitForDevice = checkWaitForDevice }; } -gnCommandFunctions loadFunctionLoaderCommandFunctions() { +gnCommandFunctions loadFunctionLoaderCommandFunctions(void) { return (gnCommandFunctions){ ._gnCommandPoolAllocateCommandBuffers = checkCommandPoolAllocateCommandBuffers, ._gnBeginCommandBuffer = checkBeginCommandBuffer, @@ -110,7 +110,7 @@ gnCommandFunctions loadFunctionLoaderCommandFunctions() { }; } -gnSyncExtFunctions loadFunctionLoaderSyncExtFunctions() { +gnSyncExtFunctions loadFunctionLoaderSyncExtFunctions(void) { return (gnSyncExtFunctions) { ._gnPresentationQueueGetImageAsync = checkPresentationQueueGetImageAsync, @@ -127,7 +127,7 @@ gnSyncExtFunctions loadFunctionLoaderSyncExtFunctions() { }; } -gnQueueExtFunctions loadFunctionLoaderQueueExtFunctions() { +gnQueueExtFunctions loadFunctionLoaderQueueExtFunctions(void) { return (gnQueueExtFunctions){ ._gnGetPhysicalDeviceQueueProperties = checkGetPhysicalDeviceQueueProperties, ._gnGetDeviceQueue = checkGetDeviceQueue,