Turn instance into a handle

This commit is contained in:
Greg Wells
2025-06-03 13:23:28 -04:00
parent cbfd6743f6
commit ed781c1d63
22 changed files with 56 additions and 52 deletions

View File

@@ -1,7 +1,7 @@
#include <core/debugger/gryphn_debugger.h> #include <core/debugger/gryphn_debugger.h>
// these do nothing because I am too lazy to write a debugger for metal at this point in time // these do nothing because I am too lazy to write a debugger for metal at this point in time
gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) { gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) {
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyDebuggerFn(gnDebugger* instance) { void gnDestroyDebuggerFn(gnDebugger* instance) {

View File

@@ -5,7 +5,7 @@
#include "core/instance/gryphn_instance.h" #include "core/instance/gryphn_instance.h"
#include <core/debugger/gryphn_debugger.h> #include <core/debugger/gryphn_debugger.h>
gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) { gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice)); outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain; outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount; outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount;

View File

@@ -3,7 +3,7 @@
#include "metal_output_devices.h" #include "metal_output_devices.h"
#include "core/window_surface/gryphn_surface.h" #include "core/window_surface/gryphn_surface.h"
gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstance* instance, uint32_t* deviceCount) { gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstanceHandle instance, uint32_t* deviceCount) {
NSArray *devices = MTLCopyAllDevices(); NSArray *devices = MTLCopyAllDevices();
*deviceCount = [devices count]; *deviceCount = [devices count];
gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount); gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);

View File

@@ -4,11 +4,11 @@
// #include "bridge/metal_bridge.h" // #include "bridge/metal_bridge.h"
gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) { gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
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 gnDestroyInstanceFn(gnInstance* instance) { void gnDestroyInstanceFn(gnInstanceHandle instance) {
free(instance->instance); free(instance->instance);
} }

View File

@@ -8,7 +8,7 @@
#import <Metal/Metal.h> #import <Metal/Metal.h>
#import <CoreGraphics/CoreGraphics.h> #import <CoreGraphics/CoreGraphics.h>
gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface)); windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface));
windowSurface->windowSurface->layer = createInfo.layer; windowSurface->windowSurface->layer = createInfo.layer;
return GN_SUCCESS; return GN_SUCCESS;

View File

@@ -90,7 +90,7 @@ void vk_destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessenger
} }
} }
gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) { gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) {
debugger->debugger = malloc(sizeof(gnPlatformDebugger)); debugger->debugger = malloc(sizeof(gnPlatformDebugger));
if (instance->valid == gnFalse) { if (instance->valid == gnFalse) {

View File

@@ -29,7 +29,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break; case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
} }
gnInstance* instance = (gnInstance*)pUserData; gnInstanceHandle instance = (gnInstanceHandle)pUserData;
if (instance->debugger) { if (instance->debugger) {
instance->debugger->info.callback( instance->debugger->info.callback(
@@ -53,7 +53,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
return VK_FALSE; return VK_FALSE;
} }
gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) { gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
instance->instance = malloc(sizeof(gnPlatformInstance)); instance->instance = malloc(sizeof(gnPlatformInstance));
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
@@ -127,7 +127,7 @@ gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInf
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyInstanceFn(gnInstance* instance) { void gnDestroyInstanceFn(gnInstanceHandle instance) {
instance->valid = gnFalse; instance->valid = gnFalse;
vkDestroyInstance(instance->instance->vk_instance, NULL); vkDestroyInstance(instance->instance->vk_instance, NULL);
} }

View File

@@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) { gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice)); outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount); VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount);

View File

@@ -3,7 +3,7 @@
#include <output_device/vulkan_device_extensions.h> #include <output_device/vulkan_device_extensions.h>
#include <vulkan_surface/vulkan_surface.h> #include <vulkan_surface/vulkan_surface.h>
gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstance* instance, uint32_t* deviceCount) { gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstanceHandle instance, uint32_t* deviceCount) {
vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, NULL); vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, NULL);
if (deviceCount == 0) if (deviceCount == 0)
return NULL; return NULL;

View File

