Hash :
e495e7fd
Author :
Date :
2022-10-14T13:52:47
Redo perf and trace test parameters. - Moves common argument parsing code into test_util. - Changes the perf test arg parsing to use the common functions. - Adds new --use-angle and --use-gl parameters to the trace tests. - Also adds new --offscreen and --vsync parameters to the traces. - Removes the now unneeded --enable-all-trace-tests argument. - Both --arg=value and --arg value work in test suites now. Now, instead of using --enable-all-trace-tests you can specify the backend with --use-angle=swiftshader, --offscreen, or combinations of those parameters. The test names are the same as they were before, but only the configured tests will run in a session. We could opt to simplify the test names in later CLs if we want to simplify the test running. Ideally we'd keep the perf reporting the same because then we'd keep the time series the same on the test infra. This also allows us to split up the trace tests into separate targets on the bots, which will better allow us to control the workloads and sampling of the tests. For example: - angle_perftests becomes - angle_perftests (microbenchmarks) - angle_trace_perf_vulkan_tests (traces with vulkan back-end) - angle_trace_perf_native_tests (traces with system GL) Bug: angleproject:7755 Change-Id: I537168f3a6de96425dfda05ed98220eff9b19b76 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3956937 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
//
// Copyright 2013 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 "SampleApplication.h"
#include "common/debug.h"
#include "util/EGLWindow.h"
#include "util/gles_loader_autogen.h"
#include "util/random_utils.h"
#include "util/shader_utils.h"
#include "util/test_utils.h"
#include "util/util_gl.h"
#include <string.h>
#include <iostream>
#include <utility>
#if defined(ANGLE_PLATFORM_WINDOWS)
# include "util/windows/WGLWindow.h"
#endif // defined(ANGLE_PLATFORM_WINDOWS)
namespace
{
const char *kUseAngleArg = "--use-angle=";
const char *kUseGlArg = "--use-gl=native";
} // anonymous namespace
bool IsGLExtensionEnabled(const std::string &extName)
{
return angle::CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extName);
}
SampleApplication::SampleApplication(std::string name,
int argc,
char **argv,
ClientType clientType,
uint32_t width,
uint32_t height)
: mName(std::move(name)),
mWidth(width),
mHeight(height),
mRunning(false),
mFrameCount(0),
mGLWindow(nullptr),
mEGLWindow(nullptr),
mOSWindow(nullptr),
mDriverType(angle::GLESDriverType::AngleEGL)
{
mPlatformParams.renderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
bool useNativeGL = false;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
if (strncmp(argv[argIndex], kUseAngleArg, strlen(kUseAngleArg)) == 0)
{
const char *arg = argv[argIndex] + strlen(kUseAngleArg);
mPlatformParams.renderer =
angle::GetPlatformANGLETypeFromArg(arg, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
mPlatformParams.deviceType = angle::GetANGLEDeviceTypeFromArg(
arg, EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
}
if (strncmp(argv[argIndex], kUseGlArg, strlen(kUseGlArg)) == 0)
{
useNativeGL = true;
}
}
EGLenum eglClientType = EGL_OPENGL_ES_API;
EGLint glMajorVersion = 2;
EGLint glMinorVersion = 0;
EGLint profileMask = 0;
switch (clientType)
{
case ClientType::ES1:
glMajorVersion = 1;
break;
case ClientType::ES2:
break;
case ClientType::ES3_0:
glMajorVersion = 3;
break;
case ClientType::ES3_1:
glMajorVersion = 3;
glMinorVersion = 1;
break;
case ClientType::GL3_3_CORE:
eglClientType = EGL_OPENGL_API;
glMajorVersion = 3;
glMinorVersion = 3;
profileMask = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
break;
case ClientType::GL3_3_COMPATIBILITY:
eglClientType = EGL_OPENGL_API;
glMajorVersion = 3;
glMinorVersion = 3;
profileMask = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
break;
case ClientType::GL4_6_CORE:
eglClientType = EGL_OPENGL_API;
glMajorVersion = 4;
glMinorVersion = 6;
profileMask = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
break;
case ClientType::GL4_6_COMPATIBILITY:
eglClientType = EGL_OPENGL_API;
glMajorVersion = 4;
glMinorVersion = 6;
profileMask = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
break;
default:
UNREACHABLE();
}
mOSWindow = OSWindow::New();
// Load EGL library so we can initialize the display.
if (useNativeGL)
{
#if defined(ANGLE_PLATFORM_WINDOWS)
mGLWindow = WGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir));
mDriverType = angle::GLESDriverType::SystemWGL;
#else
mGLWindow = EGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension(
angle::GetNativeEGLLibraryNameWithExtension(), angle::SearchType::SystemDir));
mDriverType = angle::GLESDriverType::SystemEGL;
#endif // defined(ANGLE_PLATFORM_WINDOWS)
}
else
{
#if defined(ANGLE_EXPOSE_WGL_ENTRY_POINTS)
mGLWindow = WGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::ModuleDir));
mDriverType = angle::GLESDriverType::SystemWGL;
#else
mGLWindow = mEGLWindow =
EGLWindow::New(eglClientType, glMajorVersion, glMinorVersion, profileMask);
mEntryPointsLib.reset(
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir));
#endif // defined(ANGLE_EXPOSE_WGL_ENTRY_POINTS)
}
}
SampleApplication::~SampleApplication()
{
GLWindowBase::Delete(&mGLWindow);
OSWindow::Delete(&mOSWindow);
}
bool SampleApplication::initialize()
{
return true;
}
void SampleApplication::destroy() {}
void SampleApplication::step(float dt, double totalTime) {}
void SampleApplication::draw() {}
void SampleApplication::swap()
{
mGLWindow->swap();
}
OSWindow *SampleApplication::getWindow() const
{
return mOSWindow;
}
EGLConfig SampleApplication::getConfig() const
{
ASSERT(mEGLWindow);
return mEGLWindow->getConfig();
}
EGLDisplay SampleApplication::getDisplay() const
{
ASSERT(mEGLWindow);
return mEGLWindow->getDisplay();
}
EGLSurface SampleApplication::getSurface() const
{
ASSERT(mEGLWindow);
return mEGLWindow->getSurface();
}
EGLContext SampleApplication::getContext() const
{
ASSERT(mEGLWindow);
return mEGLWindow->getContext();
}
int SampleApplication::run()
{
if (!mOSWindow->initialize(mName, mWidth, mHeight))
{
return -1;
}
mOSWindow->setVisible(true);
ConfigParameters configParams;
configParams.redBits = 8;
configParams.greenBits = 8;
configParams.blueBits = 8;
configParams.alphaBits = 8;
configParams.depthBits = 24;
configParams.stencilBits = 8;
if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mDriverType, mPlatformParams,
configParams))
{
return -1;
}
// Disable vsync
if (!mGLWindow->setSwapInterval(0))
{
return -1;
}
mRunning = true;
int result = 0;
#if defined(ANGLE_ENABLE_ASSERTS)
if (IsGLExtensionEnabled("GL_KHR_debug"))
{
EnableDebugCallback(nullptr, nullptr);
}
#endif
if (!initialize())
{
mRunning = false;
result = -1;
}
mTimer.start();
double prevTime = 0.0;
while (mRunning)
{
double elapsedTime = mTimer.getElapsedWallClockTime();
double deltaTime = elapsedTime - prevTime;
step(static_cast<float>(deltaTime), elapsedTime);
// 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
switch (event.Type)
{
case Event::EVENT_CLOSED:
exit();
break;
case Event::EVENT_KEY_RELEASED:
onKeyUp(event.Key);
break;
case Event::EVENT_KEY_PRESSED:
onKeyDown(event.Key);
break;
default:
break;
}
}
if (!mRunning)
{
break;
}
draw();
swap();
mOSWindow->messageLoop();
prevTime = elapsedTime;
mFrameCount++;
if (mFrameCount % 100 == 0)
{
printf("Rate: %0.2lf frames / second\n",
static_cast<double>(mFrameCount) / mTimer.getElapsedWallClockTime());
}
}
destroy();
mGLWindow->destroyGL();
mOSWindow->destroy();
return result;
}
void SampleApplication::exit()
{
mRunning = false;
}
bool SampleApplication::popEvent(Event *event)
{
return mOSWindow->popEvent(event);
}
void SampleApplication::onKeyUp(const Event::KeyEvent &keyEvent)
{
// Default no-op.
}
void SampleApplication::onKeyDown(const Event::KeyEvent &keyEvent)
{
// Default no-op.
}