xref: /aosp_15_r20/external/deqp/modules/glshared/glsShaderPerformanceCase.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _GLSSHADERPERFORMANCECASE_HPP
2*35238bceSAndroid Build Coastguard Worker #define _GLSSHADERPERFORMANCECASE_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL (ES) Module
5*35238bceSAndroid Build Coastguard Worker  * -----------------------------------------------
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
8*35238bceSAndroid Build Coastguard Worker  *
9*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker  *
15*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker  *
21*35238bceSAndroid Build Coastguard Worker  *//*!
22*35238bceSAndroid Build Coastguard Worker  * \file
23*35238bceSAndroid Build Coastguard Worker  * \brief Single-program test case wrapper for ShaderPerformanceMeasurer.
24*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestCase.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glsShaderPerformanceMeasurer.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deSharedPtr.hpp"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker namespace deqp
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker namespace gls
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker class ShaderPerformanceCase : public tcu::TestCase
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker public:
41*35238bceSAndroid Build Coastguard Worker     struct InitialCalibration
42*35238bceSAndroid Build Coastguard Worker     {
43*35238bceSAndroid Build Coastguard Worker         int initialNumCalls;
InitialCalibrationdeqp::gls::ShaderPerformanceCase::InitialCalibration44*35238bceSAndroid Build Coastguard Worker         InitialCalibration(void) : initialNumCalls(1)
45*35238bceSAndroid Build Coastguard Worker         {
46*35238bceSAndroid Build Coastguard Worker         }
47*35238bceSAndroid Build Coastguard Worker     };
48*35238bceSAndroid Build Coastguard Worker 
49*35238bceSAndroid Build Coastguard Worker     ShaderPerformanceCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name,
50*35238bceSAndroid Build Coastguard Worker                           const char *description, PerfCaseType caseType);
51*35238bceSAndroid Build Coastguard Worker     ~ShaderPerformanceCase(void);
52*35238bceSAndroid Build Coastguard Worker 
setCalibrationInitialParamStorage(const de::SharedPtr<InitialCalibration> & storage)53*35238bceSAndroid Build Coastguard Worker     void setCalibrationInitialParamStorage(const de::SharedPtr<InitialCalibration> &storage)
54*35238bceSAndroid Build Coastguard Worker     {
55*35238bceSAndroid Build Coastguard Worker         m_initialCalibration = storage;
56*35238bceSAndroid Build Coastguard Worker     }
57*35238bceSAndroid Build Coastguard Worker 
58*35238bceSAndroid Build Coastguard Worker     void init(void);
59*35238bceSAndroid Build Coastguard Worker     void deinit(void);
60*35238bceSAndroid Build Coastguard Worker 
61*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
62*35238bceSAndroid Build Coastguard Worker 
63*35238bceSAndroid Build Coastguard Worker protected:
64*35238bceSAndroid Build Coastguard Worker     virtual void setupProgram(uint32_t program);
65*35238bceSAndroid Build Coastguard Worker     virtual void setupRenderState(void);
66*35238bceSAndroid Build Coastguard Worker 
67*35238bceSAndroid Build Coastguard Worker     void setGridSize(int gridW, int gridH);
68*35238bceSAndroid Build Coastguard Worker     void setViewportSize(int width, int height);
69*35238bceSAndroid Build Coastguard Worker     void setVertexFragmentRatio(float fragmentsPerVertices);
70*35238bceSAndroid Build Coastguard Worker 
getGridWidth(void) const71*35238bceSAndroid Build Coastguard Worker     int getGridWidth(void) const
72*35238bceSAndroid Build Coastguard Worker     {
73*35238bceSAndroid Build Coastguard Worker         return m_measurer.getGridWidth();
74*35238bceSAndroid Build Coastguard Worker     }
getGridHeight(void) const75*35238bceSAndroid Build Coastguard Worker     int getGridHeight(void) const
76*35238bceSAndroid Build Coastguard Worker     {
77*35238bceSAndroid Build Coastguard Worker         return m_measurer.getGridHeight();
78*35238bceSAndroid Build Coastguard Worker     }
getViewportWidth(void) const79*35238bceSAndroid Build Coastguard Worker     int getViewportWidth(void) const
80*35238bceSAndroid Build Coastguard Worker     {
81*35238bceSAndroid Build Coastguard Worker         return m_measurer.getViewportWidth();
82*35238bceSAndroid Build Coastguard Worker     }
getViewportHeight(void) const83*35238bceSAndroid Build Coastguard Worker     int getViewportHeight(void) const
84*35238bceSAndroid Build Coastguard Worker     {
85*35238bceSAndroid Build Coastguard Worker         return m_measurer.getViewportHeight();
86*35238bceSAndroid Build Coastguard Worker     }
87*35238bceSAndroid Build Coastguard Worker 
88*35238bceSAndroid Build Coastguard Worker     virtual void reportResult(float mvertPerSecond, float mfragPerSecond);
89*35238bceSAndroid Build Coastguard Worker 
90*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker     PerfCaseType m_caseType;
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker     std::string m_vertShaderSource;
95*35238bceSAndroid Build Coastguard Worker     std::string m_fragShaderSource;
96*35238bceSAndroid Build Coastguard Worker     std::vector<AttribSpec> m_attributes;
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker private:
99*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram *m_program;
100*35238bceSAndroid Build Coastguard Worker     ShaderPerformanceMeasurer m_measurer;
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker     de::SharedPtr<InitialCalibration> m_initialCalibration;
103*35238bceSAndroid Build Coastguard Worker };
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker class ShaderPerformanceCaseGroup : public tcu::TestCaseGroup
106*35238bceSAndroid Build Coastguard Worker {
107*35238bceSAndroid Build Coastguard Worker public:
108*35238bceSAndroid Build Coastguard Worker     ShaderPerformanceCaseGroup(tcu::TestContext &testCtx, const char *name, const char *description);
109*35238bceSAndroid Build Coastguard Worker     void addChild(ShaderPerformanceCase *);
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker private:
112*35238bceSAndroid Build Coastguard Worker     de::SharedPtr<ShaderPerformanceCase::InitialCalibration> m_initialCalibrationStorage;
113*35238bceSAndroid Build Coastguard Worker };
114*35238bceSAndroid Build Coastguard Worker 
115*35238bceSAndroid Build Coastguard Worker } // namespace gls
116*35238bceSAndroid Build Coastguard Worker } // namespace deqp
117*35238bceSAndroid Build Coastguard Worker 
118*35238bceSAndroid Build Coastguard Worker #endif // _GLSSHADERPERFORMANCECASE_HPP
119