From b39fc43905a9e91ad7507ce6ec93ff589e131967 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Thu, 26 Jun 2025 13:02:22 -0400 Subject: [PATCH] kinda improve the loader (its worse) --- projects/loader/src/gryphn_loader.c | 42 ++++++++++++++++-------- projects/loader/src/gryphn_loader.h | 12 +++++-- projects/loader/src/gryphn_loader_info.h | 6 +++- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/projects/loader/src/gryphn_loader.c b/projects/loader/src/gryphn_loader.c index 4812ced..763bb7c 100644 --- a/projects/loader/src/gryphn_loader.c +++ b/projects/loader/src/gryphn_loader.c @@ -8,7 +8,7 @@ #endif // load the speedy API functions or something like that -gnInstanceFunctions loadAPIFunctions(gnRenderingAPI api) { +gnInstanceFunctions loadAPIInstanceFunctions(gnRenderingAPI api) { switch (api) { case GN_RENDERINGAPI_NONE: return (gnInstanceFunctions){ NULL }; #ifdef GN_API_VULKAN @@ -26,17 +26,8 @@ gnInstanceFunctions loadAPIFunctions(gnRenderingAPI api) { } } -gnInstanceFunctions loadInstanceFunctions(loaderInfo info) { - gnInstanceFunctions apiFunctions = loadAPIFunctions(info.api); - - if (info.validateIfLoaded) - return loadFunctionLoaderInstanceFunctions(&apiFunctions); - - return apiFunctions; -} - -gnDeviceFunctions loadDeviceFunctions(loaderInfo info) { - switch (info.api) { +gnDeviceFunctions loadAPIDeviceFunctions(gnRenderingAPI api) { + switch (api) { case GN_RENDERINGAPI_NONE: return (gnDeviceFunctions){ NULL }; #ifdef GN_API_VULKAN case GN_RENDERINGAPI_VULKAN: return loadVulkanDeviceFunctions(); @@ -54,8 +45,8 @@ gnDeviceFunctions loadDeviceFunctions(loaderInfo info) { } } -gnCommandFunctions loadCommandFunctions(loaderInfo info) { - switch (info.api) { +gnCommandFunctions loadAPICommandFunctions(gnRenderingAPI api) { + switch (api) { case GN_RENDERINGAPI_NONE: return (gnCommandFunctions){ NULL }; #ifdef GN_API_VULKAN case GN_RENDERINGAPI_VULKAN: return loadVulkanCommandFunctions(); @@ -72,3 +63,26 @@ gnCommandFunctions loadCommandFunctions(loaderInfo info) { default: return (gnCommandFunctions){NULL}; } } + +loaderLayer null_layer() { + return (loaderLayer){ + .instanceFunctions = (gnInstanceFunctions){ NULL }, + .deviceFunctions = (gnDeviceFunctions){ NULL }, + .commandFunctions = (gnCommandFunctions){ NULL } + }; +} + +loaderLayer api_loaded_layer(gnRenderingAPI api) { + return (loaderLayer){ + .instanceFunctions = loadAPIInstanceFunctions(api), + .deviceFunctions = loadAPIDeviceFunctions(api), + .commandFunctions = loadAPICommandFunctions(api) + }; +} + +loaderLayer loadLayer(loaderInfo info) { + if (info.layerToLoad == no_layer) return null_layer(); + if (info.layerToLoad == api_layer) return api_loaded_layer(info.api); + + return null_layer(); +} diff --git a/projects/loader/src/gryphn_loader.h b/projects/loader/src/gryphn_loader.h index b8e0576..8d9b070 100644 --- a/projects/loader/src/gryphn_loader.h +++ b/projects/loader/src/gryphn_loader.h @@ -3,7 +3,13 @@ #include "gryphn_device_functions.h" #include "gryphn_command_functions.h" #include "gryphn_loader_info.h" +#include "utils/lists/gryphn_array_list.h" -gnInstanceFunctions loadInstanceFunctions(loaderInfo info); -gnDeviceFunctions loadDeviceFunctions(loaderInfo info); -gnCommandFunctions loadCommandFunctions(loaderInfo info); +typedef struct loaderLayer { + gnInstanceFunctions instanceFunctions; + gnDeviceFunctions deviceFunctions; + gnCommandFunctions commandFunctions; +} loaderLayer; + +loaderLayer loadLayer(loaderInfo info); +GN_ARRAY_LIST(loaderLayer); diff --git a/projects/loader/src/gryphn_loader_info.h b/projects/loader/src/gryphn_loader_info.h index e38411e..6bd105d 100644 --- a/projects/loader/src/gryphn_loader_info.h +++ b/projects/loader/src/gryphn_loader_info.h @@ -1,7 +1,11 @@ #pragma once #include "gryphn_rendering_api.h" +typedef enum toLoadLayer { + no_layer, api_layer +} toLoadLayer; + typedef struct loaderInfo { gnRenderingAPI api; - gnBool validateIfLoaded; + toLoadLayer layerToLoad; } loaderInfo;