1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL (ES) Module
3 * -----------------------------------------------
5 * Copyright 2015 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Texture State Query tests.
22 *//*--------------------------------------------------------------------*/
24 #include "glsTextureStateQueryTests.hpp"
25 #include "gluStrUtil.hpp"
26 #include "gluObjectWrapper.hpp"
27 #include "gluCallLogWrapper.hpp"
28 #include "gluContextInfo.hpp"
29 #include "gluTextureUtil.hpp"
30 #include "glwEnums.hpp"
31 #include "deUniquePtr.hpp"
32 #include "deRandom.hpp"
33 #include "deStringUtil.hpp"
39 namespace TextureStateQueryTests
45 using namespace gls::StateQueryUtil;
47 static glw::GLenum mapTesterToPname (TesterType tester)
50 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
54 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R): return GL_TEXTURE_SWIZZLE_R;
55 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G): return GL_TEXTURE_SWIZZLE_G;
56 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B): return GL_TEXTURE_SWIZZLE_B;
57 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A): return GL_TEXTURE_SWIZZLE_A;
59 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
60 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER: return GL_TEXTURE_WRAP_S;
62 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
63 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER: return GL_TEXTURE_WRAP_T;
65 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
66 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER: return GL_TEXTURE_WRAP_R;
68 CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER): return GL_TEXTURE_MAG_FILTER;
69 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER): return GL_TEXTURE_MIN_FILTER;
70 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD): return GL_TEXTURE_MIN_LOD;
71 CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD): return GL_TEXTURE_MAX_LOD;
72 CASE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL): return GL_TEXTURE_BASE_LEVEL;
73 CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL): return GL_TEXTURE_MAX_LEVEL;
74 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE): return GL_TEXTURE_COMPARE_MODE;
75 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC): return GL_TEXTURE_COMPARE_FUNC;
76 case TESTER_TEXTURE_IMMUTABLE_LEVELS: return GL_TEXTURE_IMMUTABLE_LEVELS;
77 case TESTER_TEXTURE_IMMUTABLE_FORMAT: return GL_TEXTURE_IMMUTABLE_FORMAT;
78 CASE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE): return GL_DEPTH_STENCIL_TEXTURE_MODE;
79 CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT): return GL_TEXTURE_SRGB_DECODE_EXT;
80 case TESTER_TEXTURE_BORDER_COLOR: return GL_TEXTURE_BORDER_COLOR;
87 #undef CASE_PURE_SETTERS
90 static bool querySupportsSigned (QueryType type)
92 return type != QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER &&
93 type != QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER;
96 static bool isPureIntTester (TesterType tester)
98 #define HANDLE_ALL_SETTERS(X) \
100 case X ## _SET_PURE_UINT: return false; \
101 case X ## _SET_PURE_INT: return true;
105 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R)
106 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G)
107 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B)
108 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A)
109 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S)
110 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T)
111 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R)
112 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER)
113 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER)
114 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD)
115 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD)
116 HANDLE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL)
117 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL)
118 HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE)
119 HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC)
120 HANDLE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE)
121 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT)
123 case TESTER_TEXTURE_IMMUTABLE_LEVELS:
124 case TESTER_TEXTURE_IMMUTABLE_FORMAT:
125 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
126 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
127 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
128 case TESTER_TEXTURE_BORDER_COLOR:
136 #undef HANDLE_ALL_SETTERS
139 static bool isPureUintTester (TesterType tester)
141 #define HANDLE_ALL_SETTERS(X) \
143 case X ## _SET_PURE_INT: return false; \
144 case X ## _SET_PURE_UINT: return true;
148 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R)
149 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G)
150 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B)
151 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A)
152 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S)
153 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T)
154 HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R)
155 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER)
156 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER)
157 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD)
158 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD)
159 HANDLE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL)
160 HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL)
161 HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE)
162 HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC)
163 HANDLE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE)
164 HANDLE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT)
166 case TESTER_TEXTURE_IMMUTABLE_LEVELS:
167 case TESTER_TEXTURE_IMMUTABLE_FORMAT:
168 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
169 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
170 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
171 case TESTER_TEXTURE_BORDER_COLOR:
179 #undef HANDLE_ALL_SETTERS
182 class RequiredExtensions
185 RequiredExtensions (void) { }
186 explicit RequiredExtensions (const char* ext) { add(ext); }
187 RequiredExtensions (const char* extA, const char* extB) { add(extA); add(extB); }
189 void add (const char* ext);
190 void add (const RequiredExtensions& other);
191 void check (const glu::ContextInfo&) const;
194 std::vector<const char*> m_extensions;
197 void RequiredExtensions::add (const char* ext)
199 for (int ndx = 0; ndx < (int)m_extensions.size(); ++ndx)
200 if (deStringEqual(m_extensions[ndx], ext) == DE_TRUE)
202 m_extensions.push_back(ext);
205 void RequiredExtensions::add (const RequiredExtensions& other)
207 for (int ndx = 0; ndx < (int)other.m_extensions.size(); ++ndx)
208 add(other.m_extensions[ndx]);
211 void RequiredExtensions::check (const glu::ContextInfo& ctxInfo) const
213 std::vector<const char*> failedExtensions;
215 for (int ndx = 0; ndx < (int)m_extensions.size(); ++ndx)
216 if (!ctxInfo.isExtensionSupported(m_extensions[ndx]))
217 failedExtensions.push_back(m_extensions[ndx]);
219 if (!failedExtensions.empty())
221 std::ostringstream buf;
222 buf << "Test requires extension: ";
224 for (int ndx = 0; ndx < (int)failedExtensions.size(); ++ndx)
228 buf << failedExtensions[ndx];
231 throw tcu::NotSupportedError(buf.str());
238 static bool isCoreTextureTarget (glw::GLenum target)
240 return target == GL_TEXTURE_2D ||
241 target == GL_TEXTURE_3D ||
242 target == GL_TEXTURE_2D_ARRAY ||
243 target == GL_TEXTURE_CUBE_MAP;
246 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
250 return RequiredExtensions();
253 static bool isCoreTextureParam (glw::GLenum pname)
255 return pname == GL_TEXTURE_BASE_LEVEL ||
256 pname == GL_TEXTURE_COMPARE_MODE ||
257 pname == GL_TEXTURE_COMPARE_FUNC ||
258 pname == GL_TEXTURE_MAG_FILTER ||
259 pname == GL_TEXTURE_MAX_LEVEL ||
260 pname == GL_TEXTURE_MAX_LOD ||
261 pname == GL_TEXTURE_MIN_FILTER ||
262 pname == GL_TEXTURE_MIN_LOD ||
263 pname == GL_TEXTURE_SWIZZLE_R ||
264 pname == GL_TEXTURE_SWIZZLE_G ||
265 pname == GL_TEXTURE_SWIZZLE_B ||
266 pname == GL_TEXTURE_SWIZZLE_A ||
267 pname == GL_TEXTURE_WRAP_S ||
268 pname == GL_TEXTURE_WRAP_T ||
269 pname == GL_TEXTURE_WRAP_R ||
270 pname == GL_TEXTURE_IMMUTABLE_FORMAT ||
271 pname == GL_TEXTURE_IMMUTABLE_LEVELS;
274 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
278 return RequiredExtensions();
281 static bool isCoreQuery (QueryType query)
283 return query == QUERY_TEXTURE_PARAM_INTEGER ||
284 query == QUERY_TEXTURE_PARAM_FLOAT ||
285 query == QUERY_TEXTURE_PARAM_INTEGER_VEC4 ||
286 query == QUERY_TEXTURE_PARAM_FLOAT_VEC4 ||
287 query == QUERY_SAMPLER_PARAM_INTEGER ||
288 query == QUERY_SAMPLER_PARAM_FLOAT ||
289 query == QUERY_SAMPLER_PARAM_INTEGER_VEC4 ||
290 query == QUERY_SAMPLER_PARAM_FLOAT_VEC4;
293 static RequiredExtensions getQueryExtension (QueryType query)
297 return RequiredExtensions();
300 static bool isCoreTester (TesterType tester)
302 return tester == TESTER_TEXTURE_SWIZZLE_R ||
303 tester == TESTER_TEXTURE_SWIZZLE_G ||
304 tester == TESTER_TEXTURE_SWIZZLE_B ||
305 tester == TESTER_TEXTURE_SWIZZLE_A ||
306 tester == TESTER_TEXTURE_WRAP_S ||
307 tester == TESTER_TEXTURE_WRAP_T ||
308 tester == TESTER_TEXTURE_WRAP_R ||
309 tester == TESTER_TEXTURE_MAG_FILTER ||
310 tester == TESTER_TEXTURE_MIN_FILTER ||
311 tester == TESTER_TEXTURE_MIN_LOD ||
312 tester == TESTER_TEXTURE_MAX_LOD ||
313 tester == TESTER_TEXTURE_BASE_LEVEL ||
314 tester == TESTER_TEXTURE_MAX_LEVEL ||
315 tester == TESTER_TEXTURE_COMPARE_MODE ||
316 tester == TESTER_TEXTURE_COMPARE_FUNC ||
317 tester == TESTER_TEXTURE_IMMUTABLE_LEVELS ||
318 tester == TESTER_TEXTURE_IMMUTABLE_FORMAT;
321 static RequiredExtensions getTesterExtension (TesterType tester)
325 return RequiredExtensions();
333 static bool isCoreTextureTarget (glw::GLenum target)
335 return es30::isCoreTextureTarget(target) ||
336 target == GL_TEXTURE_2D_MULTISAMPLE;
339 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
343 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: return RequiredExtensions("GL_OES_texture_storage_multisample_2d_array");
344 case GL_TEXTURE_BUFFER: return RequiredExtensions("GL_EXT_texture_buffer");
345 case GL_TEXTURE_CUBE_MAP_ARRAY: return RequiredExtensions("GL_EXT_texture_cube_map_array");
348 return RequiredExtensions();
352 static bool isCoreTextureParam (glw::GLenum pname)
354 return es30::isCoreTextureParam(pname) ||
355 pname == GL_DEPTH_STENCIL_TEXTURE_MODE;
358 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
362 case GL_TEXTURE_SRGB_DECODE_EXT: return RequiredExtensions("GL_EXT_texture_sRGB_decode");
363 case GL_TEXTURE_BORDER_COLOR: return RequiredExtensions("GL_EXT_texture_border_clamp");
366 return RequiredExtensions();
370 static bool isCoreQuery (QueryType query)
372 return es30::isCoreQuery(query);
375 static RequiredExtensions getQueryExtension (QueryType query)
379 case QUERY_TEXTURE_PARAM_PURE_INTEGER:
380 case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER:
381 case QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4:
382 case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4:
383 case QUERY_SAMPLER_PARAM_PURE_INTEGER:
384 case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER:
385 case QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4:
386 case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4:
387 return RequiredExtensions("GL_EXT_texture_border_clamp");
391 return RequiredExtensions();
395 static bool isCoreTester (TesterType tester)
397 return es30::isCoreTester(tester) ||
398 tester == TESTER_DEPTH_STENCIL_TEXTURE_MODE;
401 static RequiredExtensions getTesterExtension (TesterType tester)
403 #define CASE_PURE_SETTERS(X) case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
407 CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_R):
408 CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_G):
409 CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_B):
410 CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_A):
411 CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_S):
412 CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_T):
413 CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_R):
414 CASE_PURE_SETTERS(TESTER_TEXTURE_MAG_FILTER):
415 CASE_PURE_SETTERS(TESTER_TEXTURE_MIN_FILTER):
416 CASE_PURE_SETTERS(TESTER_TEXTURE_MIN_LOD):
417 CASE_PURE_SETTERS(TESTER_TEXTURE_MAX_LOD):
418 CASE_PURE_SETTERS(TESTER_TEXTURE_BASE_LEVEL):
419 CASE_PURE_SETTERS(TESTER_TEXTURE_MAX_LEVEL):
420 CASE_PURE_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
421 CASE_PURE_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
422 CASE_PURE_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE):
423 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
424 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
425 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
426 case TESTER_TEXTURE_BORDER_COLOR:
427 return RequiredExtensions("GL_EXT_texture_border_clamp");
429 case TESTER_TEXTURE_SRGB_DECODE_EXT:
430 return RequiredExtensions("GL_EXT_texture_sRGB_decode");
432 CASE_PURE_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
433 return RequiredExtensions("GL_EXT_texture_sRGB_decode", "GL_EXT_texture_border_clamp");
437 return RequiredExtensions();
440 #undef CASE_PURE_SETTERS
448 static bool isCoreTextureTarget (glw::GLenum target)
450 return es31::isCoreTextureTarget(target) ||
451 target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY ||
452 target == GL_TEXTURE_BUFFER ||
453 target == GL_TEXTURE_CUBE_MAP_ARRAY;
456 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
460 return RequiredExtensions();
463 static bool isCoreTextureParam (glw::GLenum pname)
465 return es31::isCoreTextureParam(pname) ||
466 pname == GL_TEXTURE_BORDER_COLOR;
469 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
473 case GL_TEXTURE_SRGB_DECODE_EXT: return RequiredExtensions("GL_EXT_texture_sRGB_decode");
476 return RequiredExtensions();
480 static bool isCoreQuery (QueryType query)
482 return es31::isCoreQuery(query) ||
483 query == QUERY_TEXTURE_PARAM_PURE_INTEGER ||
484 query == QUERY_TEXTURE_PARAM_PURE_INTEGER ||
485 query == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER ||
486 query == QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4 ||
487 query == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4 ||
488 query == QUERY_SAMPLER_PARAM_PURE_INTEGER ||
489 query == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER ||
490 query == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4 ||
491 query == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4;
494 static RequiredExtensions getQueryExtension (QueryType query)
498 return RequiredExtensions();
501 static bool isCoreTester (TesterType tester)
503 #define COMPARE_PURE_SETTERS(TESTER, X) ((TESTER) == X ## _SET_PURE_INT) || ((TESTER) == X ## _SET_PURE_UINT)
505 return es31::isCoreTester(tester) ||
506 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_R) ||
507 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_G) ||
508 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_B) ||
509 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_A) ||
510 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_S) ||
511 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_T) ||
512 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_R) ||
513 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAG_FILTER) ||
514 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MIN_FILTER) ||
515 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MIN_LOD) ||
516 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAX_LOD) ||
517 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_BASE_LEVEL) ||
518 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAX_LEVEL) ||
519 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_COMPARE_MODE) ||
520 COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_COMPARE_FUNC) ||
521 COMPARE_PURE_SETTERS(tester, TESTER_DEPTH_STENCIL_TEXTURE_MODE) ||
522 tester == TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER ||
523 tester == TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER ||
524 tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER ||
525 tester == TESTER_TEXTURE_BORDER_COLOR;
527 #undef COMPARE_PURE_SETTERS
530 static RequiredExtensions getTesterExtension (TesterType tester)
532 #define CASE_PURE_SETTERS(X) case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
536 CASE_PURE_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
537 case TESTER_TEXTURE_SRGB_DECODE_EXT:
538 return RequiredExtensions("GL_EXT_texture_sRGB_decode");
542 return RequiredExtensions();
545 #undef CASE_PURE_SETTERS
550 static bool isCoreTextureTarget (const glu::ContextType& contextType, glw::GLenum target)
552 if (contextSupports(contextType, glu::ApiType::es(3,2)))
553 return es32::isCoreTextureTarget(target);
554 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
555 return es31::isCoreTextureTarget(target);
556 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
557 return es30::isCoreTextureTarget(target);
565 static bool isCoreTextureParam (const glu::ContextType& contextType, glw::GLenum pname)
567 if (contextSupports(contextType, glu::ApiType::es(3,2)))
568 return es32::isCoreTextureParam(pname);
569 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
570 return es31::isCoreTextureParam(pname);
571 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
572 return es30::isCoreTextureParam(pname);
580 static bool isCoreQuery (const glu::ContextType& contextType, QueryType query)
582 if (contextSupports(contextType, glu::ApiType::es(3,2)))
583 return es32::isCoreQuery(query);
584 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
585 return es31::isCoreQuery(query);
586 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
587 return es30::isCoreQuery(query);
595 static bool isCoreTester (const glu::ContextType& contextType, TesterType tester)
597 if (contextSupports(contextType, glu::ApiType::es(3,2)))
598 return es32::isCoreTester(tester);
599 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
600 return es31::isCoreTester(tester);
601 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
602 return es30::isCoreTester(tester);
610 static RequiredExtensions getTextureTargetExtension (const glu::ContextType& contextType, glw::GLenum target)
612 DE_ASSERT(!isCoreTextureTarget(contextType, target));
614 if (contextSupports(contextType, glu::ApiType::es(3,2)))
615 return es32::getTextureTargetExtension(target);
616 if (contextSupports(contextType, glu::ApiType::es(3,1)))
617 return es31::getTextureTargetExtension(target);
618 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
619 return es30::getTextureTargetExtension(target);
623 return RequiredExtensions();
627 static RequiredExtensions getTextureParamExtension (const glu::ContextType& contextType, glw::GLenum pname)
629 DE_ASSERT(!isCoreTextureParam(contextType, pname));
631 if (contextSupports(contextType, glu::ApiType::es(3,2)))
632 return es32::getTextureParamExtension(pname);
633 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
634 return es31::getTextureParamExtension(pname);
635 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
636 return es30::getTextureParamExtension(pname);
640 return RequiredExtensions();
644 static RequiredExtensions getQueryExtension (const glu::ContextType& contextType, QueryType query)
646 DE_ASSERT(!isCoreQuery(contextType, query));
648 if (contextSupports(contextType, glu::ApiType::es(3,2)))
649 return es32::getQueryExtension(query);
650 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
651 return es31::getQueryExtension(query);
652 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
653 return es30::getQueryExtension(query);
657 return RequiredExtensions();
661 static RequiredExtensions getTesterExtension (const glu::ContextType& contextType, TesterType tester)
663 DE_ASSERT(!isCoreTester(contextType, tester));
665 if (contextSupports(contextType, glu::ApiType::es(3,2)))
666 return es32::getTesterExtension(tester);
667 else if (contextSupports(contextType, glu::ApiType::es(3,1)))
668 return es31::getTesterExtension(tester);
669 else if (contextSupports(contextType, glu::ApiType::es(3,0)))
670 return es30::getTesterExtension(tester);
674 return RequiredExtensions();
678 class TextureTest : public tcu::TestCase
681 TextureTest (tcu::TestContext& testCtx,
682 const glu::RenderContext& renderCtx,
690 IterateResult iterate (void);
692 virtual void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
695 const glu::RenderContext& m_renderCtx;
696 const glw::GLenum m_target;
697 const glw::GLenum m_pname;
698 const TesterType m_tester;
699 const QueryType m_type;
702 TextureTest::TextureTest (tcu::TestContext& testCtx,
703 const glu::RenderContext& renderCtx,
709 : TestCase (testCtx, name, desc)
710 , m_renderCtx (renderCtx)
712 , m_pname (mapTesterToPname(tester))
718 void TextureTest::init (void)
720 const de::UniquePtr<glu::ContextInfo> ctxInfo (glu::ContextInfo::create(m_renderCtx));
721 RequiredExtensions extensions;
724 if (!isCoreTextureTarget(m_renderCtx.getType(), m_target))
725 extensions.add(getTextureTargetExtension(m_renderCtx.getType(), m_target));
728 if (!isCoreTextureParam(m_renderCtx.getType(), m_pname))
729 extensions.add(getTextureParamExtension(m_renderCtx.getType(), m_pname));
732 if (!isCoreQuery(m_renderCtx.getType(), m_type))
733 extensions.add(getQueryExtension(m_renderCtx.getType(), m_type));
736 if (!isCoreTester(m_renderCtx.getType(), m_tester))
737 extensions.add(getTesterExtension(m_renderCtx.getType(), m_tester));
739 extensions.check(*ctxInfo);
742 TextureTest::IterateResult TextureTest::iterate (void)
744 glu::CallLogWrapper gl (m_renderCtx.getFunctions(), m_testCtx.getLog());
745 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
747 gl.enableLogging(true);
750 result.setTestContextResult(m_testCtx);
754 class IsTextureCase : public tcu::TestCase
757 IsTextureCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target);
760 IterateResult iterate (void);
763 const glu::RenderContext& m_renderCtx;
764 const glw::GLenum m_target;
767 IsTextureCase::IsTextureCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target)
768 : tcu::TestCase (testCtx, name, desc)
769 , m_renderCtx (renderCtx)
774 void IsTextureCase::init (void)
776 const de::UniquePtr<glu::ContextInfo> ctxInfo (glu::ContextInfo::create(m_renderCtx));
777 RequiredExtensions extensions;
780 if (!isCoreTextureTarget(m_renderCtx.getType(), m_target))
781 extensions.add(getTextureTargetExtension(m_renderCtx.getType(), m_target));
783 extensions.check(*ctxInfo);
786 IsTextureCase::IterateResult IsTextureCase::iterate (void)
788 glu::CallLogWrapper gl (m_renderCtx.getFunctions(), m_testCtx.getLog());
789 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
790 glw::GLuint textureId = 0;
792 gl.enableLogging(true);
794 gl.glGenTextures(1, &textureId);
795 gl.glBindTexture(m_target, textureId);
796 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
798 verifyStateObjectBoolean(result, gl, textureId, true, QUERY_ISTEXTURE);
800 gl.glDeleteTextures(1, &textureId);
801 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
803 verifyStateObjectBoolean(result, gl, textureId, false, QUERY_ISTEXTURE);
805 result.setTestContextResult(m_testCtx);
809 class DepthStencilModeCase : public TextureTest
812 DepthStencilModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
813 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
816 DepthStencilModeCase::DepthStencilModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
817 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
821 void DepthStencilModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
823 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
824 glu::Texture texture (m_renderCtx);
826 gl.glBindTexture(m_target, *texture);
827 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind");
831 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
832 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
837 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Toggle", "Toggle");
838 const glw::GLint depthComponentInt = GL_DEPTH_COMPONENT;
839 const glw::GLfloat depthComponentFloat = (glw::GLfloat)GL_DEPTH_COMPONENT;
841 gl.glTexParameteri(m_target, m_pname, GL_STENCIL_INDEX);
842 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
843 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
845 gl.glTexParameteriv(m_target, m_pname, &depthComponentInt);
846 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
847 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
849 gl.glTexParameterf(m_target, m_pname, GL_STENCIL_INDEX);
850 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
851 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
853 gl.glTexParameterfv(m_target, m_pname, &depthComponentFloat);
854 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
855 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
858 if (isPureIntTester(m_tester))
860 const glw::GLint depthComponent = GL_DEPTH_COMPONENT;
861 const glw::GLint stencilIndex = GL_STENCIL_INDEX;
863 gl.glTexParameterIiv(m_target, m_pname, &stencilIndex);
864 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
865 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
867 gl.glTexParameterIiv(m_target, m_pname, &depthComponent);
868 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
869 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
872 if (isPureUintTester(m_tester))
874 const glw::GLuint depthComponent = GL_DEPTH_COMPONENT;
875 const glw::GLuint stencilIndex = GL_STENCIL_INDEX;
877 gl.glTexParameterIuiv(m_target, m_pname, &stencilIndex);
878 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
879 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
881 gl.glTexParameterIuiv(m_target, m_pname, &depthComponent);
882 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
883 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
887 class TextureSRGBDecodeCase : public TextureTest
890 TextureSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
891 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
894 TextureSRGBDecodeCase::TextureSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
895 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
899 void TextureSRGBDecodeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
901 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
902 glu::Texture texture (m_renderCtx);
904 gl.glBindTexture(m_target, *texture);
905 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind");
909 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
910 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
915 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Toggle", "Toggle");
916 const glw::GLint decodeInt = GL_DECODE_EXT;
917 const glw::GLfloat decodeFloat = (glw::GLfloat)GL_DECODE_EXT;
919 gl.glTexParameteri(m_target, m_pname, GL_SKIP_DECODE_EXT);
920 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
921 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
923 gl.glTexParameteriv(m_target, m_pname, &decodeInt);
924 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
925 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
927 gl.glTexParameterf(m_target, m_pname, GL_SKIP_DECODE_EXT);
928 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
929 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
931 gl.glTexParameterfv(m_target, m_pname, &decodeFloat);
932 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
933 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
936 if (isPureIntTester(m_tester))
938 const glw::GLint skipDecode = GL_SKIP_DECODE_EXT;
939 const glw::GLint decode = GL_DECODE_EXT;
941 gl.glTexParameterIiv(m_target, m_pname, &skipDecode);
942 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
943 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
945 gl.glTexParameterIiv(m_target, m_pname, &decode);
946 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
947 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
950 if (isPureUintTester(m_tester))
952 const glw::GLuint skipDecode = GL_SKIP_DECODE_EXT;
953 const glw::GLuint decode = GL_DECODE_EXT;
955 gl.glTexParameterIuiv(m_target, m_pname, &skipDecode);
956 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
957 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
959 gl.glTexParameterIuiv(m_target, m_pname, &decode);
960 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
961 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
965 class TextureSwizzleCase : public TextureTest
968 TextureSwizzleCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
969 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
972 TextureSwizzleCase::TextureSwizzleCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
973 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
977 void TextureSwizzleCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
979 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
980 const int initialValue = (m_pname == GL_TEXTURE_SWIZZLE_R) ? (GL_RED) :
981 (m_pname == GL_TEXTURE_SWIZZLE_G) ? (GL_GREEN) :
982 (m_pname == GL_TEXTURE_SWIZZLE_B) ? (GL_BLUE) :
983 (m_pname == GL_TEXTURE_SWIZZLE_A) ? (GL_ALPHA) :
988 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
989 verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
993 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
994 const GLenum swizzleValues[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_ZERO, GL_ONE};
998 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
1000 if (isPureIntTester(m_tester))
1002 const glw::GLint value = (glw::GLint)swizzleValues[ndx];
1003 gl.glTexParameterIiv(m_target, m_pname, &value);
1004 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1008 DE_ASSERT(isPureUintTester(m_tester));
1010 const glw::GLuint value = swizzleValues[ndx];
1011 gl.glTexParameterIuiv(m_target, m_pname, &value);
1012 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1015 verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
1020 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
1022 gl.glTexParameteri(m_target, m_pname, swizzleValues[ndx]);
1023 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1025 verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
1028 //check unit conversions with float
1030 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
1032 gl.glTexParameterf(m_target, m_pname, (GLfloat)swizzleValues[ndx]);
1033 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1035 verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
1041 class TextureWrapCase : public TextureTest
1044 TextureWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1045 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1048 TextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1049 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1053 void TextureWrapCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1055 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1059 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1060 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_REPEAT, m_type);
1064 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1065 const GLenum wrapValues[] = {GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT};
1069 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1071 if (isPureIntTester(m_tester))
1073 const glw::GLint value = (glw::GLint)wrapValues[ndx];
1074 gl.glTexParameterIiv(m_target, m_pname, &value);
1075 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1079 DE_ASSERT(isPureUintTester(m_tester));
1081 const glw::GLuint value = wrapValues[ndx];
1082 gl.glTexParameterIuiv(m_target, m_pname, &value);
1083 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1086 verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1091 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1093 gl.glTexParameteri(m_target, m_pname, wrapValues[ndx]);
1094 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1096 verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1099 //check unit conversions with float
1101 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1103 gl.glTexParameterf(m_target, m_pname, (GLfloat)wrapValues[ndx]);
1104 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1106 verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1112 class TextureFilterCase : public TextureTest
1115 TextureFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1116 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1119 TextureFilterCase::TextureFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1120 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1124 void TextureFilterCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1126 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1127 const glw::GLenum initial = (m_pname == GL_TEXTURE_MAG_FILTER) ? (GL_LINEAR)
1128 : (m_pname == GL_TEXTURE_MIN_FILTER) ? (GL_NEAREST_MIPMAP_LINEAR)
1133 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1134 verifyStateTextureParamInteger(result, gl, m_target, m_pname, initial, m_type);
1138 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1139 std::vector<GLenum> values;
1141 values.push_back(GL_NEAREST);
1142 values.push_back(GL_LINEAR);
1143 if (m_pname == GL_TEXTURE_MIN_FILTER)
1145 values.push_back(GL_NEAREST_MIPMAP_NEAREST);
1146 values.push_back(GL_NEAREST_MIPMAP_LINEAR);
1147 values.push_back(GL_LINEAR_MIPMAP_NEAREST);
1148 values.push_back(GL_LINEAR_MIPMAP_LINEAR);
1153 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
1155 if (isPureIntTester(m_tester))
1157 const glw::GLint value = (glw::GLint)values[ndx];
1158 gl.glTexParameterIiv(m_target, m_pname, &value);
1159 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1163 DE_ASSERT(isPureUintTester(m_tester));
1165 const glw::GLuint value = values[ndx];
1166 gl.glTexParameterIuiv(m_target, m_pname, &value);
1167 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1170 verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
1175 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
1177 gl.glTexParameteri(m_target, m_pname, values[ndx]);
1178 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1180 verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
1183 //check unit conversions with float
1185 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
1187 gl.glTexParameterf(m_target, m_pname, (GLfloat)values[ndx]);
1188 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1190 verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
1196 class TextureLODCase : public TextureTest
1199 TextureLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1200 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1203 TextureLODCase::TextureLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1204 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1208 void TextureLODCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1210 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1211 const int initialValue = (m_pname == GL_TEXTURE_MIN_LOD) ? (-1000)
1212 : (m_pname == GL_TEXTURE_MAX_LOD) ? (1000)
1215 if ((querySupportsSigned(m_type) || initialValue >= 0) && !isPureCase)
1217 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1218 verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
1222 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1223 const int numIterations = 20;
1224 de::Random rnd (0xabcdef);
1228 if (isPureIntTester(m_tester))
1230 for (int ndx = 0; ndx < numIterations; ++ndx)
1232 const GLint ref = rnd.getInt(-1000, 1000);
1234 gl.glTexParameterIiv(m_target, m_pname, &ref);
1235 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1237 verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
1242 DE_ASSERT(isPureUintTester(m_tester));
1244 for (int ndx = 0; ndx < numIterations; ++ndx)
1246 const GLuint ref = (glw::GLuint)rnd.getInt(0, 1000);
1248 gl.glTexParameterIuiv(m_target, m_pname, &ref);
1249 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1251 verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
1257 const int minLimit = (querySupportsSigned(m_type)) ? (-1000) : (0);
1259 for (int ndx = 0; ndx < numIterations; ++ndx)
1261 const GLfloat ref = rnd.getFloat((float)minLimit, 1000.f);
1263 gl.glTexParameterf(m_target, m_pname, ref);
1264 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1266 verifyStateTextureParamFloat(result, gl, m_target, m_pname, ref, m_type);
1269 // check unit conversions with int
1271 for (int ndx = 0; ndx < numIterations; ++ndx)
1273 const GLint ref = rnd.getInt(minLimit, 1000);
1275 gl.glTexParameteri(m_target, m_pname, ref);
1276 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1278 verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
1284 class TextureLevelCase : public TextureTest
1287 TextureLevelCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1288 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1291 TextureLevelCase::TextureLevelCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1292 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1296 void TextureLevelCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1298 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1299 const int initialValue = (m_pname == GL_TEXTURE_BASE_LEVEL) ? (0)
1300 : (m_pname == GL_TEXTURE_MAX_LEVEL) ? (1000)
1305 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1306 verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
1309 if (m_target == GL_TEXTURE_2D_MULTISAMPLE ||
1310 m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
1314 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Set", "Set");
1316 gl.glTexParameteri(m_target, m_pname, 0);
1317 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1318 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
1320 gl.glTexParameterf(m_target, m_pname, 0.0f);
1321 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1322 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
1327 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1328 const int numIterations = 20;
1329 de::Random rnd (0xabcdef);
1333 for (int ndx = 0; ndx < numIterations; ++ndx)
1335 const GLint ref = rnd.getInt(0, 64000);
1336 const GLuint uRef = (glw::GLuint)ref;
1338 if (isPureIntTester(m_tester))
1340 gl.glTexParameterIiv(m_target, m_pname, &ref);
1341 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1345 DE_ASSERT(isPureUintTester(m_tester));
1346 gl.glTexParameterIuiv(m_target, m_pname, &uRef);
1347 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1350 verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
1355 for (int ndx = 0; ndx < numIterations; ++ndx)
1357 const GLint ref = rnd.getInt(0, 64000);
1359 gl.glTexParameteri(m_target, m_pname, ref);
1360 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1362 verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
1365 // check unit conversions with float
1367 const float nonSignificantOffsets[] = {-0.45f, -0.25f, 0, 0.45f}; // offsets O so that for any integers z in Z, o in O roundToClosestInt(z+o)==z
1369 const int numConversionIterations = 30;
1370 for (int ndx = 0; ndx < numConversionIterations; ++ndx)
1372 const GLint ref = rnd.getInt(1, 64000);
1374 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(nonSignificantOffsets); ++offsetNdx)
1376 gl.glTexParameterf(m_target, m_pname, ((GLfloat)ref) + nonSignificantOffsets[offsetNdx]);
1377 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1379 verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
1386 class TextureCompareModeCase : public TextureTest
1389 TextureCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1390 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1393 TextureCompareModeCase::TextureCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1394 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1398 void TextureCompareModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1400 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1404 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1405 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_NONE, m_type);
1409 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1410 const GLenum modes[] = {GL_COMPARE_REF_TO_TEXTURE, GL_NONE};
1414 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
1416 if (isPureIntTester(m_tester))
1418 const glw::GLint value = (glw::GLint)modes[ndx];
1419 gl.glTexParameterIiv(m_target, m_pname, &value);
1420 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1424 DE_ASSERT(isPureUintTester(m_tester));
1426 const glw::GLuint value = modes[ndx];
1427 gl.glTexParameterIuiv(m_target, m_pname, &value);
1428 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1431 verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
1436 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
1438 gl.glTexParameteri(m_target, m_pname, modes[ndx]);
1439 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1441 verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
1444 //check unit conversions with float
1446 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
1448 gl.glTexParameterf(m_target, m_pname, (GLfloat)modes[ndx]);
1449 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1451 verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
1457 class TextureCompareFuncCase : public TextureTest
1460 TextureCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1461 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1464 TextureCompareFuncCase::TextureCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1465 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1469 void TextureCompareFuncCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1471 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1475 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1476 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_LEQUAL, m_type);
1480 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1481 const GLenum compareFuncs[] = {GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER};
1485 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
1487 if (isPureIntTester(m_tester))
1489 const glw::GLint value = (glw::GLint)compareFuncs[ndx];
1490 gl.glTexParameterIiv(m_target, m_pname, &value);
1491 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1495 DE_ASSERT(isPureUintTester(m_tester));
1497 const glw::GLuint value = compareFuncs[ndx];
1498 gl.glTexParameterIuiv(m_target, m_pname, &value);
1499 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1502 verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
1507 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
1509 gl.glTexParameteri(m_target, m_pname, compareFuncs[ndx]);
1510 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1512 verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
1515 //check unit conversions with float
1517 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
1519 gl.glTexParameterf(m_target, m_pname, (GLfloat)compareFuncs[ndx]);
1520 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1522 verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
1528 class TextureImmutableLevelsCase : public TextureTest
1531 TextureImmutableLevelsCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
1532 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1535 TextureImmutableLevelsCase::TextureImmutableLevelsCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
1536 : TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_IMMUTABLE_LEVELS, type)
1540 void TextureImmutableLevelsCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1543 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1544 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
1547 if (m_target == GL_TEXTURE_2D_MULTISAMPLE ||
1548 m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
1551 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Level", "Level");
1552 GLuint textureID = 0;
1554 gl.glGenTextures(1, &textureID);
1555 gl.glBindTexture(m_target, textureID);
1556 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
1558 if (m_target == GL_TEXTURE_2D_MULTISAMPLE)
1559 gl.glTexStorage2DMultisample(m_target, 2, GL_RGB8, 64, 64, GL_FALSE);
1560 else if (m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
1561 gl.glTexStorage3DMultisample(m_target, 2, GL_RGB8, 64, 64, 2, GL_FALSE);
1564 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexStorage");
1566 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 1, m_type);
1568 gl.glDeleteTextures(1, &textureID);
1569 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
1573 for (int level = 1; level <= 7; ++level)
1575 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Levels", "Levels = " + de::toString(level));
1576 GLuint textureID = 0;
1578 gl.glGenTextures(1, &textureID);
1579 gl.glBindTexture(m_target, textureID);
1580 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
1582 if (m_target == GL_TEXTURE_2D || m_target == GL_TEXTURE_CUBE_MAP)
1583 gl.glTexStorage2D(m_target, level, GL_RGB8, 64, 64);
1584 else if (m_target == GL_TEXTURE_2D_ARRAY || m_target == GL_TEXTURE_3D)
1585 gl.glTexStorage3D(m_target, level, GL_RGB8, 64, 64, 64);
1586 else if (m_target == GL_TEXTURE_CUBE_MAP_ARRAY)
1587 gl.glTexStorage3D(m_target, level, GL_RGB8, 64, 64, 6 * 2);
1590 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexStorage");
1592 verifyStateTextureParamInteger(result, gl, m_target, m_pname, level, m_type);
1594 gl.glDeleteTextures(1, &textureID);
1595 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
1600 class TextureImmutableFormatCase : public TextureTest
1603 TextureImmutableFormatCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
1604 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1607 TextureImmutableFormatCase::TextureImmutableFormatCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
1608 : TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_IMMUTABLE_FORMAT, type)
1612 void TextureImmutableFormatCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1615 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1616 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
1620 const tcu::ScopedLogSection subsection (m_testCtx.getLog(), "Immutable", "Immutable");
1621 GLuint textureID = 0;
1623 gl.glGenTextures(1, &textureID);
1624 gl.glBindTexture(m_target, textureID);
1625 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
1630 case GL_TEXTURE_CUBE_MAP:
1632 gl.glTexStorage2D(m_target, 1, GL_RGBA8, 32, 32);
1635 case GL_TEXTURE_2D_ARRAY:
1638 gl.glTexStorage3D(m_target, 1, GL_RGBA8, 32, 32, 8);
1641 case GL_TEXTURE_2D_MULTISAMPLE:
1643 gl.glTexStorage2DMultisample(m_target, 2, GL_RGB8, 64, 64, GL_FALSE);
1646 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1648 gl.glTexStorage3DMultisample(m_target, 2, GL_RGB8, 64, 64, 2, GL_FALSE);
1651 case GL_TEXTURE_CUBE_MAP_ARRAY:
1653 gl.glTexStorage3D(m_target, 1, GL_RGBA8, 32, 32, 6 * 2);
1659 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "setup texture");
1661 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 1, m_type);
1663 gl.glDeleteTextures(1, &textureID);
1664 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
1668 if (m_target == GL_TEXTURE_2D_MULTISAMPLE ||
1669 m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
1674 const tcu::ScopedLogSection subsection (m_testCtx.getLog(), "Mutable", "Mutable");
1675 GLuint textureID = 0;
1677 gl.glGenTextures(1, &textureID);
1678 gl.glBindTexture(m_target, textureID);
1679 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
1685 gl.glTexImage2D(m_target, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1688 case GL_TEXTURE_CUBE_MAP:
1690 gl.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1693 case GL_TEXTURE_2D_ARRAY:
1696 gl.glTexImage3D(m_target, 0, GL_RGBA8, 32, 32, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1699 case GL_TEXTURE_CUBE_MAP_ARRAY:
1701 gl.glTexImage3D(m_target, 0, GL_RGBA8, 32, 32, 6 * 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
1707 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "setup texture");
1709 verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
1711 gl.glDeleteTextures(1, &textureID);
1712 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
1716 class TextureWrapClampToBorderCase : public TextureTest
1719 TextureWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
1720 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1723 TextureWrapClampToBorderCase::TextureWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
1724 : TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
1728 void TextureWrapClampToBorderCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1730 gl.glTexParameteri(m_target, m_pname, GL_CLAMP_TO_BORDER_EXT);
1731 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1732 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
1734 gl.glTexParameteri(m_target, m_pname, GL_REPEAT);
1735 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
1737 gl.glTexParameterf(m_target, m_pname, (GLfloat)GL_CLAMP_TO_BORDER_EXT);
1738 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
1740 verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
1743 class TextureBorderColorCase : public TextureTest
1746 TextureBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
1747 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1750 TextureBorderColorCase::TextureBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
1751 : TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_BORDER_COLOR, type)
1755 void TextureBorderColorCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1757 // border color is undefined if queried with pure type and was not set to pure value
1758 if (m_type == QUERY_TEXTURE_PARAM_INTEGER_VEC4 || m_type == QUERY_TEXTURE_PARAM_FLOAT_VEC4)
1760 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1761 verifyStateTextureParamFloatVec4(result, gl, m_target, m_pname, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), m_type);
1764 if (m_type == QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4)
1766 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1767 const tcu::IVec4 color (0x7FFFFFFF, -2, 3, -128);
1769 gl.glTexParameterIiv(m_target, m_pname, color.getPtr());
1770 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
1772 verifyStateTextureParamIntegerVec4(result, gl, m_target, m_pname, color, m_type);
1774 else if (m_type == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4)
1776 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1777 const tcu::UVec4 color (0x8000000ul, 2, 3, 128);
1779 gl.glTexParameterIuiv(m_target, m_pname, color.getPtr());
1780 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
1782 verifyStateTextureParamUnsignedIntegerVec4(result, gl, m_target, m_pname, color, m_type);
1786 DE_ASSERT(m_type == QUERY_TEXTURE_PARAM_INTEGER_VEC4 || m_type == QUERY_TEXTURE_PARAM_FLOAT_VEC4);
1788 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1789 const tcu::Vec4 color (0.25f, 1.0f, 0.0f, 0.77f);
1790 const tcu::IVec4 icolor (0x8000000ul, 0x7FFFFFFF, 0, 0x0FFFFFFF);
1792 gl.glTexParameterfv(m_target, m_pname, color.getPtr());
1793 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterfv");
1795 verifyStateTextureParamFloatVec4(result, gl, m_target, m_pname, color, m_type);
1797 gl.glTexParameteriv(m_target, m_pname, icolor.getPtr());
1798 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteriv");
1800 verifyStateTextureParamNormalizedI32Vec4(result, gl, m_target, m_pname, icolor, m_type);
1804 class SamplerTest : public tcu::TestCase
1807 SamplerTest (tcu::TestContext& testCtx,
1808 const glu::RenderContext& renderCtx,
1815 IterateResult iterate (void);
1817 virtual void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
1820 const glu::RenderContext& m_renderCtx;
1821 const glw::GLenum m_pname;
1822 const TesterType m_tester;
1823 const QueryType m_type;
1824 glw::GLuint m_target;
1827 SamplerTest::SamplerTest (tcu::TestContext& testCtx,
1828 const glu::RenderContext& renderCtx,
1833 : TestCase (testCtx, name, desc)
1834 , m_renderCtx (renderCtx)
1835 , m_pname (mapTesterToPname(tester))
1842 void SamplerTest::init (void)
1844 const de::UniquePtr<glu::ContextInfo> ctxInfo (glu::ContextInfo::create(m_renderCtx));
1845 RequiredExtensions extensions;
1848 if (!isCoreTextureParam(m_renderCtx.getType(), m_pname))
1849 extensions.add(getTextureParamExtension(m_renderCtx.getType(), m_pname));
1852 if (!isCoreQuery(m_renderCtx.getType(), m_type))
1853 extensions.add(getQueryExtension(m_renderCtx.getType(), m_type));
1856 if (!isCoreTester(m_renderCtx.getType(), m_tester))
1857 extensions.add(getTesterExtension(m_renderCtx.getType(), m_tester));
1859 extensions.check(*ctxInfo);
1862 SamplerTest::IterateResult SamplerTest::iterate (void)
1864 glu::CallLogWrapper gl (m_renderCtx.getFunctions(), m_testCtx.getLog());
1865 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
1866 glu::Sampler sampler (m_renderCtx);
1868 gl.enableLogging(true);
1870 m_target = *sampler;
1874 result.setTestContextResult(m_testCtx);
1878 class SamplerWrapCase : public SamplerTest
1881 SamplerWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
1882 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1885 SamplerWrapCase::SamplerWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
1886 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
1890 void SamplerWrapCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1892 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1896 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1897 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_REPEAT, m_type);
1901 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1902 const GLenum wrapValues[] = {GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT};
1906 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1908 if (isPureIntTester(m_tester))
1910 const glw::GLint value = (glw::GLint)wrapValues[ndx];
1911 gl.glSamplerParameterIiv(m_target, m_pname, &value);
1912 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
1916 DE_ASSERT(isPureUintTester(m_tester));
1918 const glw::GLuint value = wrapValues[ndx];
1919 gl.glSamplerParameterIuiv(m_target, m_pname, &value);
1920 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
1923 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1928 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1930 gl.glSamplerParameteri(m_target, m_pname, wrapValues[ndx]);
1931 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
1933 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1936 //check unit conversions with float
1938 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
1940 gl.glSamplerParameterf(m_target, m_pname, (GLfloat)wrapValues[ndx]);
1941 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
1943 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
1949 class SamplerFilterCase : public SamplerTest
1952 SamplerFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
1953 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
1956 SamplerFilterCase::SamplerFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
1957 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
1961 void SamplerFilterCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1963 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
1964 const glw::GLenum initial = (m_pname == GL_TEXTURE_MAG_FILTER) ? (GL_LINEAR)
1965 : (m_pname == GL_TEXTURE_MIN_FILTER) ? (GL_NEAREST_MIPMAP_LINEAR)
1970 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
1971 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, initial, m_type);
1975 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
1976 std::vector<GLenum> values;
1978 values.push_back(GL_NEAREST);
1979 values.push_back(GL_LINEAR);
1980 if (m_pname == GL_TEXTURE_MIN_FILTER)
1982 values.push_back(GL_NEAREST_MIPMAP_NEAREST);
1983 values.push_back(GL_NEAREST_MIPMAP_LINEAR);
1984 values.push_back(GL_LINEAR_MIPMAP_NEAREST);
1985 values.push_back(GL_LINEAR_MIPMAP_LINEAR);
1990 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
1992 if (isPureIntTester(m_tester))
1994 const glw::GLint value = (glw::GLint)values[ndx];
1995 gl.glSamplerParameterIiv(m_target, m_pname, &value);
1996 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2000 DE_ASSERT(isPureUintTester(m_tester));
2002 const glw::GLuint value = values[ndx];
2003 gl.glSamplerParameterIuiv(m_target, m_pname, &value);
2004 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2007 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
2012 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
2014 gl.glSamplerParameteri(m_target, m_pname, values[ndx]);
2015 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2017 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
2020 //check unit conversions with float
2022 for (int ndx = 0; ndx < (int)values.size(); ++ndx)
2024 gl.glSamplerParameterf(m_target, m_pname, (GLfloat)values[ndx]);
2025 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
2027 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
2033 class SamplerLODCase : public SamplerTest
2036 SamplerLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
2037 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2040 SamplerLODCase::SamplerLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
2041 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
2045 void SamplerLODCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2047 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
2048 const int initialValue = (m_pname == GL_TEXTURE_MIN_LOD) ? (-1000)
2049 : (m_pname == GL_TEXTURE_MAX_LOD) ? (1000)
2052 if ((querySupportsSigned(m_type) || initialValue >= 0) && !isPureCase)
2054 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2055 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
2059 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2060 const int numIterations = 20;
2061 de::Random rnd (0xabcdef);
2065 if (isPureIntTester(m_tester))
2067 for (int ndx = 0; ndx < numIterations; ++ndx)
2069 const GLint ref = rnd.getInt(-1000, 1000);
2071 gl.glSamplerParameterIiv(m_target, m_pname, &ref);
2072 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2074 verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
2079 DE_ASSERT(isPureUintTester(m_tester));
2081 for (int ndx = 0; ndx < numIterations; ++ndx)
2083 const GLuint ref = (glw::GLuint)rnd.getInt(0, 1000);
2085 gl.glSamplerParameterIuiv(m_target, m_pname, &ref);
2086 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2088 verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
2094 const int minLimit = (querySupportsSigned(m_type)) ? (-1000) : (0);
2096 for (int ndx = 0; ndx < numIterations; ++ndx)
2098 const GLfloat ref = rnd.getFloat((float)minLimit, 1000.f);
2100 gl.glSamplerParameterf(m_target, m_pname, ref);
2101 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
2103 verifyStateSamplerParamFloat(result, gl, m_target, m_pname, ref, m_type);
2106 // check unit conversions with int
2108 for (int ndx = 0; ndx < numIterations; ++ndx)
2110 const GLint ref = rnd.getInt(minLimit, 1000);
2112 gl.glSamplerParameteri(m_target, m_pname, ref);
2113 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2115 verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
2121 class SamplerCompareModeCase : public SamplerTest
2124 SamplerCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
2125 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2128 SamplerCompareModeCase::SamplerCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
2129 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
2133 void SamplerCompareModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2135 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
2139 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2140 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_NONE, m_type);
2144 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2145 const GLenum modes[] = {GL_COMPARE_REF_TO_TEXTURE, GL_NONE};
2149 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
2151 if (isPureIntTester(m_tester))
2153 const glw::GLint value = (glw::GLint)modes[ndx];
2154 gl.glSamplerParameterIiv(m_target, m_pname, &value);
2155 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2159 DE_ASSERT(isPureUintTester(m_tester));
2161 const glw::GLuint value = modes[ndx];
2162 gl.glSamplerParameterIuiv(m_target, m_pname, &value);
2163 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2166 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
2171 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
2173 gl.glSamplerParameteri(m_target, m_pname, modes[ndx]);
2174 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2176 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
2179 //check unit conversions with float
2181 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
2183 gl.glSamplerParameterf(m_target, m_pname, (GLfloat)modes[ndx]);
2184 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
2186 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
2192 class SamplerCompareFuncCase : public SamplerTest
2195 SamplerCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
2196 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2199 SamplerCompareFuncCase::SamplerCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
2200 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
2204 void SamplerCompareFuncCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2206 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
2210 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2211 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_LEQUAL, m_type);
2215 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2216 const GLenum compareFuncs[] = {GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER};
2220 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
2222 if (isPureIntTester(m_tester))
2224 const glw::GLint value = (glw::GLint)compareFuncs[ndx];
2225 gl.glSamplerParameterIiv(m_target, m_pname, &value);
2226 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2230 DE_ASSERT(isPureUintTester(m_tester));
2232 const glw::GLuint value = compareFuncs[ndx];
2233 gl.glSamplerParameterIuiv(m_target, m_pname, &value);
2234 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2237 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
2242 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
2244 gl.glSamplerParameteri(m_target, m_pname, compareFuncs[ndx]);
2245 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2247 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
2250 //check unit conversions with float
2252 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
2254 gl.glSamplerParameterf(m_target, m_pname, (GLfloat)compareFuncs[ndx]);
2255 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
2257 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
2263 class SamplerWrapClampToBorderCase : public SamplerTest
2266 SamplerWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
2267 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2270 SamplerWrapClampToBorderCase::SamplerWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
2271 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
2275 void SamplerWrapClampToBorderCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2277 gl.glSamplerParameteri(m_target, m_pname, GL_CLAMP_TO_BORDER_EXT);
2278 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2279 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
2281 gl.glSamplerParameteri(m_target, m_pname, GL_REPEAT);
2282 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
2284 gl.glSamplerParameterf(m_target, m_pname, (GLfloat)GL_CLAMP_TO_BORDER_EXT);
2285 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
2287 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
2290 class SamplerSRGBDecodeCase : public SamplerTest
2293 SamplerSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
2294 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2297 SamplerSRGBDecodeCase::SamplerSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
2298 : SamplerTest(testCtx, renderCtx, name, desc, tester, type)
2302 void SamplerSRGBDecodeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2304 const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
2308 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2309 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
2313 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Toggle", "Toggle");
2314 const glw::GLint decodeInt = GL_DECODE_EXT;
2315 const glw::GLfloat decodeFloat = (glw::GLfloat)GL_DECODE_EXT;
2317 gl.glSamplerParameteri(m_target, m_pname, GL_SKIP_DECODE_EXT);
2318 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
2319 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
2321 gl.glSamplerParameteriv(m_target, m_pname, &decodeInt);
2322 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
2323 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
2325 gl.glSamplerParameterf(m_target, m_pname, GL_SKIP_DECODE_EXT);
2326 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
2327 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
2329 gl.glSamplerParameterfv(m_target, m_pname, &decodeFloat);
2330 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
2331 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
2334 if (isPureIntTester(m_tester))
2336 const glw::GLint skipDecode = GL_SKIP_DECODE_EXT;
2337 const glw::GLint decode = GL_DECODE_EXT;
2339 gl.glSamplerParameterIiv(m_target, m_pname, &skipDecode);
2340 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2341 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
2343 gl.glSamplerParameterIiv(m_target, m_pname, &decode);
2344 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2345 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
2348 if (isPureUintTester(m_tester))
2350 const glw::GLuint skipDecode = GL_SKIP_DECODE_EXT;
2351 const glw::GLuint decode = GL_DECODE_EXT;
2353 gl.glSamplerParameterIuiv(m_target, m_pname, &skipDecode);
2354 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2355 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
2357 gl.glSamplerParameterIuiv(m_target, m_pname, &decode);
2358 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2359 verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
2363 class SamplerBorderColorCase : public SamplerTest
2366 SamplerBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, QueryType type);
2367 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
2370 SamplerBorderColorCase::SamplerBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, QueryType type)
2371 : SamplerTest(testCtx, renderCtx, name, desc, TESTER_TEXTURE_BORDER_COLOR, type)
2373 DE_ASSERT(m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4 ||
2374 m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4 ||
2375 m_type == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4 ||
2376 m_type == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4);
2379 void SamplerBorderColorCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2381 // border color is undefined if queried with pure type and was not set to pure value
2382 if (m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4 || m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4)
2384 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
2385 verifyStateSamplerParamFloatVec4(result, gl, m_target, m_pname, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), m_type);
2388 if (m_type == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4)
2390 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2391 const tcu::IVec4 color (0x7FFFFFFF, -2, 3, -128);
2393 gl.glSamplerParameterIiv(m_target, m_pname, color.getPtr());
2394 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
2396 verifyStateSamplerParamIntegerVec4(result, gl, m_target, m_pname, color, m_type);
2398 else if (m_type == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4)
2400 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2401 const tcu::UVec4 color (0x8000000ul, 2, 3, 128);
2403 gl.glSamplerParameterIuiv(m_target, m_pname, color.getPtr());
2404 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
2406 verifyStateSamplerParamUnsignedIntegerVec4(result, gl, m_target, m_pname, color, m_type);
2410 DE_ASSERT(m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4 || m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4);
2412 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Set", "Set");
2413 const tcu::Vec4 color (0.25f, 1.0f, 0.0f, 0.77f);
2414 const tcu::IVec4 icolor (0x8000000ul, 0x7FFFFFFF, 0, 0x0FFFFFFF);
2416 gl.glSamplerParameterfv(m_target, m_pname, color.getPtr());
2417 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterfv");
2419 verifyStateSamplerParamFloatVec4(result, gl, m_target, m_pname, color, m_type);
2421 gl.glSamplerParameteriv(m_target, m_pname, icolor.getPtr());
2422 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteriv");
2424 verifyStateSamplerParamNormalizedI32Vec4(result, gl, m_target, m_pname, icolor, m_type);
2430 bool isLegalTesterForTarget (glw::GLenum target, TesterType tester)
2432 // no 3d filtering on 2d targets
2433 if ((tester == TESTER_TEXTURE_WRAP_R || tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER) && target != GL_TEXTURE_3D)
2436 // no sampling on multisample
2437 if (isMultisampleTarget(target) && isSamplerStateTester(tester))
2440 // no states in buffer
2441 if (target == GL_TEXTURE_BUFFER)
2447 bool isMultisampleTarget (glw::GLenum target)
2449 return target == GL_TEXTURE_2D_MULTISAMPLE ||
2450 target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
2453 bool isSamplerStateTester (TesterType tester)
2455 return tester == TESTER_TEXTURE_WRAP_S ||
2456 tester == TESTER_TEXTURE_WRAP_T ||
2457 tester == TESTER_TEXTURE_WRAP_R ||
2458 tester == TESTER_TEXTURE_MAG_FILTER ||
2459 tester == TESTER_TEXTURE_MIN_FILTER ||
2460 tester == TESTER_TEXTURE_MIN_LOD ||
2461 tester == TESTER_TEXTURE_MAX_LOD ||
2462 tester == TESTER_TEXTURE_COMPARE_MODE ||
2463 tester == TESTER_TEXTURE_COMPARE_FUNC ||
2464 tester == TESTER_TEXTURE_SRGB_DECODE_EXT ||
2465 tester == TESTER_TEXTURE_BORDER_COLOR ||
2466 tester == TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER ||
2467 tester == TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER ||
2468 tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER;
2471 tcu::TestCase* createIsTextureTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, glw::GLenum target)
2473 return new IsTextureCase(testCtx, renderCtx, name.c_str(), description.c_str(), target);
2476 tcu::TestCase* createTexParamTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, QueryType queryType, glw::GLenum target, TesterType tester)
2478 if (isMultisampleTarget(target) && isSamplerStateTester(tester))
2480 DE_FATAL("Multisample textures have no sampler state");
2483 if (target == GL_TEXTURE_BUFFER)
2485 DE_FATAL("Buffer textures have no texture state");
2488 if (target != GL_TEXTURE_3D && mapTesterToPname(tester) == GL_TEXTURE_WRAP_R)
2490 DE_FATAL("Only 3D textures have wrap r filter");
2494 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
2498 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R):
2499 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G):
2500 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B):
2501 CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A):
2502 return new TextureSwizzleCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2504 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
2505 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
2506 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
2507 return new TextureWrapCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2509 CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER):
2510 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER):
2511 return new TextureFilterCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2513 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD):
2514 CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD):
2515 return new TextureLODCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2517 CASE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL):
2518 CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL):
2519 return new TextureLevelCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2521 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
2522 return new TextureCompareModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2524 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
2525 return new TextureCompareFuncCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2527 case TESTER_TEXTURE_IMMUTABLE_LEVELS:
2528 return new TextureImmutableLevelsCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
2530 case TESTER_TEXTURE_IMMUTABLE_FORMAT:
2531 return new TextureImmutableFormatCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
2533 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
2534 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
2535 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
2536 return new TextureWrapClampToBorderCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2538 CASE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE):
2539 return new DepthStencilModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2541 CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
2542 return new TextureSRGBDecodeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
2544 case TESTER_TEXTURE_BORDER_COLOR:
2545 return new TextureBorderColorCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
2551 #undef CASE_ALL_SETTERS
2557 tcu::TestCase* createSamplerParamTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, StateQueryUtil::QueryType queryType, TesterType tester)
2559 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
2563 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
2564 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
2565 CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
2566 return new SamplerWrapCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2568 CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER):
2569 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER):
2570 return new SamplerFilterCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2572 CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD):
2573 CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD):
2574 return new SamplerLODCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2576 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
2577 return new SamplerCompareModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2579 CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
2580 return new SamplerCompareFuncCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2582 case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
2583 case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
2584 case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
2585 return new SamplerWrapClampToBorderCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2587 CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
2588 return new SamplerSRGBDecodeCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
2590 case TESTER_TEXTURE_BORDER_COLOR:
2591 return new SamplerBorderColorCase(testCtx, renderCtx, name.c_str(), description.c_str(), queryType);
2597 #undef CASE_ALL_SETTERS
2603 } // TextureStateQueryTests