@@ -7,7 +7,7 @@
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
#include <vulkan/vulkan_xlib.h> #include <vulkan/vulkan_xlib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
gnReturnCode gnCreateX11WindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateX11WindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo) {
windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t)); windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t));
VkXlibSurfaceCreateInfoKHR info = {}; VkXlibSurfaceCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
@@ -23,7 +23,7 @@ gnReturnCode gnCreateX11WindowSurfaceFn(struct gnWindowSurface_t* windowSurface,
#ifdef GN_WINFDOW_WAYLAND #ifdef GN_WINFDOW_WAYLAND
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo) {
windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t)); windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t));
VkWaylandSurfaceCreateInfoKHR info = {}; VkWaylandSurfaceCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
@@ -40,7 +40,7 @@ gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurfac
#ifdef GN_PLATFORM_WINDOWS #ifdef GN_PLATFORM_WINDOWS
#include "vulkan/vulkan_win32.h" #include "vulkan/vulkan_win32.h"
gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWin32WindowSurfaceInfo_t createInfo) {
windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t)); windowSurface->windowSurface = malloc(sizeof(struct gnPlatformWindowSurface_t));
VkWin32SurfaceCreateInfoKHR info = {}; VkWin32SurfaceCreateInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;

View File

@@ -11,7 +11,7 @@
#include "vulkan/vulkan_metal.h" #include "vulkan/vulkan_metal.h"
gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface)); windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface));
VkMetalSurfaceCreateInfoEXT surfaceCreateInfo = {}; VkMetalSurfaceCreateInfoEXT surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;

View File

@@ -47,7 +47,7 @@ typedef struct gnDebuggerInfo_t {
typedef struct gnDebugger_t { typedef struct gnDebugger_t {
struct gnPlatformDebugger_t* debugger; struct gnPlatformDebugger_t* debugger;
struct gnDebuggerInfo_t info; struct gnDebuggerInfo_t info;
gnInstance* instance; gnInstanceHandle instance;
} gnDebugger; } gnDebugger;
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info); gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);

View File

@@ -20,37 +20,37 @@
#include "core/present/gryphn_present.h" #include "core/present/gryphn_present.h"
typedef struct gnFunctions_t { typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info); gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, struct gnInstanceInfo_t info);
void (*_gnDestroyInstance)(gnInstance* instance); void (*_gnDestroyInstance)(gnInstanceHandle instance);
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info); gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info);
void (*_gnDestroyDebugger)(gnDebugger* debugger); void (*_gnDestroyDebugger)(gnDebugger* debugger);
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstance* instance, uint32_t* count); gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface); gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDevice* device, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo); gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDevice* device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
void (*_gnDestroyOutputDevice)(gnOutputDevice* device); void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
gnReturnCode (*_gnCreateX11WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateX11WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo);
#endif #endif
#ifdef GN_WINDOW_WAYLAND #ifdef GN_WINDOW_WAYLAND
gnReturnCode (*_gnCreateWaylandWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateWaylandWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo);
#endif #endif
#endif #endif
#ifdef GN_PLATFORM_WIN32 #ifdef GN_PLATFORM_WIN32
gnReturnCode (*_gnCreateWin32WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateWin32WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWin32WindowSurfaceInfo_t createInfo);
#endif #endif
#ifdef GN_PLATFORM_MACOS #ifdef GN_PLATFORM_MACOS
gnReturnCode (*_gnCreateMacOSWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateMacOSWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo);
#endif #endif
void (*_gnDestroyWindowSurface)(struct gnWindowSurface_t* windowSurface); void (*_gnDestroyWindowSurface)(struct gnWindowSurface_t* windowSurface);

View File

