Skip to content

Commit

Permalink
Add TraceFrameIndex atrace counter
Browse files Browse the repository at this point in the history
This adds TraceFrameIndex atrace counter so that we can identify the
exact frame index in the trace.

Bug: b/319871513
Change-Id: I6cd20dd78746dd03b43ecea2ac7b102902e82d37
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5874417
Commit-Queue: Roman Lavrov <[email protected]>
Reviewed-by: Roman Lavrov <[email protected]>
Commit-Queue: Charlie Lao <[email protected]>
  • Loading branch information
cclao authored and Angle LUCI CQ committed Sep 20, 2024
1 parent 0de7c43 commit 86a24b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/tests/perf_tests/ANGLEPerfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,22 +258,13 @@ bool ATraceEnabled()
{
return gATraceIsEnabled();
}

void ATraceCounter(const char *counterName, int64_t counterValue)
{
if (ATraceEnabled())
{
gATraceSetCounter(counterName, counterValue);
}
}
#else
constexpr bool kHasATrace = false;
void SetupATrace() {}
bool ATraceEnabled()
{
return false;
}
void ATraceCounter(const char *counterName, int64_t counterValue) {}
#endif
} // anonymous namespace

Expand Down Expand Up @@ -349,7 +340,7 @@ void ANGLEPerfTest::run()
printf("Test Trials: %d\n", static_cast<int>(numTrials));
}

ATraceCounter("TraceStage", 3);
atraceCounter("TraceStage", 3);

for (uint32_t trial = 0; trial < numTrials; ++trial)
{
Expand All @@ -366,7 +357,7 @@ void ANGLEPerfTest::run()
}
}

ATraceCounter("TraceStage", 0);
atraceCounter("TraceStage", 0);

if (gVerboseLogging && !mTestTrialResults.empty())
{
Expand Down Expand Up @@ -417,7 +408,7 @@ void ANGLEPerfTest::runTrial(double maxRunTime, int maxStepsToRun, RunTrialPolic
if (loopStepsPerformed > 0) // 0 at the first frame of the first loop
{
int frameTimeAvgUs = int(1e6 * (wallTime - lastLoopWallTime) / loopStepsPerformed);
ATraceCounter("TraceLoopFrameTimeAvgUs", frameTimeAvgUs);
atraceCounter("TraceLoopFrameTimeAvgUs", frameTimeAvgUs);
loopStepsPerformed = 0;
}
lastLoopWallTime = wallTime;
Expand Down Expand Up @@ -479,7 +470,7 @@ void ANGLEPerfTest::runTrial(double maxRunTime, int maxStepsToRun, RunTrialPolic

if (runPolicy == RunTrialPolicy::RunContinuously)
{
ATraceCounter("TraceLoopFrameTimeAvgUs", 0);
atraceCounter("TraceLoopFrameTimeAvgUs", 0);
}
finishTest();
mTrialTimer.stop();
Expand All @@ -490,7 +481,7 @@ void ANGLEPerfTest::SetUp()
{
if (gWarmup)
{
ATraceCounter("TraceStage", 1);
atraceCounter("TraceStage", 1);

// Trace tests run with glFinish for a loop (getStepAlignment == frameCount).
int warmupSteps = getStepAlignment();
Expand All @@ -506,7 +497,7 @@ void ANGLEPerfTest::SetUp()

if (warmupSteps > 1) // trace tests only: getStepAlignment() is 1 otherwise
{
ATraceCounter("TraceStage", 2);
atraceCounter("TraceStage", 2);

// Short traces (e.g. 10 frames) have some spikes after the first loop b/308975999
const double kMinWarmupTime = 1.5;
Expand Down Expand Up @@ -686,6 +677,16 @@ int ANGLEPerfTest::getStepAlignment() const
return 1;
}

void ANGLEPerfTest::atraceCounter(const char *counterName, int64_t counterValue)
{
#if defined(ANGLE_PLATFORM_ANDROID)
if (ATraceEnabled())
{
gATraceSetCounter(counterName, counterValue);
}
#endif
}

RenderTestParams::RenderTestParams()
{
#if defined(ANGLE_DEBUG_LAYERS_ENABLED)
Expand Down
2 changes: 2 additions & 0 deletions src/tests/perf_tests/ANGLEPerfTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
FAIL() << reason;
}

void atraceCounter(const char *counterName, int64_t counterValue);

std::string mName;
std::string mBackend;
std::string mStory;
Expand Down
1 change: 1 addition & 0 deletions src/tests/perf_tests/TracePerfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,7 @@ void TracePerfTest::drawBenchmark()
beginInternalTraceEvent(frameName);

startGpuTimer();
atraceCounter("TraceFrameIndex", mCurrentFrame);
mTraceReplay->replayFrame(mCurrentFrame);
stopGpuTimer();

Expand Down

0 comments on commit 86a24b8

Please sign in to comment.