start to redo validation
This commit is contained in:
@@ -18,3 +18,5 @@ Ability to create applications that can leverage Buffers and Textures to render
|
|||||||
# Plans
|
# Plans
|
||||||
Improved Validation <br />
|
Improved Validation <br />
|
||||||
Currently validation is always run and it discards the messages if you dont have a debugger attached, I plan to support layers like vulkan that can validation certain parts of the API
|
Currently validation is always run and it discards the messages if you dont have a debugger attached, I plan to support layers like vulkan that can validation certain parts of the API
|
||||||
|
Device Features <br />
|
||||||
|
Physical Devices dont report features that they support at all so the developer can't chose them based on features
|
||||||
|
@@ -1,161 +1,158 @@
|
|||||||
#include "vulkan_debugger.h"
|
#include "vulkan_debugger.h"
|
||||||
#include <instance/vulkan_instance.h>
|
#include <instance/vulkan_instance.h>
|
||||||
#include "core/instance/gryphn_instance.h"
|
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo) {
|
void vkPopulateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo) {
|
||||||
createInfo->sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
createInfo->sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
||||||
createInfo->messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
createInfo->messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||||
createInfo->messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
createInfo->messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gnBool vkCheckValidationLayerSupport(uint32_t count, const char** layers) {
|
||||||
|
// uint32_t layerCount;
|
||||||
|
// vkEnumerateInstanceLayerProperties(&layerCount, NULL);
|
||||||
|
// if (layerCount == 0) return gnFalse;
|
||||||
|
|
||||||
gnBool checkValidationLayerSupport(uint32_t count, const char** layers) {
|
// VkLayerProperties* properties = malloc(sizeof(VkLayerProperties) * layerCount);
|
||||||
uint32_t layerCount;
|
// vkEnumerateInstanceLayerProperties(&layerCount, properties);
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, NULL);
|
|
||||||
if (layerCount == 0) return gnFalse;
|
|
||||||
|
|
||||||
VkLayerProperties* properties = malloc(sizeof(VkLayerProperties) * layerCount);
|
// for (int i = 0; i < count; i++) {
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, properties);
|
// gnBool layerFound = gnFalse;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
// for (int c = 0; c < layerCount; c++) {
|
||||||
gnBool layerFound = gnFalse;
|
// if (strcmp(layers[i], properties[c].layerName) == 0) {
|
||||||
|
// layerFound = gnTrue;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (int c = 0; c < layerCount; c++) {
|
// if (layerFound == gnFalse)
|
||||||
if (strcmp(layers[i], properties[c].layerName) == 0) {
|
// return gnFalse;
|
||||||
layerFound = gnTrue;
|
// }
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layerFound == gnFalse)
|
// return gnTrue;
|
||||||
return gnFalse;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
return gnTrue;
|
// typedef struct vk_userData_t {
|
||||||
}
|
// gnDebuggerCallback debuggerCallback;
|
||||||
|
// void* userData;
|
||||||
|
// } vkUserData;
|
||||||
|
|
||||||
typedef struct vk_userData_t {
|
// static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
||||||
gnDebuggerCallback debuggerCallback;
|
// VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
void* userData;
|
// VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||||
} vkUserData;
|
// const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||||
|
// void* pUserData) {
|
||||||
|
// struct vk_userData_t userData = *(struct vk_userData_t*)pUserData;
|
||||||
|
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
// gnMessageSeverity severity;
|
||||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
// gnMessageType type;
|
||||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
// gnMessageData data = {
|
||||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
// .message = gnCreateString(pCallbackData->pMessage)
|
||||||
void* pUserData) {
|
// };
|
||||||
struct vk_userData_t userData = *(struct vk_userData_t*)pUserData;
|
|
||||||
|
|
||||||
gnMessageSeverity severity;
|
// switch (messageSeverity) {
|
||||||
gnMessageType type;
|
// default: break;
|
||||||
gnMessageData data = {
|
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||||
.message = gnCreateString(pCallbackData->pMessage)
|
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break;
|
||||||
};
|
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break;
|
||||||
|
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
|
||||||
|
// }
|
||||||
|
|
||||||
switch (messageSeverity) {
|
// switch (messageType) {
|
||||||
default: break;
|
// default: break;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
// case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break;
|
// case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break;
|
// case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
switch (messageType) {
|
// gnDebuggerCallback callback = *userData.debuggerCallback;
|
||||||
default: break;
|
// gnBool result = callback(severity, type, data, userData.userData);
|
||||||
case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break;
|
// if (result == gnFalse) return VK_FALSE;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break;
|
// return VK_TRUE;
|
||||||
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
gnDebuggerCallback callback = *userData.debuggerCallback;
|
// VkResult vk_createDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
||||||
gnBool result = callback(severity, type, data, userData.userData);
|
// PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
||||||
if (result == gnFalse) return VK_FALSE;
|
// if (vkCreateDebugUtilsMessengerEXT != NULL) {
|
||||||
return VK_TRUE;
|
// return vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, NULL, pDebugMessenger);
|
||||||
}
|
// }else
|
||||||
|
// return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
|
// return VK_SUCCESS;
|
||||||
|
// }
|
||||||
|
|
||||||
VkResult vk_createDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
// void vk_destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
|
||||||
PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
// PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||||
if (vkCreateDebugUtilsMessengerEXT != NULL) {
|
// if (vkDestroyDebugUtilsMessengerEXT != NULL) {
|
||||||
return vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, NULL, pDebugMessenger);
|
// vkDestroyDebugUtilsMessengerEXT(instance, debugMessenger, pAllocator);
|
||||||
}else
|
// }
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
// }
|
||||||
return VK_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vk_destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
|
// gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) {
|
||||||
PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
// debugger->debugger = malloc(sizeof(gnPlatformDebugger));
|
||||||
if (vkDestroyDebugUtilsMessengerEXT != NULL) {
|
|
||||||
vkDestroyDebugUtilsMessengerEXT(instance, debugMessenger, pAllocator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) {
|
// if (instance->valid == gnFalse) {
|
||||||
debugger->debugger = malloc(sizeof(gnPlatformDebugger));
|
// for (int i = 0; i < instance->instance->instanceMessageCount; i++) {
|
||||||
|
// info.callback(
|
||||||
|
// instance->instance->instanceMessages[i].severity,
|
||||||
|
// instance->instance->instanceMessages[i].type,
|
||||||
|
// instance->instance->instanceMessages[i].data,
|
||||||
|
// info.userData
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// return GN_INVALID_INSTANCE;
|
||||||
|
// } else {
|
||||||
|
// for (int i = 0; i < instance->instance->instanceMessageCount; i++) {
|
||||||
|
// info.callback(
|
||||||
|
// instance->instance->instanceMessages[i].severity,
|
||||||
|
// instance->instance->instanceMessages[i].type,
|
||||||
|
// instance->instance->instanceMessages[i].data,
|
||||||
|
// info.userData
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (instance->valid == gnFalse) {
|
// if (instance->instance->instanceMessageCount > 0) free(instance->instance->instanceMessages);
|
||||||
for (int i = 0; i < instance->instance->instanceMessageCount; i++) {
|
// instance->instance->instanceMessageCount = 0;
|
||||||
info.callback(
|
|
||||||
instance->instance->instanceMessages[i].severity,
|
|
||||||
instance->instance->instanceMessages[i].type,
|
|
||||||
instance->instance->instanceMessages[i].data,
|
|
||||||
info.userData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return GN_INVALID_INSTANCE;
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < instance->instance->instanceMessageCount; i++) {
|
|
||||||
info.callback(
|
|
||||||
instance->instance->instanceMessages[i].severity,
|
|
||||||
instance->instance->instanceMessages[i].type,
|
|
||||||
instance->instance->instanceMessages[i].data,
|
|
||||||
info.userData
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instance->instance->instanceMessageCount > 0) free(instance->instance->instanceMessages);
|
// const char* layers[] = {
|
||||||
instance->instance->instanceMessageCount = 0;
|
// "VK_LAYER_KHRONOS_validation"
|
||||||
|
// };
|
||||||
const char* layers[] = {
|
// if (!checkValidationLayerSupport(1, layers))
|
||||||
"VK_LAYER_KHRONOS_validation"
|
// return GN_FAILED_TO_CREATE_DEBUGGER;
|
||||||
};
|
|
||||||
if (!checkValidationLayerSupport(1, layers))
|
|
||||||
return GN_FAILED_TO_CREATE_DEBUGGER;
|
|
||||||
|
|
||||||
|
|
||||||
struct vk_userData_t* userData = (struct vk_userData_t*)malloc(sizeof(struct vk_userData_t));
|
// struct vk_userData_t* userData = (struct vk_userData_t*)malloc(sizeof(struct vk_userData_t));
|
||||||
userData->debuggerCallback = info.callback;
|
// userData->debuggerCallback = info.callback;
|
||||||
userData->userData = info.userData;
|
// userData->userData = info.userData;
|
||||||
|
|
||||||
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
|
// VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
// createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
||||||
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
// createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||||
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
// createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||||
createInfo.pUserData = (void*)userData;
|
// createInfo.pUserData = (void*)userData;
|
||||||
createInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
// createInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
||||||
|
|
||||||
VkResult result = vk_createDebugUtilsMessengerEXT(instance->instance->vk_instance, &createInfo, NULL, &debugger->debugger->debugMessenger); if (result != VK_SUCCESS) {
|
// VkResult result = vk_createDebugUtilsMessengerEXT(instance->instance->vk_instance, &createInfo, NULL, &debugger->debugger->debugMessenger); if (result != VK_SUCCESS) {
|
||||||
gnMessageSeverity severity = GN_MESSAGE_ERROR;
|
// gnMessageSeverity severity = GN_MESSAGE_ERROR;
|
||||||
gnMessageType type = GN_DEBUG_MESSAGE_VALIDATION;
|
// gnMessageType type = GN_DEBUG_MESSAGE_VALIDATION;
|
||||||
gnMessageData data = {
|
// gnMessageData data = {
|
||||||
.message = gnCombineStrings(
|
// .message = gnCombineStrings(
|
||||||
gnCreateString("Failed to create gnDebuggerObject with api vulkan\n"),
|
// gnCreateString("Failed to create gnDebuggerObject with api vulkan\n"),
|
||||||
gnCombineStrings(gnCreateString("Returned with a vulkan error code of: (please do this)"), "")
|
// gnCombineStrings(gnCreateString("Returned with a vulkan error code of: (please do this)"), "")
|
||||||
)
|
// )
|
||||||
};
|
// };
|
||||||
info.callback(
|
// info.callback(
|
||||||
severity,
|
// severity,
|
||||||
type,
|
// type,
|
||||||
data,
|
// data,
|
||||||
info.userData
|
// info.userData
|
||||||
);
|
// );
|
||||||
|
|
||||||
return GN_FAILED_TO_CREATE_DEBUGGER;
|
// return GN_FAILED_TO_CREATE_DEBUGGER;
|
||||||
}
|
// }
|
||||||
return GN_SUCCESS;
|
// return GN_SUCCESS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void gnDestroyDebuggerFn(gnDebuggerHandle debugger) {
|
// void gnDestroyDebuggerFn(gnDebuggerHandle debugger) {
|
||||||
vk_destroyDebugUtilsMessengerEXT(debugger->instance->instance->vk_instance, debugger->debugger->debugMessenger, NULL);
|
// vk_destroyDebugUtilsMessengerEXT(debugger->instance->instance->vk_instance, debugger->debugger->debugMessenger, NULL);
|
||||||
}
|
// }
|
||||||
|
@@ -6,10 +6,4 @@ typedef struct gnPlatformDebugger_t {
|
|||||||
VkDebugUtilsMessengerEXT debugMessenger;
|
VkDebugUtilsMessengerEXT debugMessenger;
|
||||||
} gnPlatformDebugger;
|
} gnPlatformDebugger;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
void vkPopulateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo);
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@@ -2,6 +2,11 @@
|
|||||||
#include <debugger/vulkan_debugger.h>
|
#include <debugger/vulkan_debugger.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
typedef struct vkUserData {
|
||||||
|
gnDebuggerCallback debuggerCallback;
|
||||||
|
void* userData;
|
||||||
|
} vkUserData;
|
||||||
|
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
||||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||||
@@ -29,27 +34,11 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
|
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceHandle instance = (gnInstanceHandle)pUserData;
|
vkUserData* userData = (vkUserData*)pUserData;
|
||||||
|
gnDebuggerCallback callback = userData->debuggerCallback;
|
||||||
if (instance->debugger) {
|
gnBool result = callback(severity, type, data, userData->userData);
|
||||||
instance->debugger->info.callback(
|
if (result == gnFalse) return VK_FALSE;
|
||||||
severity, type, data, instance->debugger->info.userData
|
return VK_TRUE;
|
||||||
);
|
|
||||||
} else {
|
|
||||||
instance->instance->instanceMessageCount++;
|
|
||||||
if (instance->instance->instanceMessageCount == 1)
|
|
||||||
instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
|
||||||
else
|
|
||||||
instance->instance->instanceMessages = realloc(instance->instance->instanceMessages, sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
|
||||||
|
|
||||||
instance->instance->instanceMessages[instance->instance->instanceMessageCount - 1] = (struct gnInstanceMessage){
|
|
||||||
.data = data,
|
|
||||||
.severity = severity,
|
|
||||||
.type = type
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return VK_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
|
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
|
||||||
@@ -108,15 +97,26 @@ gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instan
|
|||||||
|
|
||||||
createInfo.flags = createFlags;
|
createInfo.flags = createFlags;
|
||||||
|
|
||||||
|
if (instanceInfo.debugger != NULL) {
|
||||||
|
for (int i = 0; i < instanceInfo.debugger->info.layerCount; i++) {
|
||||||
|
if (instanceInfo.debugger->info.layers[i] == GN_DEBUGGER_LAYER_PLATFORM) {
|
||||||
const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" };
|
const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
createInfo.enabledLayerCount = 1;
|
createInfo.enabledLayerCount = 1;
|
||||||
createInfo.ppEnabledLayerNames = validation_layers;
|
createInfo.ppEnabledLayerNames = (const char*[]){ "VK_LAYER_KHRONOS_validation" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vkUserData* userData = malloc(sizeof(vkUserData));
|
||||||
|
userData->debuggerCallback = instanceInfo.debugger->info.callback;
|
||||||
|
userData->userData = instanceInfo.debugger->info.userData;
|
||||||
|
|
||||||
VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo = {};
|
VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo = {};
|
||||||
populateDebugMessengerCreateInfo(&debugCreateInfo);
|
vkPopulateDebugMessengerCreateInfo(&debugCreateInfo);
|
||||||
debugCreateInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
debugCreateInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
||||||
debugCreateInfo.pUserData = instance;
|
debugCreateInfo.pUserData = userData;
|
||||||
createInfo.pNext = &debugCreateInfo;
|
createInfo.pNext = &debugCreateInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
createInfo.enabledExtensionCount = extensionCount;
|
createInfo.enabledExtensionCount = extensionCount;
|
||||||
createInfo.ppEnabledExtensionNames = extensions;
|
createInfo.ppEnabledExtensionNames = extensions;
|
||||||
|
@@ -12,12 +12,7 @@ void gnBufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
|
|||||||
buffer->device->deviceFunctions->_gnBufferData(buffer, dataSize, data);
|
buffer->device->deviceFunctions->_gnBufferData(buffer, dataSize, data);
|
||||||
}
|
}
|
||||||
void* gnMapBuffer(gnBufferHandle buffer) {
|
void* gnMapBuffer(gnBufferHandle buffer) {
|
||||||
if (buffer->info.usage == GN_STATIC_DRAW) {
|
if (buffer->info.usage == GN_STATIC_DRAW) return NULL;
|
||||||
gnDebuggerSetErrorMessage(buffer->device->instance->debugger, (gnMessageData){
|
|
||||||
.message = gnCreateString("Cannot map static draw buffers")
|
|
||||||
});
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return buffer->device->deviceFunctions->_gnMapBuffer(buffer);
|
return buffer->device->deviceFunctions->_gnMapBuffer(buffer);
|
||||||
}
|
}
|
||||||
void gnDestroyBuffer(gnBufferHandle buffer) {
|
void gnDestroyBuffer(gnBufferHandle buffer) {
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
#include "gryphn_debugger.h"
|
#include "gryphn_debugger.h"
|
||||||
#include <core/gryphn_platform_functions.h>
|
#include <core/gryphn_platform_functions.h>
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info) {
|
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info) {
|
||||||
*debugger = malloc(sizeof(struct gnDebugger_t));
|
*debugger = malloc(sizeof(struct gnDebugger_t));
|
||||||
(*debugger)->info = info;
|
(*debugger)->info = info;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void gnDestroyDebugger(gnDebuggerHandle debugger) {
|
void gnDestroyDebugger(gnDebuggerHandle debugger) {}
|
||||||
// free(debugger);
|
|
||||||
}
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "stdint.h"
|
||||||
#include "utils/gryphn_string.h"
|
#include "utils/gryphn_string.h"
|
||||||
#include "utils/gryphn_error_code.h"
|
#include "utils/gryphn_error_code.h"
|
||||||
#include "core/gryphn_handles.h"
|
#include "core/gryphn_handles.h"
|
||||||
@@ -7,29 +8,18 @@ struct gnPlatformDebugger_t;
|
|||||||
|
|
||||||
typedef enum gnMessageSeverity_e {
|
typedef enum gnMessageSeverity_e {
|
||||||
GN_MESSAGE_VERBOSE = 0x00000001,
|
GN_MESSAGE_VERBOSE = 0x00000001,
|
||||||
GN_MESSAGE_INFO = 0x00000010,
|
GN_MESSAGE_INFO = 0x00000002,
|
||||||
GN_MESSAGE_WARNING = 0x00000100,
|
GN_MESSAGE_WARNING = 0x00000004,
|
||||||
GN_MESSAGE_ERROR = 0x00001000,
|
GN_MESSAGE_ERROR = 0x00000008,
|
||||||
} gnMessageSeverity;
|
} gnMessageSeverity;
|
||||||
|
|
||||||
typedef enum gnMessageType_e {
|
typedef enum gnMessageType_e {
|
||||||
GN_DEBUG_MESSAGE_GENERAL = 0x00000001,
|
GN_DEBUG_MESSAGE_GENERAL = 0x00000001,
|
||||||
GN_DEBUG_MESSAGE_VALIDATION = 0x00000002,
|
GN_DEBUG_MESSAGE_VALIDATION = 0x00000002,
|
||||||
GN_DEBUG_MESSAGE_PERFORMANCE = 0x00000004,
|
GN_DEBUG_MESSAGE_PERFORMANCE = 0x00000004,
|
||||||
// GN_DEBUG_MESSAGE_ADDRESS_BINDING = 0x00000008, vulkan had this but imma leave it out
|
|
||||||
} gnMessageType;
|
} gnMessageType;
|
||||||
|
|
||||||
typedef struct gnMessageData {
|
typedef struct gnMessageData {
|
||||||
// const char* pMessageIdName;
|
|
||||||
// int32_t messageIdNumber;
|
|
||||||
// uint32_t queueLabelCount;
|
|
||||||
// const VkDebugUtilsLabelEXT* pQueueLabels;
|
|
||||||
// uint32_t cmdBufLabelCount;
|
|
||||||
// const VkDebugUtilsLabelEXT* pCmdBufLabels;
|
|
||||||
// uint32_t objectCount;
|
|
||||||
// const VkDebugUtilsObjectNameInfoEXT* pObjects;
|
|
||||||
//
|
|
||||||
// If i ever figure out what this shit does il add it
|
|
||||||
gnString message;
|
gnString message;
|
||||||
} gnMessageData;
|
} gnMessageData;
|
||||||
|
|
||||||
@@ -39,20 +29,26 @@ typedef gnBool (*gnDebuggerCallback)(
|
|||||||
gnMessageData messageData,
|
gnMessageData messageData,
|
||||||
void* userData);
|
void* userData);
|
||||||
|
|
||||||
typedef struct gnDebuggerInfo_t {
|
typedef enum gnDebuggerLayer {
|
||||||
|
GN_DEBUGGER_LAYER_PLATFORM // enable platform (vulkan validation) layers
|
||||||
|
} gnDebuggerLayer;
|
||||||
|
|
||||||
|
typedef struct gnDebuggerInfo {
|
||||||
gnDebuggerCallback callback;
|
gnDebuggerCallback callback;
|
||||||
void* userData;
|
void* userData;
|
||||||
|
|
||||||
|
uint32_t layerCount;
|
||||||
|
gnDebuggerLayer* layers;
|
||||||
} gnDebuggerInfo;
|
} gnDebuggerInfo;
|
||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
|
|
||||||
struct gnDebugger_t {
|
struct gnDebugger_t {
|
||||||
struct gnPlatformDebugger_t* debugger;
|
gnDebuggerInfo info;
|
||||||
struct gnDebuggerInfo_t info;
|
|
||||||
gnInstanceHandle instance;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const struct gnDebuggerInfo_t info);
|
gnReturnCode gnCreateDebugger(gnDebuggerHandle* debugger, const gnDebuggerInfo info);
|
||||||
void gnDestroyDebugger(gnDebuggerHandle debugger);
|
void gnDestroyDebugger(gnDebuggerHandle debugger);
|
||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
// theoretically you could have multible gryphn instances running in one application,
|
// theoretically you could have multible gryphn instances running in one application,
|
||||||
// why I dont know
|
// why I dont know
|
||||||
#include "instance/gryphn_instance.h"
|
#include "instance/gryphn_instance.h"
|
||||||
#include "debugger/gryphn_debugger.h"
|
// #include "debugger/gryphn_debugger.h"
|
||||||
#include "output_device/gryphn_physical_output_device.h"
|
#include "output_device/gryphn_physical_output_device.h"
|
||||||
#include "output_device/gryphn_output_device.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
#include "window_surface/gryphn_surface.h"
|
#include "window_surface/gryphn_surface.h"
|
||||||
@@ -24,13 +24,9 @@ typedef struct gnFunctions_t {
|
|||||||
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
|
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
|
||||||
void (*_gnDestroyInstance)(gnInstanceHandle instance);
|
void (*_gnDestroyInstance)(gnInstanceHandle instance);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateDebugger)(gnDebuggerHandle debugger, gnInstanceHandle instance, const gnDebuggerInfo info);
|
|
||||||
void (*_gnDestroyDebugger)(gnDebuggerHandle debugger);
|
|
||||||
|
|
||||||
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
|
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
|
||||||
gnBool (*_gnQueueCanPresentToSurface)(const gnPhysicalDevice device, uint32_t queueIndex, const gnWindowSurfaceHandle windowSurface);
|
gnBool (*_gnQueueCanPresentToSurface)(const gnPhysicalDevice device, uint32_t queueIndex, const gnWindowSurfaceHandle windowSurface);
|
||||||
|
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDeviceHandle device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDeviceHandle device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
||||||
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#include "gryphn_instance.h"
|
#include "gryphn_instance.h"
|
||||||
#include "init/gryphn_init.h"
|
#include "init/gryphn_init.h"
|
||||||
#include <core/gryphn_platform_functions.h>
|
#include <core/gryphn_platform_functions.h>
|
||||||
#include "core/debugger/gryphn_debugger.h"
|
|
||||||
#include "core/instance/gryphn_instance.h"
|
#include "core/instance/gryphn_instance.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
@@ -18,30 +17,11 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInst
|
|||||||
instance->functions = malloc(sizeof(struct gnFunctions_t));
|
instance->functions = malloc(sizeof(struct gnFunctions_t));
|
||||||
instance->loadCommandFunctions = gnFalse;
|
instance->loadCommandFunctions = gnFalse;
|
||||||
instance->loadDeviceFunctions = gnFalse;
|
instance->loadDeviceFunctions = gnFalse;
|
||||||
|
instance->debugger = info.debugger;
|
||||||
gnLoadFunctions(instance->dynamicLib, instance->functions);
|
gnLoadFunctions(instance->dynamicLib, instance->functions);
|
||||||
return instance->functions->_gnCreateInstance(instance, info);
|
return instance->functions->_gnCreateInstance(instance, info);
|
||||||
}
|
}
|
||||||
void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) {
|
|
||||||
if (instance->debugger != NULL) {
|
|
||||||
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
|
|
||||||
.message = gnCreateString("Debugger already attached to instance")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
instance->debugger = debugger;
|
|
||||||
debugger->instance = instance;
|
|
||||||
gnReturnCode debuggerInfo = instance->functions->_gnCreateDebugger(debugger, instance, debugger->info);
|
|
||||||
if (debuggerInfo != GN_SUCCESS) {
|
|
||||||
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
|
|
||||||
.message = gnCreateString("Failed to attach debugger to instance")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void gnDestroyInstance(gnInstanceHandle instance) {
|
void gnDestroyInstance(gnInstanceHandle instance) {
|
||||||
if (instance->debugger) instance->functions->_gnDestroyDebugger(instance->debugger);
|
|
||||||
instance->functions->_gnDestroyInstance(instance);
|
instance->functions->_gnDestroyInstance(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnInstanceReleaseDebugger(gnInstanceHandle instance) {
|
|
||||||
instance->debugger = NULL;
|
|
||||||
}
|
|
||||||
|
@@ -15,6 +15,7 @@ typedef struct gnInstanceInfo_t {
|
|||||||
gnVersion engineVersion;
|
gnVersion engineVersion;
|
||||||
|
|
||||||
gnRenderingAPI renderingAPI;
|
gnRenderingAPI renderingAPI;
|
||||||
|
gnDebuggerHandle debugger;
|
||||||
} gnInstanceInfo;
|
} gnInstanceInfo;
|
||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
@@ -35,6 +36,4 @@ struct gnInstance_t {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info);
|
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, struct gnInstanceInfo_t info);
|
||||||
void gnInstanceAttachDebugger(gnInstanceHandle istance, gnDebuggerHandle debugger);
|
|
||||||
void gnInstanceReleaseDebugger(gnInstanceHandle instance);
|
|
||||||
void gnDestroyInstance(gnInstanceHandle instance);
|
void gnDestroyInstance(gnInstanceHandle instance);
|
||||||
|
@@ -40,8 +40,8 @@ struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI renderingAPI) {
|
|||||||
void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* functions) {
|
void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* functions) {
|
||||||
gnLoadDLLFunction(lib, functions->_gnCreateInstance, "gnCreateInstanceFn");
|
gnLoadDLLFunction(lib, functions->_gnCreateInstance, "gnCreateInstanceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyInstance, "gnDestroyInstanceFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyInstance, "gnDestroyInstanceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnCreateDebugger, "gnCreateDebuggerFn");
|
// gnLoadDLLFunction(lib, functions->_gnCreateDebugger, "gnCreateDebuggerFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyDebugger, "gnDestroyDebuggerFn");
|
// gnLoadDLLFunction(lib, functions->_gnDestroyDebugger, "gnDestroyDebuggerFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
|
gnLoadDLLFunction(lib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnQueueCanPresentToSurface, "gnQueueCanPresentToSurfaceFn");
|
gnLoadDLLFunction(lib, functions->_gnQueueCanPresentToSurface, "gnQueueCanPresentToSurfaceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnCreateOutputDevoce, "gnCreateOutputDeviceFn");
|
gnLoadDLLFunction(lib, functions->_gnCreateOutputDevoce, "gnCreateOutputDeviceFn");
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
#include "gryphn_physical_output_device.h"
|
#include "gryphn_physical_output_device.h"
|
||||||
#include "core/gryphn_platform_functions.h"
|
#include "core/gryphn_platform_functions.h"
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
gnPhysicalDevice* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count) {
|
gnPhysicalDevice* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count) {
|
||||||
gnPhysicalDevice* devices = instance->functions->_gnGetPhysicalDevices(instance, count);
|
gnPhysicalDevice* devices = instance->functions->_gnGetPhysicalDevices(instance, count);
|
||||||
@@ -11,14 +10,14 @@ gnPhysicalDevice* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
gnBool gnQueueCanPresentToSurface(const struct gnPhysicalDevice_t device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
||||||
if (queueIndex >= device.queueProperties.queueCount) {
|
// if (queueIndex >= device.queueProperties.queueCount) {
|
||||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
// gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||||
(gnMessageData){
|
// (gnMessageData){
|
||||||
.message = gnCreateString("gnQueueCanPresentToSurface queue index passed in is large then queueProperties.queueCount")
|
// .message = gnCreateString("gnQueueCanPresentToSurface queue index passed in is large then queueProperties.queueCount")
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
return gnFalse;
|
// return gnFalse;
|
||||||
}
|
// }
|
||||||
return device.instance->functions->_gnQueueCanPresentToSurface(device, queueIndex, windowSurface);
|
return device.instance->functions->_gnQueueCanPresentToSurface(device, queueIndex, windowSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,11 +45,11 @@ int gnGetGraphicsQueueIndex(const struct gnPhysicalDevice_t device) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
// gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||||
(gnMessageData){
|
// (gnMessageData){
|
||||||
.message = gnCreateString("gnGetGraphicsQueueIndex failed no queue that support graphics on this device")
|
// .message = gnCreateString("gnGetGraphicsQueueIndex failed no queue that support graphics on this device")
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int gnGetPresentQueueIndex(const struct gnPhysicalDevice_t device, gnWindowSurfaceHandle windowSurface) {
|
int gnGetPresentQueueIndex(const struct gnPhysicalDevice_t device, gnWindowSurfaceHandle windowSurface) {
|
||||||
@@ -60,10 +59,10 @@ int gnGetPresentQueueIndex(const struct gnPhysicalDevice_t device, gnWindowSurfa
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gnDebuggerSetErrorMessage(device.instance->debugger,
|
// gnDebuggerSetErrorMessage(device.instance->debugger,
|
||||||
(gnMessageData){
|
// (gnMessageData){
|
||||||
.message = gnCreateString("gnGetPresentQueueIndex failed no queue that support presenting to this window surface")
|
// .message = gnCreateString("gnGetPresentQueueIndex failed no queue that support presenting to this window surface")
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Submodule src/utils updated: 5b05fb287d...c5049bda3d
Reference in New Issue
Block a user