make some gryphn stuff happen (DOES NOT COMPILE)

This commit is contained in:
Gregory Wells
2025-06-24 13:04:33 -04:00
parent 78202825db
commit 1915166c82
21 changed files with 150 additions and 294 deletions

View File

@@ -1,10 +1,13 @@
#include "gryphn_instance.h"
#include <gryphn_platform_functions.h>
#include "instance/gryphn_instance.h"
#include <loader/src/gryphn_instance_functions.h>
#include "loader/src/gryphn_loader.h"
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
*instance = malloc(sizeof(struct gnInstance_t));
(*instance)->instanceFunctions = loadInstanceFunctions(info.renderingAPI);
// instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
// if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
// instance->functions = gnLoadFunctions(instance);
@@ -12,10 +15,9 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
// if (info.debugger)
// instance->debugger = info.debugger;
// return instance->functions->_gnCreateInstance(instance, info);
return GN_SUCCESS;
return (*instance)->instanceFunctions._gnCreateInstance((*instance), info);
}
void gnDestroyInstance(gnInstanceHandle instance) {
instance->functions->_gnDestroyInstance(instance);
instance->instanceFunctions._gnDestroyInstance(instance);
}

View File

@@ -1,11 +1,11 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_rendering_api.h"
#include "gryphn_handles.h"
#include "utils/gryphn_version.h"
#include "utils/gryphn_error_code.h"
#include "loader/src/gryphn_instance_functions.h"
typedef struct gnInstanceFunctions gnInstanceFunctions;
typedef struct gnInstanceInfo_t {
typedef struct gnInstanceInfo {
gnString applicationName;
gnVersion applicationVersion;
@@ -20,12 +20,10 @@ typedef struct gnInstanceInfo_t {
struct gnInstance_t {
struct gnPlatformInstance_t* instance;
gnBool valid,
loadDeviceFunctions,
loadCommandFunctions;
loadDeviceFunctions,
loadCommandFunctions;
struct gnDynamicLibrary_t* dynamicLib;
gnInstanceFunctions *functions, *unvalidatedFunctions;
gnInstanceFunctions instanceFunctions;
struct gnDeviceFunctions_t* deviceFunctions;
struct gnCommandFunctions_t* commandFunctions;
@@ -33,5 +31,5 @@ struct gnInstance_t {
};
#endif
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info);
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info);
void gnDestroyInstance(gnInstanceHandle instance);

View File

@@ -1,126 +0,0 @@
// #undef GN_UTILS_CPP
#include "gryphn_init.h"
#include <platform/gryphn_platform_include.h>
// #include <dlfcn.h>
#include "stdbool.h"
#include "stdio.h"
// gnBool gnIsAPISupported(gnRenderingAPI api) {
// int renderingAPICount = 0;
// gnRenderingAPI* supportedRenderingAPIS = gnGetSupportedRenderingAPIs(&renderingAPICount);
// for (int i = 0; i < renderingAPICount; i++) if (supportedRenderingAPIS[i] == api) return true;
// return false;
// }
// struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI renderingAPI) {
// gnString libName = gnCreateEmptyString();
// switch (renderingAPI) {
// case GN_RENDERINGAPI_NONE: return NULL;
// case GN_RENDERINGAPI_SOFTWARE: return NULL;
// case GN_RENDERINGAPI_OPENGL: return NULL;
// case GN_RENDERINGAPI_VULKAN: {
// if (!gnIsAPISupported(GN_RENDERINGAPI_VULKAN)) return NULL;
// libName = gnCreateString("GryphnVulkanImpl");
// break;
// }
// case GN_RENDERINGAPI_DIRECTX11: return NULL;
// case GN_RENDERINGAPI_DIRECTX12: return NULL;
// case GN_RENDERINGAPI_METAL: {
// if (!gnIsAPISupported(GN_RENDERINGAPI_METAL)) return NULL;
// libName = gnCreateString("GryphnMetalImpl");
// break;
// }
// }
// return gnLoadDynamicLibrary(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName));
// }
gnInstanceFunctions* gnLoadFunctions(gnInstanceHandle instance) {
gnInstanceFunctions* functions = malloc(sizeof(gnInstanceFunctions));
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateInstance, "gnCreateInstanceFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyInstance, "gnDestroyInstanceFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnQueueCanPresentToSurface, "gnQueueCanPresentToSurfaceFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateOutputDevice, "gnCreateOutputDeviceFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
// #ifdef GN_PLATFORM_LINUX
// #ifdef GN_WINDOW_X11
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn");
// #endif
// #ifdef GN_WINDOW_WAYLAND
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn");
// #endif
// #endif
// #ifdef GN_PLATFORM_WIN32
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWin32WindowSurface, "gnCreateWin32WindowSurfaceFn");
// #endif
// #ifdef GN_PLATFORM_MACOS
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn");
// #endif
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn");
// gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetSurfaceDetails, "gnGetSurfaceDetailsFn");
return functions;
}
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) {
// gnLoadDLLFunction(lib, functions->_gnCreatePresentationQueue, "gnCreatePresentationQueueFn");
// gnLoadDLLFunction(lib, functions->_gnPresentationQueueGetImage, "gnPresentationQueueGetImageFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn");
// gnLoadDLLFunction(lib, functions->_gnCreateShaderModule, "gnCreateShaderModuleFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyShaderModule, "gnDestroyShaderModuleFn");
// gnLoadDLLFunction(lib, functions->_gnCreateRenderPassDescriptor, "gnCreateRenderPassDescriptorFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyRenderPassDescriptor, "gnDestroyRenderPassDescriptorFn");
// gnLoadDLLFunction(lib, functions->_gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
// gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn");
// gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn");
// gnLoadDLLFunction(lib, functions->_gnCreateSemaphore, "gnCreateSemaphoreFn");
// gnLoadDLLFunction(lib, functions->_gnDestroySemaphore, "gnDestroySemaphoreFn");
// gnLoadDLLFunction(lib, functions->_gnCreateBuffer, "gnCreateBufferFn");
// gnLoadDLLFunction(lib, functions->_gnBufferData, "gnBufferDataFn");
// gnLoadDLLFunction(lib, functions->_gnMapBuffer, "gnMapBufferFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyBuffer, "gnDestroyBufferFn");
// gnLoadDLLFunction(lib, functions->_gnCreateUniformPool, "gnCreateUniformPoolFn");
// gnLoadDLLFunction(lib, functions->_gnUniformPoolAllocateUniforms, "gnUniformPoolAllocateUniformsFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn");
// gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
// gnLoadDLLFunction(lib, functions->_gnUpdateImageUniform, "gnUpdateImageUniformFn");
// gnLoadDLLFunction(lib, functions->_gnCreateTexture, "gnCreateTextureFn");
// gnLoadDLLFunction(lib, functions->_gnTextureData, "gnTextureDataFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyTexture, "gnDestroyTextureFn");
// gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn");
// gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn");
// gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
// gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn");
// gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn");
// gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn");
// gnLoadDLLFunction(lib, functions->_gnPresent, "gnPresentFn");
// gnLoadDLLFunction(lib, functions->_gnWaitForDevice, "gnWaitForDeviceFn");
}
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
// gnLoadDLLFunction(lib, functions->_gnCommandPoolAllocateCommandBuffers, "gnCommandPoolAllocateCommandBuffersFn");
// gnLoadDLLFunction(lib, functions->_gnBeginCommandBuffer, "gnBeginCommandBufferFn");
// gnLoadDLLFunction(lib, functions->_gnResetCommandBuffer, "gnResetCommandBufferFn");
// gnLoadDLLFunction(lib, functions->_gnEndCommandBuffer, "gnEndCommandBufferFn");
// gnLoadDLLFunction(lib, functions->_gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
// gnLoadDLLFunction(lib, functions->_gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
// gnLoadDLLFunction(lib, functions->_gnCommandBindGraphicsPipeline, "gnCommandBindGraphicsPipelineFn");
// gnLoadDLLFunction(lib, functions->_gnCommandSetViewport, "gnCommandSetViewportFn");
// gnLoadDLLFunction(lib, functions->_gnCommandSetScissor, "gnCommandSetScissorFn");
// gnLoadDLLFunction(lib, functions->_gnCommandBindUniform, "gnCommandBindUniformFn");
// gnLoadDLLFunction(lib, functions->_gnCommandBindBuffer, "gnCommandBindBufferFn");
// gnLoadDLLFunction(lib, functions->_gnCommandPushConstant, "gnCommandPushConstantFn");
// gnLoadDLLFunction(lib, functions->_gnCommandDraw, "gnCommandDrawFn");
// gnLoadDLLFunction(lib, functions->_gnCommandDrawIndexed, "gnCommandDrawIndexedFn");
}

View File

@@ -1,11 +0,0 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <gryphn_rendering_api.h>
#include "gryphn_platform_functions.h"
// #include "utils/gryphn_error_code.h"
gnBool gnIsAPISupported(gnRenderingAPI RenderingAPI);
struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI RenderingAPI);
gnInstanceFunctions* gnLoadFunctions(gnInstance instance);
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions);
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* function);