xref: /aosp_15_r20/external/deqp/modules/glshared/glsStateChangePerfTestCases.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 } // namespace glu
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,
56                                const char *description, DrawType drawType, int drawCallCount, int triangleCount);
57     ~StateChangePerformanceCase(void);
58 
59     void init(void);
60     void deinit(void);
61 
62     IterateResult iterate(void);
63 
64 protected:
65     void requireIndexBuffers(int count);
66     void requireCoordBuffers(int count);
67     void requirePrograms(int count);
68     void requireTextures(int count);
69     void requireFramebuffers(int count);
70     void requireRenderbuffers(int count);
71     void requireSamplers(int count);
72     void requireVertexArrays(int count);
73 
74     virtual void setupInitialState(const glw::Functions &gl) = 0;
75     virtual void renderTest(const glw::Functions &gl)        = 0;
76     virtual void renderReference(const glw::Functions &gl)   = 0;
77 
78     void callDraw(const glw::Functions &gl);
79 
80     void logAndSetTestResult(void);
81 
82 protected:
83     glu::RenderContext &m_renderCtx;
84 
85     const DrawType m_drawType;
86     const int m_iterationCount;
87     const int m_callCount;
88     const int m_triangleCount;
89 
90     std::vector<uint32_t> m_indexBuffers;
91     std::vector<uint32_t> m_coordBuffers;
92     std::vector<uint32_t> m_textures;
93     std::vector<glu::ShaderProgram *> m_programs;
94     std::vector<uint32_t> m_framebuffers;
95     std::vector<uint32_t> m_renderbuffers;
96     std::vector<uint32_t> m_samplers;
97     std::vector<uint32_t> m_vertexArrays;
98 
99 private:
100     StateChangePerformanceCase(const StateChangePerformanceCase &);
101     StateChangePerformanceCase &operator=(const StateChangePerformanceCase &);
102 
103     std::vector<uint16_t> m_indices;
104 
105     std::vector<uint64_t> m_interleavedResults;
106     std::vector<uint64_t> m_batchedResults;
107 };
108 
109 class StateChangeCallPerformanceCase : public tcu::TestCase
110 {
111 public:
112     StateChangeCallPerformanceCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name,
113                                    const char *description);
114     ~StateChangeCallPerformanceCase(void);
115 
116     IterateResult iterate(void);
117 
118     virtual void execCalls(const glw::Functions &gl, int iterNdx, int callCount) = 0;
119 
120 private:
121     void executeTest(void);
122     void logTestCase(void);
123 
124     void logAndSetTestResult(void);
125 
126     glu::RenderContext &m_renderCtx;
127 
128     const int m_iterationCount;
129     const int m_callCount;
130 
131     std::vector<uint64_t> m_results;
132 };
133 
134 } // namespace gls
135 } // namespace deqp
136 
137 #endif // _GLSSTATECHANGEPERFTESTCASES_HPP
138