13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSSHADERPERFORMANCEMEASURER_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSSHADERPERFORMANCEMEASURER_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ----------------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Shader performance measurer; handles calibration and measurement 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestCase.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsCalibration.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum PerfCaseType 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASETYPE_VERTEX = 0, 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASETYPE_FRAGMENT, 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASETYPE_BALANCED, 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASETYPE_LAST 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct AttribSpec 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry AttribSpec (const char* name_, const tcu::Vec4& p00_, const tcu::Vec4& p01_, const tcu::Vec4& p10_, const tcu::Vec4& p11_) 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : name (name_) 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , p00 (p00_) 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , p01 (p01_) 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , p10 (p10_) 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , p11 (p11_) 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry AttribSpec (void) {} 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p00; //!< Bottom left. 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p01; //!< Bottom right. 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p10; //!< Top left. 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p11; //!< Top right. 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderPerformanceMeasurer 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Result 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float megaVertPerSec; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float megaFragPerSec; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Result (float megaVertPerSec_, float megaFragPerSec_) : megaVertPerSec(megaVertPerSec_), megaFragPerSec(megaFragPerSec_) {} 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ShaderPerformanceMeasurer (const glu::RenderContext& renderCtx, PerfCaseType measureType); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ShaderPerformanceMeasurer (void) { deinit(); } 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (deUint32 program, const std::vector<AttribSpec>& attributes, int calibratorInitialNumCalls); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void iterate (void); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logParameters (tcu::TestLog& log) const; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isFinished (void) const { return m_state == STATE_FINISHED; } 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Result getResult (void) const { DE_ASSERT(m_state == STATE_FINISHED); return m_result; } 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logMeasurementInfo (tcu::TestLog& log) const; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setGridSize (int gridW, int gridH); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setViewportSize (int width, int height); 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getGridWidth (void) const { return m_gridSizeX; } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getGridHeight (void) const { return m_gridSizeY; } 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getViewportWidth (void) const { return m_viewportWidth; } 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getViewportHeight (void) const { return m_viewportHeight; } 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getFinalCallCount (void) const { DE_ASSERT(m_state == STATE_FINISHED); return m_calibrator.getCallCount(); } 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum State 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STATE_UNINITIALIZED = 0, 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STATE_MEASURING, 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STATE_FINISHED, 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry STATE_LAST 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (int numDrawCalls); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::RenderContext& m_renderCtx; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_gridSizeX; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_gridSizeY; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_viewportWidth; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_viewportHeight; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry State m_state; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_isFirstIteration; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 m_prevRenderStartTime; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Result m_result; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TheilSenCalibrator m_calibrator; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_indexBuffer; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<AttribSpec> m_attributes; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> m_attribBuffers; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_vao; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSSHADERPERFORMANCEMEASURER_HPP 132