• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GL4CTEXTUREFILTERMINMAXTESTS_HPP
2 #define _GL4CTEXTUREFILTERMINMAXTESTS_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
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
24  */ /*-------------------------------------------------------------------*/
25 
26 /**
27  */ /*!
28  * \file  gl4cTextureFilterMinmaxTests.hpp
29  * \brief Conformance tests for the ARB_texture_filter_minmax functionality.
30  */ /*-------------------------------------------------------------------*/
31 
32 #include "deUniquePtr.hpp"
33 #include "glcTestCase.hpp"
34 #include "gluTexture.hpp"
35 #include "glwDefs.hpp"
36 #include "glwEnums.hpp"
37 #include "tcuDefs.hpp"
38 
39 #include <string>
40 #include <vector>
41 
42 namespace gl4cts
43 {
44 class TextureFilterMinmaxUtils
45 {
46 public:
47 	enum TextureTestFlag
48 	{
49 		MINMAX		  = (1u << 0),
50 		EXCLUDE_3D	= (1u << 2),
51 		EXCLUDE_CUBE  = (1u << 3)
52 	};
53 
54 	struct SupportedTextureDataType
55 	{
56 
57 		glw::GLenum m_format;
58 		glw::GLenum m_type;
59 		int			m_testFlags;
60 
SupportedTextureDataTypegl4cts::TextureFilterMinmaxUtils::SupportedTextureDataType61 		SupportedTextureDataType(glw::GLenum format, glw::GLenum type, int testFlags = MINMAX)
62 			: m_format(format), m_type(type), m_testFlags(testFlags)
63 		{
64 		}
65 
hasFlaggl4cts::TextureFilterMinmaxUtils::SupportedTextureDataType66 		inline bool hasFlag(TextureTestFlag flag) const
67 		{
68 			return (m_testFlags & flag) != 0;
69 		}
70 	};
71 
72 	struct ReductionModeParam
73 	{
74 		glw::GLint m_reductionMode;
75 		bool	   m_queryTestOnly;
76 
ReductionModeParamgl4cts::TextureFilterMinmaxUtils::ReductionModeParam77 		ReductionModeParam(glw::GLint reductionMode, bool queryTestOnly)
78 			: m_reductionMode(reductionMode), m_queryTestOnly(queryTestOnly)
79 		{
80 		}
81 	};
82 
83 	class SupportedTextureType
84 	{
85 	protected:
86 		glw::GLenum m_type;
87 		tcu::IVec3  m_size;
88 		std::string m_vertexShader;
89 		std::string m_fragmentShader;
90 
91 		void replaceAll(std::string& str, const std::string& from, const std::string& to);
92 
93 		void renderQuad(const glu::RenderContext& context, glw::GLint reductionMode);
94 
95 		virtual glw::GLuint getTextureGL() = 0;
96 
97 		virtual std::vector<float> getTexCoords() = 0;
98 
99 	public:
100 		SupportedTextureType(glw::GLenum type, const std::string& shaderTexcoordType,
101 							 const std::string& shaderSamplerType);
~SupportedTextureType()102 		virtual ~SupportedTextureType(){};
103 
getType() const104 		inline glw::GLenum getType() const
105 		{
106 			return m_type;
107 		}
108 
109 		virtual void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
110 							  bool generateMipmaps = false) = 0;
111 
112 		void renderToFBO(const glu::RenderContext& context, glw::GLuint resultTextureId, tcu::IVec2 size,
113 						 glw::GLint reductionMode);
114 	};
115 
116 	class Texture1D : public SupportedTextureType
117 	{
118 	protected:
119 		de::MovePtr<glu::Texture1D> m_texture;
120 
121 		glw::GLuint		   getTextureGL();
122 		std::vector<float> getTexCoords();
123 
124 	public:
125 		Texture1D();
126 
127 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
128 					  bool generateMipmaps = false);
129 	};
130 
131 	class Texture1DArray : public SupportedTextureType
132 	{
133 	protected:
134 		de::MovePtr<glu::Texture1DArray> m_texture;
135 
136 		glw::GLuint		   getTextureGL();
137 		std::vector<float> getTexCoords();
138 
139 	public:
140 		Texture1DArray();
141 
142 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
143 					  bool generateMipmaps = false);
144 	};
145 
146 	class Texture2D : public SupportedTextureType
147 	{
148 	protected:
149 		de::MovePtr<glu::Texture2D> m_texture;
150 
151 		glw::GLuint		   getTextureGL();
152 		std::vector<float> getTexCoords();
153 
154 	public:
155 		Texture2D();
156 
157 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
158 					  bool generateMipmaps = false);
159 	};
160 
161 	class Texture2DArray : public SupportedTextureType
162 	{
163 	protected:
164 		de::MovePtr<glu::Texture2DArray> m_texture;
165 
166 		glw::GLuint		   getTextureGL();
167 		std::vector<float> getTexCoords();
168 
169 	public:
170 		Texture2DArray();
171 
172 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
173 					  bool generateMipmaps = false);
174 	};
175 
176 	class Texture3D : public SupportedTextureType
177 	{
178 	protected:
179 		de::MovePtr<glu::Texture3D> m_texture;
180 
181 		glw::GLuint		   getTextureGL();
182 		std::vector<float> getTexCoords();
183 
184 	public:
185 		Texture3D();
186 
187 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
188 					  bool generateMipmaps = false);
189 	};
190 
191 	class TextureCube : public SupportedTextureType
192 	{
193 	protected:
194 		de::MovePtr<glu::TextureCube> m_texture;
195 
196 		glw::GLuint		   getTextureGL();
197 		std::vector<float> getTexCoords();
198 
199 	public:
200 		TextureCube();
201 
202 		void generate(const glu::RenderContext& context, tcu::IVec3 size, glw::GLenum format, glw::GLenum type,
203 					  bool generateMipmaps = false);
204 	};
205 
206 	/* Public methods */
207 	TextureFilterMinmaxUtils();
208 	~TextureFilterMinmaxUtils();
209 
210 	std::vector<glw::GLuint> getDataFromTexture(const glu::RenderContext& context, glw::GLuint textureId,
211 												tcu::IVec2 textureSize, glw::GLenum format, glw::GLenum type);
212 
213 	glw::GLuint calcPixelSumValue(const glu::RenderContext& context, glw::GLuint textureId, tcu::IVec2 textureSize,
214 								  glw::GLenum format, glw::GLenum type);
215 
getReductionModeParams()216 	inline const std::vector<ReductionModeParam>& getReductionModeParams()
217 	{
218 		return m_reductionModeParams;
219 	}
220 
getSupportedTextureDataTypes()221 	inline const std::vector<SupportedTextureDataType>& getSupportedTextureDataTypes()
222 	{
223 		return m_supportedTextureDataTypes;
224 	}
225 
getSupportedTextureTypes()226 	inline const std::vector<SupportedTextureType*>& getSupportedTextureTypes()
227 	{
228 		return m_supportedTextureTypes;
229 	}
230 
231 	typedef std::vector<ReductionModeParam>::const_iterator		  ReductionModeParamIter;
232 	typedef std::vector<SupportedTextureDataType>::const_iterator SupportedTextureDataTypeIter;
233 	typedef std::vector<SupportedTextureType*>::const_iterator	SupportedTextureTypeIter;
234 
235 private:
236 	/* Private members */
237 	std::vector<ReductionModeParam>		  m_reductionModeParams;
238 	std::vector<SupportedTextureDataType> m_supportedTextureDataTypes;
239 	std::vector<SupportedTextureType*>	m_supportedTextureTypes;
240 };
241 
242 /** Test verifies default values and manual setting of reduction mode queries
243  **/
244 class TextureFilterMinmaxParameterQueriesTestCase : public deqp::TestCase
245 {
246 public:
247 	/* Public methods */
248 	TextureFilterMinmaxParameterQueriesTestCase(deqp::Context& context);
249 
250 	tcu::TestNode::IterateResult iterate();
251 
252 private:
253 	/* Private methods */
254 	void testReductionModeQueriesDefaultValues(const glw::Functions& gl);
255 	void testReductionModeQueries(const glw::Functions& gl, glw::GLint pname);
256 
257 	/* Private members */
258 	TextureFilterMinmaxUtils m_utils;
259 };
260 
261 /** Base class for rendering based filtering tests
262 **/
263 class TextureFilterMinmaxFilteringTestCaseBase : public deqp::TestCase
264 {
265 public:
266 	/* Public methods */
267 	TextureFilterMinmaxFilteringTestCaseBase(deqp::Context& context, const char* name, const char* description,
268 											 float renderScale, bool mipmapping);
269 
270 	tcu::TestNode::IterateResult iterate();
271 
272 protected:
273 	/* Protected members */
274 	TextureFilterMinmaxUtils m_utils;
275 	float					 m_renderScale;
276 	bool					 m_mipmapping;
277 };
278 
279 /** Test verifies results of minification filtering for different reduction modes, targets, texture formats
280 **/
281 class TextureFilterMinmaxMinificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase
282 {
283 public:
284 	/* Public methods */
285 	TextureFilterMinmaxMinificationFilteringTestCase(deqp::Context& context);
286 };
287 
288 /** Test verifies results of magnification filtering for different reduction modes, targets, texture formats
289 **/
290 class TextureFilterMinmaxMagnificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase
291 {
292 public:
293 	/* Public methods */
294 	TextureFilterMinmaxMagnificationFilteringTestCase(deqp::Context& context);
295 };
296 
297 /** Test verifies results of minification filtering for different reduction modes, targets, texture formats
298 	with mipmapping enabled
299 **/
300 class TextureFilterMinmaxMipmapMinificationFilteringTestCase : public TextureFilterMinmaxFilteringTestCaseBase
301 {
302 public:
303 	/* Public methods */
304 	TextureFilterMinmaxMipmapMinificationFilteringTestCase(deqp::Context& context);
305 };
306 
307 /** Test verifies results of calling GetInternalFormat to verify support for specific texture types
308 **/
309 class TextureFilterMinmaxSupportTestCase : public deqp::TestCase
310 {
311 public:
312 	/* Public methods */
313 	TextureFilterMinmaxSupportTestCase(deqp::Context& context);
314 
315 	tcu::TestNode::IterateResult iterate();
316 
317 private:
318 	/* Private members */
319 	TextureFilterMinmaxUtils m_utils;
320 };
321 
322 /** Test group which encapsulates all texture filter minmax conformance tests */
323 class TextureFilterMinmax : public deqp::TestCaseGroup
324 {
325 public:
326 	/* Public methods */
327 	TextureFilterMinmax(deqp::Context& context);
328 
329 	void init();
330 
331 private:
332 	TextureFilterMinmax(const TextureFilterMinmax& other);
333 	TextureFilterMinmax& operator=(const TextureFilterMinmax& other);
334 };
335 
336 } /* glcts namespace */
337 
338 #endif // _GL4CTEXTUREFILTERMINMAXTESTS_HPP
339