load vulkan backend (if compiled always say is avaliable)
This commit is contained in:
@@ -13,3 +13,6 @@ add_subdirectory(GryphnLoader)
|
||||
if (APPLE)
|
||||
add_subdirectory(apis/GryphnMetal)
|
||||
endif()
|
||||
if (UNIX)
|
||||
add_subdirectory(apis/GryphnVulkan)
|
||||
endif()
|
||||
|
||||
@@ -16,6 +16,9 @@ target_include_directories(GryphnLoader PUBLIC
|
||||
if(APPLE)
|
||||
target_compile_definitions(GryphnLoader PUBLIC GN_PLATFORM_MACOS)
|
||||
endif()
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_compile_definitions(GryphnLoader PUBLIC GN_PLATFORM_LINUX)
|
||||
endif()
|
||||
|
||||
# 4. Links
|
||||
if(UNIX AND NOT APPLE)
|
||||
|
||||
@@ -6,18 +6,32 @@
|
||||
|
||||
typedef uint32_t (*PFN_gnInternalIsApiSupported)(gnVersion);
|
||||
|
||||
gnReturnCode gnGetAvaliableBackends(gnVersion version, uint32_t* avaliable_backends, gnBackend* backends) {
|
||||
*avaliable_backends = 0;
|
||||
gnLib metalLib = gnLoadLib("bin/gryphn_metal.dylib");
|
||||
int gryphn_CheckLib(gnVersion version, const char* name) {
|
||||
gnLib metalLib = gnLoadLib(name);
|
||||
printf("Loading library: %s\n", name);
|
||||
if (gnLibValid(&metalLib)) {
|
||||
PFN_gnInternalIsApiSupported isSupported = (PFN_gnInternalIsApiSupported)gnLoadLibFunction(&metalLib, "gnInternalIsApiSupported");
|
||||
if (isSupported(version) > 0) {
|
||||
if (backends != NULL) {
|
||||
backends[*avaliable_backends] = GN_BACKEND_METAL;
|
||||
}
|
||||
*avaliable_backends += 1;
|
||||
return 1;
|
||||
}
|
||||
gnCloseLib(&metalLib);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
gnReturnCode gnGetAvaliableBackends(gnVersion version, uint32_t* avaliable_backends, gnBackend* backends) {
|
||||
*avaliable_backends = 0;
|
||||
int metalSupported = gryphn_CheckLib(version, "bin/gryphn_metal.dylib");
|
||||
int vulkanSupported = gryphn_CheckLib(version, "bin/gryphn_vulkan.so");
|
||||
if (metalSupported) {
|
||||
if (backends != NULL)
|
||||
backends[*avaliable_backends] = GN_BACKEND_METAL;
|
||||
*avaliable_backends += 1;
|
||||
}
|
||||
if (vulkanSupported) {
|
||||
if (backends != NULL)
|
||||
backends[*avaliable_backends] = GN_BACKEND_VULKAN;
|
||||
*avaliable_backends += 1;
|
||||
}
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "stdio.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
#include "gryphn_handle.h"
|
||||
|
||||
|
||||
uint32_t gnInternalIsApiSupported(gnVersion version) {
|
||||
if (version != gnCreateVersion(1, 0, 0)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// gnReturnCode destroyBackend(gnInstance instance) {
|
||||
// return GN_SUCCESS;
|
||||
// }
|
||||
|
||||
// gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) {
|
||||
// instance->dispatchTable.destroyInstance = destroyBackend;
|
||||
// instance->dispatchTable.enumeratePhysicalDevices = metalEnumeratePhysicalDevices;
|
||||
// instance->dispatchTable.getPhysicalDeviceProperties = metalGetPhysicalDeviceProperties;
|
||||
// instance->dispatchTable.createDevice = metalCreateDevice;
|
||||
|
||||
// for (int i = 0; i < info->enabledExtensionCount; i++) {
|
||||
// if (strcmp(info->enabledExtensions[i], "GN_EXT_surface") == 0) {
|
||||
// instance->dispatchTable.destroySurface = metalDestroySurface;
|
||||
// instance->dispatchTable.getSurfaceCapabilities = metalGetSurfaceCapabilities;
|
||||
// instance->dispatchTable.getSurfaceFormats = metalGetSurfaceFormats;
|
||||
// instance->dispatchTable.getSurfacePresentModes = metalGetSurfacePresentModes;
|
||||
// }
|
||||
// if (strcmp(info->enabledExtensions[i], "GN_EXT_surface_cocoa") == 0) {
|
||||
// instance->dispatchTable.createMetalSurface = metalCreateSurface;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return GN_SUCCESS;
|
||||
// }
|
||||
Reference in New Issue
Block a user