xref: /aosp_15_r20/external/deqp/modules/glshared/glsShaderPerformanceCase.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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;
InitialCalibrationdeqp::gls::ShaderPerformanceCase::InitialCalibration44         InitialCalibration(void) : initialNumCalls(1)
45         {
46         }
47     };
48 
49     ShaderPerformanceCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name,
50                           const char *description, PerfCaseType caseType);
51     ~ShaderPerformanceCase(void);
52 
setCalibrationInitialParamStorage(const de::SharedPtr<InitialCalibration> & storage)53     void setCalibrationInitialParamStorage(const de::SharedPtr<InitialCalibration> &storage)
54     {
55         m_initialCalibration = storage;
56     }
57 
58     void init(void);
59     void deinit(void);
60 
61     IterateResult iterate(void);
62 
63 protected:
64     virtual void setupProgram(uint32_t program);
65     virtual void setupRenderState(void);
66 
67     void setGridSize(int gridW, int gridH);
68     void setViewportSize(int width, int height);
69     void setVertexFragmentRatio(float fragmentsPerVertices);
70 
getGridWidth(void) const71     int getGridWidth(void) const
72     {
73         return m_measurer.getGridWidth();
74     }
getGridHeight(void) const75     int getGridHeight(void) const
76     {
77         return m_measurer.getGridHeight();
78     }
getViewportWidth(void) const79     int getViewportWidth(void) const
80     {
81         return m_measurer.getViewportWidth();
82     }
getViewportHeight(void) const83     int getViewportHeight(void) const
84     {
85         return m_measurer.getViewportHeight();
86     }
87 
88     virtual void reportResult(float mvertPerSecond, float mfragPerSecond);
89 
90     glu::RenderContext &m_renderCtx;
91 
92     PerfCaseType m_caseType;
93 
94     std::string m_vertShaderSource;
95     std::string m_fragShaderSource;
96     std::vector<AttribSpec> m_attributes;
97 
98 private:
99     glu::ShaderProgram *m_program;
100     ShaderPerformanceMeasurer m_measurer;
101 
102     de::SharedPtr<InitialCalibration> m_initialCalibration;
103 };
104 
105 class ShaderPerformanceCaseGroup : public tcu::TestCaseGroup
106 {
107 public:
108     ShaderPerformanceCaseGroup(tcu::TestContext &testCtx, const char *name, const char *description);
109     void addChild(ShaderPerformanceCase *);
110 
111 private:
112     de::SharedPtr<ShaderPerformanceCase::InitialCalibration> m_initialCalibrationStorage;
113 };
114 
115 } // namespace gls
116 } // namespace deqp
117 
118 #endif // _GLSSHADERPERFORMANCECASE_HPP
119