Skip to content

Commit

Permalink
Merge pull request #2224 from SRSaunders/report-idname
Browse files Browse the repository at this point in the history
Return MoltenVK log level string in pMessageIdName field of debug utils callback data
  • Loading branch information
billhollings committed May 4, 2024
2 parents e0a77df + a6a44a7 commit f6fc303
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
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

0 comments on commit f6fc303

Please sign in to comment.