xref: /aosp_15_r20/external/deqp/modules/glshared/glsRandomShaderCase.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _GLSRANDOMSHADERCASE_HPP
2*35238bceSAndroid Build Coastguard Worker #define _GLSRANDOMSHADERCASE_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 Random shader test case.
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 "rsgParameters.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "rsgShader.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "rsgVariableValue.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker #include <string>
36*35238bceSAndroid Build Coastguard Worker #include <vector>
37*35238bceSAndroid Build Coastguard Worker #include <map>
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker namespace deqp
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace gls
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker class VertexArray
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker public:
47*35238bceSAndroid Build Coastguard Worker     VertexArray(const rsg::ShaderInput *input, int numVertices);
~VertexArray(void)48*35238bceSAndroid Build Coastguard Worker     ~VertexArray(void)
49*35238bceSAndroid Build Coastguard Worker     {
50*35238bceSAndroid Build Coastguard Worker     }
51*35238bceSAndroid Build Coastguard Worker 
getVertices(void) const52*35238bceSAndroid Build Coastguard Worker     const std::vector<float> &getVertices(void) const
53*35238bceSAndroid Build Coastguard Worker     {
54*35238bceSAndroid Build Coastguard Worker         return m_vertices;
55*35238bceSAndroid Build Coastguard Worker     }
getVertices(void)56*35238bceSAndroid Build Coastguard Worker     std::vector<float> &getVertices(void)
57*35238bceSAndroid Build Coastguard Worker     {
58*35238bceSAndroid Build Coastguard Worker         return m_vertices;
59*35238bceSAndroid Build Coastguard Worker     }
getName(void) const60*35238bceSAndroid Build Coastguard Worker     const char *getName(void) const
61*35238bceSAndroid Build Coastguard Worker     {
62*35238bceSAndroid Build Coastguard Worker         return m_input->getVariable()->getName();
63*35238bceSAndroid Build Coastguard Worker     }
getNumComponents(void) const64*35238bceSAndroid Build Coastguard Worker     int getNumComponents(void) const
65*35238bceSAndroid Build Coastguard Worker     {
66*35238bceSAndroid Build Coastguard Worker         return m_input->getVariable()->getType().getNumElements();
67*35238bceSAndroid Build Coastguard Worker     }
getValueRange(void) const68*35238bceSAndroid Build Coastguard Worker     rsg::ConstValueRangeAccess getValueRange(void) const
69*35238bceSAndroid Build Coastguard Worker     {
70*35238bceSAndroid Build Coastguard Worker         return m_input->getValueRange();
71*35238bceSAndroid Build Coastguard Worker     }
72*35238bceSAndroid Build Coastguard Worker 
73*35238bceSAndroid Build Coastguard Worker private:
74*35238bceSAndroid Build Coastguard Worker     const rsg::ShaderInput *m_input;
75*35238bceSAndroid Build Coastguard Worker     std::vector<float> m_vertices;
76*35238bceSAndroid Build Coastguard Worker };
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker class TextureManager
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker public:
81*35238bceSAndroid Build Coastguard Worker     TextureManager(void);
82*35238bceSAndroid Build Coastguard Worker     ~TextureManager(void);
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker     void bindTexture(int unit, const glu::Texture2D *tex2D);
85*35238bceSAndroid Build Coastguard Worker     void bindTexture(int unit, const glu::TextureCube *texCube);
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker     std::vector<std::pair<int, const glu::Texture2D *>> getBindings2D(void) const;
88*35238bceSAndroid Build Coastguard Worker     std::vector<std::pair<int, const glu::TextureCube *>> getBindingsCube(void) const;
89*35238bceSAndroid Build Coastguard Worker 
90*35238bceSAndroid Build Coastguard Worker private:
91*35238bceSAndroid Build Coastguard Worker     std::map<int, const glu::Texture2D *> m_tex2D;
92*35238bceSAndroid Build Coastguard Worker     std::map<int, const glu::TextureCube *> m_texCube;
93*35238bceSAndroid Build Coastguard Worker };
94*35238bceSAndroid Build Coastguard Worker 
95*35238bceSAndroid Build Coastguard Worker class RandomShaderCase : public tcu::TestCase
96*35238bceSAndroid Build Coastguard Worker {
97*35238bceSAndroid Build Coastguard Worker public:
98*35238bceSAndroid Build Coastguard Worker     RandomShaderCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name,
99*35238bceSAndroid Build Coastguard Worker                      const char *description, const rsg::ProgramParameters &params);
100*35238bceSAndroid Build Coastguard Worker     virtual ~RandomShaderCase(void);
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker     virtual void init(void);
103*35238bceSAndroid Build Coastguard Worker     virtual void deinit(void);
104*35238bceSAndroid Build Coastguard Worker     virtual IterateResult iterate(void);
105*35238bceSAndroid Build Coastguard Worker 
106*35238bceSAndroid Build Coastguard Worker private:
107*35238bceSAndroid Build Coastguard Worker     void checkShaderLimits(const rsg::Shader &shader) const;
108*35238bceSAndroid Build Coastguard Worker     void checkProgramLimits(const rsg::Shader &vtxShader, const rsg::Shader &frgShader) const;
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker protected:
111*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
112*35238bceSAndroid Build Coastguard Worker 
113*35238bceSAndroid Build Coastguard Worker     // \todo [2011-12-21 pyry] Multiple textures!
114*35238bceSAndroid Build Coastguard Worker     const glu::Texture2D *getTex2D(void);
115*35238bceSAndroid Build Coastguard Worker     const glu::TextureCube *getTexCube(void);
116*35238bceSAndroid Build Coastguard Worker 
117*35238bceSAndroid Build Coastguard Worker     rsg::ProgramParameters m_parameters;
118*35238bceSAndroid Build Coastguard Worker     int m_gridWidth;
119*35238bceSAndroid Build Coastguard Worker     int m_gridHeight;
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker     rsg::Shader m_vertexShader;
122*35238bceSAndroid Build Coastguard Worker     rsg::Shader m_fragmentShader;
123*35238bceSAndroid Build Coastguard Worker     std::vector<rsg::VariableValue> m_uniforms;
124*35238bceSAndroid Build Coastguard Worker 
125*35238bceSAndroid Build Coastguard Worker     std::vector<VertexArray> m_vertexArrays;
126*35238bceSAndroid Build Coastguard Worker     std::vector<uint16_t> m_indices;
127*35238bceSAndroid Build Coastguard Worker 
128*35238bceSAndroid Build Coastguard Worker     TextureManager m_texManager;
129*35238bceSAndroid Build Coastguard Worker     glu::Texture2D *m_tex2D;
130*35238bceSAndroid Build Coastguard Worker     glu::TextureCube *m_texCube;
131*35238bceSAndroid Build Coastguard Worker };
132*35238bceSAndroid Build Coastguard Worker 
133*35238bceSAndroid Build Coastguard Worker } // namespace gls
134*35238bceSAndroid Build Coastguard Worker } // namespace deqp
135*35238bceSAndroid Build Coastguard Worker 
136*35238bceSAndroid Build Coastguard Worker #endif // _GLSRANDOMSHADERCASE_HPP
137