Rework tracing and perf defines.
Changed ANGLE_DISABLE_* to ANGLE_ENABLE_* for perf and tracing defines so
they are disabled by default. Updated the gyp files to only turn on perf
by default for windows debug builds.
Change-Id: I71706674e6d12fbf4208acc8f100d963b82c7674
Reviewed-on: https://chromium-review.googlesource.com/183250
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/common/debug.cpp b/src/common/debug.cpp
index 5b0f9c1..523802d 100644
--- a/src/common/debug.cpp
+++ b/src/common/debug.cpp
@@ -9,13 +9,13 @@
#include "common/debug.h"
#include "common/system.h"
-#if defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
#include <d3d9.h>
#endif
namespace gl
{
-#if defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
#else
typedef void (*PerfOutputFunction)(unsigned int, const wchar_t*);
@@ -23,7 +23,7 @@
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
{
-#if !defined(ANGLE_DISABLE_PERF)
+#if defined(ANGLE_ENABLE_PERF)
if (perfActive())
{
char message[32768];
@@ -43,15 +43,15 @@
perfFunc(0, wideMessage);
}
-#endif
+#endif // ANGLE_ENABLE_PERF
-#if !defined(ANGLE_DISABLE_TRACE)
+#if defined(ANGLE_ENABLE_TRACE)
#if defined(NDEBUG)
if (traceFileDebugOnly)
{
return;
}
-#endif
+#endif // NDEBUG
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
if (file)
@@ -59,50 +59,50 @@
vfprintf(file, format, vararg);
fclose(file);
}
-#endif
+#endif // ANGLE_ENABLE_TRACE
}
void trace(bool traceFileDebugOnly, const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
-#if defined(ANGLE_DISABLE_PERF) || !defined(ANGLE_ENABLE_D3D_EVENTS)
- output(traceFileDebugOnly, NULL, format, vararg);
-#else
+#if defined(ANGLE_ENABLE_PERF)
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
+#else
+ output(traceFileDebugOnly, NULL, format, vararg);
#endif
va_end(vararg);
}
bool perfActive()
{
-#if defined(ANGLE_DISABLE_PERF) || !defined(ANGLE_ENABLE_D3D_EVENTS)
- return false;
-#else
+#if defined(ANGLE_ENABLE_PERF)
static bool active = D3DPERF_GetStatus() != 0;
return active;
+#else
+ return false;
#endif
}
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
{
-#if !defined(ANGLE_DISABLE_PERF) && defined(ANGLE_ENABLE_D3D_EVENTS)
-#if defined(ANGLE_DISABLE_TRACE)
+#if defined(ANGLE_ENABLE_PERF)
+#if !defined(ANGLE_ENABLE_TRACE)
if (!perfActive())
{
return;
}
-#endif
+#endif // !ANGLE_ENABLE_TRACE
va_list vararg;
va_start(vararg, format);
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
va_end(vararg);
-#endif
+#endif // ANGLE_ENABLE_PERF
}
ScopedPerfEventHelper::~ScopedPerfEventHelper()
{
-#if !defined(ANGLE_DISABLE_PERF) && defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
if (perfActive())
{
D3DPERF_EndEvent();
diff --git a/src/common/debug.h b/src/common/debug.h
index 8bebd53..22cd7bc 100644
--- a/src/common/debug.h
+++ b/src/common/debug.h
@@ -39,33 +39,35 @@
}
// A macro to output a trace of a function call and its arguments to the debugging log
-#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
-#define TRACE(message, ...) (void(0))
-#else
+#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define TRACE(message, ...) (void(0))
#endif
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
-#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
-#define FIXME(message, ...) (void(0))
-#else
+#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define FIXME(message, ...) (void(0))
#endif
// A macro to output a function call and its arguments to the debugging log, in case of error.
-#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
-#define ERR(message, ...) (void(0))
-#else
+#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
#define ERR(message, ...) gl::trace(false, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define ERR(message, ...) (void(0))
#endif
// A macro to log a performance event around a scope.
-#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
-#define EVENT(message, ...) (void(0))
-#elif defined(_MSC_VER)
+#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
+#if defined(_MSC_VER)
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__(__FUNCTION__ message "\n", __VA_ARGS__);
#else
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__);
+#endif // _MSC_VER
+#else
+#define EVENT(message, ...) (void(0))
#endif
// A macro asserting a condition and outputting failures to the debug log
diff --git a/src/libEGL.gypi b/src/libEGL.gypi
index a3fd462..13ba774 100644
--- a/src/libEGL.gypi
+++ b/src/libEGL.gypi
@@ -19,10 +19,6 @@
'../include',
'libGLESv2',
],
- 'defines':
- [
- 'ANGLE_ENABLE_D3D_EVENTS',
- ],
'sources': [ '<!@(python enumerate_files.py common libEGL -types *.cpp *.h *.def libEGL.rc)' ],
# TODO(jschuh): http://crbug.com/167187 size_t -> int
'msvs_disabled_warnings': [ 4267 ],
@@ -36,6 +32,16 @@
],
},
},
+ 'configurations':
+ {
+ 'Debug':
+ {
+ 'defines':
+ [
+ 'ANGLE_ENABLE_PERF',
+ ],
+ },
+ },
},
],
},
diff --git a/src/libEGL/main.cpp b/src/libEGL/main.cpp
index c146925..80dcc34 100644
--- a/src/libEGL/main.cpp
+++ b/src/libEGL/main.cpp
@@ -55,7 +55,7 @@
{
case DLL_PROCESS_ATTACH:
{
-#if !defined(ANGLE_DISABLE_TRACE)
+#if defined(ANGLE_ENABLE_TRACE)
FILE *debug = fopen(TRACE_OUTPUT_FILE, "rt");
if (debug)
diff --git a/src/libGLESv2.gypi b/src/libGLESv2.gypi
index 6d5aa2d..04ef356 100644
--- a/src/libGLESv2.gypi
+++ b/src/libGLESv2.gypi
@@ -7,7 +7,6 @@
{
'defines':
[
- 'ANGLE_DISABLE_TRACE',
'ANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL1',
'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }',
],
@@ -29,11 +28,6 @@
'../include',
'libGLESv2',
],
- 'defines':
- [
- 'NOMINMAX',
- 'ANGLE_ENABLE_D3D_EVENTS',
- ],
'sources': [ '<!@(python enumerate_files.py common libGLESv2 third_party/murmurhash -types *.cpp *.h *.hlsl *.vs *.ps *.bat *.def libGLESv2.rc)' ],
# TODO(jschuh): http://crbug.com/167187 size_t -> int
'msvs_disabled_warnings': [ 4267 ],
@@ -48,6 +42,16 @@
]
}
},
+ 'configurations':
+ {
+ 'Debug':
+ {
+ 'defines':
+ [
+ 'ANGLE_ENABLE_PERF',
+ ],
+ },
+ },
},
],
},