@@ -3,7 +3,10 @@
#include <core/gryphn_platform_functions.h> #include <core/gryphn_platform_functions.h>
#include "core/debugger/gryphn_debugger.h" #include "core/debugger/gryphn_debugger.h"
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) { gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) {
*instanceHandlePtr = malloc(sizeof(struct gnInstance_t));
gnInstanceHandle instance = *instanceHandlePtr;
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API; if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
instance->loadDeviceFunctions = gnFalse; instance->loadDeviceFunctions = gnFalse;
instance->debugger = NULL; instance->debugger = NULL;
@@ -13,8 +16,7 @@ gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info
gnLoadFunctions(instance->dynamicLib, instance->functions); gnLoadFunctions(instance->dynamicLib, instance->functions);
return instance->functions->_gnCreateInstance(instance, info); return instance->functions->_gnCreateInstance(instance, info);
} }
void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) {
void gnInstanceAttachDebugger(gnInstance *instance, struct gnDebugger_t *debugger) {
if (instance->debugger != NULL) { if (instance->debugger != NULL) {
gnDebuggerSetErrorMessage(debugger, (gnMessageData){ gnDebuggerSetErrorMessage(debugger, (gnMessageData){
.message = gnCreateString("Debugger already attached to instance") .message = gnCreateString("Debugger already attached to instance")
@@ -31,13 +33,13 @@ void gnInstanceAttachDebugger(gnInstance *instance, struct gnDebugger_t *debugge
} }
#include "stdio.h" #include "stdio.h"
void gnDestroyInstance(gnInstance* instance) { void gnDestroyInstance(gnInstanceHandle instance) {
if (instance->debugger) { if (instance->debugger) {
instance->functions->_gnDestroyDebugger(instance->debugger); instance->functions->_gnDestroyDebugger(instance->debugger);
} }
instance->functions->_gnDestroyInstance(instance); instance->functions->_gnDestroyInstance(instance);
} }
void gnInstanceReleaseDebugger(gnInstance* instance) { void gnInstanceReleaseDebugger(gnInstanceHandle instance) {
instance->debugger = NULL; instance->debugger = NULL;
} }

View File

@@ -17,7 +17,7 @@ typedef struct gnInstanceInfo_t {
gnRenderingAPI renderingAPI; gnRenderingAPI renderingAPI;
} gnInstanceInfo; } gnInstanceInfo;
typedef struct gnInstance_t { struct gnInstance_t {
struct gnPlatformInstance_t* instance; struct gnPlatformInstance_t* instance;
gnBool valid, gnBool valid,
loadDeviceFunctions, loadDeviceFunctions,
@@ -30,9 +30,11 @@ typedef struct gnInstance_t {
struct gnCommandFunctions_t* commandFunctions; struct gnCommandFunctions_t* commandFunctions;
struct gnDebugger_t* debugger; struct gnDebugger_t* debugger;
} gnInstance; } gnInstance_t;
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info); typedef struct gnInstance_t* gnInstanceHandle;
void gnInstanceAttachDebugger(gnInstance* istance, struct gnDebugger_t* debugger);
void gnInstanceReleaseDebugger(gnInstance* instance); gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info);
void gnDestroyInstance(gnInstance* instance); void gnInstanceAttachDebugger(gnInstanceHandle istance, struct gnDebugger_t* debugger);
void gnInstanceReleaseDebugger(gnInstanceHandle instance);
void gnDestroyInstance(gnInstanceHandle instance);

View File

@@ -3,7 +3,7 @@
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
#include "core/instance/init/gryphn_init.h" #include "core/instance/init/gryphn_init.h"
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) { gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
if (instance->loadDeviceFunctions == gnFalse) { if (instance->loadDeviceFunctions == gnFalse) {
instance->deviceFunctions = malloc(sizeof(struct gnDeviceFunctions_t)); instance->deviceFunctions = malloc(sizeof(struct gnDeviceFunctions_t));
gnLoadDeviceFunctions(instance->dynamicLib, instance->deviceFunctions); gnLoadDeviceFunctions(instance->dynamicLib, instance->deviceFunctions);

View File

@@ -21,10 +21,10 @@ typedef struct gnOutputDevice_t {
struct gnPlatformOutputDevice_t* outputDevice; struct gnPlatformOutputDevice_t* outputDevice;
struct gnDeviceFunctions_t* deviceFunctions; struct gnDeviceFunctions_t* deviceFunctions;
struct gnOutputDeviceInfo_t deviceInfo; struct gnOutputDeviceInfo_t deviceInfo;
gnInstance* instance; gnInstanceHandle instance;
gnPhysicalDevice physicalDevice; gnPhysicalDevice physicalDevice;
} gnOutputDevice; } gnOutputDevice;
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo); gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
void gnWaitForDevice(gnOutputDevice* device); void gnWaitForDevice(gnOutputDevice* device);
void gnDestroyOutputDevice(gnOutputDevice* device); void gnDestroyOutputDevice(gnOutputDevice* device);

View File

@@ -3,7 +3,7 @@
#include "core/window_surface/gryphn_surface.h" #include "core/window_surface/gryphn_surface.h"
#include "stdio.h" #include "stdio.h"
gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count) { gnPhysicalDevice* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count) {
gnPhysicalDevice* devices = instance->functions->_gnGetPhysicalDevices(instance, count); gnPhysicalDevice* devices = instance->functions->_gnGetPhysicalDevices(instance, count);
for (int i = 0; i < *count; i++) { for (int i = 0; i < *count; i++) {
devices[i].instance = instance; devices[i].instance = instance;

View File

@@ -40,10 +40,10 @@ typedef struct gnPhysicalDevice_t {
struct gnPhysicalDeviceFeatures_t features; struct gnPhysicalDeviceFeatures_t features;
struct gnPhysicalDeviceQueueProperties_t queueProperties; struct gnPhysicalDeviceQueueProperties_t queueProperties;
gnInstance* instance; gnInstanceHandle instance;
} gnPhysicalDevice; } gnPhysicalDevice;
gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count); gnPhysicalDevice* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count);
gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface); gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);
gnBool gnHasGraphicsQueue(const struct gnPhysicalDevice_t device); gnBool gnHasGraphicsQueue(const struct gnPhysicalDevice_t device);

View File

@@ -20,7 +20,7 @@ typedef struct gnSurfaceDetails_t {
typedef struct gnWindowSurface_t { typedef struct gnWindowSurface_t {
struct gnPlatformWindowSurface_t* windowSurface; struct gnPlatformWindowSurface_t* windowSurface;
gnInstance* instance; gnInstanceHandle instance;
} gnWindowSurface; } gnWindowSurface;
void gnDestroyWindowSurface(struct gnWindowSurface_t* windowSurface); void gnDestroyWindowSurface(struct gnWindowSurface_t* windowSurface);
struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats( struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats(

View File

@@ -4,12 +4,12 @@
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo) {
return instance->functions->_gnCreateX11WindowSurface(windowSurface, instance, createInfo); return instance->functions->_gnCreateX11WindowSurface(windowSurface, instance, createInfo);
} }
#endif #endif
#ifdef GN_WINDOW_WAYLAND #ifdef GN_WINDOW_WAYLAND
gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo) {
return instance->functions->_gnCreateWaylandWindowSurface(windowSurface, instance, createInfo); return instance->functions->_gnCreateWaylandWindowSurface(windowSurface, instance, createInfo);
} }
#endif #endif
@@ -17,13 +17,13 @@
#ifdef GN_PLATFORM_WIN32 #ifdef GN_PLATFORM_WIN32
gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWin32WindowSurfaceInfo_t createInfo) {
return instance->functions->_gnCreateWin32WindowSurface(windowSurface, instance, createInfo); return instance->functions->_gnCreateWin32WindowSurface(windowSurface, instance, createInfo);
} }
#endif #endif
#ifdef GN_PLATFORM_MACOS #ifdef GN_PLATFORM_MACOS
gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
windowSurface->instance = instance; windowSurface->instance = instance;
return instance->functions->_gnCreateMacOSWindowSurface(windowSurface, instance, createInfo); return instance->functions->_gnCreateMacOSWindowSurface(windowSurface, instance, createInfo);
} }

