mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 00:28:20 +00:00
[host/common] d12: add debug tracing
This commit is contained in:
parent
8d25469d27
commit
fdad5daff8
@ -36,6 +36,7 @@ enum DebugLevel
|
|||||||
DEBUG_LEVEL_INFO,
|
DEBUG_LEVEL_INFO,
|
||||||
DEBUG_LEVEL_WARN,
|
DEBUG_LEVEL_WARN,
|
||||||
DEBUG_LEVEL_ERROR,
|
DEBUG_LEVEL_ERROR,
|
||||||
|
DEBUG_LEVEL_TRACE,
|
||||||
DEBUG_LEVEL_FIXME,
|
DEBUG_LEVEL_FIXME,
|
||||||
DEBUG_LEVEL_FATAL
|
DEBUG_LEVEL_FATAL
|
||||||
};
|
};
|
||||||
@ -43,6 +44,7 @@ enum DebugLevel
|
|||||||
extern const char ** debug_lookup;
|
extern const char ** debug_lookup;
|
||||||
|
|
||||||
void debug_init(void);
|
void debug_init(void);
|
||||||
|
void debug_enableTracing(void);
|
||||||
|
|
||||||
// platform specific debug initialization
|
// platform specific debug initialization
|
||||||
void platform_debugInit(void);
|
void platform_debugInit(void);
|
||||||
@ -81,6 +83,9 @@ void debug_warn(const char * file, unsigned int line, const char * function,
|
|||||||
void debug_error(const char * file, unsigned int line, const char * function,
|
void debug_error(const char * file, unsigned int line, const char * function,
|
||||||
const char * format, ...) __attribute__((format (printf, 4, 5)));
|
const char * format, ...) __attribute__((format (printf, 4, 5)));
|
||||||
|
|
||||||
|
void debug_trace(const char * file, unsigned int line, const char * function,
|
||||||
|
const char * format, ...) __attribute__((format (printf, 4, 5)));
|
||||||
|
|
||||||
#define STRIPPATH(s) ( \
|
#define STRIPPATH(s) ( \
|
||||||
sizeof(s) > 2 && (s)[sizeof(s)- 3] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 2 : \
|
sizeof(s) > 2 && (s)[sizeof(s)- 3] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 2 : \
|
||||||
sizeof(s) > 3 && (s)[sizeof(s)- 4] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 3 : \
|
sizeof(s) > 3 && (s)[sizeof(s)- 4] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 3 : \
|
||||||
@ -112,6 +117,7 @@ void debug_error(const char * file, unsigned int line, const char * function,
|
|||||||
#define DEBUG_INFO(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_INFO, fmt, ##__VA_ARGS__)
|
#define DEBUG_INFO(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_INFO, fmt, ##__VA_ARGS__)
|
||||||
#define DEBUG_WARN(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
#define DEBUG_WARN(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||||
#define DEBUG_ERROR(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
|
#define DEBUG_ERROR(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
|
||||||
|
#define DEBUG_TRACE(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_TRACE, fmt, ##__VA_ARGS__)
|
||||||
#define DEBUG_FIXME(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_FIXME, fmt, ##__VA_ARGS__)
|
#define DEBUG_FIXME(fmt, ...) DEBUG_PRINT(DEBUG_LEVEL_FIXME, fmt, ##__VA_ARGS__)
|
||||||
#define DEBUG_FATAL(fmt, ...) do { \
|
#define DEBUG_FATAL(fmt, ...) do { \
|
||||||
DEBUG_BREAK(); \
|
DEBUG_BREAK(); \
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static uint64_t startTime;
|
static uint64_t startTime;
|
||||||
|
static bool traceEnabled = false;
|
||||||
|
|
||||||
void debug_init(void)
|
void debug_init(void)
|
||||||
{
|
{
|
||||||
@ -32,9 +33,17 @@ void debug_init(void)
|
|||||||
platform_debugInit();
|
platform_debugInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_enableTracing(void)
|
||||||
|
{
|
||||||
|
traceEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
inline static void debug_levelVA(enum DebugLevel level, const char * file,
|
inline static void debug_levelVA(enum DebugLevel level, const char * file,
|
||||||
unsigned int line, const char * function, const char * format, va_list va)
|
unsigned int line, const char * function, const char * format, va_list va)
|
||||||
{
|
{
|
||||||
|
if (level == DEBUG_LEVEL_TRACE && !traceEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
const char * f = strrchr(file, DIRECTORY_SEPARATOR);
|
const char * f = strrchr(file, DIRECTORY_SEPARATOR);
|
||||||
if (!f)
|
if (!f)
|
||||||
f = file;
|
f = file;
|
||||||
@ -94,3 +103,12 @@ void debug_error(const char * file, unsigned int line, const char * function,
|
|||||||
debug_levelVA(DEBUG_LEVEL_ERROR, file, line, function, format, va);
|
debug_levelVA(DEBUG_LEVEL_ERROR, file, line, function, format, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_trace(const char * file, unsigned int line, const char * function,
|
||||||
|
const char * format, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
debug_levelVA(DEBUG_LEVEL_INFO, file, line, function, format, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#define COLOR_RED "\033[0;31m"
|
#define COLOR_RED "\033[0;31m"
|
||||||
#define COLOR_CYAN "\033[0;36m"
|
#define COLOR_CYAN "\033[0;36m"
|
||||||
#define COLOR_WHITE "\033[0;37m"
|
#define COLOR_WHITE "\033[0;37m"
|
||||||
|
#define COLOR_GREY "\033[0;90m"
|
||||||
|
|
||||||
const char ** debug_lookup = NULL;
|
const char ** debug_lookup = NULL;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ void platform_debugInit(void)
|
|||||||
COLOR_RESET "[I] ", // DEBUG_LEVEL_INFO
|
COLOR_RESET "[I] ", // DEBUG_LEVEL_INFO
|
||||||
COLOR_YELLOW "[W] ", // DEBUG_LEVEL_WARN
|
COLOR_YELLOW "[W] ", // DEBUG_LEVEL_WARN
|
||||||
COLOR_RED "[E] ", // DEBUG_LEVEL_ERROR
|
COLOR_RED "[E] ", // DEBUG_LEVEL_ERROR
|
||||||
|
COLOR_GREY "[T] ", // DEBUG_LEVEL_TRACE
|
||||||
COLOR_CYAN "[F] ", // DEBUG_LEVEL_FIXME
|
COLOR_CYAN "[F] ", // DEBUG_LEVEL_FIXME
|
||||||
COLOR_WHITE "[!] " // DEBUG_LEVEL_FATAL
|
COLOR_WHITE "[!] " // DEBUG_LEVEL_FATAL
|
||||||
};
|
};
|
||||||
@ -48,6 +50,7 @@ void platform_debugInit(void)
|
|||||||
"[I] ", // DEBUG_LEVEL_INFO
|
"[I] ", // DEBUG_LEVEL_INFO
|
||||||
"[W] ", // DEBUG_LEVEL_WARN
|
"[W] ", // DEBUG_LEVEL_WARN
|
||||||
"[E] ", // DEBUG_LEVEL_ERROR
|
"[E] ", // DEBUG_LEVEL_ERROR
|
||||||
|
"[T] ", // DEBUG_LEVEL_TRACE
|
||||||
"[F] ", // DEBUG_LEVEL_FIXME
|
"[F] ", // DEBUG_LEVEL_FIXME
|
||||||
"[!] " // DEBUG_LEVEL_FATAL
|
"[!] " // DEBUG_LEVEL_FATAL
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ void platform_debugInit(void)
|
|||||||
"[I] ", // DEBUG_LEVEL_INFO
|
"[I] ", // DEBUG_LEVEL_INFO
|
||||||
"[W] ", // DEBUG_LEVEL_WARN
|
"[W] ", // DEBUG_LEVEL_WARN
|
||||||
"[E] ", // DEBUG_LEVEL_ERROR
|
"[E] ", // DEBUG_LEVEL_ERROR
|
||||||
|
"[T] ", // DEBUG_LEVEL_TRACE
|
||||||
"[F] ", // DEBUG_LEVEL_FIXME
|
"[F] ", // DEBUG_LEVEL_FIXME
|
||||||
"[!] " // DEBUG_LEVEL_FATAL
|
"[!] " // DEBUG_LEVEL_FATAL
|
||||||
};
|
};
|
||||||
|
@ -143,6 +143,8 @@ static bool d12_dd_init(
|
|||||||
// create a DirectX11 context
|
// create a DirectX11 context
|
||||||
comRef_defineLocal(ID3D11Device , d11device);
|
comRef_defineLocal(ID3D11Device , d11device);
|
||||||
comRef_defineLocal(ID3D11DeviceContext, d11context);
|
comRef_defineLocal(ID3D11DeviceContext, d11context);
|
||||||
|
|
||||||
|
DEBUG_TRACE("D3D11CreateDevice");
|
||||||
hr = D3D11CreateDevice(
|
hr = D3D11CreateDevice(
|
||||||
*_adapter,
|
*_adapter,
|
||||||
D3D_DRIVER_TYPE_UNKNOWN,
|
D3D_DRIVER_TYPE_UNKNOWN,
|
||||||
@ -215,6 +217,7 @@ static bool d12_dd_init(
|
|||||||
// we try this twice in case we still get an error on re-initialization
|
// we try this twice in case we still get an error on re-initialization
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("IDXGIOutput1_DuplicateOutput");
|
||||||
hr = IDXGIOutput1_DuplicateOutput(*output1, *(IUnknown **)d11device, dup);
|
hr = IDXGIOutput1_DuplicateOutput(*output1, *(IUnknown **)d11device, dup);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
break;
|
break;
|
||||||
@ -233,6 +236,7 @@ static bool d12_dd_init(
|
|||||||
// we try this twice in case we still get an error on re-initialization
|
// we try this twice in case we still get an error on re-initialization
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("IDXGIOutput5_DuplicateOutput1");
|
||||||
hr = IDXGIOutput5_DuplicateOutput1(
|
hr = IDXGIOutput5_DuplicateOutput1(
|
||||||
*output5,
|
*output5,
|
||||||
*(IUnknown **)d11device,
|
*(IUnknown **)d11device,
|
||||||
@ -310,12 +314,14 @@ static bool d12_dd_deinit(D12Backend * instance)
|
|||||||
|
|
||||||
if (this->release)
|
if (this->release)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("IDXGIOutputDuplication_ReleaseFrame");
|
||||||
IDXGIOutputDuplication_ReleaseFrame(*this->dup);
|
IDXGIOutputDuplication_ReleaseFrame(*this->dup);
|
||||||
this->release = false;
|
this->release = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->desktop)
|
if (this->desktop)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("CloseDesktop");
|
||||||
CloseDesktop(this->desktop);
|
CloseDesktop(this->desktop);
|
||||||
this->desktop = NULL;
|
this->desktop = NULL;
|
||||||
}
|
}
|
||||||
@ -466,14 +472,17 @@ static ID3D12Resource * d12_dd_fetch(D12Backend * instance,
|
|||||||
|
|
||||||
static void d12_dd_openDesktop(DDInstance * this)
|
static void d12_dd_openDesktop(DDInstance * this)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("OpenInputDesktop");
|
||||||
this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ);
|
this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ);
|
||||||
if (!this->desktop)
|
if (!this->desktop)
|
||||||
DEBUG_WINERROR("Failed to open the desktop", GetLastError());
|
DEBUG_WINERROR("Failed to open the desktop", GetLastError());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACE("SetThreadDesktop");
|
||||||
if (!SetThreadDesktop(this->desktop))
|
if (!SetThreadDesktop(this->desktop))
|
||||||
{
|
{
|
||||||
DEBUG_WINERROR("Failed to set the thread desktop", GetLastError());
|
DEBUG_WINERROR("Failed to set the thread desktop", GetLastError());
|
||||||
|
DEBUG_TRACE("CloseDesktop");
|
||||||
CloseDesktop(this->desktop);
|
CloseDesktop(this->desktop);
|
||||||
this->desktop = NULL;
|
this->desktop = NULL;
|
||||||
}
|
}
|
||||||
|
@ -571,6 +571,9 @@ bool app_init(void)
|
|||||||
const char * logFile = option_get_string("os", "logFile");
|
const char * logFile = option_get_string("os", "logFile");
|
||||||
const bool ods = option_get_bool ("os", "ods" );
|
const bool ods = option_get_bool ("os", "ods" );
|
||||||
|
|
||||||
|
if (ods)
|
||||||
|
debug_enableTracing();
|
||||||
|
|
||||||
// redirect stderr to a file
|
// redirect stderr to a file
|
||||||
if (logFile && strcmp(logFile, "stderr") != 0)
|
if (logFile && strcmp(logFile, "stderr") != 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user