Home | History | Annotate | Download | only in glshared
      1 #ifndef _GLSSHADERPERFORMANCECASE_HPP
      2 #define _GLSSHADERPERFORMANCECASE_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program OpenGL (ES) Module
      5  * -----------------------------------------------
      6  *
      7  * Copyright 2014 The Android Open Source Project
      8  *
      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
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     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.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Single-program test case wrapper for ShaderPerformanceMeasurer.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "tcuTestCase.hpp"
     28 #include "gluRenderContext.hpp"
     29 #include "gluShaderProgram.hpp"
     30 #include "glsShaderPerformanceMeasurer.hpp"
     31 #include "deSharedPtr.hpp"
     32 
     33 namespace deqp
     34 {
     35 namespace gls
     36 {
     37 
     38 class ShaderPerformanceCase : public tcu::TestCase
     39 {
     40 public:
     41 	struct InitialCalibration
     42 	{
     43 		int initialNumCalls;
     44 		InitialCalibration (void) : initialNumCalls(1) {}
     45 	};
     46 
     47 										ShaderPerformanceCase				(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, PerfCaseType caseType);
     48 										~ShaderPerformanceCase				(void);
     49 
     50 	void								setCalibrationInitialParamStorage	(const de::SharedPtr<InitialCalibration>& storage) { m_initialCalibration = storage; }
     51 
     52 	void								init								(void);
     53 	void								deinit								(void);
     54 
     55 	IterateResult						iterate								(void);
     56 
     57 protected:
     58 	virtual void						setupProgram						(deUint32 program);
     59 	virtual void						setupRenderState					(void);
     60 
     61 	void								setGridSize							(int gridW, int gridH);
     62 	void								setViewportSize						(int width, int height);
     63 	void								setVertexFragmentRatio				(float fragmentsPerVertices);
     64 
     65 	int									getGridWidth						(void) const { return m_measurer.getGridWidth();		}
     66 	int									getGridHeight						(void) const { return m_measurer.getGridHeight();		}
     67 	int									getViewportWidth					(void) const { return m_measurer.getViewportWidth();	}
     68 	int									getViewportHeight					(void) const { return m_measurer.getViewportHeight();	}
     69 
     70 	virtual void						reportResult						(float mvertPerSecond, float mfragPerSecond);
     71 
     72 	glu::RenderContext&					m_renderCtx;
     73 
     74 	PerfCaseType						m_caseType;
     75 
     76 	std::string							m_vertShaderSource;
     77 	std::string							m_fragShaderSource;
     78 	std::vector<AttribSpec>				m_attributes;
     79 
     80 private:
     81 	glu::ShaderProgram*					m_program;
     82 	ShaderPerformanceMeasurer			m_measurer;
     83 
     84 	de::SharedPtr<InitialCalibration>	m_initialCalibration;
     85 };
     86 
     87 class ShaderPerformanceCaseGroup : public tcu::TestCaseGroup
     88 {
     89 public:
     90 																ShaderPerformanceCaseGroup	(tcu::TestContext& testCtx, const char* name, const char* description);
     91 	void														addChild					(ShaderPerformanceCase*);
     92 
     93 private:
     94 	de::SharedPtr<ShaderPerformanceCase::InitialCalibration>	m_initialCalibrationStorage;
     95 };
     96 
     97 } // gls
     98 } // deqp
     99 
    100 #endif // _GLSSHADERPERFORMANCECASE_HPP
    101