diff --git a/CMakeLists.txt b/CMakeLists.txt index abda137..7b68180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,7 @@ add_subdirectory(projects/core) # build gryphn core add_subdirectory(projects/extensions) add_subdirectory(projects/platform) # build gryphn platform add_subdirectory(projects/validation_layers/function_loader/) -add_subdirectory(depends/Dispatcher/) -target_link_libraries(Gryphn INTERFACE dispatcher GryphnCore GryphnLoader GryphnPlatform GryphnFunctionValidator GryphnExtensions) +target_link_libraries(Gryphn INTERFACE GryphnCore GryphnLoader GryphnPlatform GryphnFunctionValidator GryphnExtensions) if (VULKAN_BUILT) target_link_libraries(Gryphn INTERFACE GryphnVulkanImpl) diff --git a/projects/apis/vulkan/src/buffers/vulkan_buffer.c b/projects/apis/vulkan/src/buffers/vulkan_buffer.c index 820ba30..cf7002d 100644 --- a/projects/apis/vulkan/src/buffers/vulkan_buffer.c +++ b/projects/apis/vulkan/src/buffers/vulkan_buffer.c @@ -2,7 +2,6 @@ #include "buffers/gryphn_buffer.h" #include "output_device/gryphn_output_device.h" #include "output_device/vulkan_output_devices.h" -#include "output_device/vulkan_physical_device.h" #include VkBufferUsageFlags vkGryphnBufferType(gnBufferType type) { @@ -49,7 +48,7 @@ gnReturnCode VkCreateBuffer( VkMemoryAllocateInfo memoryAllocateInfo = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = bufferRequirements.size, - .memoryTypeIndex = VkMemoryIndex(device->physicalDevice->physicalDevice->device, bufferRequirements.memoryTypeBits, flags, &foundMemory) + .memoryTypeIndex = VkMemoryIndex(device->outputDevice->physicalDevice, bufferRequirements.memoryTypeBits, flags, &foundMemory) }; if (!foundMemory) return GN_FAILED_TO_ALLOCATE_MEMORY; diff --git a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c index e971140..87154bb 100644 --- a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c +++ b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c @@ -9,7 +9,7 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo) { presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t)); - vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice->physicalDevice->device, presentationInfo.surface->windowSurface->surface); + vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->outputDevice->physicalDevice, presentationInfo.surface->windowSurface->surface); VkFormat convertedFormat = vkGryphnFormatToVulkanFormat(presentationInfo.format.format); VkColorSpaceKHR convertedColorSpace = vkGryphnColorSpaceToVulkanColorSpace(presentationInfo.format.colorSpace); diff --git a/projects/apis/vulkan/src/textures/vulkan_texture.c b/projects/apis/vulkan/src/textures/vulkan_texture.c index 9d229b7..b02ab59 100644 --- a/projects/apis/vulkan/src/textures/vulkan_texture.c +++ b/projects/apis/vulkan/src/textures/vulkan_texture.c @@ -182,7 +182,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn VkMemoryAllocateInfo allocInfo = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = memRequirements.size, - .memoryTypeIndex = VkMemoryIndex(device->physicalDevice->physicalDevice->device, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &foundMemory) + .memoryTypeIndex = VkMemoryIndex(device->outputDevice->physicalDevice, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &foundMemory) }; if (!foundMemory) return GN_FAILED_TO_ALLOCATE_MEMORY; @@ -209,7 +209,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn if (image_view != VK_SUCCESS) return VkResultToGnReturnCode(image_view); VkPhysicalDeviceProperties properties = {}; - vkGetPhysicalDeviceProperties(device->physicalDevice->physicalDevice->device, &properties); + vkGetPhysicalDeviceProperties(device->outputDevice->physicalDevice, &properties); VkSamplerCreateInfo samplerInfo = { .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, diff --git a/projects/loader/src/gryphn_loader.c b/projects/loader/src/gryphn_loader.c index 71dc7d7..6370c2a 100644 --- a/projects/loader/src/gryphn_loader.c +++ b/projects/loader/src/gryphn_loader.c @@ -139,6 +139,7 @@ loaderLayer null_layer() { loaderLayer api_loaded_layer(gnRenderingAPI api) { return (loaderLayer){ + .instanceFunctions = loadAPIInstanceFunctions(api), .deviceFunctions = loadAPIDeviceFunctions(api), .commandFunctions = loadAPICommandFunctions(api), }; @@ -146,6 +147,7 @@ loaderLayer api_loaded_layer(gnRenderingAPI api) { loaderLayer function_check_layer() { return (loaderLayer){ + .instanceFunctions = loadFunctionLoaderInstanceFunctions(), .deviceFunctions = loadFunctionLoaderDeviceFunctions(), .commandFunctions = loadFunctionLoaderCommandFunctions(), diff --git a/projects/loader/src/gryphn_loader.h b/projects/loader/src/gryphn_loader.h index 5fc23c8..aba19a5 100644 --- a/projects/loader/src/gryphn_loader.h +++ b/projects/loader/src/gryphn_loader.h @@ -4,7 +4,6 @@ #include "gryphn_command_functions.h" #include "gryphn_loader_info.h" #include "utils/lists/gryphn_array_list.h" -#include #include "extensions/synchronization/loader/sync_functions.h" #include "extensions/queues/queues_functions.h" @@ -25,8 +24,7 @@ typedef struct loaderLayer { // they used to be loaded seperatly but I guess there not anymore // initlization is hard - // gnInstanceFunctions instanceFunctions; - + gnInstanceFunctions instanceFunctions; gnDeviceFunctions deviceFunctions; gnCommandFunctions commandFunctions; diff --git a/projects/validation_layers/function_loader/loader/function_loader.c b/projects/validation_layers/function_loader/loader/function_loader.c index ceef1ba..01ea408 100644 --- a/projects/validation_layers/function_loader/loader/function_loader.c +++ b/projects/validation_layers/function_loader/loader/function_loader.c @@ -5,11 +5,15 @@ #include "extensions/sync_functions.h" #include "extensions/queue_functions.h" +gryphnInstanceFunctionLayers checkerLoadInstanceFunctions() { + return (gryphnInstanceFunctionLayers) { + .createInstance = { checkCreateInstance, NULL }, + .destroyInstance = { checkDestroyInstance, NULL } + }; +} + gnInstanceFunctions loadFunctionLoaderInstanceFunctions() { return (gnInstanceFunctions){ - ._gnCreateInstance = checkCreateInstance, - ._gnDestroyInstance = checkDestroyInstance, - ._gnGetPhysicalDevices = checkGetPhysicalDevices, ._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent, diff --git a/projects/validation_layers/function_loader/src/instance_functions.c b/projects/validation_layers/function_loader/src/instance_functions.c index 9aa41f0..2b61eeb 100644 --- a/projects/validation_layers/function_loader/src/instance_functions.c +++ b/projects/validation_layers/function_loader/src/instance_functions.c @@ -4,12 +4,23 @@ #include "core/src/output_device/gryphn_output_device.h" #include "core/src/window_surface/gryphn_surface.h" -gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info) { - CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateInstance, instanceFunctions, instance, info); +gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnFunctionLayer* next) { + if (next->function == NULL) { + gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){ + .message = gnCreateString("Failed to load gnCreateInstance this indicates a bug within gryphn") + }); + return GN_FAILED_TO_LOAD_FUNCTION; + } + return (*(PFN_gnCreateInstance*)next->function)(instance, info, next->next); } -void checkDestroyInstance(gnInstance instance) { - CHECK_VOID_FUNCTION(instance, _gnDestroyInstance, instanceFunctions, instance); +void checkDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next) { + if (next->function == NULL) { + gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){ + .message = gnCreateString("Failed to load gnDestroyInstance this indicates a bug within gryphn") + }); + } + (*(PFN_gnDestroyInstance*)next->function)(instance, next->next); } gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count) { @@ -19,11 +30,11 @@ gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle wind CHECK_RETURNED_FUNCTION(device->instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, GN_FALSE, device, windowSurface); } -gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) { - CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateOutputDevice, instanceFunctions, device, instance, deviceInfo); +gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) { + CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateOutputDevice, instanceFunctions, instance, device, deviceInfo); } -void checkDestroyOutputDevice(gnOutputDeviceHandle device) { - CHECK_VOID_FUNCTION(device->instance, _gnDestroyOutputDevice, instanceFunctions, device); +void checkDestroyOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device) { + CHECK_VOID_FUNCTION(device->instance, _gnDestroyOutputDevice, instanceFunctions, instance, device); } #ifdef GN_PLATFORM_MACOS diff --git a/projects/validation_layers/function_loader/src/instance_functions.h b/projects/validation_layers/function_loader/src/instance_functions.h index a7ab6e9..1fdecab 100644 --- a/projects/validation_layers/function_loader/src/instance_functions.h +++ b/projects/validation_layers/function_loader/src/instance_functions.h @@ -2,14 +2,14 @@ #include "core/src/instance/gryphn_instance.h" #include -gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info); -void checkDestroyInstance(gnInstance instance); +gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnFunctionLayer* next); +void checkDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next); gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count); gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface); -gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo); -void checkDestroyOutputDevice(gnOutputDeviceHandle device); +gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo); +void checkDestroyOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device); #ifdef GN_PLATFORM_MACOS gnReturnCode checkCreateSurfaceMacOS(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnMacOSWindowSurfaceInfo createInfo);