Edit

kc3-lang/angle/src/tests/perf_tests/ANGLEPerfTest.h

Branch :

  • Show log

    Commit

  • Author : Corentin Wallez
    Date : 2015-05-21 10:39:43
    Hash : b45a80db
    Message : Make perftests use ANGLE_INSTANTIATE_TEST This also moves ANGLE_INSTANTIATE_TEST to its own header and makes it generic over the type of test parameter. BUG=angleproject:892 Change-Id: Id4e3929d7ad06964b3259015915be84a8ee414f9 Reviewed-on: https://chromium-review.googlesource.com/272553 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>

  • src/tests/perf_tests/ANGLEPerfTest.h
  • //
    // 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 <EGL/egl.h>
    #include <EGL/eglext.h>
    
    #include "EGLWindow.h"
    #include "OSWindow.h"
    #include "Timer.h"
    #include "common/angleutils.h"
    #include "common/debug.h"
    #include "test_utils/angle_test_instantiate.h"
    
    class Event;
    
    #ifndef ASSERT_GL_NO_ERROR
    #define ASSERT_GL_NO_ERROR() ASSERT_TRUE(glGetError() == GL_NO_ERROR)
    #endif
    
    class ANGLEPerfTest : public testing::Test, angle::NonCopyable
    {
      public:
        ANGLEPerfTest(const std::string &name, const std::string &suffix);
        virtual ~ANGLEPerfTest();
    
        virtual void step(float dt, double totalTime) = 0;
    
      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;
    
        std::string mName;
        std::string mSuffix;
    
        bool mRunning;
        Timer *mTimer;
        int mNumFrames;
    };
    
    struct RenderTestParams
    {
        virtual std::string suffix() const;
    
        EGLint getRenderer() const;
    
        EGLint requestedRenderer;
        EGLint deviceType;
        EGLint glesMajorVersion;
        EGLint widowWidth;
        EGLint windowHeight;
    };
    
    class ANGLERenderTest : public ANGLEPerfTest
    {
      public:
        ANGLERenderTest(const std::string &name, const RenderTestParams &testParams);
        ~ANGLERenderTest();
    
        virtual void initializeBenchmark() { }
        virtual void destroyBenchmark() { }
    
        virtual void stepBenchmark(float dt, double totalTime) { }
    
        virtual void beginDrawBenchmark() { }
        virtual void drawBenchmark() = 0;
        virtual void endDrawBenchmark() { }
    
        bool popEvent(Event *event);
    
        OSWindow *getWindow();
    
      protected:
        const RenderTestParams &mTestParams;
        unsigned int mDrawIterations;
        double mRunTimeSeconds;
    
      private:
        void SetUp() override;
        void TearDown() override;
    
        void step(float dt, double totalTime) override;
        void draw();
    
        EGLWindow *mEGLWindow;
        OSWindow *mOSWindow;
    };
    
    #endif // PERF_TESTS_ANGLE_PERF_TEST_H_