1 #ifndef _GLSSHADERPERFORMANCEMEASURER_HPP
2 #define _GLSSHADERPERFORMANCEMEASURER_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL (ES) Module
5 * -----------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Shader performance measurer; handles calibration and measurement
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
28 #include "tcuVector.hpp"
29 #include "gluRenderContext.hpp"
30 #include "glsCalibration.hpp"
48 AttribSpec (const char* name_, const tcu::Vec4& p00_, const tcu::Vec4& p01_, const tcu::Vec4& p10_, const tcu::Vec4& p11_)
60 tcu::Vec4 p00; //!< Bottom left.
61 tcu::Vec4 p01; //!< Bottom right.
62 tcu::Vec4 p10; //!< Top left.
63 tcu::Vec4 p11; //!< Top right.
66 class ShaderPerformanceMeasurer
74 Result (float megaVertPerSec_, float megaFragPerSec_) : megaVertPerSec(megaVertPerSec_), megaFragPerSec(megaFragPerSec_) {}
77 ShaderPerformanceMeasurer (const glu::RenderContext& renderCtx, PerfCaseType measureType);
78 ~ShaderPerformanceMeasurer (void) { deinit(); }
80 void init (deUint32 program, const std::vector<AttribSpec>& attributes, int calibratorInitialNumCalls);
84 void logParameters (tcu::TestLog& log) const;
85 bool isFinished (void) const { return m_state == STATE_FINISHED; }
86 Result getResult (void) const { DE_ASSERT(m_state == STATE_FINISHED); return m_result; }
87 void logMeasurementInfo (tcu::TestLog& log) const;
89 void setGridSize (int gridW, int gridH);
90 void setViewportSize (int width, int height);
92 int getGridWidth (void) const { return m_gridSizeX; }
93 int getGridHeight (void) const { return m_gridSizeY; }
94 int getViewportWidth (void) const { return m_viewportWidth; }
95 int getViewportHeight (void) const { return m_viewportHeight; }
97 int getFinalCallCount (void) const { DE_ASSERT(m_state == STATE_FINISHED); return m_calibrator.getCallCount(); }
102 STATE_UNINITIALIZED = 0,
109 void render (int numDrawCalls);
111 const glu::RenderContext& m_renderCtx;
115 int m_viewportHeight;
118 bool m_isFirstIteration;
119 deUint64 m_prevRenderStartTime;
121 TheilSenCalibrator m_calibrator;
122 deUint32 m_indexBuffer;
123 std::vector<AttribSpec> m_attributes;
124 std::vector<deUint32> m_attribBuffers;
131 #endif // _GLSSHADERPERFORMANCEMEASURER_HPP