Turn instance into a handle
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#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
|
||||
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;
|
||||
}
|
||||
void gnDestroyDebuggerFn(gnDebugger* instance) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "core/instance/gryphn_instance.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->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
|
||||
outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include "metal_output_devices.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();
|
||||
*deviceCount = [devices count];
|
||||
gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
||||
|
@@ -4,11 +4,11 @@
|
||||
// #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));
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
void gnDestroyInstanceFn(gnInstance* instance) {
|
||||
void gnDestroyInstanceFn(gnInstanceHandle instance) {
|
||||
free(instance->instance);
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#import <Metal/Metal.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->layer = createInfo.layer;
|
||||
return GN_SUCCESS;
|
||||
|
@@ -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));
|
||||
|
||||
if (instance->valid == gnFalse) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
gnInstance* instance = (gnInstance*)pUserData;
|
||||
gnInstanceHandle instance = (gnInstanceHandle)pUserData;
|
||||
|
||||
if (instance->debugger) {
|
||||
instance->debugger->info.callback(
|
||||
@@ -53,7 +53,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) {
|
||||
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
|
||||
instance->instance = malloc(sizeof(gnPlatformInstance));
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
@@ -127,7 +127,7 @@ gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInf
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
void gnDestroyInstanceFn(gnInstance* instance) {
|
||||
void gnDestroyInstanceFn(gnInstanceHandle instance) {
|
||||
instance->valid = gnFalse;
|
||||
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
#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));
|
||||
|
||||
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <output_device/vulkan_device_extensions.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);
|
||||
if (deviceCount == 0)
|
||||
return NULL;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#ifdef GN_WINDOW_X11
|
||||
#include <vulkan/vulkan_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));
|
||||
VkXlibSurfaceCreateInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||
@@ -23,7 +23,7 @@ gnReturnCode gnCreateX11WindowSurfaceFn(struct gnWindowSurface_t* windowSurface,
|
||||
|
||||
#ifdef GN_WINFDOW_WAYLAND
|
||||
#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));
|
||||
VkWaylandSurfaceCreateInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||
@@ -40,7 +40,7 @@ gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurfac
|
||||
|
||||
#ifdef GN_PLATFORM_WINDOWS
|
||||
#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));
|
||||
VkWin32SurfaceCreateInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
#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));
|
||||
VkMetalSurfaceCreateInfoEXT surfaceCreateInfo = {};
|
||||
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||
|
Reference in New Issue
Block a user