continue instance functions redo
This commit is contained in:
@@ -4,10 +4,15 @@
|
|||||||
#include <output_device/vulkan_output_devices.h>
|
#include <output_device/vulkan_output_devices.h>
|
||||||
#include <vulkan_surface/vulkan_surface.h>
|
#include <vulkan_surface/vulkan_surface.h>
|
||||||
|
|
||||||
|
gryphnInstanceFunctionLayers loadVulkanAPILayer() {
|
||||||
|
return (gryphnInstanceFunctionLayers) {
|
||||||
|
.createInstance = {vulkanCreateInstance, NULL},
|
||||||
|
.destroyInstance = {vulkanDestroyInstance, NULL}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions() {
|
gnInstanceFunctions loadVulkanInstanceFunctions() {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
.createInstance = (PFN_gnCreateInstance)createVulkanInstance,
|
|
||||||
.destroyInstance = (PFN_gnDestroyInstance)destroyVulkanInstance,
|
|
||||||
|
|
||||||
._gnGetPhysicalDevices = getPhysicalDevices,
|
._gnGetPhysicalDevices = getPhysicalDevices,
|
||||||
._gnPhysicalDeviceCanPresentToSurface = deviceCanPresentToSurface,
|
._gnPhysicalDeviceCanPresentToSurface = deviceCanPresentToSurface,
|
||||||
|
@@ -35,7 +35,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
return VK_TRUE;
|
return VK_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode createVulkanInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, PFN_gnCreateInstance* next) {
|
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnFunctionLayer* next) {
|
||||||
instance->instance = malloc(sizeof(gnPlatformInstance));
|
instance->instance = malloc(sizeof(gnPlatformInstance));
|
||||||
|
|
||||||
vkStringArrayList extensions = vkStringArrayListCreate();
|
vkStringArrayList extensions = vkStringArrayListCreate();
|
||||||
@@ -101,6 +101,6 @@ gnReturnCode createVulkanInstance(gnInstanceHandle instance, gnInstanceCreateInf
|
|||||||
return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance));
|
return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyVulkanInstance(gnInstanceHandle instance, PFN_gnDestroyInstance* next) {
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next) {
|
||||||
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -14,8 +14,8 @@ typedef struct gnPlatformInstance_t {
|
|||||||
vkUserData userData;
|
vkUserData userData;
|
||||||
} gnPlatformInstance;
|
} gnPlatformInstance;
|
||||||
|
|
||||||
gnReturnCode createVulkanInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, PFN_gnCreateInstance* next);
|
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnFunctionLayer* next);
|
||||||
void destroyVulkanInstance(gnInstanceHandle instance, PFN_gnDestroyInstance* next);
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next);
|
||||||
|
|
||||||
typedef const char* vkString;
|
typedef const char* vkString;
|
||||||
GN_ARRAY_LIST(vkString);
|
GN_ARRAY_LIST(vkString);
|
||||||
|
@@ -18,13 +18,11 @@ typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
|||||||
typedef struct gnMacOSWindowSurfaceInfo gnMacOSWindowSurfaceInfo;
|
typedef struct gnMacOSWindowSurfaceInfo gnMacOSWindowSurfaceInfo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle instance, gnInstanceCreateInfo* info, void* next);
|
typedef struct gryphnFunctionLayer gryphnFunctionLayer;
|
||||||
typedef gnReturnCode (*PFN_gnDestroyInstance)(gnInstanceHandle instance, void* next);
|
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnFunctionLayer* next);
|
||||||
|
typedef gnReturnCode (*PFN_gnDestroyInstance)(gnInstanceHandle instance, gryphnFunctionLayer* next);
|
||||||
|
|
||||||
typedef struct gnInstanceFunctions {
|
typedef struct gnInstanceFunctions {
|
||||||
PFN_gnCreateInstance createInstance;
|
|
||||||
PFN_gnDestroyInstance destroyInstance;
|
|
||||||
|
|
||||||
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
|
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
|
||||||
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
||||||
|
|
||||||
|
@@ -10,31 +10,47 @@
|
|||||||
#include <apis/opengl/loader/opengl_loader.h>
|
#include <apis/opengl/loader/opengl_loader.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "core/src/instance/gryphn_instance.h"
|
#include "core/src/instance/gryphn_instance.h"
|
||||||
|
|
||||||
// load the speedy API functions or something like that
|
gryphnInstanceFunctionLayers gryphnLoadAPILayer(gnRenderingAPI api) {
|
||||||
dispatcher_bool loadAPIInstanceFunctions(dispatcher_layer* layer) {
|
|
||||||
gnRenderingAPI api = *(gnRenderingAPI*)layer->userData;
|
|
||||||
gnInstanceFunctions* funcs = (gnInstanceFunctions*)layer->function_array;
|
|
||||||
switch (api) {
|
switch (api) {
|
||||||
case GN_RENDERINGAPI_NONE: *funcs = (gnInstanceFunctions){ NULL };
|
case GN_RENDERINGAPI_NONE: return (gryphnInstanceFunctionLayers){};
|
||||||
#ifdef GN_API_VULKAN
|
#ifdef GN_API_VULKAN
|
||||||
case GN_RENDERINGAPI_VULKAN: *funcs = loadVulkanInstanceFunctions();
|
case GN_RENDERINGAPI_VULKAN: return loadVulkanAPILayer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case GN_RENDERINGAPI_SOFTWARE: *funcs = (gnInstanceFunctions){ NULL };
|
case GN_RENDERINGAPI_SOFTWARE: return (gryphnInstanceFunctionLayers){};
|
||||||
case GN_RENDERINGAPI_DIRECTX11: *funcs = (gnInstanceFunctions){ NULL };
|
case GN_RENDERINGAPI_DIRECTX11: return (gryphnInstanceFunctionLayers){};
|
||||||
case GN_RENDERINGAPI_DIRECTX12: *funcs = (gnInstanceFunctions){ NULL };
|
case GN_RENDERINGAPI_DIRECTX12: return (gryphnInstanceFunctionLayers){};
|
||||||
#ifdef GN_API_OPENGL
|
#ifdef GN_API_OPENGL
|
||||||
case GN_RENDERINGAPI_OPENGL: *funcs = loadOpenGLInstanceFunctions();
|
// case GN_RENDERINGAPI_OPENGL: return loadOpenGLInstanceFunctions();
|
||||||
#endif
|
#endif
|
||||||
#ifdef GN_API_METAL
|
#ifdef GN_API_METAL
|
||||||
case GN_RENDERINGAPI_METAL: *funcs = loadMetalInstanceFunctions();
|
// case GN_RENDERINGAPI_METAL: return loadMetalInstanceFunctions();
|
||||||
#endif
|
#endif
|
||||||
default: *funcs = (gnInstanceFunctions){NULL};
|
default: return (gryphnInstanceFunctionLayers){};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// load the speedy API functions or something like that
|
||||||
|
gnInstanceFunctions loadAPIInstanceFunctions(gnRenderingAPI api) {
|
||||||
|
switch (api) {
|
||||||
|
case GN_RENDERINGAPI_NONE: return (gnInstanceFunctions){ NULL };
|
||||||
|
#ifdef GN_API_VULKAN
|
||||||
|
case GN_RENDERINGAPI_VULKAN: return loadVulkanInstanceFunctions();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case GN_RENDERINGAPI_SOFTWARE: return (gnInstanceFunctions){ NULL };
|
||||||
|
case GN_RENDERINGAPI_DIRECTX11: return (gnInstanceFunctions){ NULL };
|
||||||
|
case GN_RENDERINGAPI_DIRECTX12: return (gnInstanceFunctions){ NULL };
|
||||||
|
#ifdef GN_API_OPENGL
|
||||||
|
case GN_RENDERINGAPI_OPENGL: return loadOpenGLInstanceFunctions();
|
||||||
|
#endif
|
||||||
|
#ifdef GN_API_METAL
|
||||||
|
case GN_RENDERINGAPI_METAL: return loadMetalInstanceFunctions();
|
||||||
|
#endif
|
||||||
|
default: return (gnInstanceFunctions){NULL};
|
||||||
}
|
}
|
||||||
return dispatcher_true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnDeviceFunctions loadAPIDeviceFunctions(gnRenderingAPI api) {
|
gnDeviceFunctions loadAPIDeviceFunctions(gnRenderingAPI api) {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "gryphn_instance_functions.h"
|
||||||
#include "gryphn_device_functions.h"
|
#include "gryphn_device_functions.h"
|
||||||
#include "gryphn_command_functions.h"
|
#include "gryphn_command_functions.h"
|
||||||
#include "gryphn_loader_info.h"
|
#include "gryphn_loader_info.h"
|
||||||
@@ -8,6 +9,17 @@
|
|||||||
#include "extensions/synchronization/loader/sync_functions.h"
|
#include "extensions/synchronization/loader/sync_functions.h"
|
||||||
#include "extensions/queues/queues_functions.h"
|
#include "extensions/queues/queues_functions.h"
|
||||||
|
|
||||||
|
typedef struct gryphnFunctionLayer {
|
||||||
|
void* function;
|
||||||
|
struct gryphnFunctionLayer* next;
|
||||||
|
} gryphnFunctionLayer;
|
||||||
|
|
||||||
|
typedef struct gryphnInstanceFunctionLayers {
|
||||||
|
gryphnFunctionLayer createInstance; // PFN_gnCreateInstance
|
||||||
|
gryphnFunctionLayer destroyInstance; // PFN_gnDestroyInstance
|
||||||
|
} gryphnInstanceFunctionLayers;
|
||||||
|
gryphnInstanceFunctionLayers gryphnLoadAPILayer(gnRenderingAPI api);
|
||||||
|
|
||||||
typedef struct loaderLayer {
|
typedef struct loaderLayer {
|
||||||
// idk why I sperate these info different classes, I should really shove them in one bit class
|
// 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
|
// they used to be loaded seperatly but I guess there not anymore
|
||||||
@@ -31,9 +43,6 @@ GN_ARRAY_LIST(loaderLayer);
|
|||||||
loaderLayer* loaderGetNextLayer(gnInstance instance);
|
loaderLayer* loaderGetNextLayer(gnInstance instance);
|
||||||
void resetLayer(gnInstance instance);
|
void resetLayer(gnInstance instance);
|
||||||
|
|
||||||
|
gnInstanceFunctions loadAPIInstanceFunctions(gnRenderingAPI api);
|
||||||
gnSyncExtFunctions loadAPISyncFunctions(gnRenderingAPI api);
|
gnSyncExtFunctions loadAPISyncFunctions(gnRenderingAPI api);
|
||||||
gnQueueExtFunctions loadAPIQueueFunctions(gnRenderingAPI api);
|
gnQueueExtFunctions loadAPIQueueFunctions(gnRenderingAPI api);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dispatcher_bool loadAPIInstanceFunctions(dispatcher_layer* layer);
|
|
||||||
|
Reference in New Issue
Block a user