allow debugger to be created before the instance and attached to it
later
This commit is contained in:
@@ -114,6 +114,9 @@ gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instance->instance->instanceMessageCount = 0;
|
||||||
|
free(instance->instance->instanceMessages);
|
||||||
|
|
||||||
const char* layers[] = {
|
const char* layers[] = {
|
||||||
"VK_LAYER_KHRONOS_validation"
|
"VK_LAYER_KHRONOS_validation"
|
||||||
};
|
};
|
||||||
@@ -154,5 +157,5 @@ gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyDebuggerFn(gnDebugger* debugger) {
|
void gnDestroyDebuggerFn(gnDebugger* debugger) {
|
||||||
vk_destroyDebugUtilsMessengerEXT(*debugger->debugger->instance, debugger->debugger->debugMessenger, NULL);
|
vk_destroyDebugUtilsMessengerEXT(debugger->instance->instance->vk_instance, debugger->debugger->debugMessenger, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
typedef struct gnPlatformDebugger_t {
|
typedef struct gnPlatformDebugger_t {
|
||||||
VkDebugUtilsMessengerEXT debugMessenger;
|
VkDebugUtilsMessengerEXT debugMessenger;
|
||||||
VkInstance* instance;
|
|
||||||
} gnPlatformDebugger;
|
} gnPlatformDebugger;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -30,6 +30,12 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnInstance* instance = (gnInstance*)pUserData;
|
gnInstance* instance = (gnInstance*)pUserData;
|
||||||
|
|
||||||
|
if (instance->debugger) {
|
||||||
|
instance->debugger->info.callback(
|
||||||
|
severity, type, data, instance->debugger->info.userData
|
||||||
|
);
|
||||||
|
} else {
|
||||||
instance->instance->instanceMessageCount++;
|
instance->instance->instanceMessageCount++;
|
||||||
if (instance->instance->instanceMessageCount == 1) {
|
if (instance->instance->instanceMessageCount == 1) {
|
||||||
instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
||||||
@@ -42,6 +48,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
|||||||
.severity = severity,
|
.severity = severity,
|
||||||
.type = type
|
.type = type
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,11 @@
|
|||||||
#include "gryphn_debugger.h"
|
#include "gryphn_debugger.h"
|
||||||
#include "core/gryphn_platform_functions.h"
|
#include <core/gryphn_platform_functions.h>
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
|
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info) {
|
||||||
if (instance->debugger != NULL)
|
|
||||||
return GN_DEBUGGER_EXISTS;
|
|
||||||
debugger->info = info;
|
debugger->info = info;
|
||||||
debugger->instance = instance;
|
return GN_SUCCESS;
|
||||||
instance->debugger = debugger;
|
|
||||||
return instance->functions->_gnCreateDebugger(debugger, instance, info);
|
|
||||||
}
|
}
|
||||||
void gnDestroyDebugger(gnDebugger* debugger) {
|
void gnDestroyDebugger(gnDebugger* debugger) {
|
||||||
debugger->instance->functions->_gnDestroyDebugger(debugger);
|
// debugger->instance->functions->_gnDestroyDebugger(debugger);
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ typedef struct gnDebugger_t {
|
|||||||
gnInstance* instance;
|
gnInstance* instance;
|
||||||
} gnDebugger;
|
} gnDebugger;
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
|
||||||
void gnDestroyDebugger(gnDebugger* debugger);
|
void gnDestroyDebugger(gnDebugger* debugger);
|
||||||
|
|
||||||
static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
|
static void gnDebuggerSetErrorMessage(gnDebugger* debugger, gnMessageData data) {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#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"
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
|
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
|
||||||
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
|
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
|
||||||
@@ -11,6 +12,31 @@ gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info
|
|||||||
gnLoadFunctions(instance->dynamicLib, instance->functions);
|
gnLoadFunctions(instance->dynamicLib, instance->functions);
|
||||||
return instance->functions->_gnCreateInstance(instance, info);
|
return instance->functions->_gnCreateInstance(instance, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gnInstanceAttachDebugger(gnInstance *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")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "stdio.h"
|
||||||
void gnDestroyInstance(gnInstance* instance) {
|
void gnDestroyInstance(gnInstance* instance) {
|
||||||
|
if (instance->debugger) {
|
||||||
|
instance->functions->_gnDestroyDebugger(instance->debugger);
|
||||||
|
}
|
||||||
instance->functions->_gnDestroyInstance(instance);
|
instance->functions->_gnDestroyInstance(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gnInstanceReleaseDebugger(gnInstance* instance) {
|
||||||
|
instance->debugger = NULL;
|
||||||
|
}
|
||||||
|
@@ -28,4 +28,6 @@ typedef struct gnInstance_t {
|
|||||||
} gnInstance;
|
} gnInstance;
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
|
void gnInstanceAttachDebugger(gnInstance* istance, struct gnDebugger_t* debugger);
|
||||||
|
void gnInstanceReleaseDebugger(gnInstance* instance);
|
||||||
void gnDestroyInstance(gnInstance* instance);
|
void gnDestroyInstance(gnInstance* instance);
|
||||||
|
Reference in New Issue
Block a user