instance suitability functions
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = vulkanCreateInstance,
|
.createInstance = vulkanCreateInstance,
|
||||||
|
.isSuitable = vulkanIsInstanceSuitable,
|
||||||
.destroyInstance = vulkanDestroyInstance,
|
.destroyInstance = vulkanDestroyInstance,
|
||||||
.queryDevices = vulkanQueryDevices,
|
.queryDevices = vulkanQueryDevices,
|
||||||
.next = NULL
|
.next = NULL
|
||||||
|
@@ -113,36 +113,13 @@ gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInf
|
|||||||
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
||||||
return VkResultToGnReturnCode(vkEnumeratePhysicalDevices(handle->instance->vk_instance, count, NULL));
|
return VkResultToGnReturnCode(vkEnumeratePhysicalDevices(handle->instance->vk_instance, count, NULL));
|
||||||
}
|
}
|
||||||
// for (uint32_t i = 0; i < *count; i++) {
|
|
||||||
// outputDevices[i] = (uint64_t)malloc(sizeof(vulkanPhysicalDevice));
|
|
||||||
// vulkanPhysicalDevice* device = (vulkanPhysicalDevice*)outputDevices[i];
|
|
||||||
// device->device = physicalDevices[i];
|
|
||||||
|
|
||||||
// VkPhysicalDeviceProperties deviceProperties;
|
gnBool vulkanIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next) {
|
||||||
// vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
|
switch (field) {
|
||||||
// device->properties.name = gnCreateString(deviceProperties.deviceName);
|
case GN_NON_EXISTANT_PHYSICAL_DEVICE: return GN_FALSE;
|
||||||
// switch(deviceProperties.deviceType) {
|
}
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_OTHER: device->properties.deviceType = GN_EXTERNAL_DEVICE;
|
return GN_FALSE;
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: device->properties.deviceType = GN_INTEGRATED_DEVICE;
|
}
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: device->properties.deviceType = GN_DEDICATED_DEVICE;
|
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: device->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_CPU: device->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
// case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: device->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (handle->enabledExtensions[GN_EXT_QUEUES] == GN_FALSE)
|
|
||||||
// vulkanLoadNeededQueues(outputDevices[i]);
|
|
||||||
|
|
||||||
|
|
||||||
// VkPhysicalDeviceProperties physicalDeviceProperties;
|
|
||||||
// vkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties);
|
|
||||||
// device->features.maxColorSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferColorSampleCounts);
|
|
||||||
// device->features.maxDepthSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferDepthSampleCounts);
|
|
||||||
// device->features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount;
|
|
||||||
// device->features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize;
|
|
||||||
// }
|
|
||||||
// free(physicalDevices);
|
|
||||||
// return outputDevices;
|
|
||||||
|
|
||||||
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors) {
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors) {
|
||||||
if (next != NULL) { return; }
|
if (next != NULL) { return; }
|
||||||
|
@@ -17,6 +17,7 @@ typedef struct gnPlatformInstance_t {
|
|||||||
} gnPlatformInstance;
|
} gnPlatformInstance;
|
||||||
|
|
||||||
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
gnBool vulkanIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next);
|
||||||
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
||||||
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
|
||||||
|
@@ -84,8 +84,12 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
|||||||
return (*instance)->functions->createInstance(*instance, info, (*instance)->functions->next, &(*instance)->allocators);
|
return (*instance)->functions->createInstance(*instance, info, (*instance)->functions->next, &(*instance)->allocators);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gnBool gnIsInstanceSuitable(gnInstance instance, gnSuitableField field) {
|
||||||
|
return instance->functions->isSuitable(instance, field, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices) {
|
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices) {
|
||||||
return instance->functions->queryDevices(instance, count, devices);
|
return instance->functions->queryDevices(instance, count, devices, instance->functions->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyInstance(gnInstanceHandle* instance) {
|
void gnDestroyInstance(gnInstanceHandle* instance) {
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include "gryphn_allocators.h"
|
#include "gryphn_allocators.h"
|
||||||
#include <gryphn_extensions.h>
|
#include <gryphn_extensions.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct gnApplicationInfo {
|
typedef struct gnApplicationInfo {
|
||||||
gnString applicationName;
|
gnString applicationName;
|
||||||
gnVersion applicationVersion;
|
gnVersion applicationVersion;
|
||||||
@@ -16,6 +15,10 @@ typedef struct gnApplicationInfo {
|
|||||||
gnVersion engineVersion;
|
gnVersion engineVersion;
|
||||||
} gnApplicationInfo;
|
} gnApplicationInfo;
|
||||||
|
|
||||||
|
typedef enum gnSuitableField {
|
||||||
|
GN_NON_EXISTANT_PHYSICAL_DEVICE
|
||||||
|
} gnSuitableField;
|
||||||
|
|
||||||
typedef struct gnInstanceCreateInfo {
|
typedef struct gnInstanceCreateInfo {
|
||||||
gnApplicationInfo applicationInfo;
|
gnApplicationInfo applicationInfo;
|
||||||
gnDebuggerCreateInfo debuggerInfo;
|
gnDebuggerCreateInfo debuggerInfo;
|
||||||
@@ -45,5 +48,6 @@ struct gnInstance_t {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
||||||
|
gnBool gnIsInstanceSuitable(gnInstance instance, gnSuitableField field);
|
||||||
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices);
|
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices);
|
||||||
void gnDestroyInstance(gnInstanceHandle* instance);
|
void gnDestroyInstance(gnInstanceHandle* instance);
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
typedef struct gnInstanceCreateInfo gnInstanceCreateInfo;
|
typedef struct gnInstanceCreateInfo gnInstanceCreateInfo;
|
||||||
typedef struct gnSurfaceDetails gnSurfaceDetails;
|
typedef struct gnSurfaceDetails gnSurfaceDetails;
|
||||||
typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
||||||
|
typedef enum gnSuitableField gnSuitableField;
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
#ifdef GN_WINDOW_X11
|
#ifdef GN_WINDOW_X11
|
||||||
@@ -21,6 +21,7 @@ typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
|||||||
|
|
||||||
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
||||||
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle, gnInstanceCreateInfo*, gryphnInstanceFunctionLayers*, gnAllocators*);
|
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle, gnInstanceCreateInfo*, gryphnInstanceFunctionLayers*, gnAllocators*);
|
||||||
|
typedef gnBool (*PFN_gnIsInstanceSuitable)(gnInstanceHandle, gnSuitableField, gryphnInstanceFunctionLayers*);
|
||||||
typedef gnReturnCode (*PFN_gnInstanceQueryDevices)(gnInstanceHandle, uint32_t*, gnPhysicalDeviceHandle*, gryphnInstanceFunctionLayers*);
|
typedef gnReturnCode (*PFN_gnInstanceQueryDevices)(gnInstanceHandle, uint32_t*, gnPhysicalDeviceHandle*, gryphnInstanceFunctionLayers*);
|
||||||
typedef void (*PFN_gnDestroyInstance)(gnInstanceHandle, gryphnInstanceFunctionLayers*, gnAllocators*);
|
typedef void (*PFN_gnDestroyInstance)(gnInstanceHandle, gryphnInstanceFunctionLayers*, gnAllocators*);
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ typedef struct gryphnFunctionLayer {
|
|||||||
|
|
||||||
typedef struct gryphnInstanceFunctionLayers {
|
typedef struct gryphnInstanceFunctionLayers {
|
||||||
PFN_gnCreateInstance createInstance;
|
PFN_gnCreateInstance createInstance;
|
||||||
|
PFN_gnIsInstanceSuitable isSuitable;
|
||||||
PFN_gnInstanceQueryDevices queryDevices;
|
PFN_gnInstanceQueryDevices queryDevices;
|
||||||
PFN_gnDestroyInstance destroyInstance;
|
PFN_gnDestroyInstance destroyInstance;
|
||||||
struct gryphnInstanceFunctionLayers* next;
|
struct gryphnInstanceFunctionLayers* next;
|
||||||
|
@@ -8,13 +8,15 @@
|
|||||||
gryphnInstanceFunctionLayers checkerLoadInstanceFunctions(void) {
|
gryphnInstanceFunctionLayers checkerLoadInstanceFunctions(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = checkCreateInstance,
|
.createInstance = checkCreateInstance,
|
||||||
.destroyInstance = checkDestroyInstance
|
.isSuitable = checkIsInstanceSuitable,
|
||||||
|
.queryDevices = checkQueryDevices,
|
||||||
|
.destroyInstance = checkDestroyInstance,
|
||||||
|
.next = GN_NULL_HANDLE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadFunctionLoaderInstanceFunctions(void) {
|
gnInstanceFunctions loadFunctionLoaderInstanceFunctions(void) {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
._gnGetPhysicalDevices = checkGetPhysicalDevices,
|
|
||||||
._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent,
|
._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent,
|
||||||
|
|
||||||
._gnCreateOutputDevice = checkCreateOutputDevice,
|
._gnCreateOutputDevice = checkCreateOutputDevice,
|
||||||
|
@@ -24,6 +24,16 @@ void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayer
|
|||||||
next->destroyInstance(instance, next->next, alloctors);
|
next->destroyInstance(instance, next->next, alloctors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gnBool checkIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (next == NULL || next->isSuitable == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnCreateInstance this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return GN_FAILED_TO_LOAD_FUNCTION;
|
||||||
|
}
|
||||||
|
return next->isSuitable(instance, field, next);
|
||||||
|
}
|
||||||
|
|
||||||
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
||||||
if (next == NULL || next->queryDevices == NULL) {
|
if (next == NULL || next->queryDevices == NULL) {
|
||||||
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
||||||
|
|
||||||
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
gnBool checkIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next);
|
||||||
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
||||||
void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user