Commit ae5a2047 by Jamie Madill Committed by Commit Bot

Trace Tests: Screenshot within the render loop.

Previously we were using a separate mechanism to capture screen shots. This would cause very long traces to replay the entire trace before normal execution. The Maps trace used hundreds of frames and this was timing out the test step. Instead we can capture a screenshot after the first time we run a trace. This will normally not interfere with performance work because we don't usually capture screenshots and do performance work at the same time. Bug: b/172977194 Change-Id: I12cfe2d051d41f1e000a98ac8aef16eb153879c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2552925Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c4ca12e3
...@@ -707,16 +707,6 @@ void ANGLERenderTest::SetUp() ...@@ -707,16 +707,6 @@ void ANGLERenderTest::SetUp()
mTestTrialResults.reserve(gTestTrials); mTestTrialResults.reserve(gTestTrials);
// Capture a screenshot if enabled.
if (gScreenShotDir != nullptr)
{
std::stringstream screenshotNameStr;
screenshotNameStr << gScreenShotDir << GetPathSeparator() << "angle" << mBackend << "_"
<< mStory << ".png";
std::string screenshotName = screenshotNameStr.str();
saveScreenshot(screenshotName);
}
for (int loopIndex = 0; loopIndex < gWarmupLoops; ++loopIndex) for (int loopIndex = 0; loopIndex < gWarmupLoops; ++loopIndex)
{ {
doRunLoop(gCalibrationTimeSeconds, std::numeric_limits<int>::max(), doRunLoop(gCalibrationTimeSeconds, std::numeric_limits<int>::max(),
......
...@@ -112,6 +112,7 @@ class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterfa ...@@ -112,6 +112,7 @@ class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterfa
void sampleTime(); void sampleTime();
void saveScreenshot(const std::string &screenshotName) override; void saveScreenshot(const std::string &screenshotName) override;
void swap();
// For tracking RenderPass/FBO change timing. // For tracking RenderPass/FBO change timing.
QueryInfo mCurrentQuery = {}; QueryInfo mCurrentQuery = {};
...@@ -129,6 +130,7 @@ class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterfa ...@@ -129,6 +130,7 @@ class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterfa
GLuint mReadFramebufferBinding = 0; GLuint mReadFramebufferBinding = 0;
uint32_t mCurrentFrame = 0; uint32_t mCurrentFrame = 0;
uint32_t mOffscreenFrameCount = 0; uint32_t mOffscreenFrameCount = 0;
bool mScreenshotSaved = false;
}; };
class TracePerfTest; class TracePerfTest;
...@@ -481,7 +483,7 @@ void TracePerfTest::drawBenchmark() ...@@ -481,7 +483,7 @@ void TracePerfTest::drawBenchmark()
if (frameX == kFramesPerX - 1 && frameY == kFramesPerY - 1) if (frameX == kFramesPerX - 1 && frameY == kFramesPerY - 1)
{ {
getGLWindow()->swap(); swap();
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
mOffscreenFrameCount = 0; mOffscreenFrameCount = 0;
...@@ -500,7 +502,7 @@ void TracePerfTest::drawBenchmark() ...@@ -500,7 +502,7 @@ void TracePerfTest::drawBenchmark()
} }
else else
{ {
getGLWindow()->swap(); swap();
} }
endInternalTraceEvent(frameName); endInternalTraceEvent(frameName);
...@@ -773,12 +775,25 @@ void TracePerfTest::onReplayDiscardFramebufferEXT(GLenum target, ...@@ -773,12 +775,25 @@ void TracePerfTest::onReplayDiscardFramebufferEXT(GLenum target,
} }
} }
void TracePerfTest::swap()
{
// Capture a screenshot if enabled.
if (gScreenShotDir != nullptr && !mScreenshotSaved)
{
std::stringstream screenshotNameStr;
screenshotNameStr << gScreenShotDir << GetPathSeparator() << "angle" << mBackend << "_"
<< mStory << ".png";
std::string screenshotName = screenshotNameStr.str();
saveScreenshot(screenshotName);
mScreenshotSaved = true;
}
getGLWindow()->swap();
}
void TracePerfTest::saveScreenshot(const std::string &screenshotName) void TracePerfTest::saveScreenshot(const std::string &screenshotName)
{ {
// Render a single frame. // The frame is already rendered and is waiting in the default framebuffer.
RestrictedTraceID testID = GetParam().testID;
const TraceInfo &traceInfo = GetTraceInfo(testID);
ReplayFrame(testID, traceInfo.startFrame);
// RGBA 4-byte data. // RGBA 4-byte data.
uint32_t pixelCount = mTestParams.windowWidth * mTestParams.windowHeight; uint32_t pixelCount = mTestParams.windowWidth * mTestParams.windowHeight;
...@@ -809,16 +824,6 @@ void TracePerfTest::saveScreenshot(const std::string &screenshotName) ...@@ -809,16 +824,6 @@ void TracePerfTest::saveScreenshot(const std::string &screenshotName)
{ {
printf("Saved screenshot: '%s'\n", screenshotName.c_str()); printf("Saved screenshot: '%s'\n", screenshotName.c_str());
} }
// Finish the frame loop.
for (uint32_t nextFrame = traceInfo.startFrame + 1; nextFrame <= traceInfo.endFrame;
++nextFrame)
{
ReplayFrame(testID, nextFrame);
}
ResetReplay(testID);
getGLWindow()->swap();
glFinish();
} }
TEST_P(TracePerfTest, Run) TEST_P(TracePerfTest, Run)
......
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