Commit e89c8f7c by Ian Elliott Committed by Commit Bot

Add run-time check in EVENT() to disable debug markers

To avoid a large performance impact from adding Vulkan debug-util markers for every GLES entrypoint, the EVENT() macro needs a run-time check that avoids constructing a ScopedPerfEventHelper object. Test: angle_perftests -v --local-output --gtest_filter="TracePerfTest.Run/*nba*" Bug: b/170249632 Change-Id: I422111cdf6f6f713800e7ac587e66582bd00359f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2491009 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent fbec291e
......@@ -120,19 +120,22 @@ std::mutex &GetDebugMutex()
return *g_debugMutex;
}
ScopedPerfEventHelper::ScopedPerfEventHelper(gl::Context *context,
gl::EntryPoint entryPoint,
const char *format,
...)
: mContext(context), mEntryPoint(entryPoint), mFunctionName(GetEntryPointName(entryPoint))
ScopedPerfEventHelper::ScopedPerfEventHelper(gl::Context *context, gl::EntryPoint entryPoint)
: mContext(context), mEntryPoint(entryPoint), mFunctionName(nullptr)
{}
ScopedPerfEventHelper::~ScopedPerfEventHelper()
{
bool dbgTrace = DebugAnnotationsActive();
#if !defined(ANGLE_ENABLE_DEBUG_TRACE)
if (!dbgTrace)
// EGL_Terminate() can set g_debugAnnotator to nullptr; must call DebugAnnotationsActive() here
if (mFunctionName && DebugAnnotationsActive())
{
return;
g_debugAnnotator->endEvent(mContext, mFunctionName, mEntryPoint);
}
#endif // !ANGLE_ENABLE_DEBUG_TRACE
}
void ScopedPerfEventHelper::begin(const char *format, ...)
{
mFunctionName = GetEntryPointName(mEntryPoint);
va_list vararg;
va_start(vararg, format);
......@@ -142,18 +145,8 @@ ScopedPerfEventHelper::ScopedPerfEventHelper(gl::Context *context,
va_end(vararg);
ANGLE_LOG(EVENT) << std::string(&buffer[0], len);
if (dbgTrace)
{
g_debugAnnotator->beginEvent(context, entryPoint, mFunctionName, buffer.data());
}
}
ScopedPerfEventHelper::~ScopedPerfEventHelper()
{
if (DebugAnnotationsActive())
{
g_debugAnnotator->endEvent(mContext, mFunctionName, mEntryPoint);
}
// Do not need to call DebugAnnotationsActive() here, because it was called in EVENT()
g_debugAnnotator->beginEvent(mContext, mEntryPoint, mFunctionName, buffer.data());
}
LogMessage::LogMessage(const char *file, const char *function, int line, LogSeverity severity)
......
......@@ -35,9 +35,10 @@ enum class EntryPoint;
class ScopedPerfEventHelper : angle::NonCopyable
{
public:
ANGLE_FORMAT_PRINTF(4, 5)
ScopedPerfEventHelper(gl::Context *context, gl::EntryPoint entryPoint, const char *format, ...);
ScopedPerfEventHelper(gl::Context *context, gl::EntryPoint entryPoint);
~ScopedPerfEventHelper();
ANGLE_FORMAT_PRINTF(2, 3)
void begin(const char *format, ...);
private:
gl::Context *mContext;
......@@ -255,12 +256,25 @@ std::ostream &FmtHex(std::ostream &os, T value)
#if defined(ANGLE_TRACE_ENABLED)
# if defined(_MSC_VER)
# define EVENT(context, entryPoint, function, message, ...) \
gl::ScopedPerfEventHelper scopedPerfEventHelper##__LINE__( \
context, entryPoint, "%s(" message ")", function, __VA_ARGS__)
gl::ScopedPerfEventHelper scopedPerfEventHelper##__LINE__(context, entryPoint); \
do \
{ \
if (gl::DebugAnnotationsActive()) \
{ \
scopedPerfEventHelper##__LINE__.begin("%s(" message ")", function, \
__VA_ARGS__); \
} \
} while (0)
# else
# define EVENT(context, entryPoint, function, message, ...) \
gl::ScopedPerfEventHelper scopedPerfEventHelper( \
context, entryPoint, "%s(" message ")", function, ##__VA_ARGS__)
gl::ScopedPerfEventHelper scopedPerfEventHelper(context, entryPoint); \
do \
{ \
if (gl::DebugAnnotationsActive()) \
{ \
scopedPerfEventHelper.begin("%s(" message ")", function, ##__VA_ARGS__); \
} \
} while (0)
# endif // _MSC_VER
#else
# define EVENT(message, ...) (void(0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment