Hash :
dd323e95
Author :
Date :
2015-06-09T15:16:31
Only run tests that the current hardware can support. For each config, determine if a context can be created at test instantiation time. This allows skipping of ES3 tests when the hardware does not support ES3. Updated the perf_tests to use the EGLPlatformParameters struct so that they can be filtered in the same way. Change-Id: If664604b057cec4005eb4b63bebd83cd4964b7b2 Reviewed-on: https://chromium-review.googlesource.com/276460 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Tested-by: Geoff Lang <geofflang@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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
//
// Copyright (c) 2014 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 "ANGLEPerfTest.h"
#include "third_party/perf/perf_test.h"
#include <iostream>
#include <cassert>
ANGLEPerfTest::ANGLEPerfTest(const std::string &name, const std::string &suffix)
: mName(name),
mSuffix(suffix),
mRunning(false),
mTimer(nullptr),
mNumFrames(0)
{
mTimer = CreateTimer();
}
ANGLEPerfTest::~ANGLEPerfTest()
{
SafeDelete(mTimer);
}
void ANGLEPerfTest::run()
{
mTimer->start();
double prevTime = 0.0;
while (mRunning)
{
double elapsedTime = mTimer->getElapsedTime();
double deltaTime = elapsedTime - prevTime;
++mNumFrames;
step(static_cast<float>(deltaTime), elapsedTime);
if (!mRunning)
{
break;
}
prevTime = elapsedTime;
}
}
void ANGLEPerfTest::printResult(const std::string &trace, double value, const std::string &units, bool important) const
{
perf_test::PrintResult(mName, mSuffix, trace, value, units, important);
}
void ANGLEPerfTest::printResult(const std::string &trace, size_t value, const std::string &units, bool important) const
{
perf_test::PrintResult(mName, mSuffix, trace, value, units, important);
}
void ANGLEPerfTest::SetUp()
{
mRunning = true;
}
void ANGLEPerfTest::TearDown()
{
printResult("score", static_cast<size_t>(mNumFrames), "score", true);
}
std::string RenderTestParams::suffix() const
{
switch (getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: return "_d3d11";
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE: return "_d3d9";
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE: return "_gl";
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: return "_gles";
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: return "_default";
default: assert(0); return "_unk";
}
}
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, testParams.suffix()),
mTestParams(testParams),
mDrawIterations(10),
mRunTimeSeconds(5.0),
mEGLWindow(nullptr),
mOSWindow(nullptr)
{
}
ANGLERenderTest::~ANGLERenderTest()
{
SafeDelete(mOSWindow);
SafeDelete(mEGLWindow);
}
void ANGLERenderTest::SetUp()
{
mOSWindow = CreateOSWindow();
mEGLWindow = new EGLWindow(mTestParams.widowWidth,
mTestParams.windowHeight,
mTestParams.majorVersion,
mTestParams.eglParameters);
mEGLWindow->setSwapInterval(0);
if (!mOSWindow->initialize(mName, mEGLWindow->getWidth(), mEGLWindow->getHeight()))
{
FAIL() << "Failed initializing OSWindow";
return;
}
if (!mEGLWindow->initializeGL(mOSWindow))
{
FAIL() << "Failed initializing EGLWindow";
return;
}
initializeBenchmark();
ANGLEPerfTest::SetUp();
}
void ANGLERenderTest::TearDown()
{
ANGLEPerfTest::TearDown();
destroyBenchmark();
mEGLWindow->destroyGL();
mOSWindow->destroy();
}
void ANGLERenderTest::step(float dt, double totalTime)
{
stepBenchmark(dt, totalTime);
// Clear events that the application did not process from this frame
Event event;
while (popEvent(&event))
{
// If the application did not catch a close event, close now
if (event.Type == Event::EVENT_CLOSED)
{
mRunning = false;
}
}
if (mRunning)
{
draw();
mEGLWindow->swap();
mOSWindow->messageLoop();
}
}
void ANGLERenderTest::draw()
{
if (mTimer->getElapsedTime() > mRunTimeSeconds)
{
mRunning = false;
return;
}
++mNumFrames;
beginDrawBenchmark();
for (unsigned int iteration = 0; iteration < mDrawIterations; ++iteration)
{
drawBenchmark();
}
endDrawBenchmark();
}
bool ANGLERenderTest::popEvent(Event *event)
{
return mOSWindow->popEvent(event);
}
OSWindow *ANGLERenderTest::getWindow()
{
return mOSWindow;
}