xref: /aosp_15_r20/external/deqp/modules/glshared/glsTextureTestUtil.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GLSTEXTURETESTUTIL_HPP
2 #define _GLSTEXTURETESTUTIL_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 Texture test utilities.
24  *
25  * About coordinates:
26  *  + Quads consist of 2 triangles, rendered using explicit indices.
27  *  + All TextureTestUtil functions and classes expect texture coordinates
28  *    for quads to be specified in order (-1, -1), (-1, 1), (1, -1), (1, 1).
29  *//*--------------------------------------------------------------------*/
30 
31 #include "tcuDefs.hpp"
32 #include "tcuTexture.hpp"
33 #include "tcuSurface.hpp"
34 #include "tcuPixelFormat.hpp"
35 #include "tcuRenderTarget.hpp"
36 #include "tcuTestContext.hpp"
37 #include "tcuTestLog.hpp"
38 #include "tcuCompressedTexture.hpp"
39 #include "tcuTextureUtil.hpp"
40 #include "tcuTexVerifierUtil.hpp"
41 
42 #include "gluShaderProgram.hpp"
43 #include "gluShaderUtil.hpp"
44 #include "gluTextureTestUtil.hpp"
45 
46 #include "deInt32.h"
47 
48 #include <map>
49 
50 namespace tcu
51 {
52 struct LookupPrecision;
53 struct LodPrecision;
54 struct TexComparePrecision;
55 } // namespace tcu
56 
57 namespace deqp
58 {
59 namespace gls
60 {
61 namespace TextureTestUtil
62 {
63 
64 enum Program
65 {
66     PROGRAM_2D_FLOAT = 0,
67     PROGRAM_2D_INT,
68     PROGRAM_2D_UINT,
69     PROGRAM_2D_SHADOW,
70 
71     PROGRAM_2D_FLOAT_BIAS,
72     PROGRAM_2D_INT_BIAS,
73     PROGRAM_2D_UINT_BIAS,
74     PROGRAM_2D_SHADOW_BIAS,
75 
76     PROGRAM_1D_FLOAT,
77     PROGRAM_1D_INT,
78     PROGRAM_1D_UINT,
79     PROGRAM_1D_SHADOW,
80 
81     PROGRAM_1D_FLOAT_BIAS,
82     PROGRAM_1D_INT_BIAS,
83     PROGRAM_1D_UINT_BIAS,
84     PROGRAM_1D_SHADOW_BIAS,
85 
86     PROGRAM_CUBE_FLOAT,
87     PROGRAM_CUBE_INT,
88     PROGRAM_CUBE_UINT,
89     PROGRAM_CUBE_SHADOW,
90 
91     PROGRAM_CUBE_FLOAT_BIAS,
92     PROGRAM_CUBE_INT_BIAS,
93     PROGRAM_CUBE_UINT_BIAS,
94     PROGRAM_CUBE_SHADOW_BIAS,
95 
96     PROGRAM_1D_ARRAY_FLOAT,
97     PROGRAM_1D_ARRAY_INT,
98     PROGRAM_1D_ARRAY_UINT,
99     PROGRAM_1D_ARRAY_SHADOW,
100 
101     PROGRAM_2D_ARRAY_FLOAT,
102     PROGRAM_2D_ARRAY_INT,
103     PROGRAM_2D_ARRAY_UINT,
104     PROGRAM_2D_ARRAY_SHADOW,
105 
106     PROGRAM_3D_FLOAT,
107     PROGRAM_3D_INT,
108     PROGRAM_3D_UINT,
109 
110     PROGRAM_3D_FLOAT_BIAS,
111     PROGRAM_3D_INT_BIAS,
112     PROGRAM_3D_UINT_BIAS,
113 
114     PROGRAM_CUBE_ARRAY_FLOAT,
115     PROGRAM_CUBE_ARRAY_INT,
116     PROGRAM_CUBE_ARRAY_UINT,
117     PROGRAM_CUBE_ARRAY_SHADOW,
118 
119     PROGRAM_BUFFER_FLOAT,
120     PROGRAM_BUFFER_INT,
121     PROGRAM_BUFFER_UINT,
122 
123     PROGRAM_LAST
124 };
125 
126 class ProgramLibrary
127 {
128 public:
129     ProgramLibrary(const glu::RenderContext &context, tcu::TestLog &log, glu::GLSLVersion glslVersion,
130                    glu::Precision texCoordPrecision);
131     ~ProgramLibrary(void);
132 
133     glu::ShaderProgram *getProgram(Program program);
134     void clear(void);
135     glu::Precision getTexCoordPrecision();
136 
137 private:
138     ProgramLibrary(const ProgramLibrary &other);
139     ProgramLibrary &operator=(const ProgramLibrary &other);
140 
141     const glu::RenderContext &m_context;
142     tcu::TestLog &m_log;
143     glu::GLSLVersion m_glslVersion;
144     glu::Precision m_texCoordPrecision;
145     std::map<Program, glu::ShaderProgram *> m_programs;
146 };
147 
148 class TextureRenderer
149 {
150 public:
151     TextureRenderer(const glu::RenderContext &context, tcu::TestLog &log, glu::GLSLVersion glslVersion,
152                     glu::Precision texCoordPrecision);
153     ~TextureRenderer(void);
154 
155     void clear(void); //!< Frees allocated resources. Destructor will call clear() as well.
156 
157     void renderQuad(int texUnit, const float *texCoord, glu::TextureTestUtil::TextureType texType);
158     void renderQuad(int texUnit, const float *texCoord, const glu::TextureTestUtil::RenderParams &params);
159     glu::Precision getTexCoordPrecision();
160 
161 private:
162     TextureRenderer(const TextureRenderer &other);
163     TextureRenderer &operator=(const TextureRenderer &other);
164 
165     const glu::RenderContext &m_renderCtx;
166     tcu::TestLog &m_log;
167     ProgramLibrary m_programLibrary;
168 };
169 
170 class RandomViewport
171 {
172 public:
173     int x;
174     int y;
175     int width;
176     int height;
177 
178     RandomViewport(const tcu::RenderTarget &renderTarget, int preferredWidth, int preferredHeight, uint32_t seed);
179 };
180 
181 } // namespace TextureTestUtil
182 } // namespace gls
183 } // namespace deqp
184 
185 #endif // _GLSTEXTURETESTUTIL_HPP
186