rewrote instance creation
This commit is contained in:
@@ -1,46 +1,49 @@
|
||||
#include "gryphn_instance.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
#include <loader/src/gryphn_instance_functions.h>
|
||||
#include "loader/src/gryphn_extension_loader.h"
|
||||
#include "loader/src/gryphn_loader.h"
|
||||
#include "loader/src/gryphn_loader.h"
|
||||
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
||||
// this implementation of gnCreateInstance cannot return GN_UNLOADED_LAYER
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info) {
|
||||
*instance = malloc(sizeof(struct gnInstance_t));
|
||||
(*instance)->hasDebugger = GN_FALSE;
|
||||
|
||||
(*instance)->layers = loaderLayerArrayListCreate();
|
||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||
.api = info.renderingAPI,
|
||||
.api = info->coreAPI,
|
||||
.layerToLoad = api_layer
|
||||
}));
|
||||
|
||||
gnBool unsupportedExtension = GN_FALSE;
|
||||
for (int c = 0; c < GN_EXT_MAX; c++) (*instance)->enabledExtensions[c] = GN_FALSE;
|
||||
for (int i = 0; i < info.extensionCount; i++) (*instance)->enabledExtensions[info.extensions[i]] = GN_TRUE;
|
||||
|
||||
if ((*instance)->enabledExtensions[GN_EXT_SYNCHRONIZATION]) (*instance)->layers.data[0].syncFunctions = loadAPISyncFunctions(info.renderingAPI);
|
||||
|
||||
gnBool loaderFunctionChecker = GN_FALSE;
|
||||
if (info.debugger != NULL) {
|
||||
for (int i = 0; i < info.debugger->layerCount; i++) {
|
||||
if (info.debugger->layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) loaderFunctionChecker = GN_TRUE;
|
||||
}
|
||||
(*instance)->debugger = *info.debugger;
|
||||
(*instance)->hasDebugger = GN_TRUE;
|
||||
for (int i = 0; i < info->extensionCount; i++) {
|
||||
(*instance)->enabledExtensions[info->extensions[i]] = GN_TRUE;
|
||||
if (!gnIsExtensionSuppoted(info->coreAPI, info->extensions[i])) unsupportedExtension = GN_TRUE;
|
||||
}
|
||||
|
||||
if (loaderFunctionChecker) {
|
||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||
.api = info.renderingAPI,
|
||||
.layerToLoad = function_checker_layer
|
||||
}));
|
||||
if ((*instance)->enabledExtensions[GN_EXT_SYNCHRONIZATION]) (*instance)->layers.data[0].syncFunctions = loadAPISyncFunctions(info->coreAPI);
|
||||
if ((*instance)->enabledExtensions[GN_EXT_QUEUES]) (*instance)->layers.data[0].queueFunctions = loadAPIQueueFunctions(info->coreAPI);
|
||||
|
||||
if (info->debuggerInfo.layerCount > 0) {
|
||||
for (int i = 0; i < info->debuggerInfo.layerCount; i++) {
|
||||
if (info->debuggerInfo.layers[i] == GN_DEBUGGER_LAYER_FUNCTIONS) {
|
||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||
.api = info->coreAPI,
|
||||
.layerToLoad = function_checker_layer
|
||||
}));
|
||||
}
|
||||
}
|
||||
(*instance)->debugger = info->debuggerInfo;
|
||||
(*instance)->hasDebugger = GN_TRUE;
|
||||
}
|
||||
|
||||
(*instance)->currentLayer = ((*instance)->layers.count - 1);
|
||||
for (int i = 0; i < (*instance)->layers.count; i++) (*instance)->layers.data[i].layerIndex = i;
|
||||
|
||||
// i hate this line of code but im not fixing it
|
||||
(*instance)->callingLayer = &(*instance)->layers.data[(*instance)->layers.count - 1];
|
||||
return (*instance)->callingLayer->instanceFunctions._gnCreateInstance((*instance), info);
|
||||
gnReturnCode core_code = (*instance)->callingLayer->instanceFunctions._gnCreateInstance((*instance), info);
|
||||
if (unsupportedExtension) return GN_UNLOADED_EXTENSION;
|
||||
return core_code;
|
||||
}
|
||||
|
||||
void gnDestroyInstance(gnInstanceHandle instance) {
|
||||
|
@@ -2,40 +2,38 @@
|
||||
#include "core/src/gryphn_rendering_api.h"
|
||||
#include "core/src/gryphn_handles.h"
|
||||
#include "utils/gryphn_version.h"
|
||||
#include "utils/gryphn_error_code.h"
|
||||
#include "core/gryphn_error_code.h"
|
||||
#include "core/src/instance/gryphn_debugger.h"
|
||||
#include <gryphn_extensions.h>
|
||||
|
||||
typedef struct gnInstanceInfo {
|
||||
typedef struct gnApplicationInfo {
|
||||
gnString applicationName;
|
||||
gnVersion applicationVersion;
|
||||
|
||||
gnString engineName;
|
||||
gnVersion engineVersion;
|
||||
} gnApplicationInfo;
|
||||
|
||||
gnRenderingAPI renderingAPI;
|
||||
gnDebuggerInfo* debugger;
|
||||
|
||||
typedef struct gnInstanceCreateInfo {
|
||||
gnApplicationInfo applicationInfo;
|
||||
gnDebuggerCreateInfo debuggerInfo;
|
||||
uint32_t extensionCount;
|
||||
gnExtension* extensions;
|
||||
} gnInstanceInfo;
|
||||
gnRenderingAPI coreAPI;
|
||||
} gnInstanceCreateInfo;
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
#include <loader/src/gryphn_loader.h>
|
||||
struct gnInstance_t {
|
||||
struct gnPlatformInstance_t* instance;
|
||||
gnBool valid;
|
||||
|
||||
loaderLayerArrayList layers;
|
||||
loaderLayer* callingLayer;
|
||||
uint32_t currentLayer;
|
||||
|
||||
gnBool enabledExtensions[GN_EXT_MAX];
|
||||
|
||||
gnBool hasDebugger;
|
||||
gnDebuggerInfo debugger;
|
||||
gnDebuggerCreateInfo debugger;
|
||||
};
|
||||
#endif
|
||||
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info);
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
||||
void gnDestroyInstance(gnInstanceHandle instance);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <output_device/gryphn_physical_output_device.h>
|
||||
#include <utils/gryphn_error_code.h>
|
||||
#include <core/gryphn_error_code.h>
|
||||
|
||||
typedef struct gnOutputDeviceEnabledFeatures {
|
||||
|
||||
|
@@ -99,7 +99,6 @@ gnQueueExtFunctions loadAPIQueueFunctions(gnRenderingAPI api) {
|
||||
#ifdef GN_API_VULKAN
|
||||
case GN_RENDERINGAPI_VULKAN: return loadVulkanQueueFunctions();
|
||||
#endif
|
||||
|
||||
case GN_RENDERINGAPI_SOFTWARE: return (gnQueueExtFunctions){ NULL };
|
||||
case GN_RENDERINGAPI_DIRECTX11: return (gnQueueExtFunctions){ NULL };
|
||||
case GN_RENDERINGAPI_DIRECTX12: return (gnQueueExtFunctions){ NULL };
|
||||
|
Reference in New Issue
Block a user