• 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 			verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndx, GL_R32UI, m_verifierType);
828 	}
829 
830 	{
831 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSetting", "After setting");
832 		glu::Texture				textureA		(m_context.getRenderContext());
833 		glu::Texture				textureB		(m_context.getRenderContext());
834 		const int					ndxA			= 0;
835 		const int					ndxB			= maxImages / 2;
836 
837 		gl.glBindTexture(GL_TEXTURE_2D, *textureA);
838 		gl.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 32, 32);
839 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
840 
841 		gl.glBindImageTexture(ndxA, *textureA, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8UI);
842 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
843 
844 		gl.glBindTexture(GL_TEXTURE_2D_ARRAY, *textureB);
845 		gl.glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_R32F, 32, 32, 4);
846 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "gen tex");
847 
848 		gl.glBindImageTexture(ndxB, *textureB, 0, GL_TRUE, 2, GL_READ_WRITE, GL_R32F);
849 		GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind unit");
850 
851 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndxA, GL_RGBA8UI, m_verifierType);
852 		verifyStateIndexedInteger(result, gl, GL_IMAGE_BINDING_FORMAT, ndxB, GL_R32F, m_verifierType);
853 	}
854 
855 	result.setTestContextResult(m_testCtx);
856 	return STOP;
857 }
858 
859 class EnableBlendCase : public TestCase
860 {
861 public:
862 						EnableBlendCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
863 
864 	void				init			(void);
865 private:
866 	IterateResult		iterate			(void);
867 
868 	const QueryType		m_verifierType;
869 };
870 
EnableBlendCase(Context & context,const char * name,const char * desc,QueryType verifierType)871 EnableBlendCase::EnableBlendCase (Context& context, const char* name, const char* desc, QueryType verifierType)
872 	: TestCase			(context, name, desc)
873 	, m_verifierType	(verifierType)
874 {
875 }
876 
init(void)877 void EnableBlendCase::init (void)
878 {
879 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
880 }
881 
iterate(void)882 EnableBlendCase::IterateResult EnableBlendCase::iterate (void)
883 {
884 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
885 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
886 	deInt32					maxDrawBuffers = 0;
887 
888 	gl.enableLogging(true);
889 
890 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
891 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
892 
893 	{
894 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
895 
896 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
897 			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, false, m_verifierType);
898 	}
899 	{
900 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
901 
902 		gl.glEnable(GL_BLEND);
903 
904 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
905 			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, true, m_verifierType);
906 
907 	}
908 	{
909 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
910 
911 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
912 		{
913 			if (ndx % 2 == 0)
914 				gl.glEnablei(GL_BLEND, ndx);
915 			else
916 				gl.glDisablei(GL_BLEND, ndx);
917 		}
918 
919 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
920 			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, (ndx % 2 == 0), m_verifierType);
921 	}
922 	{
923 		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
924 
925 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
926 		{
927 			if (ndx % 2 == 0)
928 				gl.glEnablei(GL_BLEND, ndx);
929 			else
930 				gl.glDisablei(GL_BLEND, ndx);
931 		}
932 
933 		gl.glEnable(GL_BLEND);
934 
935 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
936 			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, true, m_verifierType);
937 	}
938 
939 	result.setTestContextResult(m_testCtx);
940 	return STOP;
941 }
942 
943 class ColorMaskCase : public TestCase
944 {
945 public:
946 						ColorMaskCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
947 
948 	void				init			(void);
949 private:
950 	IterateResult		iterate			(void);
951 
952 	const QueryType		m_verifierType;
953 };
954 
ColorMaskCase(Context & context,const char * name,const char * desc,QueryType verifierType)955 ColorMaskCase::ColorMaskCase (Context& context, const char* name, const char* desc, QueryType verifierType)
956 	: TestCase			(context, name, desc)
957 	, m_verifierType	(verifierType)
958 {
959 }
960 
init(void)961 void ColorMaskCase::init (void)
962 {
963 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
964 }
965 
iterate(void)966 ColorMaskCase::IterateResult ColorMaskCase::iterate (void)
967 {
968 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
969 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
970 	deInt32					maxDrawBuffers = 0;
971 
972 	gl.enableLogging(true);
973 
974 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
975 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
976 
977 	{
978 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
979 
980 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
981 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(true), m_verifierType);
982 	}
983 	{
984 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
985 
986 		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
987 
988 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
989 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
990 	}
991 	{
992 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
993 
994 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
995 			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));
996 
997 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
998 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, (ndx % 2 == 0 ? tcu::BVec4(true, false, true, false) : tcu::BVec4(false, true, false, true)), m_verifierType);
999 	}
1000 	{
1001 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1002 
1003 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1004 			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));
1005 
1006 		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
1007 
1008 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1009 			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
1010 	}
1011 
1012 	result.setTestContextResult(m_testCtx);
1013 	return STOP;
1014 }
1015 
1016 class BlendFuncCase : public TestCase
1017 {
1018 public:
1019 						BlendFuncCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1020 
1021 	void				init			(void);
1022 private:
1023 	IterateResult		iterate			(void);
1024 
1025 	const QueryType		m_verifierType;
1026 };
1027 
BlendFuncCase(Context & context,const char * name,const char * desc,QueryType verifierType)1028 BlendFuncCase::BlendFuncCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1029 	: TestCase			(context, name, desc)
1030 	, m_verifierType	(verifierType)
1031 {
1032 }
1033 
init(void)1034 void BlendFuncCase::init (void)
1035 {
1036 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1037 }
1038 
iterate(void)1039 BlendFuncCase::IterateResult BlendFuncCase::iterate (void)
1040 {
1041 	const deUint32 blendFuncs[] =
1042 	{
1043 		GL_ZERO,
1044 		GL_ONE,
1045 		GL_SRC_COLOR,
1046 		GL_ONE_MINUS_SRC_COLOR,
1047 		GL_DST_COLOR,
1048 		GL_ONE_MINUS_DST_COLOR,
1049 		GL_SRC_ALPHA,
1050 		GL_ONE_MINUS_SRC_ALPHA,
1051 		GL_DST_ALPHA,
1052 		GL_ONE_MINUS_DST_ALPHA,
1053 		GL_CONSTANT_COLOR,
1054 		GL_ONE_MINUS_CONSTANT_COLOR,
1055 		GL_CONSTANT_ALPHA,
1056 		GL_ONE_MINUS_CONSTANT_ALPHA,
1057 		GL_SRC_ALPHA_SATURATE
1058 	};
1059 
1060 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1061 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1062 	deInt32					maxDrawBuffers = 0;
1063 
1064 	gl.enableLogging(true);
1065 
1066 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1067 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1068 
1069 	{
1070 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
1071 
1072 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1073 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_ONE, m_verifierType);
1074 
1075 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1076 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ZERO, m_verifierType);
1077 
1078 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1079 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_ONE, m_verifierType);
1080 
1081 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1082 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ZERO, m_verifierType);
1083 	}
1084 	{
1085 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1086 
1087 		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
1088 
1089 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1090 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
1091 
1092 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1093 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
1094 
1095 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1096 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
1097 
1098 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1099 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
1100 	}
1101 	{
1102 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
1103 
1104 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1105 
1106 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1107 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
1108 
1109 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1110 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
1111 
1112 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1113 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
1114 
1115 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1116 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
1117 	}
1118 	{
1119 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1120 
1121 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1122 			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1123 
1124 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1125 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1126 
1127 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1128 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1129 
1130 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1131 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1132 
1133 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1134 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1135 	}
1136 	{
1137 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
1138 
1139 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1140 			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1141 										 blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1142 										 blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1143 										 blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1144 
1145 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1146 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1147 
1148 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1149 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1150 
1151 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1152 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1153 
1154 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1155 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
1156 
1157 	}
1158 	{
1159 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1160 
1161 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1162 			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1163 
1164 		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
1165 
1166 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1167 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
1168 
1169 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1170 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
1171 
1172 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1173 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
1174 
1175 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1176 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
1177 	}
1178 	{
1179 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
1180 
1181 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1182 
1183 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1184 			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1185 										 blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1186 										 blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
1187 										 blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
1188 
1189 		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
1190 
1191 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1192 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
1193 
1194 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1195 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
1196 
1197 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1198 			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
1199 
1200 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1201 			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
1202 	}
1203 
1204 	result.setTestContextResult(m_testCtx);
1205 	return STOP;
1206 }
1207 
1208 class BlendEquationCase : public TestCase
1209 {
1210 public:
1211 						BlendEquationCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1212 
1213 	void				init				(void);
1214 private:
1215 	IterateResult		iterate				(void);
1216 
1217 	const QueryType		m_verifierType;
1218 };
1219 
BlendEquationCase(Context & context,const char * name,const char * desc,QueryType verifierType)1220 BlendEquationCase::BlendEquationCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1221 	: TestCase			(context, name, desc)
1222 	, m_verifierType	(verifierType)
1223 {
1224 }
1225 
init(void)1226 void BlendEquationCase::init (void)
1227 {
1228 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1229 }
1230 
iterate(void)1231 BlendEquationCase::IterateResult BlendEquationCase::iterate (void)
1232 {
1233 	const deUint32 blendEquations[] =
1234 	{
1235 		GL_FUNC_ADD,
1236 		GL_FUNC_SUBTRACT,
1237 		GL_FUNC_REVERSE_SUBTRACT,
1238 		GL_MIN,
1239 		GL_MAX
1240 	};
1241 
1242 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1243 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1244 	deInt32					maxDrawBuffers = 0;
1245 
1246 	gl.enableLogging(true);
1247 
1248 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1249 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1250 
1251 	{
1252 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
1253 
1254 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1255 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_ADD, m_verifierType);
1256 
1257 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1258 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_ADD, m_verifierType);
1259 	}
1260 	{
1261 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1262 
1263 		gl.glBlendEquation(GL_FUNC_SUBTRACT);
1264 
1265 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1266 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1267 
1268 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1269 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1270 	}
1271 	{
1272 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
1273 
1274 		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
1275 
1276 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1277 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
1278 
1279 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1280 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1281 	}
1282 	{
1283 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1284 
1285 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1286 			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
1287 
1288 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1289 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1290 
1291 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1292 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1293 	}
1294 	{
1295 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
1296 
1297 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1298 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1299 
1300 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1301 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1302 
1303 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1304 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
1305 	}
1306 	{
1307 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1308 
1309 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1310 			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
1311 
1312 		gl.glBlendEquation(GL_FUNC_SUBTRACT);
1313 
1314 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1315 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1316 
1317 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1318 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1319 	}
1320 	{
1321 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
1322 
1323 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1324 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1325 
1326 		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
1327 
1328 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1329 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
1330 
1331 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1332 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1333 	}
1334 
1335 	result.setTestContextResult(m_testCtx);
1336 	return STOP;
1337 }
1338 
1339 class BlendEquationAdvancedCase : public TestCase
1340 {
1341 public:
1342 						BlendEquationAdvancedCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1343 
1344 	void				init				(void);
1345 private:
1346 	IterateResult		iterate				(void);
1347 
1348 	const QueryType		m_verifierType;
1349 };
1350 
BlendEquationAdvancedCase(Context & context,const char * name,const char * desc,QueryType verifierType)1351 BlendEquationAdvancedCase::BlendEquationAdvancedCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1352 	: TestCase			(context, name, desc)
1353 	, m_verifierType	(verifierType)
1354 {
1355 }
1356 
init(void)1357 void BlendEquationAdvancedCase::init (void)
1358 {
1359 	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1360 	isExtensionSupported(m_context, "GL_KHR_blend_equation_advanced");
1361 }
1362 
iterate(void)1363 BlendEquationAdvancedCase::IterateResult BlendEquationAdvancedCase::iterate (void)
1364 {
1365 	const deUint32 blendEquations[] =
1366 	{
1367 		GL_FUNC_ADD,
1368 		GL_FUNC_SUBTRACT,
1369 		GL_FUNC_REVERSE_SUBTRACT,
1370 		GL_MIN,
1371 		GL_MAX
1372 	};
1373 
1374 	const deUint32 blendEquationAdvanced[] =
1375 	{
1376 		GL_MULTIPLY,
1377 		GL_SCREEN,
1378 		GL_OVERLAY,
1379 		GL_DARKEN,
1380 		GL_LIGHTEN,
1381 		GL_COLORDODGE,
1382 		GL_COLORBURN,
1383 		GL_HARDLIGHT,
1384 		GL_SOFTLIGHT,
1385 		GL_DIFFERENCE,
1386 		GL_EXCLUSION,
1387 		GL_HSL_HUE,
1388 		GL_HSL_SATURATION,
1389 		GL_HSL_COLOR,
1390 		GL_HSL_LUMINOSITY
1391 	};
1392 
1393 	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1394 	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1395 	deInt32					maxDrawBuffers = 0;
1396 
1397 	gl.enableLogging(true);
1398 
1399 	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1400 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1401 
1402 	{
1403 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1404 
1405 		gl.glBlendEquation(GL_SCREEN);
1406 
1407 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1408 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_SCREEN, m_verifierType);
1409 
1410 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1411 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_SCREEN, m_verifierType);
1412 	}
1413 	{
1414 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1415 
1416 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1417 			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1418 
1419 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1420 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1421 
1422 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1423 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1424 	}
1425 	{
1426 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1427 
1428 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1429 			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1430 
1431 		gl.glBlendEquation(GL_MULTIPLY);
1432 
1433 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1434 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_MULTIPLY, m_verifierType);
1435 
1436 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1437 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_MULTIPLY, m_verifierType);
1438 	}
1439 	{
1440 		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedSeparateWithCommon", "After resetting indexed separate with common");
1441 
1442 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1443 			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1444 
1445 		gl.glBlendEquation(GL_LIGHTEN);
1446 
1447 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1448 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_LIGHTEN, m_verifierType);
1449 
1450 		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1451 			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_LIGHTEN, m_verifierType);
1452 	}
1453 
1454 	result.setTestContextResult(m_testCtx);
1455 	return STOP;
1456 }
1457 
1458 } // anonymous
1459 
IndexedStateQueryTests(Context & context)1460 IndexedStateQueryTests::IndexedStateQueryTests (Context& context)
1461 	: TestCaseGroup(context, "indexed", "Indexed state queries")
1462 {
1463 }
1464 
~IndexedStateQueryTests(void)1465 IndexedStateQueryTests::~IndexedStateQueryTests (void)
1466 {
1467 }
1468 
init(void)1469 void IndexedStateQueryTests::init (void)
1470 {
1471 	static const QueryType verifiers[] = { QUERY_INDEXED_BOOLEAN, QUERY_INDEXED_INTEGER, QUERY_INDEXED_INTEGER64 };
1472 	static const QueryType vec4Verifiers[] = { QUERY_INDEXED_BOOLEAN_VEC4, QUERY_INDEXED_INTEGER_VEC4, QUERY_INDEXED_INTEGER64_VEC4 };
1473 
1474 #define FOR_EACH_VERIFIER(X) \
1475 	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)	\
1476 	{																						\
1477 		const QueryType verifier = verifiers[verifierNdx];									\
1478 		const char* verifierSuffix = getVerifierSuffix(verifier);							\
1479 		this->addChild(X);																	\
1480 	}
1481 
1482 #define FOR_EACH_VEC4_VERIFIER(X) \
1483 	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(vec4Verifiers); ++verifierNdx)	\
1484 	{																							\
1485 		const QueryType verifier = vec4Verifiers[verifierNdx];									\
1486 		const char* verifierSuffix = getVerifierSuffix(verifier);								\
1487 		this->addChild(X);																		\
1488 	}
1489 
1490 	FOR_EACH_VERIFIER(new SampleMaskCase			(m_context, (std::string() + "sample_mask_value_" + verifierSuffix).c_str(),				"Test SAMPLE_MASK_VALUE", verifier))
1491 
1492 	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))
1493 	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))
1494 
1495 	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))
1496 	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))
1497 	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))
1498 
1499 	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))
1500 	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))
1501 	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))
1502 
1503 	FOR_EACH_VERIFIER(new ImageBindingNameCase		(m_context, (std::string() + "image_binding_name_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_NAME",				verifier))
1504 	FOR_EACH_VERIFIER(new ImageBindingLevelCase		(m_context, (std::string() + "image_binding_level_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_LEVEL",				verifier))
1505 	FOR_EACH_VERIFIER(new ImageBindingLayeredCase	(m_context, (std::string() + "image_binding_layered_" + verifierSuffix).c_str(),			"Test IMAGE_BINDING_LAYERED",			verifier))
1506 	FOR_EACH_VERIFIER(new ImageBindingLayerCase		(m_context, (std::string() + "image_binding_layer_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_LAYER",				verifier))
1507 	FOR_EACH_VERIFIER(new ImageBindingAccessCase	(m_context, (std::string() + "image_binding_access_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_ACCESS",			verifier))
1508 	FOR_EACH_VERIFIER(new ImageBindingFormatCase	(m_context, (std::string() + "image_binding_format_" + verifierSuffix).c_str(),				"Test IMAGE_BINDING_FORMAT",			verifier))
1509 
1510 	{
1511 		const QueryType verifier = QUERY_INDEXED_ISENABLED;
1512 		const char* verifierSuffix = getVerifierSuffix(verifier);
1513 		this->addChild(new EnableBlendCase			(m_context, (std::string() + "blend_" + verifierSuffix).c_str(),							"BLEND",								verifier));
1514 	}
1515 	FOR_EACH_VEC4_VERIFIER(new ColorMaskCase		(m_context, (std::string() + "color_mask_" + verifierSuffix).c_str(),						"COLOR_WRITEMASK",						verifier))
1516 	FOR_EACH_VERIFIER(new BlendFuncCase				(m_context, (std::string() + "blend_func_" + verifierSuffix).c_str(),						"BLEND_SRC and BLEND_DST",				verifier))
1517 	FOR_EACH_VERIFIER(new BlendEquationCase			(m_context, (std::string() + "blend_equation_" + verifierSuffix).c_str(),					"BLEND_EQUATION_RGB and BLEND_DST",		verifier))
1518 	FOR_EACH_VERIFIER(new BlendEquationAdvancedCase	(m_context, (std::string() + "blend_equation_advanced_" + verifierSuffix).c_str(),			"BLEND_EQUATION_RGB and BLEND_DST",		verifier))
1519 
1520 #undef FOR_EACH_VEC4_VERIFIER
1521 #undef FOR_EACH_VERIFIER
1522 }
1523 
1524 } // Functional
1525 } // gles31
1526 } // deqp
1527