Commit 51ff0d05 by Jamie Madill Committed by Commit Bot

Trace Tests: Add vsync-limited mode with a GPU timer.

Local testing on Linux shows that ANGLE and native have the same wall-time, and ANGLE has a 10 ms vs native 6 ms GPU time. Bug: angleproject:5183 Change-Id: I26da678b984af916bfb40e1db6416f5df4f85c08 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2480782 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent ecbac31c
......@@ -341,6 +341,14 @@ double ANGLEPerfTest::printResults()
}
mReporter->AddResult(clockNames[i], retValue);
}
if (gVerboseLogging)
{
double fps =
static_cast<double>(mNumStepsPerformed * mIterationsPerStep) / elapsedTimeSeconds[0];
printf("Ran %0.2lf iterations per second\n", fps);
}
return retValue;
}
......@@ -428,7 +436,18 @@ std::string RenderTestParams::backend() const
std::string RenderTestParams::story() const
{
return (surfaceType == SurfaceType::Offscreen ? "_offscreen" : "");
switch (surfaceType)
{
case SurfaceType::Window:
return "";
case SurfaceType::WindowWithVSync:
return "_vsync";
case SurfaceType::Offscreen:
return "_offscreen";
default:
UNREACHABLE();
return "";
}
}
std::string RenderTestParams::backendAndStory() const
......@@ -562,11 +581,14 @@ void ANGLERenderTest::SetUp()
}
// Disable vsync.
if (!mGLWindow->setSwapInterval(0))
if (mTestParams.surfaceType != SurfaceType::WindowWithVSync)
{
mSkipTest = true;
FAIL() << "Failed setting swap interval";
// FAIL returns.
if (!mGLWindow->setSwapInterval(0))
{
mSkipTest = true;
FAIL() << "Failed setting swap interval";
// FAIL returns.
}
}
mIsTimestampQueryAvailable = IsGLExtensionEnabled("GL_EXT_disjoint_timer_query");
......
......@@ -114,6 +114,7 @@ class ANGLEPerfTest : public testing::Test, angle::NonCopyable
enum class SurfaceType
{
Window,
WindowWithVSync,
Offscreen,
};
......
......@@ -22,7 +22,7 @@ bool gVerboseLogging = false;
double gTestTimeSeconds = 1.0;
int gTestTrials = 3;
bool gNoFinish = false;
bool gEnableOffscreen = false;
bool gEnableAllTraceTests = false;
// Default to three warmup loops. There's no science to this. More than two loops was experimentally
// helpful on a Windows NVIDIA setup when testing with Vulkan and native trace tests.
......@@ -117,9 +117,9 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv)
{
gNoFinish = true;
}
else if (strcmp("--enable-offscreen", argv[argIndex]) == 0)
else if (strcmp("--enable-all-trace-tests", argv[argIndex]) == 0)
{
gEnableOffscreen = true;
gEnableAllTraceTests = true;
}
else
{
......
......@@ -24,7 +24,7 @@ extern int gWarmupLoops;
extern double gTestTimeSeconds;
extern int gTestTrials;
extern bool gNoFinish;
extern bool gEnableOffscreen;
extern bool gEnableAllTraceTests;
inline bool OneFrame()
{
......
......@@ -35,7 +35,7 @@ Several command-line arguments control how the tests run:
* `--test-time`: Run each test trial in a fixed time. Defaults to 1 second.
* `--trials`: Number of times to repeat testing. Defaults to 3.
* `--no-finish`: Don't call glFinish after each test trial.
* `--enable-offscreen`: Offscreen tests disabled by default to reduce test time.
* `--enable-all-trace-tests`: Offscreen and vsync-limited trace tests are disabled by default to reduce test time.
For example, for an endless run with no warmup, run:
......
......@@ -36,9 +36,6 @@ struct TracePerfParams final : public RenderTestParams
majorVersion = 3;
minorVersion = 0;
// Tracking GPU time adds overhead to native traces. http://anglebug.com/4879
trackGpuTime = false;
// Display the frame after every drawBenchmark invocation
iterationsPerStep = 1;
}
......@@ -218,9 +215,9 @@ TracePerfTest::TracePerfTest()
mSkipTest = true;
}
if (param.surfaceType == SurfaceType::Offscreen && !gEnableOffscreen)
if (param.surfaceType != SurfaceType::Window && !gEnableAllTraceTests)
{
printf("Test skipped because offscreen tests are disabled.\n");
printf("Test skipped. Use --enable-all-trace-tests to run.\n");
mSkipTest = true;
}
......@@ -390,17 +387,17 @@ void TracePerfTest::drawBenchmark()
// Add a time sample from GL and the host.
sampleTime();
startGpuTimer();
for (uint32_t frame = mStartFrame; frame <= mEndFrame; ++frame)
{
char frameName[32];
sprintf(frameName, "Frame %u", frame);
beginInternalTraceEvent(frameName);
startGpuTimer();
ReplayFrame(params.testID, frame);
stopGpuTimer();
if (params.surfaceType == SurfaceType::Window)
if (params.surfaceType != SurfaceType::Offscreen)
{
getGLWindow()->swap();
}
......@@ -496,8 +493,6 @@ void TracePerfTest::drawBenchmark()
queryIndex++;
}
}
stopGpuTimer();
}
// Converts a GL timestamp into a host-side CPU time aligned with "GetHostTimeSeconds".
......@@ -646,7 +641,7 @@ void TracePerfTest::onReplayInvalidateFramebuffer(GLenum target,
GLsizei numAttachments,
const GLenum *attachments)
{
if (GetParam().surfaceType == SurfaceType::Window || !isDefaultFramebuffer(target))
if (GetParam().surfaceType != SurfaceType::Offscreen || !isDefaultFramebuffer(target))
{
glInvalidateFramebuffer(target, numAttachments, attachments);
}
......@@ -666,7 +661,7 @@ void TracePerfTest::onReplayInvalidateSubFramebuffer(GLenum target,
GLsizei width,
GLsizei height)
{
if (GetParam().surfaceType == SurfaceType::Window || !isDefaultFramebuffer(target))
if (GetParam().surfaceType != SurfaceType::Offscreen || !isDefaultFramebuffer(target))
{
glInvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
}
......@@ -681,7 +676,8 @@ void TracePerfTest::onReplayInvalidateSubFramebuffer(GLenum target,
void TracePerfTest::onReplayDrawBuffers(GLsizei n, const GLenum *bufs)
{
if (GetParam().surfaceType == SurfaceType::Window || !isDefaultFramebuffer(GL_DRAW_FRAMEBUFFER))
if (GetParam().surfaceType != SurfaceType::Offscreen ||
!isDefaultFramebuffer(GL_DRAW_FRAMEBUFFER))
{
glDrawBuffers(n, bufs);
}
......@@ -694,7 +690,8 @@ void TracePerfTest::onReplayDrawBuffers(GLsizei n, const GLenum *bufs)
void TracePerfTest::onReplayReadBuffer(GLenum src)
{
if (GetParam().surfaceType == SurfaceType::Window || !isDefaultFramebuffer(GL_READ_FRAMEBUFFER))
if (GetParam().surfaceType != SurfaceType::Offscreen ||
!isDefaultFramebuffer(GL_READ_FRAMEBUFFER))
{
glReadBuffer(src);
}
......@@ -709,7 +706,7 @@ void TracePerfTest::onReplayDiscardFramebufferEXT(GLenum target,
GLsizei numAttachments,
const GLenum *attachments)
{
if (GetParam().surfaceType == SurfaceType::Window || !isDefaultFramebuffer(target))
if (GetParam().surfaceType != SurfaceType::Offscreen || !isDefaultFramebuffer(target))
{
glDiscardFramebufferEXT(target, numAttachments, attachments);
}
......@@ -801,6 +798,9 @@ TracePerfParams CombineWithSurfaceType(const TracePerfParams &in, SurfaceType su
out.windowHeight /= 4;
}
// We track GPU time only in frame-rate-limited cases.
out.trackGpuTime = surfaceType == SurfaceType::WindowWithVSync;
return out;
}
......@@ -811,7 +811,7 @@ std::vector<P> gTestsWithID =
CombineWithValues({P()}, AllEnums<RestrictedTraceID>(), CombineTestID);
std::vector<P> gTestsWithSurfaceType =
CombineWithValues(gTestsWithID,
{SurfaceType::Offscreen, SurfaceType::Window},
{SurfaceType::Offscreen, SurfaceType::Window, SurfaceType::WindowWithVSync},
CombineWithSurfaceType);
std::vector<P> gTestsWithRenderer =
CombineWithFuncs(gTestsWithSurfaceType, {Vulkan<P>, VulkanMockICD<P>, Native<P>});
......
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