load vulkan backend (if compiled always say is avaliable)
This commit is contained in:
@@ -13,3 +13,6 @@ add_subdirectory(GryphnLoader)
|
|||||||
if (APPLE)
|
if (APPLE)
|
||||||
add_subdirectory(apis/GryphnMetal)
|
add_subdirectory(apis/GryphnMetal)
|
||||||
endif()
|
endif()
|
||||||
|
if (UNIX)
|
||||||
|
add_subdirectory(apis/GryphnVulkan)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ target_include_directories(GryphnLoader PUBLIC
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_compile_definitions(GryphnLoader PUBLIC GN_PLATFORM_MACOS)
|
target_compile_definitions(GryphnLoader PUBLIC GN_PLATFORM_MACOS)
|
||||||
endif()
|
endif()
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
target_compile_definitions(GryphnLoader PUBLIC GN_PLATFORM_LINUX)
|
||||||
|
endif()
|
||||||
|
|
||||||
# 4. Links
|
# 4. Links
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
|
|||||||
@@ -6,18 +6,32 @@
|
|||||||
|
|
||||||
typedef uint32_t (*PFN_gnInternalIsApiSupported)(gnVersion);
|
typedef uint32_t (*PFN_gnInternalIsApiSupported)(gnVersion);
|
||||||
|
|
||||||
gnReturnCode gnGetAvaliableBackends(gnVersion version, uint32_t* avaliable_backends, gnBackend* backends) {
|
int gryphn_CheckLib(gnVersion version, const char* name) {
|
||||||
*avaliable_backends = 0;
|
gnLib metalLib = gnLoadLib(name);
|
||||||
gnLib metalLib = gnLoadLib("bin/gryphn_metal.dylib");
|
printf("Loading library: %s\n", name);
|
||||||
if (gnLibValid(&metalLib)) {
|
if (gnLibValid(&metalLib)) {
|
||||||
PFN_gnInternalIsApiSupported isSupported = (PFN_gnInternalIsApiSupported)gnLoadLibFunction(&metalLib, "gnInternalIsApiSupported");
|
PFN_gnInternalIsApiSupported isSupported = (PFN_gnInternalIsApiSupported)gnLoadLibFunction(&metalLib, "gnInternalIsApiSupported");
|
||||||
if (isSupported(version) > 0) {
|
if (isSupported(version) > 0) {
|
||||||
if (backends != NULL) {
|
return 1;
|
||||||
backends[*avaliable_backends] = GN_BACKEND_METAL;
|
|
||||||
}
|
|
||||||
*avaliable_backends += 1;
|
|
||||||
}
|
}
|
||||||
gnCloseLib(&metalLib);
|
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;
|
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;
|
||||||
|
// }
|
||||||
@@ -115,9 +115,9 @@ int main() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
createInstance();
|
createInstance();
|
||||||
createDevice();
|
// createDevice();
|
||||||
createSurface();
|
// createSurface();
|
||||||
createSwapchain();
|
// createSwapchain();
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user