mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 05:20:45 +00:00
Add custom logging callback mechanism to NvPerfUtility
This is needed to send log messages to the RenderDoc UI rather than to stderr.
This commit is contained in:
committed by
Baldur Karlsson
parent
fce1920d5b
commit
a362e42124
@@ -174,6 +174,15 @@ namespace nv { namespace perf {
|
||||
COUNT
|
||||
};
|
||||
|
||||
using WriteCustomLogCallbackFn = void (*)(
|
||||
const char* /* pPrefix */,
|
||||
const char* /* pDate */,
|
||||
const char* /* pTime */,
|
||||
const char* /* pFunctionName */,
|
||||
const char* /* pMessage */,
|
||||
void* /* pData */
|
||||
);
|
||||
|
||||
struct LogSettings
|
||||
{
|
||||
uint32_t volumeLevels[(unsigned)LogSeverity::COUNT] = { 50, 50, 50 };
|
||||
@@ -183,13 +192,15 @@ namespace nv { namespace perf {
|
||||
#else
|
||||
bool writePlatform = false;
|
||||
#endif
|
||||
bool writeStderr = true;
|
||||
FILE* writeFileFD = nullptr;
|
||||
bool appendToFile = true;
|
||||
LogSeverity flushFileSeverity = LogSeverity::Err;
|
||||
bool writeStderr = true;
|
||||
FILE* writeFileFD = nullptr;
|
||||
bool appendToFile = true;
|
||||
LogSeverity flushFileSeverity = LogSeverity::Err;
|
||||
WriteCustomLogCallbackFn pFnWriteCustomCB = nullptr;
|
||||
void* writeCustomData = nullptr;
|
||||
|
||||
bool logDate = true;
|
||||
bool logTime = true;
|
||||
bool logDate = true;
|
||||
bool logTime = true;
|
||||
|
||||
LogSettings()
|
||||
{
|
||||
@@ -327,6 +338,18 @@ namespace nv { namespace perf {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void UserLogEnableCustom(WriteCustomLogCallbackFn cb, void* data)
|
||||
{
|
||||
LogSettings* pSettings = GetLogSettingsStorage_();
|
||||
pSettings->pFnWriteCustomCB = cb;
|
||||
pSettings->writeCustomData = data;
|
||||
}
|
||||
|
||||
inline void UserLogDisableCustom()
|
||||
{
|
||||
UserLogEnableCustom(nullptr, nullptr);
|
||||
}
|
||||
|
||||
inline void UserLogImplStderr(const char* pMessage)
|
||||
{
|
||||
fprintf(stderr, "%s", pMessage);
|
||||
@@ -446,6 +469,17 @@ namespace nv { namespace perf {
|
||||
UserLogImplFileFlush(settings.writeFileFD);
|
||||
}
|
||||
}
|
||||
if (settings.pFnWriteCustomCB)
|
||||
{
|
||||
settings.pFnWriteCustomCB(
|
||||
pPrefix,
|
||||
settings.logDate ? datebuf : nullptr,
|
||||
settings.logTime ? timebuf : nullptr,
|
||||
pFunctionName,
|
||||
str.c_str(),
|
||||
settings.writeCustomData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool InitializeNvPerf()
|
||||
|
||||
Reference in New Issue
Block a user