Hash :
33ea2f97
Author :
Date :
2014-08-29T15:15:01
Added BufferSubData benchmark. BUG=angle:705 Change-Id: I65d557f35e4c9f1d94853a775330a92b7d428847 Reviewed-on: https://chromium-review.googlesource.com/213810 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@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
//
// 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.
//
#ifndef SAMPLE_UTIL_SIMPLE_BENCHMARK_H
#define SAMPLE_UTIL_SIMPLE_BENCHMARK_H
#include <memory>
#include <vector>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <string>
#include "shared_utils.h"
#include "OSWindow.h"
#include "EGLWindow.h"
#include "Timer.h"
class Event;
class SimpleBenchmark
{
public:
SimpleBenchmark(const std::string &name, size_t width, size_t height,
EGLint glesMajorVersion = 2,
EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE);
virtual ~SimpleBenchmark() { };
virtual bool initializeBenchmark() { return true; }
virtual void destroyBenchmark() { }
virtual void stepBenchmark(float dt, double totalTime) { }
virtual void beginDrawBenchmark() { }
virtual void drawBenchmark() = 0;
virtual void endDrawBenchmark() { }
int run();
bool popEvent(Event *event);
OSWindow *getWindow();
protected:
unsigned int mDrawIterations;
double mRunTimeSeconds;
private:
DISALLOW_COPY_AND_ASSIGN(SimpleBenchmark);
bool initialize();
void destroy();
void step(float dt, double totalTime);
void draw();
int mNumFrames;
std::string mName;
bool mRunning;
std::unique_ptr<EGLWindow> mEGLWindow;
std::unique_ptr<OSWindow> mOSWindow;
std::unique_ptr<Timer> mTimer;
};
// Base class
struct BenchmarkParams
{
virtual std::string name() const = 0;
};
template <typename BenchmarkT, typename ParamsT>
inline int RunBenchmarks(const std::vector<ParamsT> &benchmarks)
{
int result;
for (size_t benchIndex = 0; benchIndex < benchmarks.size(); benchIndex++)
{
BenchmarkT benchmark(benchmarks[benchIndex]);
result = benchmark.run();
if (result != 0) { return result; }
}
return 0;
}
#endif // SAMPLE_UTIL_SIMPLE_BENCHMARK_H