Hash :
080d711b
Author :
Date :
2020-01-08T13:04:44
Tests: Add a perf test using traces
This test will load traces and cycle through a set of frames.
The new tests are:
TracePerfTest.Run/gl_trex_200_210
TracePerfTest.Run/gl_trex_800_810
TracePerfTest.Run/gl_trex_900_910
TracePerfTest.Run/gl_trex_1300_1310
To download the traces, you must be granted access and authenticate
with the cloud. See the steps in RestrictedTraces.md for this.
Then add the following to the end of your .gclient file:
"custom_vars": {
"checkout_angle_internal":"True"
},
And run `glcient runhooks`.
To enable building the test, add the following GN arg:
build_angle_trace_perf_tests = true
See the new markdown document for ways to execute the tests.
Bug: angleproject:3630
Change-Id: Ic25cd94fb36b35fcf187e88d3bf9548c65f59755
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1949605
Commit-Queue: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Jamie Madill <jmadill@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 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 240 241 242 243 244 245 246 247 248 249
//
// Copyright 2020 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.
//
// TracePerf:
// Performance test for ANGLE replaying traces.
//
#include <gtest/gtest.h>
#include "common/system_utils.h"
#include "tests/perf_tests/ANGLEPerfTest.h"
#include "util/egl_loader_autogen.h"
#include "restricted_traces/trex_1300_1310/trex_1300_1310_capture_context1.h"
#include "restricted_traces/trex_200_210/trex_200_210_capture_context1.h"
#include "restricted_traces/trex_800_810/trex_800_810_capture_context1.h"
#include "restricted_traces/trex_900_910/trex_900_910_capture_context1.h"
#include <cassert>
#include <functional>
#include <sstream>
using namespace angle;
using namespace egl_platform;
namespace
{
enum class TracePerfTestID
{
TRex200,
TRex800,
TRex900,
TRex1300,
};
struct TracePerfParams final : public RenderTestParams
{
// Common default options
TracePerfParams()
{
majorVersion = 2;
minorVersion = 0;
windowWidth = 1920;
windowHeight = 1080;
trackGpuTime = true;
// Display the frame after every drawBenchmark invocation
iterationsPerStep = 1;
}
std::string story() const override
{
std::stringstream strstr;
strstr << RenderTestParams::story();
switch (testID)
{
case TracePerfTestID::TRex200:
strstr << "_trex_200";
break;
case TracePerfTestID::TRex800:
strstr << "_trex_800";
break;
case TracePerfTestID::TRex900:
strstr << "_trex_900";
break;
case TracePerfTestID::TRex1300:
strstr << "_trex_1300";
break;
default:
assert(0);
break;
}
return strstr.str();
}
TracePerfTestID testID;
};
std::ostream &operator<<(std::ostream &os, const TracePerfParams ¶ms)
{
os << params.backendAndStory().substr(1);
return os;
}
class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterface<TracePerfParams>
{
public:
TracePerfTest();
void initializeBenchmark() override;
void destroyBenchmark() override;
void drawBenchmark() override;
uint32_t mStartFrame;
uint32_t mEndFrame;
std::function<void(uint32_t)> mReplayFunc;
};
TracePerfTest::TracePerfTest()
: ANGLERenderTest("TracePerf", GetParam()), mStartFrame(0), mEndFrame(0)
{}
void TracePerfTest::initializeBenchmark()
{
const auto ¶ms = GetParam();
// TODO: Note the start and end frames in the trace
// i.e. mStartFrame = trex_200_210::kReplayFrameStart
switch (params.testID)
{
// For each case, bootstrap the trace
case TracePerfTestID::TRex200:
mStartFrame = 200;
mEndFrame = 210;
mReplayFunc = trex_200_210::ReplayContext1Frame;
trex_200_210::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_200_210);
trex_200_210::SetupContext1Replay();
break;
case TracePerfTestID::TRex800:
mStartFrame = 800;
mEndFrame = 810;
mReplayFunc = trex_800_810::ReplayContext1Frame;
trex_800_810::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_800_810);
trex_800_810::SetupContext1Replay();
break;
case TracePerfTestID::TRex900:
mStartFrame = 900;
mEndFrame = 910;
mReplayFunc = trex_900_910::ReplayContext1Frame;
trex_900_910::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_900_910);
trex_900_910::SetupContext1Replay();
break;
case TracePerfTestID::TRex1300:
mStartFrame = 1300;
mEndFrame = 1310;
mReplayFunc = trex_1300_1310::ReplayContext1Frame;
trex_1300_1310::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_1300_1310);
trex_1300_1310::SetupContext1Replay();
break;
default:
assert(0);
break;
}
ASSERT_TRUE(mEndFrame > mStartFrame);
getWindow()->setVisible(true);
}
void TracePerfTest::destroyBenchmark() {}
void TracePerfTest::drawBenchmark()
{
startGpuTimer();
for (uint32_t frame = mStartFrame; frame < mEndFrame; ++frame)
{
mReplayFunc(frame);
getGLWindow()->swap();
}
stopGpuTimer();
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_200_210()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex200;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_800_810()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex800;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_900_910()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex900;
return params;
}
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_1300_1310()
{
TracePerfParams params;
params.eglParameters = OPENGL_OR_GLES();
params.testID = TracePerfTestID::TRex1300;
return params;
}
TracePerfParams TRexReplayPerfVulkanParams_200_210()
{
TracePerfParams params;
params.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex200;
return params;
}
TracePerfParams TRexReplayPerfVulkanParams_800_810()
{
TracePerfParams params;
params.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex800;
return params;
}
TracePerfParams TRexReplayPerfVulkanParams_900_910()
{
TracePerfParams params;
params.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex900;
return params;
}
TracePerfParams TRexReplayPerfVulkanParams_1300_1310()
{
TracePerfParams params;
params.eglParameters = VULKAN();
params.testID = TracePerfTestID::TRex1300;
return params;
}
TEST_P(TracePerfTest, Run)
{
run();
}
ANGLE_INSTANTIATE_TEST(TracePerfTest,
TRexReplayPerfOpenGLOrGLESParams_200_210(),
TRexReplayPerfOpenGLOrGLESParams_800_810(),
TRexReplayPerfOpenGLOrGLESParams_900_910(),
TRexReplayPerfOpenGLOrGLESParams_1300_1310(),
TRexReplayPerfVulkanParams_200_210(),
TRexReplayPerfVulkanParams_800_810(),
TRexReplayPerfVulkanParams_900_910(),
TRexReplayPerfVulkanParams_1300_1310());
} // anonymous namespace