more loader redoing (for instance)
This commit is contained in:
@@ -3,10 +3,15 @@
|
|||||||
#include "surface/metal_surface.h"
|
#include "surface/metal_surface.h"
|
||||||
#include "devices/metal_output_devices.h"
|
#include "devices/metal_output_devices.h"
|
||||||
|
|
||||||
|
gryphnInstanceFunctionLayers metalLoadAPILayer() {
|
||||||
|
return (gryphnInstanceFunctionLayers) {
|
||||||
|
.createInstance = { metalCreateInstance, NULL },
|
||||||
|
.destroyInstance = { metalDestroyInstance, NULL }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadMetalInstanceFunctions() {
|
gnInstanceFunctions loadMetalInstanceFunctions() {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
._gnCreateInstance = createMetalInstance,
|
|
||||||
._gnDestroyInstance = destroyMetalInstance,
|
|
||||||
._gnGetPhysicalDevices = getMetalDevices,
|
._gnGetPhysicalDevices = getMetalDevices,
|
||||||
._gnPhysicalDeviceCanPresentToSurface = metalCanDevicePresent,
|
._gnPhysicalDeviceCanPresentToSurface = metalCanDevicePresent,
|
||||||
._gnCreateOutputDevice = createMetalOutputDevice,
|
._gnCreateOutputDevice = createMetalOutputDevice,
|
||||||
|
@@ -5,6 +5,9 @@
|
|||||||
#include "extensions/synchronization/loader/sync_functions.h"
|
#include "extensions/synchronization/loader/sync_functions.h"
|
||||||
#include "core/gryphn_extensions.h"
|
#include "core/gryphn_extensions.h"
|
||||||
|
|
||||||
|
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
||||||
|
gryphnInstanceFunctionLayers metalLoadAPILayer();
|
||||||
|
|
||||||
gnInstanceFunctions loadMetalInstanceFunctions();
|
gnInstanceFunctions loadMetalInstanceFunctions();
|
||||||
gnDeviceFunctions loadMetalDeviceFunctions();
|
gnDeviceFunctions loadMetalDeviceFunctions();
|
||||||
gnCommandFunctions loadMetalCommandFunctions();
|
gnCommandFunctions loadMetalCommandFunctions();
|
||||||
|
@@ -7,5 +7,5 @@ typedef struct gnPlatformInstance_t {
|
|||||||
NSView* metalContentView;
|
NSView* metalContentView;
|
||||||
} gnPlatformInstance;
|
} gnPlatformInstance;
|
||||||
|
|
||||||
gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo);
|
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnFunctionLayer* next);
|
||||||
void destroyMetalInstance(gnInstance instance);
|
void metalDestroyInstance(gnInstance instance, gryphnFunctionLayer* next);
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
#include "metal_instance.h"
|
#include "metal_instance.h"
|
||||||
|
|
||||||
// metal instances are kinda useless
|
// metal instances are kinda useless
|
||||||
gnReturnCode createMetalInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo) {
|
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnFunctionLayer* next) {
|
||||||
if (instance->instance == NULL) instance->instance = malloc(sizeof(gnPlatformInstance));
|
if (instance->instance == NULL) instance->instance = malloc(sizeof(gnPlatformInstance));
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void destroyMetalInstance(gnInstance instance) {
|
void metalDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next) {
|
||||||
free(instance->instance);
|
free(instance->instance);
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,9 @@
|
|||||||
#include "extensions/queues/queues_functions.h"
|
#include "extensions/queues/queues_functions.h"
|
||||||
#include "core/gryphn_extensions.h"
|
#include "core/gryphn_extensions.h"
|
||||||
|
|
||||||
|
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
||||||
|
gryphnInstanceFunctionLayers loadVulkanAPILayer();
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions();
|
gnInstanceFunctions loadVulkanInstanceFunctions();
|
||||||
gnDeviceFunctions loadVulkanDeviceFunctions();
|
gnDeviceFunctions loadVulkanDeviceFunctions();
|
||||||
gnCommandFunctions loadVulkanCommandFunctions();
|
gnCommandFunctions loadVulkanCommandFunctions();
|
||||||
|
@@ -10,10 +10,8 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
|||||||
*instance = malloc(sizeof(struct gnInstance_t));
|
*instance = malloc(sizeof(struct gnInstance_t));
|
||||||
(*instance)->hasDebugger = GN_FALSE;
|
(*instance)->hasDebugger = GN_FALSE;
|
||||||
(*instance)->layers = loaderLayerArrayListCreate();
|
(*instance)->layers = loaderLayerArrayListCreate();
|
||||||
dispatcher_init(&(*instance)->dispatch);
|
|
||||||
dispatcher_set_function_array_size(&(*instance)->dispatch, sizeof(gnInstanceFunctions));
|
|
||||||
|
|
||||||
dispatcher_create_layer(&(*instance)->dispatch, loadAPIInstanceFunctions, &info->coreAPI);
|
// (*instance)->functions =
|
||||||
|
|
||||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||||
.api = info->coreAPI,
|
.api = info->coreAPI,
|
||||||
@@ -46,17 +44,12 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
|||||||
(*instance)->currentLayer = ((*instance)->layers.count - 1);
|
(*instance)->currentLayer = ((*instance)->layers.count - 1);
|
||||||
for (int i = 0; i < (*instance)->layers.count; i++) (*instance)->layers.data[i].layerIndex = i;
|
for (int i = 0; i < (*instance)->layers.count; i++) (*instance)->layers.data[i].layerIndex = i;
|
||||||
(*instance)->callingLayer = &(*instance)->layers.data[(*instance)->layers.count - 1];
|
(*instance)->callingLayer = &(*instance)->layers.data[(*instance)->layers.count - 1];
|
||||||
|
|
||||||
gnInstanceFunctions* instance_funcs = (gnInstanceFunctions*)((*instance)->dispatch.first_layer->function_array);
|
|
||||||
gnReturnCode core_code = instance_funcs->_gnCreateInstance((*instance), info);
|
|
||||||
if (unsupportedExtension) return GN_UNLOADED_EXTENSION;
|
if (unsupportedExtension) return GN_UNLOADED_EXTENSION;
|
||||||
return core_code;
|
return (*(PFN_gnCreateInstance*)(*instance)->functions.createInstance.function)(*instance, info, (*instance)->functions.createInstance.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyInstance(gnInstanceHandle* instance) {
|
void gnDestroyInstance(gnInstanceHandle* instance) {
|
||||||
if (instance == GN_NULL_HANDLE) return;
|
if (instance == GN_NULL_HANDLE) return;
|
||||||
|
(*(PFN_gnDestroyInstance*)(*instance)->functions.destroyInstance.function)(*instance, (*instance)->functions.destroyInstance.next);
|
||||||
gnInstanceFunctions* instance_funcs = (gnInstanceFunctions*)((*instance)->dispatch.first_layer->function_array);
|
|
||||||
instance_funcs->_gnDestroyInstance((*instance));
|
|
||||||
*instance = GN_NULL_HANDLE;
|
*instance = GN_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
#include "core/gryphn_return_code.h"
|
#include "core/gryphn_return_code.h"
|
||||||
#include "core/src/instance/gryphn_debugger.h"
|
#include "core/src/instance/gryphn_debugger.h"
|
||||||
#include <gryphn_extensions.h>
|
#include <gryphn_extensions.h>
|
||||||
#include "Dispatcher/dispatcher.h"
|
|
||||||
|
|
||||||
typedef struct gnApplicationInfo {
|
typedef struct gnApplicationInfo {
|
||||||
gnString applicationName;
|
gnString applicationName;
|
||||||
@@ -25,11 +24,14 @@ typedef struct gnInstanceCreateInfo {
|
|||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
#include <loader/src/gryphn_loader.h>
|
#include <loader/src/gryphn_loader.h>
|
||||||
|
|
||||||
struct gnInstance_t {
|
struct gnInstance_t {
|
||||||
struct gnPlatformInstance_t* instance;
|
struct gnPlatformInstance_t* instance;
|
||||||
gnDebuggerCreateInfo debugger;
|
gnDebuggerCreateInfo debugger;
|
||||||
gnBool enabledExtensions[GN_EXT_MAX];
|
gnBool enabledExtensions[GN_EXT_MAX];
|
||||||
|
|
||||||
|
gryphnInstanceFunctionLayers functions;
|
||||||
|
|
||||||
loaderLayerArrayList layers;
|
loaderLayerArrayList layers;
|
||||||
loaderLayer* callingLayer;
|
loaderLayer* callingLayer;
|
||||||
uint32_t currentLayer;
|
uint32_t currentLayer;
|
||||||
|
@@ -26,7 +26,7 @@ gryphnInstanceFunctionLayers gryphnLoadAPILayer(gnRenderingAPI api) {
|
|||||||
// case GN_RENDERINGAPI_OPENGL: return loadOpenGLInstanceFunctions();
|
// case GN_RENDERINGAPI_OPENGL: return loadOpenGLInstanceFunctions();
|
||||||
#endif
|
#endif
|
||||||
#ifdef GN_API_METAL
|
#ifdef GN_API_METAL
|
||||||
// case GN_RENDERINGAPI_METAL: return loadMetalInstanceFunctions();
|
case GN_RENDERINGAPI_METAL: return metalLoadAPILayer();
|
||||||
#endif
|
#endif
|
||||||
default: return (gryphnInstanceFunctionLayers){};
|
default: return (gryphnInstanceFunctionLayers){};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user