diff --git a/.gitmodules b/.gitmodules index c64c247..32bff6c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "projects/apis/metal/depends/SPIRV-Cross"] path = projects/apis/metal/depends/SPIRV-Cross url = https://github.com/KhronosGroup/SPIRV-Cross.git -[submodule "depends/Dispatcher"] - path = depends/Dispatcher - url = https://github.com/GregoryWells2007/Dispatcher.git diff --git a/projects/apis/metal/CMakeLists.txt b/projects/apis/metal/CMakeLists.txt index 3c6ffdf..c090be2 100644 --- a/projects/apis/metal/CMakeLists.txt +++ b/projects/apis/metal/CMakeLists.txt @@ -19,7 +19,6 @@ target_include_directories(GryphnMetalImpl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../platform/ ${CMAKE_CURRENT_SOURCE_DIR}/../../../depends/ ${CMAKE_CURRENT_SOURCE_DIR}/src/ - depends/SPIRV-Cross/ ) add_compile_definitions(GN_REVEAL_IMPL) add_subdirectory(depends/SPIRV-Cross) diff --git a/projects/apis/vulkan/loader/vulkan_instance_loader.c b/projects/apis/vulkan/loader/vulkan_instance_loader.c index d628f03..df787b2 100644 --- a/projects/apis/vulkan/loader/vulkan_instance_loader.c +++ b/projects/apis/vulkan/loader/vulkan_instance_loader.c @@ -6,14 +6,14 @@ gnInstanceFunctions loadVulkanInstanceFunctions() { return (gnInstanceFunctions){ - ._gnCreateInstance = createInstance, - ._gnDestroyInstance = destroyInstance, + .createInstance = (PFN_gnCreateInstance)createVulkanInstance, + .destroyInstance = (PFN_gnDestroyInstance)destroyVulkanInstance, ._gnGetPhysicalDevices = getPhysicalDevices, ._gnPhysicalDeviceCanPresentToSurface = deviceCanPresentToSurface, - ._gnCreateOutputDevice = createOutputDevice, - ._gnDestroyOutputDevice = destroyOutputDevice, + ._gnCreateOutputDevice = createVulkanOutputDevice, + ._gnDestroyOutputDevice = destroyVulkanOutputDevice, #ifdef GN_PLATFORM_LINUX diff --git a/projects/apis/vulkan/src/instance/vulkan_instance.c b/projects/apis/vulkan/src/instance/vulkan_instance.c index fc274be..513082c 100644 --- a/projects/apis/vulkan/src/instance/vulkan_instance.c +++ b/projects/apis/vulkan/src/instance/vulkan_instance.c @@ -35,7 +35,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback( return VK_TRUE; } -gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo) { +gnReturnCode createVulkanInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, PFN_gnCreateInstance* next) { instance->instance = malloc(sizeof(gnPlatformInstance)); vkStringArrayList extensions = vkStringArrayListCreate(); @@ -101,6 +101,6 @@ gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceCreateInfo* ins return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance)); } -void destroyInstance(gnInstanceHandle instance) { +void destroyVulkanInstance(gnInstanceHandle instance, PFN_gnDestroyInstance* next) { vkDestroyInstance(instance->instance->vk_instance, NULL); } diff --git a/projects/apis/vulkan/src/instance/vulkan_instance.h b/projects/apis/vulkan/src/instance/vulkan_instance.h index f9cf294..dd4ce80 100644 --- a/projects/apis/vulkan/src/instance/vulkan_instance.h +++ b/projects/apis/vulkan/src/instance/vulkan_instance.h @@ -2,6 +2,7 @@ #include #include "instance/gryphn_instance.h" #include "utils/lists/gryphn_array_list.h" +#include "loader/src/gryphn_instance_functions.h" typedef struct vkUserData { gnDebuggerCallback debuggerCallback; @@ -13,9 +14,8 @@ typedef struct gnPlatformInstance_t { vkUserData userData; } gnPlatformInstance; -gnReturnCode createInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo); -void destroyInstance(gnInstanceHandle instance); +gnReturnCode createVulkanInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, PFN_gnCreateInstance* next); +void destroyVulkanInstance(gnInstanceHandle instance, PFN_gnDestroyInstance* next); typedef const char* vkString; - GN_ARRAY_LIST(vkString); diff --git a/projects/core/src/gryphn_handles.h b/projects/core/src/gryphn_handles.h index 65a4ad3..edb746f 100644 --- a/projects/core/src/gryphn_handles.h +++ b/projects/core/src/gryphn_handles.h @@ -4,20 +4,24 @@ #define GN_NULL_HANDLE 0 typedef uint32_t gnFlags; +// The value of this handle is defined by the gryphn spec #define GN_HANDLE(type) \ typedef struct type##_t* type##Handle; \ typedef struct type##_t* type +// The value of this handle is defined by the implementation #define GN_IMPLEMENTATION_HANDLE(type) \ typedef uint64_t type##Handle; \ typedef uint64_t type +// can be used to alias a normal handle or an implementation handle #define GN_HANDLE_ALIAS(handle, alias) \ typedef struct handle##_t* alias##Handle; \ typedef struct handle##_t* alias GN_HANDLE(gnInstance); -GN_HANDLE(gnDebugger); + + GN_HANDLE(gnWindowSurface); GN_HANDLE(gnPresentationQueue); GN_HANDLE(gnTexture); diff --git a/projects/core/src/instance/gryphn_instance.h b/projects/core/src/instance/gryphn_instance.h index 80dd021..c6ba5c4 100644 --- a/projects/core/src/instance/gryphn_instance.h +++ b/projects/core/src/instance/gryphn_instance.h @@ -29,7 +29,6 @@ struct gnInstance_t { struct gnPlatformInstance_t* instance; gnDebuggerCreateInfo debugger; gnBool enabledExtensions[GN_EXT_MAX]; - dispatcher dispatch; loaderLayerArrayList layers; loaderLayer* callingLayer; diff --git a/projects/loader/src/gryphn_instance_functions.h b/projects/loader/src/gryphn_instance_functions.h index bc0a95f..fffd01d 100644 --- a/projects/loader/src/gryphn_instance_functions.h +++ b/projects/loader/src/gryphn_instance_functions.h @@ -18,15 +18,18 @@ typedef struct gnOutputDeviceInfo gnOutputDeviceInfo; typedef struct gnMacOSWindowSurfaceInfo gnMacOSWindowSurfaceInfo; #endif +typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle instance, gnInstanceCreateInfo* info, void* next); +typedef gnReturnCode (*PFN_gnDestroyInstance)(gnInstanceHandle instance, void* next); + typedef struct gnInstanceFunctions { - gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceCreateInfo* info); - void (*_gnDestroyInstance)(gnInstanceHandle instance); + PFN_gnCreateInstance createInstance; + PFN_gnDestroyInstance destroyInstance; gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count); gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface); gnReturnCode (*_gnCreateOutputDevice)(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo); - void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device); + void (*_gnDestroyOutputDevice)(gnInstanceHandle handle, gnOutputDeviceHandle device); #ifdef GN_PLATFORM_LINUX