start using the dispatcher

This commit is contained in:
Gregory Wells
2025-07-30 21:32:04 -04:00
parent d130fff385
commit 797191c2b6
12 changed files with 51 additions and 22 deletions

View File

@@ -25,7 +25,7 @@ typedef struct gnInstanceFunctions {
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
gnReturnCode (*_gnCreateOutputDevice)(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo);
gnReturnCode (*_gnCreateOutputDevice)(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);

View File

@@ -14,24 +14,27 @@
#include "core/src/instance/gryphn_instance.h"
// load the speedy API functions or something like that
gnInstanceFunctions loadAPIInstanceFunctions(gnRenderingAPI api) {
dispatcher_bool loadAPIInstanceFunctions(dispatcher_layer* layer) {
gnRenderingAPI api = *(gnRenderingAPI*)layer->userData;
gnInstanceFunctions* funcs = (gnInstanceFunctions*)layer->function_array;
switch (api) {
case GN_RENDERINGAPI_NONE: return (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_NONE: *funcs = (gnInstanceFunctions){ NULL };
#ifdef GN_API_VULKAN
case GN_RENDERINGAPI_VULKAN: return loadVulkanInstanceFunctions();
case GN_RENDERINGAPI_VULKAN: *funcs = loadVulkanInstanceFunctions();
#endif
case GN_RENDERINGAPI_SOFTWARE: return (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX11: return (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX12: return (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_SOFTWARE: *funcs = (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX11: *funcs = (gnInstanceFunctions){ NULL };
case GN_RENDERINGAPI_DIRECTX12: *funcs = (gnInstanceFunctions){ NULL };
#ifdef GN_API_OPENGL
case GN_RENDERINGAPI_OPENGL: return loadOpenGLInstanceFunctions();
case GN_RENDERINGAPI_OPENGL: *funcs = loadOpenGLInstanceFunctions();
#endif
#ifdef GN_API_METAL
case GN_RENDERINGAPI_METAL: return loadMetalInstanceFunctions();
case GN_RENDERINGAPI_METAL: *funcs = loadMetalInstanceFunctions();
#endif
default: return (gnInstanceFunctions){NULL};
default: *funcs = (gnInstanceFunctions){NULL};
}
return dispatcher_true;
}
gnDeviceFunctions loadAPIDeviceFunctions(gnRenderingAPI api) {
@@ -113,7 +116,6 @@ gnQueueExtFunctions loadAPIQueueFunctions(gnRenderingAPI api) {
loaderLayer null_layer() {
return (loaderLayer){
.instanceFunctions = (gnInstanceFunctions){ NULL },
.deviceFunctions = (gnDeviceFunctions){ NULL },
.commandFunctions = (gnCommandFunctions){ NULL }
};
@@ -121,7 +123,6 @@ loaderLayer null_layer() {
loaderLayer api_loaded_layer(gnRenderingAPI api) {
return (loaderLayer){
.instanceFunctions = loadAPIInstanceFunctions(api),
.deviceFunctions = loadAPIDeviceFunctions(api),
.commandFunctions = loadAPICommandFunctions(api),
};
@@ -129,7 +130,6 @@ loaderLayer api_loaded_layer(gnRenderingAPI api) {
loaderLayer function_check_layer() {
return (loaderLayer){
.instanceFunctions = loadFunctionLoaderInstanceFunctions(),
.deviceFunctions = loadFunctionLoaderDeviceFunctions(),
.commandFunctions = loadFunctionLoaderCommandFunctions(),

View File

@@ -1,9 +1,9 @@
#pragma once
#include "gryphn_instance_functions.h"
#include "gryphn_device_functions.h"
#include "gryphn_command_functions.h"
#include "gryphn_loader_info.h"
#include "utils/lists/gryphn_array_list.h"
#include <Dispatcher/dispatcher.h>
#include "extensions/synchronization/loader/sync_functions.h"
#include "extensions/queues/queues_functions.h"
@@ -12,7 +12,9 @@ typedef struct loaderLayer {
// idk why I sperate these info different classes, I should really shove them in one bit class
// they used to be loaded seperatly but I guess there not anymore
// initlization is hard
gnInstanceFunctions instanceFunctions;
// gnInstanceFunctions instanceFunctions;
gnDeviceFunctions deviceFunctions;
gnCommandFunctions commandFunctions;
@@ -31,3 +33,7 @@ void resetLayer(gnInstance instance);
gnSyncExtFunctions loadAPISyncFunctions(gnRenderingAPI api);
gnQueueExtFunctions loadAPIQueueFunctions(gnRenderingAPI api);
dispatcher_bool loadAPIInstanceFunctions(dispatcher_layer* layer);