re implement debugger in C
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <platform/gryphn_platform_include.h>
|
#include <platform/gryphn_platform_include.h>
|
||||||
#include <core/instance/init/gryphn_init.h>
|
#include <core/instance/init/gryphn_init.h>
|
||||||
#include <core/instance/gryphn_instance.h>
|
#include <core/instance/gryphn_instance.h>
|
||||||
|
#include <core/debugger/gryphn_debugger.h>
|
||||||
|
|
||||||
// #pragma once
|
// #pragma once
|
||||||
|
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
#undef GN_UTILS_CPP
|
|
||||||
#include <core/debugger/gryphn_layers.h>
|
|
||||||
|
|
||||||
GN_EXPORT gnString gnGetPlatformLayerNameFn(const gnString& gnName) {
|
|
||||||
if (gnStringEquals(gnName, "GN_DEFAULT_DEBUG_LAYER")) return gnCreateString("METAL_DEBUG_LAYER");
|
|
||||||
return gnCreateString("GN_NO_LAYER");
|
|
||||||
}
|
|
@@ -1,4 +1,5 @@
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
project(GryphnVulkanImpl)
|
project(GryphnVulkanImpl)
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
|
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
|
||||||
|
@@ -1,5 +1,34 @@
|
|||||||
#include "iostream"
|
|
||||||
#include "vulkan_debugger.h"
|
#include "vulkan_debugger.h"
|
||||||
|
#include "instance/vulkan_instance.h"
|
||||||
|
|
||||||
|
bool checkValidationLayerSupport(std::vector<std::string> layers_to_validate) {
|
||||||
|
uint32_t layerCount;
|
||||||
|
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||||
|
|
||||||
|
std::vector<VkLayerProperties> availableLayers(layerCount);
|
||||||
|
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
||||||
|
|
||||||
|
for (int i = 0; i < layers_to_validate.size(); i++) {
|
||||||
|
bool layerFound = false;
|
||||||
|
|
||||||
|
for (const auto& layerProperties : availableLayers) {
|
||||||
|
if (strcmp(layers_to_validate[i].c_str(), layerProperties.layerName) == 0) {
|
||||||
|
layerFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!layerFound)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct vk_userData_t {
|
||||||
|
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,
|
||||||
@@ -7,22 +36,42 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||||
void* pUserData) {
|
void* pUserData) {
|
||||||
|
|
||||||
if (messageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
|
vk_userData_t userData = *(struct vk_userData_t*)pUserData;
|
||||||
std::cerr << "validation layer error: " << pCallbackData->pMessage << std::endl;
|
|
||||||
else
|
|
||||||
std::cout << "validation layer: " << pCallbackData->pMessage << std::endl;
|
|
||||||
|
|
||||||
|
gnMessageSeverity severity;
|
||||||
|
gnMessageType type;
|
||||||
|
gnMessageData data = {
|
||||||
|
.message = gnCreateString(pCallbackData->pMessage)
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (messageSeverity) {
|
||||||
|
default: break;
|
||||||
|
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||||
|
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 (messageType) {
|
||||||
|
default: break;
|
||||||
|
case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break;
|
||||||
|
case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break;
|
||||||
|
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gnDebuggerCallback callback = *userData.debuggerCallback;
|
||||||
|
gnBool result = callback(severity, type, data, userData.userData);
|
||||||
|
if (result == gnFalse) return VK_FALSE;
|
||||||
|
else if (result == gnTrue) return VK_TRUE;
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero fucking clue what this does but the guy who wrote vulkan-tutorial.com does
|
VkResult vk_createDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
||||||
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
||||||
auto func = (PFN_vkCreateDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
if (vkCreateDebugUtilsMessengerEXT != nullptr)
|
||||||
if (func != nullptr) {
|
return vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pDebugMessenger);
|
||||||
return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
|
else
|
||||||
} else {
|
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) {
|
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) {
|
||||||
@@ -33,25 +82,33 @@ void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& create
|
|||||||
createInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
createInfo.pfnUserCallback = vk_debuggerDebugCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
|
void vk_destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
|
||||||
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||||
if (func != nullptr) {
|
if (vkDestroyDebugUtilsMessengerEXT != nullptr) {
|
||||||
func(instance, debugMessenger, pAllocator);
|
vkDestroyDebugUtilsMessengerEXT(instance, debugMessenger, pAllocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GN_EXPORT gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger) {
|
GN_EXPORT gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, const gnDebuggerInfo_t info) {
|
||||||
if (debugger->debugger == nullptr) debugger->debugger = new gnPlatformDebugger();
|
debugger->debugger = new gnPlatformDebugger();
|
||||||
|
|
||||||
|
if (!checkValidationLayerSupport({"VK_LAYER_KHRONOS_validation"}))
|
||||||
|
return GN_FAILED_TO_CREATE_DEBUGGER;
|
||||||
|
|
||||||
VkDebugUtilsMessengerCreateInfoEXT createInfo;
|
VkDebugUtilsMessengerCreateInfoEXT createInfo;
|
||||||
populateDebugMessengerCreateInfo(createInfo);
|
|
||||||
|
|
||||||
if (CreateDebugUtilsMessengerEXT(*debugger->debugger->instance, &createInfo, nullptr, &debugger->debugger->debugMessenger) != VK_SUCCESS) {
|
vk_userData_t* userData = (vk_userData_t*)malloc(sizeof(vk_userData_t));
|
||||||
return GN_FAILED;
|
userData->debuggerCallback = info.callback;
|
||||||
}
|
userData->userData = info.userData;
|
||||||
|
|
||||||
|
populateDebugMessengerCreateInfo(createInfo);
|
||||||
|
createInfo.pUserData = (void*)userData;
|
||||||
|
|
||||||
|
if (vk_createDebugUtilsMessengerEXT(instance->instance->vk_instance, &createInfo, nullptr, &debugger->debugger->debugMessenger) != VK_SUCCESS)
|
||||||
|
return GN_FAILED_TO_CREATE_DEBUGGER;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
GN_EXPORT void gnDestroyDebuggerFn(gnDebugger& debugger) {
|
GN_EXPORT void gnDestroyDebuggerFn(gnDebugger& debugger) {
|
||||||
DestroyDebugUtilsMessengerEXT(*debugger.debugger->instance, debugger.debugger->debugMessenger, nullptr);
|
vk_destroyDebugUtilsMessengerEXT(*debugger.debugger->instance, debugger.debugger->debugMessenger, nullptr);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
#undef GN_UTILS_CPP
|
|
||||||
#include <core/debugger/gryphn_layers.h>
|
|
||||||
|
|
||||||
GN_EXPORT gnString gnGetPlatformLayerNameFn(const gnString& gnName) {
|
|
||||||
if (gnStringEquals(gnName, "GN_DEFAULT_DEBUG_LAYER")) return gnCreateString("VK_LAYER_KHRONOS_validation");
|
|
||||||
return gnCreateString("GN_NO_LAYER");
|
|
||||||
}
|
|
@@ -1,57 +1,10 @@
|
|||||||
#include "gryphn/gryphn_utils.h"
|
#include "gryphn/gryphn_utils.h"
|
||||||
#include "vector"
|
#include "vector"
|
||||||
#include <cstring>
|
|
||||||
// #include "debugger/vulkan_debugger.h"
|
|
||||||
#include "vulkan_instance.h"
|
#include "vulkan_instance.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// now I gotta do some shit to setup debug layers
|
|
||||||
bool checkValidationLayerSupport(std::vector<std::string> layers_to_validate) {
|
|
||||||
uint32_t layerCount;
|
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
|
||||||
|
|
||||||
std::vector<VkLayerProperties> availableLayers(layerCount);
|
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
|
||||||
|
|
||||||
for (int i = 0; i < layers_to_validate.size(); i++) {
|
|
||||||
bool layerFound = false;
|
|
||||||
|
|
||||||
for (const auto& layerProperties : availableLayers) {
|
|
||||||
if (strcmp(layers_to_validate[i].c_str(), layerProperties.layerName) == 0) {
|
|
||||||
layerFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!layerFound)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// void gnInstanceSetAppInfoFn(gnInstance& instance, gnInstanceInfo& info) {
|
|
||||||
// if (instance.instance == nullptr) instance.instance = new gnPlatformInstanceData();
|
|
||||||
|
|
||||||
// instance.AppInfo = info;
|
|
||||||
// instance.instance->appInfo = {};
|
|
||||||
// instance.instance->appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
|
||||||
// instance.instance->appInfo.pApplicationName = "Hello Triangle";
|
|
||||||
// instance.instance->appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
|
||||||
// instance.instance->appInfo.pEngineName = "No Engine";
|
|
||||||
// instance.instance->appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
|
||||||
// instance.instance->appInfo.apiVersion = VK_API_VERSION_1_3;
|
|
||||||
// }
|
|
||||||
|
|
||||||
GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) {
|
GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) {
|
||||||
instance->instance = new gnPlatformInstance();
|
instance->instance = new gnPlatformInstance();
|
||||||
|
|
||||||
// if (instance->debugger != nullptr && !checkValidationLayerSupport(instance->debugger->debug_layers)) {
|
|
||||||
// return gnReturnError(GN_FAILED_CREATE_INSTANCE, "validation layers requested, but not available!");
|
|
||||||
// }
|
|
||||||
// gnInstanceSetAppInfoFn(*instance, instance->AppInfo);
|
|
||||||
|
|
||||||
instance->valid = true;
|
instance->valid = true;
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
@@ -73,8 +26,7 @@ GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo i
|
|||||||
|
|
||||||
|
|
||||||
instance->instance->extensions.push_back("VK_KHR_surface");
|
instance->instance->extensions.push_back("VK_KHR_surface");
|
||||||
// if (instance->debugger)
|
instance->instance->extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
// instance->instance->extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
|
||||||
|
|
||||||
VkApplicationInfo appInfo = {
|
VkApplicationInfo appInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
@@ -89,34 +41,14 @@ GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo i
|
|||||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
createInfo.pApplicationInfo = &appInfo;
|
createInfo.pApplicationInfo = &appInfo;
|
||||||
createInfo.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
createInfo.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||||
// auto extensions = getRequiredExtensions(instance->debugger);
|
|
||||||
|
|
||||||
createInfo.enabledExtensionCount = static_cast<uint32_t>(instance->instance->extensions.size());;
|
createInfo.enabledExtensionCount = static_cast<uint32_t>(instance->instance->extensions.size());;
|
||||||
createInfo.ppEnabledExtensionNames = instance->instance->extensions.data();
|
createInfo.ppEnabledExtensionNames = instance->instance->extensions.data();
|
||||||
|
|
||||||
// VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
|
|
||||||
// if (instance->debugger != nullptr) {
|
|
||||||
// auto validation_layers = instance->debugger->debug_layers;
|
|
||||||
|
|
||||||
// gnList<const char*> validation_layers_c = gnCreateList<const char*>();
|
|
||||||
// for (int i = 0; i < gnListLength(validation_layers); i++)
|
|
||||||
// gnListAdd(validation_layers_c, gnToCString(validation_layers[i]));
|
|
||||||
|
|
||||||
// createInfo.enabledLayerCount = static_cast<uint32_t>(gnListLength(validation_layers_c));
|
|
||||||
// createInfo.ppEnabledLayerNames = gnListData(validation_layers_c);
|
|
||||||
|
|
||||||
// populateDebugMessengerCreateInfo(debugCreateInfo);
|
|
||||||
// createInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT*) &debugCreateInfo;
|
|
||||||
// } else {
|
|
||||||
createInfo.enabledLayerCount = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (vkCreateInstance(&createInfo, nullptr, &instance->instance->vk_instance) != VK_SUCCESS) {
|
if (vkCreateInstance(&createInfo, nullptr, &instance->instance->vk_instance) != VK_SUCCESS) {
|
||||||
return GN_FAILED_CREATE_INSTANCE;
|
return GN_FAILED_CREATE_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (instance->debugger->debugger == nullptr) instance->debugger->debugger = new gnPlatformDebugger();
|
|
||||||
// instance->debugger->debugger->instance = &instance->instance->vk_instance;
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,17 +1,11 @@
|
|||||||
#undef GN_UTILS_CPP
|
|
||||||
#include "gryphn_debugger.h"
|
#include "gryphn_debugger.h"
|
||||||
|
#include "core/gryphn_platform_functions.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
static gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
|
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
|
||||||
static void (*_gnDestroyDebugger)(gnDebugger* debugger);
|
debugger->instance = instance;
|
||||||
|
return instance->functions->_gnCreateDebugger(debugger, instance, info);
|
||||||
void gn_load_functions() {
|
}
|
||||||
|
void gnDestroyDebugger(gnDebugger* debugger) {
|
||||||
|
debugger->instance->functions->_gnDestroyDebugger(debugger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer) {
|
|
||||||
// gnListAdd(debugger.debug_layers, layer);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger) {
|
|
||||||
// return debugger.debug_layers;
|
|
||||||
// }
|
|
||||||
|
@@ -1,17 +1,53 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "utils/strings/gryphn_string.h"
|
#include "utils/strings/gryphn_string.h"
|
||||||
#include "utils/gryphn_error_code.h"
|
#include "utils/gryphn_error_code.h"
|
||||||
|
#include "core/instance/gryphn_instance.h"
|
||||||
|
|
||||||
struct gnPlatformDebugger;
|
struct gnPlatformDebugger;
|
||||||
|
|
||||||
|
typedef enum gnMessageSeverity_e {
|
||||||
|
GN_MESSAGE_VERBOSE = 0x00000001,
|
||||||
|
GN_MESSAGE_INFO = 0x00000010,
|
||||||
|
GN_MESSAGE_WARNING = 0x00000100,
|
||||||
|
GN_MESSAGE_ERROR = 0x00001000,
|
||||||
|
} gnMessageSeverity;
|
||||||
|
|
||||||
|
typedef enum gnMessageType_e {
|
||||||
|
GN_DEBUG_MESSAGE_GENERAL = 0x00000001,
|
||||||
|
GN_DEBUG_MESSAGE_VALIDATION = 0x00000002,
|
||||||
|
GN_DEBUG_MESSAGE_PERFORMANCE = 0x00000004,
|
||||||
|
// GN_DEBUG_MESSAGE_ADDRESS_BINDING = 0x00000008, vulkan had this but imma leave it out
|
||||||
|
} gnMessageType;
|
||||||
|
|
||||||
|
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;
|
||||||
|
} gnMessageData;
|
||||||
|
|
||||||
|
typedef gnBool (*gnDebuggerCallback)(
|
||||||
|
gnMessageSeverity messageSeverity,
|
||||||
|
gnMessageType messageType,
|
||||||
|
gnMessageData messageData,
|
||||||
|
void* userData);
|
||||||
|
|
||||||
typedef struct gnDebuggerInfo_t {
|
typedef struct gnDebuggerInfo_t {
|
||||||
int layerCount;
|
gnDebuggerCallback callback;
|
||||||
gnString* layerNames;
|
void* userData;
|
||||||
} gnDebuggerInfo;
|
} gnDebuggerInfo;
|
||||||
|
|
||||||
typedef struct gnDebugger_t {
|
typedef struct gnDebugger_t {
|
||||||
struct gnPlatformDebugger* debugger;
|
struct gnPlatformDebugger* debugger;
|
||||||
|
gnInstance* instance;
|
||||||
} gnDebugger;
|
} gnDebugger;
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
|
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
||||||
gnReturnCode gnDestroyDebugger(gnDebugger* debugger);
|
void gnDestroyDebugger(gnDebugger* debugger);
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
// 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 "utils/gryphn_error_code.h"
|
|
||||||
#include "instance/gryphn_instance.h"
|
#include "instance/gryphn_instance.h"
|
||||||
|
#include "debugger/gryphn_debugger.h"
|
||||||
|
|
||||||
typedef struct gnFunctions_t {
|
typedef struct gnFunctions_t {
|
||||||
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
void (*_gnDestroyInstance)(gnInstance* instance);
|
void (*_gnDestroyInstance)(gnInstance* instance);
|
||||||
|
|
||||||
|
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
||||||
|
void (*_gnDestroyDebugger)(gnDebugger* debugger);
|
||||||
} gnFunctions;
|
} gnFunctions;
|
||||||
|
@@ -38,131 +38,6 @@ 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->_gnDestroyDebugger, "gnDestroyDebuggerFn");
|
||||||
}
|
}
|
||||||
|
|
||||||
// gnReturnCode gnInit(gnRenderingAPI RenderingAPI) {
|
|
||||||
|
|
||||||
// gnRenderingAPILIB = gnLoadDLL(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName));
|
|
||||||
// if (!gnRenderingAPILIB.isValid) { return GN_UNABLE_TO_LOAD_DLL; }
|
|
||||||
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateInstance, "gnCreateInstanceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyInstance, "gnDestroyInstanceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetPlatformLayerName, "gnGetPlatformLayerNameFn");
|
|
||||||
|
|
||||||
// // LOAD THE SET WINDOW FUNCTIONS
|
|
||||||
// // #ifdef GN_PLATFORM_LINUX
|
|
||||||
// // #ifdef GN_WINDOW_X11
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn");
|
|
||||||
// // #endif
|
|
||||||
// // #ifdef GN_WINDOW_WAYLAND
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn");
|
|
||||||
// // #endif
|
|
||||||
// // #endif
|
|
||||||
|
|
||||||
|
|
||||||
// // #ifdef GN_PLATFORM_WIN32
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWindowsWindowSurface, "gnCreateWindowsWindowSurfaceFn");
|
|
||||||
// // #endif
|
|
||||||
|
|
||||||
// // #ifdef GN_PLATFORM_MACOS
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn");
|
|
||||||
// // #endif
|
|
||||||
// // This is stupid
|
|
||||||
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateDebugger, "gnCreateDebuggerFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyDebugger, "gnDestroyDebuggerFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetPhysicalOutputDevices, "gnGetPhysicalOutputDevicesFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForDevice, "gnWaitForDeviceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetDevicePresentationDetails, "gnGetDevicePresentationDetailsFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetNextImageAsync, "gnPresentationQueueGetNextImageAsyncFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetState, "gnPresentationQueueGetStateFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreatePresentationQueue, "gnCreatePresentationQueueFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetBindingDescription, "gnVertexDescriptionSetBindingDescriptionFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetPropertiesCount, "gnVertexDescriptionSetPropertiesCountFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetProperty, "gnVertexDescriptionSetPropertyFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateBuffer, "gnCreateBufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferData, "gnBufferDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferMapData, "gnBufferMapDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyBuffer, "gnDestroyBufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferSubData, "gnBufferSubDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferClearData, "gnBufferClearDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnTextureData, "gnTextureDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnTextureCubeMapData, "gnTextureCubeMapDataFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateTexture, "gnCreateTextureFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyTexture, "gnDestroyTextureFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniformLayout, "gnCreateUniformLayoutFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniformLayout, "gnDestroyUniformLayoutFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateRenderPass, "gnCreateRenderPassFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyRenderPass, "gnDestroyRenderPassFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFence, "gnCreateFenceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForFence, "gnWaitForFenceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnResetFence, "gnResetFenceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFence, "gnDestroyFenceFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateCommandBuffer, "gnCreateCommandBufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnCreateCommandBuffers, "_gnCreateCommandBuffersFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferReset, "gnCommandBufferResetFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyCommandBuffer, "gnDestroyCommandBufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShaderModule, "gnBuildShaderModuleFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyShaderModule, "gnDestroyShaderModuleFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShader, "gnBuildShaderFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniform, "gnCreateUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniform, "gnDestroyUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateSamplerUniform, "gnUpdateSamplerUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnAPISupports, "gnAPISupportsFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetPrimative, "gnGraphicsPipelineSetPrimativeFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicStates, "gnGraphicsPipelineEnableDynamicStatesFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicState, "gnGraphicsPipelineEnableDynamicStateFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnGraphicsPipelineSetViewport, "_gnGraphicsPipelineSetViewportFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCrop, "gnGraphicsPipelineSetCropFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetDepthClamp, "gnGraphicsPipelineSetDepthClampFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetFillMode, "gnGraphicsPipelineSetFillModeFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetLineWidth, "gnGraphicsPipelineSetLineWidthFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCullMode, "gnGraphicsPipelineSetCullModeFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetMultisampling, "gnGraphicsPipelineSetMultisamplingFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDepthTest, "gnGraphicsPipelineEnableDepthTestFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetColorBlend, "gnGraphicsPipelineSetColorBlendFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetVertexDescription, "gnGraphicsPipelineSetVertexDescriptionFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineBindShader, "gnGraphicsPipelineBindShaderFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetRenderPass, "gnGraphicsPipelineSetRenderPassFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddUniformLayout, "gnGraphicsPipelineAddUniformLayoutFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddPushConstant, "gnGraphicsPipelineAddPushConstantFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebuffer, "gnCreateFramebufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFramebuffer, "gnDestroyFramebufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebufferAttachment, "gnCreateFramebufferAttachmentFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateSyncSemaphore, "gnCreateSyncSemaphoreFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroySyncSemaphore, "gnDestroySyncSemaphoreFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferStart, "gnCommandBufferStartFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferEnd, "gnCommandBufferEndFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetGraphicsPipeline, "gnCommandSetGraphicsPipelineFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindSamplerUniform, "gnCommandBindSamplerUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBuffer, "gnCommandBindBufferFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBufferUniform, "gnCommandBindBufferUniformFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPushConstant, "gnCommandPushConstantFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandDrawIndexed, "gnCommandDrawIndexedFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetViewport, "gnCommandSetViewportFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetScissor, "gnCommandSetScissorFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnCommandDraw, "gnCommandDrawFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmitGetValidPresentationQueue, "gnCommandSubmitGetValidPresentationQueueFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmit, "gnCommandSubmitFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresentGetValidPresentationQueue, "gnCommandPresentGetValidPresentationQueueFn");
|
|
||||||
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresent, "gnCommandPresentFn");
|
|
||||||
|
|
||||||
// return GN_SUCCESS;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void* gnLoadFunction(gnString name) {
|
|
||||||
// return gnLoadFunctionPtr(gnRenderingAPILIB, name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void gnDestroy() {
|
|
||||||
// gnUnloadDLL(&gnRenderingAPILIB);
|
|
||||||
// }
|
|
||||||
|
@@ -1,8 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
typedef int gnBool;
|
typedef int gnBool;
|
||||||
#define gnFalse 0;
|
#define gnFalse 0
|
||||||
#define gnTrue 1;
|
#define gnTrue 1
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef size_t gnSize;
|
typedef size_t gnSize;
|
||||||
|
@@ -5,7 +5,8 @@ typedef enum gnReturnCode_t {
|
|||||||
GN_UNKNOWN_RENDERINGAPI,
|
GN_UNKNOWN_RENDERINGAPI,
|
||||||
GN_UNSUPPORTED_RENDERING_API,
|
GN_UNSUPPORTED_RENDERING_API,
|
||||||
GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY,
|
GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY,
|
||||||
GN_FAILED_CREATE_INSTANCE
|
GN_FAILED_CREATE_INSTANCE,
|
||||||
|
GN_FAILED_TO_CREATE_DEBUGGER
|
||||||
|
|
||||||
// GN_UNKNOWN_ERROR,
|
// GN_UNKNOWN_ERROR,
|
||||||
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
||||||
@@ -25,3 +26,14 @@ typedef enum gnReturnCode_t {
|
|||||||
} gnReturnCode;
|
} gnReturnCode;
|
||||||
|
|
||||||
typedef gnReturnCode gnErrorCode;
|
typedef gnReturnCode gnErrorCode;
|
||||||
|
static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
|
||||||
|
switch (returnCode) {
|
||||||
|
default: return "GN_FORGOT";
|
||||||
|
case GN_SUCCESS: return "GN_SUCCESS";
|
||||||
|
case GN_UNKNOWN_RENDERINGAPI: return "GN_UNKNOWN_RENDERINGAPI";
|
||||||
|
case GN_UNSUPPORTED_RENDERING_API: return "GN_UNSUPPORTED_RENDERING_API";
|
||||||
|
case GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY: return "GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY";
|
||||||
|
case GN_FAILED_CREATE_INSTANCE: return "GN_FAILED_CREATE_INSTANCE";
|
||||||
|
case GN_FAILED_TO_CREATE_DEBUGGER: return "GN_FAILED_TO_CREATE_DEBUGGER";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user