Hash :
3571ad49
Author :
Date :
2019-02-06T12:24:19
Vulkan:Adding Cmd Buffer Reset tests Resetting cmd buffers in various ways to understand VK driver perf on various devices. Also includes some changes to get the chromium APK wrapper for angle_white_box_perftests compiling. Bug: angleproject:3137 Change-Id: I56bd163cdd6605ce09effe509a9c7ac5e0008e7a Reviewed-on: https://chromium-review.googlesource.com/c/1456482 Commit-Queue: Tobin Ehlis <tobine@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
//
// 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
//
#ifndef PERF_TESTS_ANGLE_PERF_TEST_H_
#define PERF_TESTS_ANGLE_PERF_TEST_H_
#include <gtest/gtest.h>
#include <string>
#include <vector>
#include "platform/Platform.h"
#include "test_utils/angle_test_configs.h"
#include "test_utils/angle_test_instantiate.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
#include "util/Timer.h"
#include "util/util_gl.h"
class Event;
#if !defined(ASSERT_GL_NO_ERROR)
# define ASSERT_GL_NO_ERROR() ASSERT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError())
#endif // !defined(ASSERT_GL_NO_ERROR)
#if !defined(ASSERT_GLENUM_EQ)
# define ASSERT_GLENUM_EQ(expected, actual) \
ASSERT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#endif // !defined(ASSERT_GLENUM_EQ)
// These are trace events according to Google's "Trace Event Format".
// See https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
// Only a subset of the properties are implemented.
struct TraceEvent final
{
TraceEvent() {}
TraceEvent(char phaseIn, const char *categoryNameIn, const char *nameIn, double timestampIn)
: phase(phaseIn), categoryName(categoryNameIn), name(nameIn), timestamp(timestampIn)
{}
char phase = 0;
const char *categoryName = nullptr;
const char *name = nullptr;
double timestamp = 0;
};
class ANGLEPerfTest : public testing::Test, angle::NonCopyable
{
public:
ANGLEPerfTest(const std::string &name,
const std::string &suffix,
unsigned int iterationsPerStep);
virtual ~ANGLEPerfTest();
virtual void step() = 0;
// Called right after the timer starts to let the test initialize other metrics if necessary
virtual void startTest() {}
// Called right before timer is stopped to let the test wait for asynchronous operations.
virtual void finishTest() {}
Timer *getTimer() const { return mTimer; }
protected:
void run();
void printResult(const std::string &trace,
double value,
const std::string &units,
bool important) const;
void printResult(const std::string &trace,
size_t value,
const std::string &units,
bool important) const;
void SetUp() override;
void TearDown() override;
// Normalize a time value according to the number of test loop iterations (mFrameCount)
double normalizedTime(size_t value) const;
// Call if the test step was aborted and the test should stop running.
void abortTest() { mRunning = false; }
unsigned int getNumStepsPerformed() const { return mNumStepsPerformed; }
void doRunLoop(double maxRunTime);
std::string mName;
std::string mSuffix;
Timer *mTimer;
uint64_t mGPUTimeNs;
bool mSkipTest;
private:
double printResults();
unsigned int mStepsToRun;
unsigned int mNumStepsPerformed;
unsigned int mIterationsPerStep;
bool mRunning;
};
struct RenderTestParams : public angle::PlatformParameters
{
virtual ~RenderTestParams() {}
virtual std::string suffix() const;
EGLint windowWidth = 64;
EGLint windowHeight = 64;
unsigned int iterationsPerStep = 0;
bool trackGpuTime = false;
};
class ANGLERenderTest : public ANGLEPerfTest
{
public:
ANGLERenderTest(const std::string &name, const RenderTestParams &testParams);
~ANGLERenderTest();
void addExtensionPrerequisite(const char *extensionName);
virtual void initializeBenchmark() {}
virtual void destroyBenchmark() {}
virtual void drawBenchmark() = 0;
bool popEvent(Event *event);
OSWindow *getWindow();
std::vector<TraceEvent> &getTraceEventBuffer();
virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {}
protected:
const RenderTestParams &mTestParams;
void setWebGLCompatibilityEnabled(bool webglCompatibility);
void setRobustResourceInit(bool enabled);
void startGpuTimer();
void stopGpuTimer();
private:
void SetUp() override;
void TearDown() override;
void step() override;
void startTest() override;
void finishTest() override;
bool areExtensionPrerequisitesFulfilled() const;
static EGLWindow *createEGLWindow(const RenderTestParams &testParams);
GLWindowBase *mGLWindow;
OSWindow *mOSWindow;
std::vector<const char *> mExtensionPrerequisites;
angle::PlatformMethods mPlatformMethods;
GLuint mTimestampQuery;
// Trace event record that can be output.
std::vector<TraceEvent> mTraceEventBuffer;
// Handle to the entry point binding library.
std::unique_ptr<angle::Library> mEntryPointsLib;
};
#endif // PERF_TESTS_ANGLE_PERF_TEST_H_