• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2015 The Android Open Source Project
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  *//*!
20  * \file
21  * \brief Indexed state query tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fIndexedStateQueryTests.hpp"
25 #include "tcuTestLog.hpp"
26 #include "tcuFormatUtil.hpp"
27 #include "gluRenderContext.hpp"
28 #include "gluCallLogWrapper.hpp"
29 #include "gluStrUtil.hpp"
30 #include "gluContextInfo.hpp"
31 #include "gluObjectWrapper.hpp"
32 #include "glwFunctions.hpp"
33 #include "glwEnums.hpp"
34 #include "glsStateQueryUtil.hpp"
35 #include "deRandom.hpp"
36 #include "deStringUtil.hpp"
37 
38 namespace deqp
39 {
40 namespace gles31
41 {
42 namespace Functional
43 {
44 namespace
45 {
46 
47 using namespace gls::StateQueryUtil;
48 
getVerifierSuffix(QueryType type)49 static const char* getVerifierSuffix (QueryType type)
50 {
51 	switch (type)
52 	{
53 		case QUERY_INDEXED_BOOLEAN:			return "getbooleani_v";
54 		case QUERY_INDEXED_INTEGER:			return "getintegeri_v";
55 		case QUERY_INDEXED_INTEGER64:		return "getinteger64i_v";
56 		case QUERY_INDEXED_BOOLEAN_VEC4:	return "getbooleani_v";
57 		case QUERY_INDEXED_INTEGER_VEC4:	return "getintegeri_v";
58 		case QUERY_INDEXED_INTEGER64_VEC4:	return "getinteger64i_v";
59 		case QUERY_INDEXED_ISENABLED:		return "isenabledi";
60 		default:
61 			DE_ASSERT(DE_FALSE);
62 			return DE_NULL;
63 	}
64 }
65 
isExtensionSupported(Context & context,std::string extensionName)66 void isExtensionSupported (Context& context, std::string extensionName)
67 {
68 	if (contextSupports(context.getRenderContext().getType(), glu::ApiType::core(4, 5)))
69 		return;
70 
71 	if (extensionName == "GL_EXT_draw_buffers_indexed" || extensionName == "GL_KHR_blend_equation_advanced")
72 	{
73 		if (!contextSupports(context.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !context.getContextInfo().isExtensionSupported(extensionName.c_str()))
74 			TCU_THROW(NotSupportedError, (std::string("Extension ") + extensionName + std::string(" not supported.")).c_str());
75 	}
76 	else if (!context.getContextInfo().isExtensionSupported(extensionName.c_str()))
77 		TCU_THROW(NotSupportedError, (std::string("Extension ") + extensionName + std::string(" not supported.")).c_str());
78 }
79 
80 class SampleMaskCase : public TestCase
81 {
82 public:
83 						SampleMaskCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
84 
85 private:
86 	void				init			(void);
87 	IterateResult		iterate			(void);
88 
89 	const QueryType		m_verifierType;
90 	int					m_maxSampleMaskWords;
91 };
92 
SampleMaskCase(Context & context,const char * name,const char * desc,QueryType verifierType)93 SampleMaskCase::SampleMaskCase (Context& context, const char* name, const char* desc, QueryType verifierType)
94 	: TestCase				(context, name, desc)
95 	, m_verifierType		(verifierType)
96 	, m_maxSampleMaskWords	(-1)
97 {
98 }
99 
init(void)100 void SampleMaskCase::init (void)
101 {
102 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
103 
104 	gl.getIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &m_maxSampleMaskWords);
105 	GLU_EXPECT_NO_ERROR(gl.getError(), "query sample mask words");
106 
107 	// mask word count ok?
108 	if (m_maxSampleMaskWords <= 0)
109 		throw tcu::TestError("Minimum value of GL_MAX_SAMPLE_MASK_WORDS is 1. Got " + de::toString(m_maxSampleMaskWords));
110 
111 	m_testCtx.getLog() << tcu::TestLog::Message << "GL_MAX_SAMPLE_MASK_WORDS = " << m_maxSampleMaskWords << tcu::TestLog::EndMessage;
112 }
113 
iterate(void)114 SampleMaskCase::IterateResult SampleMaskCase::iterate (void)
115 {
116 	glu::CallLogWrapper		gl		(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
117 	tcu::ResultCollector	result	(m_testCtx.getLog(), " // ERROR: ");
118 
119 	gl.enableLogging(true);
120 
121 	// initial values
122 	{
123 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "initial", "Initial values");
124 
125 		for (int ndx = 0; ndx < m_maxSampleMaskWords; ++ndx)
126 			verifyStateIndexedInteger(result, gl, GL_SAMPLE_MASK_VALUE, ndx, -1, m_verifierType);
127 	}
128 
129 	// fixed values
130 	{
131 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "fixed", "Fixed values");
132 
133 		for (int ndx = 0; ndx < m_maxSampleMaskWords; ++ndx)
134 		{
135 			gl.glSampleMaski(ndx, 0);
136 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "glSampleMaski");
137 
138 			verifyStateIndexedInteger(result, gl, GL_SAMPLE_MASK_VALUE, ndx, 0, m_verifierType);
139 		}
140 	}
141 
142 	// random masks
143 	{
144 		const int					numRandomTest	= 20;
145 		const tcu::ScopedLogSection section			(m_testCtx.getLog(), "random", "Random values");
146 		de::Random					rnd				(0x4312);
147 
148 		for (int testNdx = 0; testNdx < numRandomTest; ++testNdx)
149 		{
150 			const glw::GLint	maskIndex		= (glw::GLint)(rnd.getUint32() % m_maxSampleMaskWords);
151 			glw::GLint			mask			= (glw::GLint)(rnd.getUint32());
152 
153 			gl.glSampleMaski(maskIndex, mask);
154 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "glSampleMaski");
155 
156 			verifyStateIndexedInteger(result, gl, GL_SAMPLE_MASK_VALUE, maskIndex, mask, m_verifierType);
157 		}
158 	}
159 
160 	result.setTestContextResult(m_testCtx);
161 	return STOP;
162 }
163 
164 class MinValueIndexed3Case : public TestCase
165 {
166 public:
167 						MinValueIndexed3Case	(Context& context, const char* name, const char* desc, glw::GLenum target, const tcu::IVec3& ref, QueryType verifierType);
168 
169 private:
170 	IterateResult		iterate					(void);
171 
172 	const glw::GLenum	m_target;
173 	const tcu::IVec3	m_ref;
174 	const QueryType		m_verifierType;
175 };
176 
MinValueIndexed3Case(Context & context,const char * name,const char * desc,glw::GLenum target,const tcu::IVec3 & ref,QueryType verifierType)177 MinValueIndexed3Case::MinValueIndexed3Case (Context& context, const char* name, const char* desc, glw::GLenum target, const tcu::IVec3& ref, QueryType verifierType)
178 	: TestCase				(context, name, desc)
179 	, m_target				(target)
180 	, m_ref					(ref)
181 	, m_verifierType		(verifierType)
182 {
183 }
184 
iterate(void)185 MinValueIndexed3Case::IterateResult MinValueIndexed3Case::iterate (void)
186 {
187 	glu::CallLogWrapper		gl		(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
188 	tcu::ResultCollector	result	(m_testCtx.getLog(), " // ERROR: ");
189 
190 	gl.enableLogging(true);
191 
192 	for (int ndx = 0; ndx < 3; ++ndx)
193 	{
194 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Element", "Element " + de::toString(ndx));
195 
196 		verifyStateIndexedIntegerMin(result, gl, m_target, ndx, m_ref[ndx], m_verifierType);
197 	}
198 
199 	result.setTestContextResult(m_testCtx);
200 	return STOP;
201 }
202 
203 class BufferBindingCase : public TestCase
204 {
205 public:
206 						BufferBindingCase	(Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType);
207 
208 private:
209 	IterateResult		iterate				(void);
210 
211 	const glw::GLenum	m_queryTarget;
212 	const glw::GLenum	m_bufferTarget;
213 	const glw::GLenum	m_numBindingsTarget;
214 	const QueryType		m_verifierType;
215 };
216 
BufferBindingCase(Context & context,const char * name,const char * desc,glw::GLenum queryTarget,glw::GLenum bufferTarget,glw::GLenum numBindingsTarget,QueryType verifierType)217 BufferBindingCase::BufferBindingCase (Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType)
218 	: TestCase				(context, name, desc)
219 	, m_queryTarget			(queryTarget)
220 	, m_bufferTarget		(bufferTarget)
221 	, m_numBindingsTarget	(numBindingsTarget)
222 	, m_verifierType		(verifierType)
223 {
224 }
225 
iterate(void)226 BufferBindingCase::IterateResult BufferBindingCase::iterate (void)
227 {
228 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
229 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
230 	int						maxBindings	= -1;
231 
232 	gl.enableLogging(true);
233 
234 	gl.glGetIntegerv(m_numBindingsTarget, &maxBindings);
235 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
236 
237 	{
238 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
239 
240 		for (int ndx = 0; ndx < maxBindings; ++ndx)
241 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndx, 0, m_verifierType);
242 	}
243 
244 	{
245 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
246 		glu::Buffer					bufferA			(m_context.getRenderContext());
247 		glu::Buffer					bufferB			(m_context.getRenderContext());
248 		const int					ndxA			= 0;
249 		const int					ndxB			= maxBindings / 2;
250 
251 		{
252 			const tcu::ScopedLogSection section(m_testCtx.getLog(), "Generic", "After setting generic binding point");
253 
254 			gl.glBindBuffer(m_bufferTarget, *bufferA);
255 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "glBindBuffer");
256 
257 			verifyStateIndexedInteger(result, gl, m_queryTarget, 0, 0, m_verifierType);
258 		}
259 		{
260 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferBase");
261 
262 			gl.glBindBufferBase(m_bufferTarget, ndxA, *bufferA);
263 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "glBindBufferBase");
264 
265 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, *bufferA, m_verifierType);
266 		}
267 		{
268 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferRange");
269 
270 			gl.glBindBufferRange(m_bufferTarget, ndxB, *bufferB, 0, 8);
271 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "glBindBufferRange");
272 
273 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxB, *bufferB, m_verifierType);
274 		}
275 		if (ndxA != ndxB)
276 		{
277 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "DifferentStates", "Original state did not change");
278 
279 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, *bufferA, m_verifierType);
280 		}
281 	}
282 
283 	result.setTestContextResult(m_testCtx);
284 	return STOP;
285 }
286 
287 class BufferStartCase : public TestCase
288 {
289 public:
290 						BufferStartCase		(Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType);
291 
292 private:
293 	IterateResult		iterate				(void);
294 
295 	const glw::GLenum	m_queryTarget;
296 	const glw::GLenum	m_bufferTarget;
297 	const glw::GLenum	m_numBindingsTarget;
298 	const QueryType		m_verifierType;
299 };
300 
BufferStartCase(Context & context,const char * name,const char * desc,glw::GLenum queryTarget,glw::GLenum bufferTarget,glw::GLenum numBindingsTarget,QueryType verifierType)301 BufferStartCase::BufferStartCase (Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType)
302 	: TestCase				(context, name, desc)
303 	, m_queryTarget			(queryTarget)
304 	, m_bufferTarget		(bufferTarget)
305 	, m_numBindingsTarget	(numBindingsTarget)
306 	, m_verifierType		(verifierType)
307 {
308 }
309 
iterate(void)310 BufferStartCase::IterateResult BufferStartCase::iterate (void)
311 {
312 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
313 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
314 	int						maxBindings	= -1;
315 
316 	gl.enableLogging(true);
317 
318 	gl.glGetIntegerv(m_numBindingsTarget, &maxBindings);
319 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
320 
321 	{
322 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
323 
324 		for (int ndx = 0; ndx < maxBindings; ++ndx)
325 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndx, 0, m_verifierType);
326 	}
327 
328 
329 	{
330 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
331 		glu::Buffer					bufferA			(m_context.getRenderContext());
332 		glu::Buffer					bufferB			(m_context.getRenderContext());
333 		const int					ndxA			= 0;
334 		const int					ndxB			= maxBindings / 2;
335 		int							offset			= -1;
336 
337 		if (m_bufferTarget == GL_ATOMIC_COUNTER_BUFFER)
338 			offset = 4;
339 		else if (m_bufferTarget == GL_SHADER_STORAGE_BUFFER)
340 		{
341 			gl.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &offset);
342 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "get align");
343 		}
344 		else
345 			DE_ASSERT(false);
346 
347 		TCU_CHECK(offset >= 0);
348 
349 		{
350 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Generic", "After setting generic binding point");
351 
352 			gl.glBindBuffer(m_bufferTarget, *bufferA);
353 			gl.glBufferData(m_bufferTarget, 16, DE_NULL, GL_DYNAMIC_READ);
354 			gl.glBindBuffer(m_bufferTarget, *bufferB);
355 			gl.glBufferData(m_bufferTarget, 32, DE_NULL, GL_DYNAMIC_READ);
356 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen bufs");
357 
358 			verifyStateIndexedInteger(result, gl, m_queryTarget, 0, 0, m_verifierType);
359 		}
360 		{
361 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferBase");
362 
363 			gl.glBindBufferBase(m_bufferTarget, ndxA, *bufferA);
364 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind buf");
365 
366 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, 0, m_verifierType);
367 		}
368 		{
369 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferRange");
370 
371 			gl.glBindBufferRange(m_bufferTarget, ndxB, *bufferB, offset, 8);
372 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind buf");
373 
374 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxB, offset, m_verifierType);
375 		}
376 		if (ndxA != ndxB)
377 		{
378 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "DifferentStates", "Original state did not change");
379 
380 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, 0, m_verifierType);
381 		}
382 	}
383 
384 	result.setTestContextResult(m_testCtx);
385 	return STOP;
386 }
387 
388 class BufferSizeCase : public TestCase
389 {
390 public:
391 						BufferSizeCase	(Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType);
392 
393 private:
394 	IterateResult		iterate			(void);
395 
396 	const glw::GLenum	m_queryTarget;
397 	const glw::GLenum	m_bufferTarget;
398 	const glw::GLenum	m_numBindingsTarget;
399 	const QueryType		m_verifierType;
400 };
401 
BufferSizeCase(Context & context,const char * name,const char * desc,glw::GLenum queryTarget,glw::GLenum bufferTarget,glw::GLenum numBindingsTarget,QueryType verifierType)402 BufferSizeCase::BufferSizeCase (Context& context, const char* name, const char* desc, glw::GLenum queryTarget, glw::GLenum bufferTarget, glw::GLenum numBindingsTarget, QueryType verifierType)
403 	: TestCase				(context, name, desc)
404 	, m_queryTarget			(queryTarget)
405 	, m_bufferTarget		(bufferTarget)
406 	, m_numBindingsTarget	(numBindingsTarget)
407 	, m_verifierType		(verifierType)
408 {
409 }
410 
iterate(void)411 BufferSizeCase::IterateResult BufferSizeCase::iterate (void)
412 {
413 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
414 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
415 	int						maxBindings	= -1;
416 
417 	gl.enableLogging(true);
418 
419 	gl.glGetIntegerv(m_numBindingsTarget, &maxBindings);
420 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
421 
422 	{
423 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
424 
425 		for (int ndx = 0; ndx < maxBindings; ++ndx)
426 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndx, 0, m_verifierType);
427 	}
428 
429 	{
430 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
431 		glu::Buffer					bufferA			(m_context.getRenderContext());
432 		glu::Buffer					bufferB			(m_context.getRenderContext());
433 		const int					ndxA			= 0;
434 		const int					ndxB			= maxBindings / 2;
435 
436 		{
437 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Generic", "After setting generic binding point");
438 
439 			gl.glBindBuffer(m_bufferTarget, *bufferA);
440 			gl.glBufferData(m_bufferTarget, 16, DE_NULL, GL_DYNAMIC_READ);
441 			gl.glBindBuffer(m_bufferTarget, *bufferB);
442 			gl.glBufferData(m_bufferTarget, 32, DE_NULL, GL_DYNAMIC_READ);
443 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen bufs");
444 
445 			verifyStateIndexedInteger(result, gl, m_queryTarget, 0, 0, m_verifierType);
446 		}
447 		{
448 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferBase");
449 
450 			gl.glBindBufferBase(m_bufferTarget, ndxA, *bufferA);
451 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind buf");
452 
453 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, 0, m_verifierType);
454 		}
455 		{
456 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "Indexed", "After setting with glBindBufferRange");
457 
458 			gl.glBindBufferRange(m_bufferTarget, ndxB, *bufferB, 0, 8);
459 			GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind buf");
460 
461 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxB, 8, m_verifierType);
462 		}
463 		if (ndxA != ndxB)
464 		{
465 			const tcu::ScopedLogSection	section(m_testCtx.getLog(), "DifferentStates", "Original state did not change");
466 
467 			verifyStateIndexedInteger(result, gl, m_queryTarget, ndxA, 0, m_verifierType);
468 		}
469 	}
470 
471 	result.setTestContextResult(m_testCtx);
472 	return STOP;
473 }
474 
475 class ImageBindingNameCase : public TestCase
476 {
477 public:
478 						ImageBindingNameCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
479 
480 private:
481 	IterateResult		iterate					(void);
482 
483 	const QueryType		m_verifierType;
484 };
485 
ImageBindingNameCase(Context & context,const char * name,const char * desc,QueryType verifierType)486 ImageBindingNameCase::ImageBindingNameCase (Context& context, const char* name, const char* desc, QueryType verifierType)
487 	: TestCase			(context, name, desc)
488 	, m_verifierType	(verifierType)
489 {
490 }
491 
iterate(void)492 ImageBindingNameCase::IterateResult ImageBindingNameCase::iterate (void)
493 {
494 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
495 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
496 	int						maxImages	= -1;
497 
498 	gl.enableLogging(true);
499 
500 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
501 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
502 
503 	{
504 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
505 
506 		for (int ndx = 0; ndx < maxImages; ++ndx)
507 			verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_NAME, ndx, 0, m_verifierType);
508 	}
509 
510 	{
511 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
512 		glu::Texture				textureA		(m_context.getRenderContext());
513 		glu::Texture				textureB		(m_context.getRenderContext());
514 		const int					ndxA			= 0;
515 		const int					ndxB			= maxImages / 2;
516 
517 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
518 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
519 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
520 
521 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
522 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
523 
524 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
525 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 32, 32, 4);
526 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
527 
528 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_FALSE, 2, GL_READ_ONLY, GL_RGBA8UI);
529 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
530 
531 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_NAME, ndxA, *textureA, m_verifierType);
532 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_NAME, ndxB, *textureB, m_verifierType);
533 	}
534 
535 	result.setTestContextResult(m_testCtx);
536 	return STOP;
537 }
538 
539 class ImageBindingLevelCase : public TestCase
540 {
541 public:
542 						ImageBindingLevelCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
543 
544 private:
545 	IterateResult		iterate					(void);
546 
547 	const QueryType		m_verifierType;
548 };
549 
ImageBindingLevelCase(Context & context,const char * name,const char * desc,QueryType verifierType)550 ImageBindingLevelCase::ImageBindingLevelCase (Context& context, const char* name, const char* desc, QueryType verifierType)
551 	: TestCase			(context, name, desc)
552 	, m_verifierType	(verifierType)
553 {
554 }
555 
iterate(void)556 ImageBindingLevelCase::IterateResult ImageBindingLevelCase::iterate (void)
557 {
558 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
559 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
560 	int						maxImages	= -1;
561 
562 	gl.enableLogging(true);
563 
564 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
565 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
566 
567 	{
568 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
569 
570 		for (int ndx = 0; ndx < maxImages; ++ndx)
571 			verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LEVEL, ndx, 0, m_verifierType);
572 	}
573 
574 	{
575 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
576 		glu::Texture				textureA		(m_context.getRenderContext());
577 		glu::Texture				textureB		(m_context.getRenderContext());
578 		const int					ndxA			= 0;
579 		const int					ndxB			= maxImages / 2;
580 
581 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
582 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
583 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
584 
585 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
586 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
587 
588 		gl.glBindTexture(GL_TEXTURE_2D, *textureB);
589 		gl.glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 32, 32);
590 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
591 
592 		gl.glBindImageTexture(ndxB, *textureB, 2, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
593 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
594 
595 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LEVEL, ndxA, 0, m_verifierType);
596 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LEVEL, ndxB, 2, m_verifierType);
597 	}
598 
599 	result.setTestContextResult(m_testCtx);
600 	return STOP;
601 }
602 
603 class ImageBindingLayeredCase : public TestCase
604 {
605 public:
606 						ImageBindingLayeredCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
607 
608 private:
609 	IterateResult		iterate					(void);
610 
611 	const QueryType		m_verifierType;
612 };
613 
ImageBindingLayeredCase(Context & context,const char * name,const char * desc,QueryType verifierType)614 ImageBindingLayeredCase::ImageBindingLayeredCase (Context& context, const char* name, const char* desc, QueryType verifierType)
615 	: TestCase			(context, name, desc)
616 	, m_verifierType	(verifierType)
617 {
618 }
619 
iterate(void)620 ImageBindingLayeredCase::IterateResult ImageBindingLayeredCase::iterate (void)
621 {
622 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
623 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
624 	int						maxImages	= -1;
625 
626 	gl.enableLogging(true);
627 
628 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
629 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
630 
631 	{
632 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
633 
634 		for (int ndx = 0; ndx < maxImages; ++ndx)
635 			verifyStateIndexedBoolean(result, gl, GL_IMAGE_BINDING_LAYERED, ndx, false, m_verifierType);
636 	}
637 
638 	{
639 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
640 		glu::Texture				textureA		(m_context.getRenderContext());
641 		glu::Texture				textureB		(m_context.getRenderContext());
642 		const int					ndxA			= 0;
643 		const int					ndxB			= maxImages / 2;
644 
645 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
646 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
647 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
648 
649 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
650 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
651 
652 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
653 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 32, 32, 4);
654 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
655 
656 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_TRUE, 2, GL_READ_ONLY, GL_RGBA8UI);
657 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
658 
659 		verifyStateIndexedBoolean(result, gl, GL_IMAGE_BINDING_LAYERED, ndxA, false, m_verifierType);
660 		verifyStateIndexedBoolean(result, gl, GL_IMAGE_BINDING_LAYERED, ndxB, true, m_verifierType);
661 	}
662 
663 	result.setTestContextResult(m_testCtx);
664 	return STOP;
665 }
666 
667 class ImageBindingLayerCase : public TestCase
668 {
669 public:
670 						ImageBindingLayerCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
671 
672 private:
673 	IterateResult		iterate					(void);
674 
675 	const QueryType		m_verifierType;
676 };
677 
ImageBindingLayerCase(Context & context,const char * name,const char * desc,QueryType verifierType)678 ImageBindingLayerCase::ImageBindingLayerCase (Context& context, const char* name, const char* desc, QueryType verifierType)
679 	: TestCase			(context, name, desc)
680 	, m_verifierType	(verifierType)
681 {
682 }
683 
iterate(void)684 ImageBindingLayerCase::IterateResult ImageBindingLayerCase::iterate (void)
685 {
686 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
687 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
688 	int						maxImages	= -1;
689 
690 	gl.enableLogging(true);
691 
692 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
693 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
694 
695 	{
696 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
697 
698 		for (int ndx = 0; ndx < maxImages; ++ndx)
699 			verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LAYER, ndx, 0, m_verifierType);
700 	}
701 
702 	{
703 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
704 		glu::Texture				textureA		(m_context.getRenderContext());
705 		glu::Texture				textureB		(m_context.getRenderContext());
706 		const int					ndxA			= 0;
707 		const int					ndxB			= maxImages / 2;
708 
709 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
710 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
711 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
712 
713 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
714 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
715 
716 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
717 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 32, 32, 4);
718 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
719 
720 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_TRUE, 2, GL_READ_ONLY, GL_RGBA8UI);
721 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
722 
723 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LAYER, ndxA, 0, m_verifierType);
724 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_LAYER, ndxB, 2, m_verifierType);
725 	}
726 
727 	result.setTestContextResult(m_testCtx);
728 	return STOP;
729 }
730 
731 class ImageBindingAccessCase : public TestCase
732 {
733 public:
734 						ImageBindingAccessCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
735 
736 private:
737 	IterateResult		iterate					(void);
738 
739 	const QueryType		m_verifierType;
740 };
741 
ImageBindingAccessCase(Context & context,const char * name,const char * desc,QueryType verifierType)742 ImageBindingAccessCase::ImageBindingAccessCase (Context& context, const char* name, const char* desc, QueryType verifierType)
743 	: TestCase			(context, name, desc)
744 	, m_verifierType	(verifierType)
745 {
746 }
747 
iterate(void)748 ImageBindingAccessCase::IterateResult ImageBindingAccessCase::iterate (void)
749 {
750 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
751 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
752 	int						maxImages	= -1;
753 
754 	gl.enableLogging(true);
755 
756 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
757 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
758 
759 	{
760 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
761 
762 		for (int ndx = 0; ndx < maxImages; ++ndx)
763 			verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_ACCESS, ndx, GL_READ_ONLY, m_verifierType);
764 	}
765 
766 	{
767 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
768 		glu::Texture				textureA		(m_context.getRenderContext());
769 		glu::Texture				textureB		(m_context.getRenderContext());
770 		const int					ndxA			= 0;
771 		const int					ndxB			= maxImages / 2;
772 
773 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
774 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
775 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
776 
777 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
778 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
779 
780 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
781 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 32, 32, 4);
782 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
783 
784 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_TRUE, 2, GL_READ_WRITE, GL_RGBA8UI);
785 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
786 
787 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_ACCESS, ndxA, GL_READ_ONLY, m_verifierType);
788 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_ACCESS, ndxB, GL_READ_WRITE, m_verifierType);
789 	}
790 
791 	result.setTestContextResult(m_testCtx);
792 	return STOP;
793 }
794 
795 class ImageBindingFormatCase : public TestCase
796 {
797 public:
798 						ImageBindingFormatCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
799 
800 private:
801 	IterateResult		iterate					(void);
802 
803 	const QueryType		m_verifierType;
804 };
805 
ImageBindingFormatCase(Context & context,const char * name,const char * desc,QueryType verifierType)806 ImageBindingFormatCase::ImageBindingFormatCase (Context& context, const char* name, const char* desc, QueryType verifierType)
807 	: TestCase			(context, name, desc)
808 	, m_verifierType	(verifierType)
809 {
810 }
811 
iterate(void)812 ImageBindingFormatCase::IterateResult ImageBindingFormatCase::iterate (void)
813 {
814 	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
815 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
816 	int						maxImages	= -1;
817 
818 	gl.enableLogging(true);
819 
820 	gl.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImages);
821 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
822 
823 	{
824 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
825 
826 		for (int ndx = 0; ndx < maxImages; ++ndx)
827 			if (glu::isContextTypeES(m_context.getRenderContext().getType()))
828 				verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndx, GL_R32UI, m_verifierType);
829 			else
830 				verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndx, GL_R8, m_verifierType);
831 	}
832 
833 	{
834 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
835 		glu::Texture				textureA		(m_context.getRenderContext());
836 		glu::Texture				textureB		(m_context.getRenderContext());
837 		const int					ndxA			= 0;
838 		const int					ndxB			= maxImages / 2;
839 
840 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
841 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
842 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
843 
844 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
845 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
846 
847 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
848 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_R32F, 32, 32, 4);
849 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
850 
851 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_TRUE, 2, GL_READ_WRITE, GL_R32F);
852 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
853 
854 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndxA, GL_RGBA8UI, m_verifierType);
855 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndxB, GL_R32F, m_verifierType);
856 	}
857 
858 	result.setTestContextResult(m_testCtx);
859 	return STOP;
860 }
861 
862 class ColorMaskCase : public TestCase
863 {
864 public:
865 						ColorMaskCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
866 
867 	void				init			(void);
868 private:
869 	IterateResult		iterate			(void);
870 
871 	const QueryType		m_verifierType;
872 };
873 
ColorMaskCase(Context & context,const char * name,const char * desc,QueryType verifierType)874 ColorMaskCase::ColorMaskCase (Context& context, const char* name, const char* desc, QueryType verifierType)
875 	: TestCase			(context, name, desc)
876 	, m_verifierType	(verifierType)
877 {
878 }
879 
init(void)880 void ColorMaskCase::init (void)
881 {
882 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
883 }
884 
iterate(void)885 ColorMaskCase::IterateResult ColorMaskCase::iterate (void)
886 {
887 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
888 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
889 	deInt32					maxDrawBuffers = 0;
890 
891 	gl.enableLogging(true);
892 
893 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
894 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
895 
896 	{
897 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
898 
899 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
900 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(true), m_verifierType);
901 	}
902 	{
903 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
904 
905 		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
906 
907 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
908 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
909 	}
910 	{
911 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
912 
913 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
914 			gl.glColorMaski(ndx, (ndx % 2 == 0 ? GL_TRUE : GL_FALSE), (ndx % 2 == 1 ? GL_TRUE : GL_FALSE), (ndx % 2 == 0 ? GL_TRUE : GL_FALSE), (ndx % 2 == 1 ? GL_TRUE : GL_FALSE));
915 
916 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
917 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, (ndx % 2 == 0 ? tcu::BVec4(true, false, true, false) : tcu::BVec4(false, true, false, true)), m_verifierType);
918 	}
919 	{
920 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
921 
922 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
923 			gl.glColorMaski(ndx, (ndx % 2 == 0 ? GL_TRUE : GL_FALSE), (ndx % 2 == 1 ? GL_TRUE : GL_FALSE), (ndx % 2 == 0 ? GL_TRUE : GL_FALSE), (ndx % 2 == 1 ? GL_TRUE : GL_FALSE));
924 
925 		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
926 
927 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
928 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
929 	}
930 
931 	result.setTestContextResult(m_testCtx);
932 	return STOP;
933 }
934 
935 class BlendFuncCase : public TestCase
936 {
937 public:
938 						BlendFuncCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
939 
940 	void				init			(void);
941 private:
942 	IterateResult		iterate			(void);
943 
944 	const QueryType		m_verifierType;
945 };
946 
BlendFuncCase(Context & context,const char * name,const char * desc,QueryType verifierType)947 BlendFuncCase::BlendFuncCase (Context& context, const char* name, const char* desc, QueryType verifierType)
948 	: TestCase			(context, name, desc)
949 	, m_verifierType	(verifierType)
950 {
951 }
952 
init(void)953 void BlendFuncCase::init (void)
954 {
955 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
956 }
957 
iterate(void)958 BlendFuncCase::IterateResult BlendFuncCase::iterate (void)
959 {
960 	const deUint32 blendFuncs[] =
961 	{
962 		GL_ZERO,
963 		GL_ONE,
964 		GL_SRC_COLOR,
965 		GL_ONE_MINUS_SRC_COLOR,
966 		GL_DST_COLOR,
967 		GL_ONE_MINUS_DST_COLOR,
968 		GL_SRC_ALPHA,
969 		GL_ONE_MINUS_SRC_ALPHA,
970 		GL_DST_ALPHA,
971 		GL_ONE_MINUS_DST_ALPHA,
972 		GL_CONSTANT_COLOR,
973 		GL_ONE_MINUS_CONSTANT_COLOR,
974 		GL_CONSTANT_ALPHA,
975 		GL_ONE_MINUS_CONSTANT_ALPHA,
976 		GL_SRC_ALPHA_SATURATE
977 	};
978 
979 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
980 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
981 	deInt32					maxDrawBuffers = 0;
982 
983 	gl.enableLogging(true);
984 
985 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
986 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
987 
988 	{
989 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
990 
991 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
992 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_ONE, m_verifierType);
993 
994 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
995 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ZERO, m_verifierType);
996 
997 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
998 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_ONE, m_verifierType);
999 
1000 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1001 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ZERO, m_verifierType);
1002 	}
1003 	{
1004 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1005 
1006 		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
1007 
1008 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1009 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
1010 
1011 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1012 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
1013 
1014 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1015 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
1016 
1017 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1018 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
1019 	}
1020 	{
1021 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
1022 
1023 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1024 
1025 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1026 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
1027 
1028 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1029 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
1030 
1031 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1032 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
1033 
1034 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1035 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
1036 	}
1037 	{
1038 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1039 
1040 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1041 			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1042 
1043 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1044 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1045 
1046 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1047 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1048 
1049 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1050 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1051 
1052 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1053 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1054 	}
1055 	{
1056 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
1057 
1058 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1059 			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1060 										 blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1061 										 blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1062 										 blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1063 
1064 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1065 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1066 
1067 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1068 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1069 
1070 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1071 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1072 
1073 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1074 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1075 
1076 	}
1077 	{
1078 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1079 
1080 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1081 			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1082 
1083 		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
1084 
1085 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1086 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
1087 
1088 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1089 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
1090 
1091 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1092 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
1093 
1094 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1095 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
1096 	}
1097 	{
1098 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
1099 
1100 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1101 
1102 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1103 			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1104 										 blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1105 										 blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1106 										 blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1107 
1108 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1109 
1110 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1111 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
1112 
1113 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1114 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
1115 
1116 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1117 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
1118 
1119 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1120 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
1121 	}
1122 
1123 	result.setTestContextResult(m_testCtx);
1124 	return STOP;
1125 }
1126 
1127 class BlendEquationCase : public TestCase
1128 {
1129 public:
1130 						BlendEquationCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1131 
1132 	void				init				(void);
1133 private:
1134 	IterateResult		iterate				(void);
1135 
1136 	const QueryType		m_verifierType;
1137 };
1138 
BlendEquationCase(Context & context,const char * name,const char * desc,QueryType verifierType)1139 BlendEquationCase::BlendEquationCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1140 	: TestCase			(context, name, desc)
1141 	, m_verifierType	(verifierType)
1142 {
1143 }
1144 
init(void)1145 void BlendEquationCase::init (void)
1146 {
1147 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1148 }
1149 
iterate(void)1150 BlendEquationCase::IterateResult BlendEquationCase::iterate (void)
1151 {
1152 	const deUint32 blendEquations[] =
1153 	{
1154 		GL_FUNC_ADD,
1155 		GL_FUNC_SUBTRACT,
1156 		GL_FUNC_REVERSE_SUBTRACT,
1157 		GL_MIN,
1158 		GL_MAX
1159 	};
1160 
1161 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1162 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1163 	deInt32					maxDrawBuffers = 0;
1164 
1165 	gl.enableLogging(true);
1166 
1167 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1168 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1169 
1170 	{
1171 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
1172 
1173 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1174 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_ADD, m_verifierType);
1175 
1176 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1177 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_ADD, m_verifierType);
1178 	}
1179 	{
1180 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1181 
1182 		gl.glBlendEquation(GL_FUNC_SUBTRACT);
1183 
1184 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1185 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1186 
1187 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1188 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1189 	}
1190 	{
1191 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
1192 
1193 		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
1194 
1195 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1196 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
1197 
1198 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1199 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1200 	}
1201 	{
1202 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1203 
1204 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1205 			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
1206 
1207 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1208 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1209 
1210 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1211 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1212 	}
1213 	{
1214 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
1215 
1216 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1217 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1218 
1219 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1220 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1221 
1222 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1223 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1224 	}
1225 	{
1226 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1227 
1228 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1229 			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
1230 
1231 		gl.glBlendEquation(GL_FUNC_SUBTRACT);
1232 
1233 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1234 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1235 
1236 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1237 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1238 	}
1239 	{
1240 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
1241 
1242 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1243 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1244 
1245 		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
1246 
1247 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1248 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
1249 
1250 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1251 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1252 	}
1253 
1254 	result.setTestContextResult(m_testCtx);
1255 	return STOP;
1256 }
1257 
1258 class BlendEquationAdvancedCase : public TestCase
1259 {
1260 public:
1261 						BlendEquationAdvancedCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1262 
1263 	void				init				(void);
1264 private:
1265 	IterateResult		iterate				(void);
1266 
1267 	const QueryType		m_verifierType;
1268 };
1269 
BlendEquationAdvancedCase(Context & context,const char * name,const char * desc,QueryType verifierType)1270 BlendEquationAdvancedCase::BlendEquationAdvancedCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1271 	: TestCase			(context, name, desc)
1272 	, m_verifierType	(verifierType)
1273 {
1274 }
1275 
init(void)1276 void BlendEquationAdvancedCase::init (void)
1277 {
1278 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1279 	isExtensionSupported(m_context, "GL_KHR_blend_equation_advanced");
1280 }
1281 
iterate(void)1282 BlendEquationAdvancedCase::IterateResult BlendEquationAdvancedCase::iterate (void)
1283 {
1284 	const deUint32 blendEquations[] =
1285 	{
1286 		GL_FUNC_ADD,
1287 		GL_FUNC_SUBTRACT,
1288 		GL_FUNC_REVERSE_SUBTRACT,
1289 		GL_MIN,
1290 		GL_MAX
1291 	};
1292 
1293 	const deUint32 blendEquationAdvanced[] =
1294 	{
1295 		GL_MULTIPLY,
1296 		GL_SCREEN,
1297 		GL_OVERLAY,
1298 		GL_DARKEN,
1299 		GL_LIGHTEN,
1300 		GL_COLORDODGE,
1301 		GL_COLORBURN,
1302 		GL_HARDLIGHT,
1303 		GL_SOFTLIGHT,
1304 		GL_DIFFERENCE,
1305 		GL_EXCLUSION,
1306 		GL_HSL_HUE,
1307 		GL_HSL_SATURATION,
1308 		GL_HSL_COLOR,
1309 		GL_HSL_LUMINOSITY
1310 	};
1311 
1312 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1313 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1314 	deInt32					maxDrawBuffers = 0;
1315 
1316 	gl.enableLogging(true);
1317 
1318 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1319 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1320 
1321 	{
1322 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1323 
1324 		gl.glBlendEquation(GL_SCREEN);
1325 
1326 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1327 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_SCREEN, m_verifierType);
1328 
1329 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1330 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_SCREEN, m_verifierType);
1331 	}
1332 	{
1333 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1334 
1335 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1336 			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1337 
1338 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1339 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1340 
1341 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1342 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1343 	}
1344 	{
1345 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1346 
1347 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1348 			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1349 
1350 		gl.glBlendEquation(GL_MULTIPLY);
1351 
1352 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1353 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_MULTIPLY, m_verifierType);
1354 
1355 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1356 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_MULTIPLY, m_verifierType);
1357 	}
1358 	{
1359 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedSeparateWithCommon", "After resetting indexed separate with common");
1360 
1361 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1362 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1363 
1364 		gl.glBlendEquation(GL_LIGHTEN);
1365 
1366 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1367 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_LIGHTEN, m_verifierType);
1368 
1369 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1370 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_LIGHTEN, m_verifierType);
1371 	}
1372 
1373 	result.setTestContextResult(m_testCtx);
1374 	return STOP;
1375 }
1376 
1377 } // anonymous
1378 
IndexedStateQueryTests(Context & context)1379 IndexedStateQueryTests::IndexedStateQueryTests (Context& context)
1380 	: TestCaseGroup(context, "indexed", "Indexed state queries")
1381 {
1382 }
1383 
~IndexedStateQueryTests(void)1384 IndexedStateQueryTests::~IndexedStateQueryTests (void)
1385 {
1386 }
1387 
init(void)1388 void IndexedStateQueryTests::init (void)
1389 {
1390 	static const QueryType verifiers[] = { QUERY_INDEXED_BOOLEAN, QUERY_INDEXED_INTEGER, QUERY_INDEXED_INTEGER64 };
1391 
1392 #define FOR_EACH_VERIFIER(X) \
1393 	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)	\
1394 	{																						\
1395 		const QueryType verifier = verifiers[verifierNdx];									\
1396 		const char* verifierSuffix = getVerifierSuffix(verifier);							\
1397 		this->addChild(X);																	\
1398 	}
1399 
1400 	FOR_EACH_VERIFIER(new SampleMaskCase			(m_context, (std::string() + "sample_mask_value_" + verifierSuffix).c_str(),				"Test SAMPLE_MASK_VALUE", verifier))
1401 
1402 	FOR_EACH_VERIFIER(new MinValueIndexed3Case		(m_context, (std::string() + "max_compute_work_group_count_" + verifierSuffix).c_str(),		"Test MAX_COMPUTE_WORK_GROUP_COUNT",	GL_MAX_COMPUTE_WORK_GROUP_COUNT,	tcu::IVec3(65535,65535,65535),	verifier))
1403 	FOR_EACH_VERIFIER(new MinValueIndexed3Case		(m_context, (std::string() + "max_compute_work_group_size_" + verifierSuffix).c_str(),		"Test MAX_COMPUTE_WORK_GROUP_SIZE",		GL_MAX_COMPUTE_WORK_GROUP_SIZE,		tcu::IVec3(128, 128, 64),		verifier))
1404 
1405 	FOR_EACH_VERIFIER(new BufferBindingCase			(m_context, (std::string() + "atomic_counter_buffer_binding_" + verifierSuffix).c_str(),	"Test ATOMIC_COUNTER_BUFFER_BINDING",	GL_ATOMIC_COUNTER_BUFFER_BINDING,	GL_ATOMIC_COUNTER_BUFFER,	GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS,	verifier))
1406 	FOR_EACH_VERIFIER(new BufferStartCase			(m_context, (std::string() + "atomic_counter_buffer_start_" + verifierSuffix).c_str(),		"Test ATOMIC_COUNTER_BUFFER_START",		GL_ATOMIC_COUNTER_BUFFER_START,		GL_ATOMIC_COUNTER_BUFFER,	GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS,	verifier))
1407 	FOR_EACH_VERIFIER(new BufferSizeCase			(m_context, (std::string() + "atomic_counter_buffer_size_" + verifierSuffix).c_str(),		"Test ATOMIC_COUNTER_BUFFER_SIZE",		GL_ATOMIC_COUNTER_BUFFER_SIZE,		GL_ATOMIC_COUNTER_BUFFER,	GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS,	verifier))
1408 
1409 	FOR_EACH_VERIFIER(new BufferBindingCase			(m_context, (std::string() + "shader_storage_buffer_binding_" + verifierSuffix).c_str(),	"Test SHADER_STORAGE_BUFFER_BINDING",	GL_SHADER_STORAGE_BUFFER_BINDING,	GL_SHADER_STORAGE_BUFFER,	GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,	verifier))
1410 	FOR_EACH_VERIFIER(new BufferStartCase			(m_context, (std::string() + "shader_storage_buffer_start_" + verifierSuffix).c_str(),		"Test SHADER_STORAGE_BUFFER_START",		GL_SHADER_STORAGE_BUFFER_START,		GL_SHADER_STORAGE_BUFFER,	GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,	verifier))
1411 	FOR_EACH_VERIFIER(new BufferSizeCase			(m_context, (std::string() + "shader_storage_buffer_size_" + verifierSuffix).c_str(),		"Test SHADER_STORAGE_BUFFER_SIZE",		GL_SHADER_STORAGE_BUFFER_SIZE,		GL_SHADER_STORAGE_BUFFER,	GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,	verifier))
1412 
1413 	FOR_EACH_VERIFIER(new ImageBindingNameCase		(m_context, (std::string() + "image_binding_name_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_NAME",				verifier))
1414 	FOR_EACH_VERIFIER(new ImageBindingLevelCase		(m_context, (std::string() + "image_binding_level_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_LEVEL",				verifier))
1415 	FOR_EACH_VERIFIER(new ImageBindingLayeredCase	(m_context, (std::string() + "image_binding_layered_" + verifierSuffix).c_str(),			"Test IMAGE_BINDING_LAYERED",			verifier))
1416 	FOR_EACH_VERIFIER(new ImageBindingLayerCase		(m_context, (std::string() + "image_binding_layer_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_LAYER",				verifier))
1417 	FOR_EACH_VERIFIER(new ImageBindingAccessCase	(m_context, (std::string() + "image_binding_access_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_ACCESS",			verifier))
1418 	FOR_EACH_VERIFIER(new ImageBindingFormatCase	(m_context, (std::string() + "image_binding_format_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_FORMAT",			verifier))
1419 
1420 	// All non-boolean verifiers are tested in ES3 test module.
1421 	addChild(new ColorMaskCase(m_context, "color_mask_getbooleani_v", "COLOR_WRITEMASK", QUERY_INDEXED_BOOLEAN_VEC4));
1422 	addChild(new BlendFuncCase(m_context, "blend_func_getbooleani_v", "BLEND_SRC and BLEND_DST", QUERY_INDEXED_BOOLEAN));
1423 	addChild(new BlendEquationCase(m_context, "blend_equation_getbooleani_v", "BLEND_EQUATION_RGB and BLEND_DST", QUERY_INDEXED_BOOLEAN));
1424 	addChild(new BlendEquationAdvancedCase(m_context, "blend_equation_advanced_getbooleani_v", "BLEND_EQUATION_RGB and BLEND_DST", QUERY_INDEXED_BOOLEAN));
1425 
1426 #undef FOR_EACH_VEC4_VERIFIER
1427 #undef FOR_EACH_VERIFIER
1428 }
1429 
1430 } // Functional
1431 } // gles31
1432 } // deqp
1433