Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return MoltenVK log level string in pMessageIdName field of debug utils callback data #2224

Merged
merged 2 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT,
.pNext = nullptr,
.flags = 0,
.pMessageIdName = nullptr,
.pMessageIdName = mvkGetReportingLevelString(logLevel),
.messageIdNumber = 0,
.pMessage = pMessage,
.queueLabelCount = 0,
Expand Down
11 changes: 11 additions & 0 deletions MoltenVK/MoltenVK/Utility/MVKBaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,14 @@ class MVKConfigurableMixin {
static inline const MVKConfiguration& mvkGetMVKConfig(MVKBaseObject* mvkObj) {
return mvkObj ? mvkObj->getMVKConfig() : getGlobalMVKConfig();
}

/** Returns the reporting level string associated with the specified MoltenVK log level. */
static constexpr char* mvkGetReportingLevelString(MVKConfigLogLevel logLevel) {
switch (logLevel) {
case MVK_CONFIG_LOG_LEVEL_ERROR: return "mvk-error";
case MVK_CONFIG_LOG_LEVEL_WARNING: return "mvk-warn";
case MVK_CONFIG_LOG_LEVEL_INFO: return "mvk-info";
case MVK_CONFIG_LOG_LEVEL_DEBUG: return "mvk-debug";
default: return "mvk-unknown";
}
}
12 changes: 1 addition & 11 deletions MoltenVK/MoltenVK/Utility/MVKBaseObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@
#pragma mark -
#pragma mark MVKBaseObject

static const char* getReportingLevelString(MVKConfigLogLevel logLevel) {
switch (logLevel) {
case MVK_CONFIG_LOG_LEVEL_ERROR: return "mvk-error";
case MVK_CONFIG_LOG_LEVEL_WARNING: return "mvk-warn";
case MVK_CONFIG_LOG_LEVEL_INFO: return "mvk-info";
case MVK_CONFIG_LOG_LEVEL_DEBUG: return "mvk-debug";
default: return "mvk-unknown";
}
}

string MVKBaseObject::getClassName() { return mvk::getTypeName(this); }

const MVKConfiguration& MVKBaseObject::getMVKConfig() {
Expand Down Expand Up @@ -95,7 +85,7 @@
va_end(origArgs);

// Log the message to the standard error stream
if (shouldLog) { fprintf(stderr, "[%s] %s\n", getReportingLevelString(logLevel), pMessage); }
if (shouldLog) { fprintf(stderr, "[%s] %s\n", mvkGetReportingLevelString(logLevel), pMessage); }

// Broadcast the message to any Vulkan debug report callbacks
if (hasDebugCallbacks) { mvkInst->debugReportMessage(mvkAPIObj, logLevel, pMessage); }
Expand Down
Loading