Home | History | Annotate | Download | only in glshared
      1 #ifndef _GLSSTATECHANGEPERFTESTCASES_HPP
      2 #define _GLSSTATECHANGEPERFTESTCASES_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 State change performance tests.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "tcuTestCase.hpp"
     28 
     29 namespace glu
     30 {
     31 class ShaderProgram;
     32 class RenderContext;
     33 }
     34 
     35 namespace glw
     36 {
     37 class Functions;
     38 }
     39 
     40 namespace deqp
     41 {
     42 namespace gls
     43 {
     44 
     45 class StateChangePerformanceCase : public tcu::TestCase
     46 {
     47 public:
     48 	enum DrawType
     49 	{
     50 		DRAWTYPE_NOT_INDEXED		= 0,	//!< glDrawArrays()
     51 		DRAWTYPE_INDEXED_USER_PTR,			//!< glDrawElements(), indices from user pointer.
     52 		DRAWTYPE_INDEXED_BUFFER,			//!< glDrawElements(), indices in buffer.
     53 	};
     54 
     55 										StateChangePerformanceCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, DrawType drawType, int drawCallCount, int triangleCount);
     56 										~StateChangePerformanceCase		(void);
     57 
     58 	void								init							(void);
     59 	void								deinit							(void);
     60 
     61 	IterateResult						iterate							(void);
     62 
     63 protected:
     64 	void								requireIndexBuffers				(int count);
     65 	void								requireCoordBuffers				(int count);
     66 	void								requirePrograms					(int count);
     67 	void								requireTextures					(int count);
     68 	void								requireFramebuffers				(int count);
     69 	void								requireRenderbuffers			(int count);
     70 	void								requireSamplers					(int count);
     71 	void								requireVertexArrays				(int count);
     72 
     73 	virtual void						setupInitialState				(const glw::Functions& gl) = 0;
     74 	virtual void						renderTest						(const glw::Functions& gl) = 0;
     75 	virtual void						renderReference					(const glw::Functions& gl) = 0;
     76 
     77 	void								callDraw						(const glw::Functions& gl);
     78 
     79 	void								logAndSetTestResult				(void);
     80 
     81 protected:
     82 	glu::RenderContext&					m_renderCtx;
     83 
     84 	const DrawType						m_drawType;
     85 	const int							m_iterationCount;
     86 	const int							m_callCount;
     87 	const int							m_triangleCount;
     88 
     89 	std::vector<deUint32>				m_indexBuffers;
     90 	std::vector<deUint32>				m_coordBuffers;
     91 	std::vector<deUint32>				m_textures;
     92 	std::vector<glu::ShaderProgram*>	m_programs;
     93 	std::vector<deUint32>				m_framebuffers;
     94 	std::vector<deUint32>				m_renderbuffers;
     95 	std::vector<deUint32>				m_samplers;
     96 	std::vector<deUint32>				m_vertexArrays;
     97 
     98 private:
     99 										StateChangePerformanceCase		(const StateChangePerformanceCase&);
    100 	StateChangePerformanceCase&			operator=						(const StateChangePerformanceCase&);
    101 
    102 	std::vector<deUint16>				m_indices;
    103 
    104 	std::vector<deUint64>				m_interleavedResults;
    105 	std::vector<deUint64>				m_batchedResults;
    106 };
    107 
    108 class StateChangeCallPerformanceCase : public tcu::TestCase
    109 {
    110 public:
    111 
    112 							StateChangeCallPerformanceCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description);
    113 							~StateChangeCallPerformanceCase	(void);
    114 
    115 	IterateResult			iterate							(void);
    116 
    117 	virtual void			execCalls						(const glw::Functions& gl, int iterNdx, int callCount) = 0;
    118 
    119 private:
    120 	void					executeTest						(void);
    121 	void					logTestCase						(void);
    122 
    123 	void					logAndSetTestResult				(void);
    124 
    125 	glu::RenderContext&		m_renderCtx;
    126 
    127 	const int				m_iterationCount;
    128 	const int				m_callCount;
    129 
    130 	std::vector<deUint64>	m_results;
    131 };
    132 
    133 } // gls
    134 } // deqp
    135 
    136 #endif // _GLSSTATECHANGEPERFTESTCASES_HPP
    137