Hash :
ae2d8a3a
Author :
Date :
2015-04-07T11:21:07
Add Platform methods for event tracing. Event tracing requires pulling in timing counters, so we can sync with Chromium's timestamps. It may require a bit more tricky stuff to sync ANGLE's GPU timestamps with trace timestamps, but should allow us to add GPU trace events in the future. BUG=chromium:436191 BUG=angleproject:966 Change-Id: Ie1dc2981650d96888f988fa74b6fa435fbe8edc2 Reviewed-on: https://chromium-review.googlesource.com/263781 Reviewed-by: Brandon Jones <bajones@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "common/event_tracer.h"
#include "common/debug.h"
#include "platform/Platform.h"
namespace gl
{
GetCategoryEnabledFlagFunc g_getCategoryEnabledFlag;
AddTraceEventFunc g_addTraceEvent;
} // namespace gl
namespace gl
{
const unsigned char *TraceGetTraceCategoryEnabledFlag(const char *name)
{
angle::Platform *platform = ANGLEPlatformCurrent();
ASSERT(platform);
// TODO(jmadill): only use platform once it's working
const unsigned char *categoryEnabledFlag = platform->getTraceCategoryEnabledFlag(name);
if (categoryEnabledFlag != nullptr)
{
return categoryEnabledFlag;
}
if (g_getCategoryEnabledFlag)
{
return g_getCategoryEnabledFlag(name);
}
static unsigned char disabled = 0;
return &disabled;
}
void TraceAddTraceEvent(char phase, const unsigned char* categoryGroupEnabled, const char* name, unsigned long long id,
int numArgs, const char** argNames, const unsigned char* argTypes,
const unsigned long long* argValues, unsigned char flags)
{
angle::Platform *platform = ANGLEPlatformCurrent();
ASSERT(platform);
// TODO(jmadill): only use platform once it's working
double timestamp = platform->monotonicallyIncreasingTime();
if (timestamp != 0)
{
angle::Platform::TraceEventHandle handle =
platform->addTraceEvent(phase,
categoryGroupEnabled,
name,
id,
timestamp,
numArgs,
argNames,
argTypes,
argValues,
flags);
ASSERT(handle != 0);
UNUSED_ASSERTION_VARIABLE(handle);
}
else if (g_addTraceEvent)
{
g_addTraceEvent(phase, categoryGroupEnabled, name, id, numArgs, argNames, argTypes, argValues, flags);
}
}
} // namespace gl