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