2
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
7
// Performance test for ANGLE replaying traces.
10
#include <gtest/gtest.h>
11
#include "common/system_utils.h"
12
#include "tests/perf_tests/ANGLEPerfTest.h"
13
#include "util/egl_loader_autogen.h"
15
#include "restricted_traces/trex_1300_1310/trex_1300_1310_capture_context1.h"
16
#include "restricted_traces/trex_200_210/trex_200_210_capture_context1.h"
17
#include "restricted_traces/trex_800_810/trex_800_810_capture_context1.h"
18
#include "restricted_traces/trex_900_910/trex_900_910_capture_context1.h"
24
using namespace angle;
25
using namespace egl_platform;
30
enum class TracePerfTestID
38
struct TracePerfParams final : public RenderTestParams
40
// Common default options
49
// Display the frame after every drawBenchmark invocation
50
iterationsPerStep = 1;
53
std::string story() const override
55
std::stringstream strstr;
57
strstr << RenderTestParams::story();
61
case TracePerfTestID::TRex200:
62
strstr << "_trex_200";
64
case TracePerfTestID::TRex800:
65
strstr << "_trex_800";
67
case TracePerfTestID::TRex900:
68
strstr << "_trex_900";
70
case TracePerfTestID::TRex1300:
71
strstr << "_trex_1300";
81
TracePerfTestID testID;
84
std::ostream &operator<<(std::ostream &os, const TracePerfParams ¶ms)
86
os << params.backendAndStory().substr(1);
90
class TracePerfTest : public ANGLERenderTest, public ::testing::WithParamInterface<TracePerfParams>
95
void initializeBenchmark() override;
96
void destroyBenchmark() override;
97
void drawBenchmark() override;
101
std::function<void(uint32_t)> mReplayFunc;
104
TracePerfTest::TracePerfTest()
105
: ANGLERenderTest("TracePerf", GetParam()), mStartFrame(0), mEndFrame(0)
108
void TracePerfTest::initializeBenchmark()
110
const auto ¶ms = GetParam();
112
// TODO: Note the start and end frames in the trace
113
// i.e. mStartFrame = trex_200_210::kReplayFrameStart
114
switch (params.testID)
116
// For each case, bootstrap the trace
117
case TracePerfTestID::TRex200:
120
mReplayFunc = trex_200_210::ReplayContext1Frame;
121
trex_200_210::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_200_210);
122
trex_200_210::SetupContext1Replay();
124
case TracePerfTestID::TRex800:
127
mReplayFunc = trex_800_810::ReplayContext1Frame;
128
trex_800_810::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_800_810);
129
trex_800_810::SetupContext1Replay();
131
case TracePerfTestID::TRex900:
134
mReplayFunc = trex_900_910::ReplayContext1Frame;
135
trex_900_910::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_900_910);
136
trex_900_910::SetupContext1Replay();
138
case TracePerfTestID::TRex1300:
141
mReplayFunc = trex_1300_1310::ReplayContext1Frame;
142
trex_1300_1310::SetBinaryDataDir(ANGLE_TRACE_DATA_DIR_trex_1300_1310);
143
trex_1300_1310::SetupContext1Replay();
150
ASSERT_TRUE(mEndFrame > mStartFrame);
152
getWindow()->setVisible(true);
155
void TracePerfTest::destroyBenchmark() {}
157
void TracePerfTest::drawBenchmark()
161
for (uint32_t frame = mStartFrame; frame < mEndFrame; ++frame)
164
getGLWindow()->swap();
170
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_200_210()
172
TracePerfParams params;
173
params.eglParameters = OPENGL_OR_GLES();
174
params.testID = TracePerfTestID::TRex200;
178
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_800_810()
180
TracePerfParams params;
181
params.eglParameters = OPENGL_OR_GLES();
182
params.testID = TracePerfTestID::TRex800;
186
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_900_910()
188
TracePerfParams params;
189
params.eglParameters = OPENGL_OR_GLES();
190
params.testID = TracePerfTestID::TRex900;
194
TracePerfParams TRexReplayPerfOpenGLOrGLESParams_1300_1310()
196
TracePerfParams params;
197
params.eglParameters = OPENGL_OR_GLES();
198
params.testID = TracePerfTestID::TRex1300;
202
TracePerfParams TRexReplayPerfVulkanParams_200_210()
204
TracePerfParams params;
205
params.eglParameters = VULKAN();
206
params.testID = TracePerfTestID::TRex200;
210
TracePerfParams TRexReplayPerfVulkanParams_800_810()
212
TracePerfParams params;
213
params.eglParameters = VULKAN();
214
params.testID = TracePerfTestID::TRex800;
218
TracePerfParams TRexReplayPerfVulkanParams_900_910()
220
TracePerfParams params;
221
params.eglParameters = VULKAN();
222
params.testID = TracePerfTestID::TRex900;
226
TracePerfParams TRexReplayPerfVulkanParams_1300_1310()
228
TracePerfParams params;
229
params.eglParameters = VULKAN();
230
params.testID = TracePerfTestID::TRex1300;
234
TEST_P(TracePerfTest, Run)
239
ANGLE_INSTANTIATE_TEST(TracePerfTest,
240
TRexReplayPerfOpenGLOrGLESParams_200_210(),
241
TRexReplayPerfOpenGLOrGLESParams_800_810(),
242
TRexReplayPerfOpenGLOrGLESParams_900_910(),
243
TRexReplayPerfOpenGLOrGLESParams_1300_1310(),
244
TRexReplayPerfVulkanParams_200_210(),
245
TRexReplayPerfVulkanParams_800_810(),
246
TRexReplayPerfVulkanParams_900_910(),
247
TRexReplayPerfVulkanParams_1300_1310());
249
} // anonymous namespace