redo some instance funcions stuff

This commit is contained in:
Gregory Wells
2025-08-03 09:28:49 -04:00
parent 797191c2b6
commit 77b52b5d2d
8 changed files with 20 additions and 18 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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);
}

View File

@@ -2,6 +2,7 @@
#include <vulkan/vulkan.h>
#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);

View File

@@ -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);

View File

@@ -29,7 +29,6 @@ struct gnInstance_t {
struct gnPlatformInstance_t* instance;
gnDebuggerCreateInfo debugger;
gnBool enabledExtensions[GN_EXT_MAX];
dispatcher dispatch;
loaderLayerArrayList layers;
loaderLayer* callingLayer;

View File

@@ -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