Hash :
6a6199b4
Author :
Date :
2017-06-05T17:30:55
Add multiview performance tests The patch adds two tests to measure the performance of the ANGLE_multiview extension implementation: 1) The first test renders onto two views by issuing thousands of state changes and draw calls. The aim of the test is to stress the CPU. 2) The second test renders onto two views by drawing with one draw call half a million quads with multiple attributes per vertex. The attributes are passed to the fragment shader where they are used for computing the color. The aim of the test is to stress the GPU's memory system. The patch also extends the ANGLEPerfTest's functionality to only run the benchmark if the necessary extensions are available. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: Ic63d54a69fdddb72439eeeb1951a500fb1247e95 Reviewed-on: https://chromium-review.googlesource.com/597630 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
//
// 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.
//
// ANGLEPerfTests:
// Base class for google test performance tests
//
#include "ANGLEPerfTest.h"
#include "third_party/perf/perf_test.h"
#include <cassert>
#include <cmath>
#include <iostream>
ANGLEPerfTest::ANGLEPerfTest(const std::string &name, const std::string &suffix)
: mName(name),
mSuffix(suffix),
mTimer(CreateTimer()),
mRunTimeSeconds(5.0),
mSkipTest(false),
mNumStepsPerformed(0),
mRunning(true)
{
}
ANGLEPerfTest::~ANGLEPerfTest()
{
SafeDelete(mTimer);
}
void ANGLEPerfTest::run()
{
if (mSkipTest)
{
return;
}
mTimer->start();
while (mRunning)
{
step();
if (mRunning)
{
++mNumStepsPerformed;
}
if (mTimer->getElapsedTime() > mRunTimeSeconds)
{
mRunning = false;
}
}
finishTest();
mTimer->stop();
}
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()
{
}
void ANGLEPerfTest::TearDown()
{
if (mSkipTest)
{
return;
}
double relativeScore = static_cast<double>(mNumStepsPerformed) / mTimer->getElapsedTime();
printResult("score", static_cast<size_t>(std::round(relativeScore)), "score", true);
}
double ANGLEPerfTest::normalizedTime(size_t value) const
{
return static_cast<double>(value) / static_cast<double>(mNumStepsPerformed);
}
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";
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
return "_vulkan";
default:
assert(0);
return "_unk";
}
}
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, testParams.suffix()),
mTestParams(testParams),
mEGLWindow(nullptr),
mOSWindow(nullptr)
{
}
ANGLERenderTest::ANGLERenderTest(const std::string &name,
const RenderTestParams &testParams,
const std::vector<std::string> &extensionPrerequisites)
: ANGLEPerfTest(name, testParams.suffix()),
mTestParams(testParams),
mEGLWindow(nullptr),
mOSWindow(nullptr),
mExtensionPrerequisites(extensionPrerequisites)
{
}
ANGLERenderTest::~ANGLERenderTest()
{
SafeDelete(mOSWindow);
SafeDelete(mEGLWindow);
}
void ANGLERenderTest::SetUp()
{
ANGLEPerfTest::SetUp();
mOSWindow = CreateOSWindow();
mEGLWindow = new EGLWindow(mTestParams.majorVersion, mTestParams.minorVersion,
mTestParams.eglParameters);
mEGLWindow->setSwapInterval(0);
if (!mOSWindow->initialize(mName, mTestParams.windowWidth, mTestParams.windowHeight))
{
FAIL() << "Failed initializing OSWindow";
return;
}
if (!mEGLWindow->initializeGL(mOSWindow))
{
FAIL() << "Failed initializing EGLWindow";
return;
}
if (!areExtensionPrerequisitesFulfilled())
{
mSkipTest = true;
}
if (mSkipTest)
{
std::cout << "Test skipped due to missing extension." << std::endl;
return;
}
initializeBenchmark();
}
void ANGLERenderTest::TearDown()
{
destroyBenchmark();
mEGLWindow->destroyGL();
mOSWindow->destroy();
ANGLEPerfTest::TearDown();
}
void ANGLERenderTest::step()
{
// Clear events that the application did not process from this frame
Event event;
bool closed = false;
while (popEvent(&event))
{
// If the application did not catch a close event, close now
if (event.Type == Event::EVENT_CLOSED)
{
closed = true;
}
}
if (closed)
{
abortTest();
}
else
{
drawBenchmark();
// Swap is needed so that the GPU driver will occasionally flush its internal command queue
// to the GPU. The null device benchmarks are only testing CPU overhead, so they don't need
// to swap.
if (mTestParams.eglParameters.deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{
mEGLWindow->swap();
}
mOSWindow->messageLoop();
}
}
void ANGLERenderTest::finishTest()
{
if (mTestParams.eglParameters.deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{
glFinish();
}
}
bool ANGLERenderTest::popEvent(Event *event)
{
return mOSWindow->popEvent(event);
}
OSWindow *ANGLERenderTest::getWindow()
{
return mOSWindow;
}
bool ANGLERenderTest::areExtensionPrerequisitesFulfilled() const
{
for (const auto &extension : mExtensionPrerequisites)
{
if (!CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extension))
{
return false;
}
}
return true;
}