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