View File

@@ -8,7 +8,7 @@
Window* window; Window* window;
} gnX11WindowSurfaceCreateInfo; } gnX11WindowSurfaceCreateInfo;
gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo); gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo);
#endif #endif
#ifdef GN_WINDOW_WAYLAND #ifdef GN_WINDOW_WAYLAND
typedef struct gnWaylandWindowSurfaceInfo_t { typedef struct gnWaylandWindowSurfaceInfo_t {
@@ -16,7 +16,7 @@
wl_surface* surface; wl_surface* surface;
} gnWaylandWindowSurfaceInfo; } gnWaylandWindowSurfaceInfo;
gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo); gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo);
#endif #endif
#endif #endif
@@ -27,7 +27,7 @@
HINSTANCE* instance; HINSTANCE* instance;
} gnWin32WindowSurfaceInfo; } gnWin32WindowSurfaceInfo;
gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo); gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnWin32WindowSurfaceInfo_t createInfo);
#endif #endif
#ifdef GN_PLATFORM_MACOS #ifdef GN_PLATFORM_MACOS
@@ -35,5 +35,5 @@
CAMetalLayer* layer; CAMetalLayer* layer;
} gnMacOSWindowSurfaceInfo; } gnMacOSWindowSurfaceInfo;
gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo); gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo);
#endif #endif