1e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 3.0 Module
3e5c31af7Sopenharmony_ci * -------------------------------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
10e5c31af7Sopenharmony_ci *
11e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
17e5c31af7Sopenharmony_ci * limitations under the License.
18e5c31af7Sopenharmony_ci *
19e5c31af7Sopenharmony_ci *//*!
20e5c31af7Sopenharmony_ci * \file
21e5c31af7Sopenharmony_ci * \brief Indexed State Query tests.
22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
23e5c31af7Sopenharmony_ci
24e5c31af7Sopenharmony_ci#include "es3fIndexedStateQueryTests.hpp"
25e5c31af7Sopenharmony_ci#include "es3fApiCase.hpp"
26e5c31af7Sopenharmony_ci#include "glsStateQueryUtil.hpp"
27e5c31af7Sopenharmony_ci#include "tcuRenderTarget.hpp"
28e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp"
29e5c31af7Sopenharmony_ci#include "glwEnums.hpp"
30e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp"
31e5c31af7Sopenharmony_ci#include "gluCallLogWrapper.hpp"
32e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp"
33e5c31af7Sopenharmony_ci#include "deRandom.hpp"
34e5c31af7Sopenharmony_ci
35e5c31af7Sopenharmony_cinamespace deqp
36e5c31af7Sopenharmony_ci{
37e5c31af7Sopenharmony_cinamespace gles3
38e5c31af7Sopenharmony_ci{
39e5c31af7Sopenharmony_cinamespace Functional
40e5c31af7Sopenharmony_ci{
41e5c31af7Sopenharmony_cinamespace
42e5c31af7Sopenharmony_ci{
43e5c31af7Sopenharmony_ci
44e5c31af7Sopenharmony_ciusing namespace glw; // GLint and other GL types
45e5c31af7Sopenharmony_ciusing namespace gls::StateQueryUtil;
46e5c31af7Sopenharmony_ci
47e5c31af7Sopenharmony_civoid checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected)
48e5c31af7Sopenharmony_ci{
49e5c31af7Sopenharmony_ci	using tcu::TestLog;
50e5c31af7Sopenharmony_ci
51e5c31af7Sopenharmony_ci	if (got != expected)
52e5c31af7Sopenharmony_ci	{
53e5c31af7Sopenharmony_ci		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
54e5c31af7Sopenharmony_ci		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
55e5c31af7Sopenharmony_ci			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
56e5c31af7Sopenharmony_ci	}
57e5c31af7Sopenharmony_ci}
58e5c31af7Sopenharmony_ci
59e5c31af7Sopenharmony_civoid checkIntEquals (tcu::TestContext& testCtx, GLint64 got, GLint64 expected)
60e5c31af7Sopenharmony_ci{
61e5c31af7Sopenharmony_ci	using tcu::TestLog;
62e5c31af7Sopenharmony_ci
63e5c31af7Sopenharmony_ci	if (got != expected)
64e5c31af7Sopenharmony_ci	{
65e5c31af7Sopenharmony_ci		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
66e5c31af7Sopenharmony_ci		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
67e5c31af7Sopenharmony_ci			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
68e5c31af7Sopenharmony_ci	}
69e5c31af7Sopenharmony_ci}
70e5c31af7Sopenharmony_ci
71e5c31af7Sopenharmony_ciclass TransformFeedbackCase : public ApiCase
72e5c31af7Sopenharmony_ci{
73e5c31af7Sopenharmony_cipublic:
74e5c31af7Sopenharmony_ci	TransformFeedbackCase (Context& context, const char* name, const char* description)
75e5c31af7Sopenharmony_ci		: ApiCase(context, name, description)
76e5c31af7Sopenharmony_ci	{
77e5c31af7Sopenharmony_ci	}
78e5c31af7Sopenharmony_ci
79e5c31af7Sopenharmony_ci	virtual void testTransformFeedback (void) = DE_NULL;
80e5c31af7Sopenharmony_ci
81e5c31af7Sopenharmony_ci	void test (void)
82e5c31af7Sopenharmony_ci	{
83e5c31af7Sopenharmony_ci		static const char* transformFeedbackTestVertSource	=	"#version 300 es\n"
84e5c31af7Sopenharmony_ci																"out highp vec4 anotherOutput;\n"
85e5c31af7Sopenharmony_ci																"void main (void)\n"
86e5c31af7Sopenharmony_ci																"{\n"
87e5c31af7Sopenharmony_ci																"	gl_Position = vec4(0.0);\n"
88e5c31af7Sopenharmony_ci																"	anotherOutput = vec4(0.0);\n"
89e5c31af7Sopenharmony_ci																"}\n\0";
90e5c31af7Sopenharmony_ci		static const char* transformFeedbackTestFragSource	=	"#version 300 es\n"
91e5c31af7Sopenharmony_ci																"layout(location = 0) out mediump vec4 fragColor;"
92e5c31af7Sopenharmony_ci																"void main (void)\n"
93e5c31af7Sopenharmony_ci																"{\n"
94e5c31af7Sopenharmony_ci																"	fragColor = vec4(0.0);\n"
95e5c31af7Sopenharmony_ci																"}\n\0";
96e5c31af7Sopenharmony_ci
97e5c31af7Sopenharmony_ci		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
98e5c31af7Sopenharmony_ci		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
99e5c31af7Sopenharmony_ci
100e5c31af7Sopenharmony_ci		glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
101e5c31af7Sopenharmony_ci		glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
102e5c31af7Sopenharmony_ci
103e5c31af7Sopenharmony_ci		glCompileShader(shaderVert);
104e5c31af7Sopenharmony_ci		glCompileShader(shaderFrag);
105e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
106e5c31af7Sopenharmony_ci
107e5c31af7Sopenharmony_ci		GLuint shaderProg = glCreateProgram();
108e5c31af7Sopenharmony_ci		glAttachShader(shaderProg, shaderVert);
109e5c31af7Sopenharmony_ci		glAttachShader(shaderProg, shaderFrag);
110e5c31af7Sopenharmony_ci
111e5c31af7Sopenharmony_ci		const char* transformFeedbackOutputs[] =
112e5c31af7Sopenharmony_ci		{
113e5c31af7Sopenharmony_ci			"gl_Position",
114e5c31af7Sopenharmony_ci			"anotherOutput"
115e5c31af7Sopenharmony_ci		};
116e5c31af7Sopenharmony_ci
117e5c31af7Sopenharmony_ci		glTransformFeedbackVaryings(shaderProg, 2, transformFeedbackOutputs, GL_INTERLEAVED_ATTRIBS);
118e5c31af7Sopenharmony_ci		glLinkProgram(shaderProg);
119e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
120e5c31af7Sopenharmony_ci
121e5c31af7Sopenharmony_ci		glGenTransformFeedbacks(2, transformFeedbacks);
122e5c31af7Sopenharmony_ci		// Also store the default transform feedback in the array.
123e5c31af7Sopenharmony_ci		transformFeedbacks[2] = 0;
124e5c31af7Sopenharmony_ci		glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbacks[0]);
125e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
126e5c31af7Sopenharmony_ci
127e5c31af7Sopenharmony_ci		testTransformFeedback();
128e5c31af7Sopenharmony_ci
129e5c31af7Sopenharmony_ci		// cleanup
130e5c31af7Sopenharmony_ci
131e5c31af7Sopenharmony_ci		glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
132e5c31af7Sopenharmony_ci
133e5c31af7Sopenharmony_ci		glDeleteTransformFeedbacks(2, transformFeedbacks);
134e5c31af7Sopenharmony_ci		glDeleteShader(shaderVert);
135e5c31af7Sopenharmony_ci		glDeleteShader(shaderFrag);
136e5c31af7Sopenharmony_ci		glDeleteProgram(shaderProg);
137e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
138e5c31af7Sopenharmony_ci	}
139e5c31af7Sopenharmony_ciprotected:
140e5c31af7Sopenharmony_ci	GLuint transformFeedbacks[3];
141e5c31af7Sopenharmony_ci};
142e5c31af7Sopenharmony_ci
143e5c31af7Sopenharmony_ciclass TransformFeedbackBufferBindingCase : public TransformFeedbackCase
144e5c31af7Sopenharmony_ci{
145e5c31af7Sopenharmony_cipublic:
146e5c31af7Sopenharmony_ci	TransformFeedbackBufferBindingCase (Context& context, const char* name, const char* description)
147e5c31af7Sopenharmony_ci		: TransformFeedbackCase(context, name, description)
148e5c31af7Sopenharmony_ci	{
149e5c31af7Sopenharmony_ci	}
150e5c31af7Sopenharmony_ci
151e5c31af7Sopenharmony_ci	void testTransformFeedback (void)
152e5c31af7Sopenharmony_ci	{
153e5c31af7Sopenharmony_ci		const int feedbackPositionIndex = 0;
154e5c31af7Sopenharmony_ci		const int feedbackOutputIndex = 1;
155e5c31af7Sopenharmony_ci		const int feedbackIndex[2] = {feedbackPositionIndex, feedbackOutputIndex};
156e5c31af7Sopenharmony_ci
157e5c31af7Sopenharmony_ci		// bind bffers
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_ci		GLuint feedbackBuffers[2];
160e5c31af7Sopenharmony_ci		glGenBuffers(2, feedbackBuffers);
161e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
162e5c31af7Sopenharmony_ci
163e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < 2; ++ndx)
164e5c31af7Sopenharmony_ci		{
165e5c31af7Sopenharmony_ci			glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBuffers[ndx]);
166e5c31af7Sopenharmony_ci			glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
167e5c31af7Sopenharmony_ci			glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackIndex[ndx], feedbackBuffers[ndx]);
168e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
169e5c31af7Sopenharmony_ci		}
170e5c31af7Sopenharmony_ci
171e5c31af7Sopenharmony_ci		// test TRANSFORM_FEEDBACK_BUFFER_BINDING
172e5c31af7Sopenharmony_ci
173e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < 2; ++ndx)
174e5c31af7Sopenharmony_ci		{
175e5c31af7Sopenharmony_ci			StateQueryMemoryWriteGuard<GLint> boundBuffer;
176e5c31af7Sopenharmony_ci			glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, feedbackIndex[ndx], &boundBuffer);
177e5c31af7Sopenharmony_ci			boundBuffer.verifyValidity(m_testCtx);
178e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, boundBuffer, feedbackBuffers[ndx]);
179e5c31af7Sopenharmony_ci		}
180e5c31af7Sopenharmony_ci
181e5c31af7Sopenharmony_ci
182e5c31af7Sopenharmony_ci		// cleanup
183e5c31af7Sopenharmony_ci
184e5c31af7Sopenharmony_ci		glDeleteBuffers(2, feedbackBuffers);
185e5c31af7Sopenharmony_ci	}
186e5c31af7Sopenharmony_ci};
187e5c31af7Sopenharmony_ci
188e5c31af7Sopenharmony_ciclass TransformFeedbackBufferBufferCase : public TransformFeedbackCase
189e5c31af7Sopenharmony_ci{
190e5c31af7Sopenharmony_cipublic:
191e5c31af7Sopenharmony_ci	TransformFeedbackBufferBufferCase (Context& context, const char* name, const char* description)
192e5c31af7Sopenharmony_ci		: TransformFeedbackCase(context, name, description)
193e5c31af7Sopenharmony_ci	{
194e5c31af7Sopenharmony_ci	}
195e5c31af7Sopenharmony_ci
196e5c31af7Sopenharmony_ci	void testTransformFeedback (void)
197e5c31af7Sopenharmony_ci	{
198e5c31af7Sopenharmony_ci		const int feedbackPositionIndex = 0;
199e5c31af7Sopenharmony_ci		const int feedbackOutputIndex = 1;
200e5c31af7Sopenharmony_ci
201e5c31af7Sopenharmony_ci		const int rangeBufferOffset = 4;
202e5c31af7Sopenharmony_ci		const int rangeBufferSize = 8;
203e5c31af7Sopenharmony_ci
204e5c31af7Sopenharmony_ci		// bind buffers
205e5c31af7Sopenharmony_ci
206e5c31af7Sopenharmony_ci		GLuint feedbackBuffers[2];
207e5c31af7Sopenharmony_ci		glGenBuffers(2, feedbackBuffers);
208e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
209e5c31af7Sopenharmony_ci
210e5c31af7Sopenharmony_ci		glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBuffers[0]);
211e5c31af7Sopenharmony_ci		glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
212e5c31af7Sopenharmony_ci		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackPositionIndex, feedbackBuffers[0]);
213e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
214e5c31af7Sopenharmony_ci
215e5c31af7Sopenharmony_ci		glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBuffers[1]);
216e5c31af7Sopenharmony_ci		glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
217e5c31af7Sopenharmony_ci		glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackOutputIndex, feedbackBuffers[1], rangeBufferOffset, rangeBufferSize);
218e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
219e5c31af7Sopenharmony_ci
220e5c31af7Sopenharmony_ci		// test TRANSFORM_FEEDBACK_BUFFER_START and TRANSFORM_FEEDBACK_BUFFER_SIZE
221e5c31af7Sopenharmony_ci
222e5c31af7Sopenharmony_ci		const struct BufferRequirements
223e5c31af7Sopenharmony_ci		{
224e5c31af7Sopenharmony_ci			GLint	index;
225e5c31af7Sopenharmony_ci			GLenum	pname;
226e5c31af7Sopenharmony_ci			GLint64 value;
227e5c31af7Sopenharmony_ci		} requirements[] =
228e5c31af7Sopenharmony_ci		{
229e5c31af7Sopenharmony_ci			{ feedbackPositionIndex,	GL_TRANSFORM_FEEDBACK_BUFFER_START, 0					},
230e5c31af7Sopenharmony_ci			{ feedbackPositionIndex,	GL_TRANSFORM_FEEDBACK_BUFFER_SIZE,	0					},
231e5c31af7Sopenharmony_ci			{ feedbackOutputIndex,		GL_TRANSFORM_FEEDBACK_BUFFER_START, rangeBufferOffset	},
232e5c31af7Sopenharmony_ci			{ feedbackOutputIndex,		GL_TRANSFORM_FEEDBACK_BUFFER_SIZE,	rangeBufferSize		}
233e5c31af7Sopenharmony_ci		};
234e5c31af7Sopenharmony_ci
235e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requirements); ++ndx)
236e5c31af7Sopenharmony_ci		{
237e5c31af7Sopenharmony_ci			StateQueryMemoryWriteGuard<GLint64> state;
238e5c31af7Sopenharmony_ci			glGetInteger64i_v(requirements[ndx].pname, requirements[ndx].index, &state);
239e5c31af7Sopenharmony_ci
240e5c31af7Sopenharmony_ci			if (state.verifyValidity(m_testCtx))
241e5c31af7Sopenharmony_ci				checkIntEquals(m_testCtx, state, requirements[ndx].value);
242e5c31af7Sopenharmony_ci		}
243e5c31af7Sopenharmony_ci
244e5c31af7Sopenharmony_ci		// cleanup
245e5c31af7Sopenharmony_ci
246e5c31af7Sopenharmony_ci		glDeleteBuffers(2, feedbackBuffers);
247e5c31af7Sopenharmony_ci	}
248e5c31af7Sopenharmony_ci};
249e5c31af7Sopenharmony_ci
250e5c31af7Sopenharmony_ciclass TransformFeedbackSwitchingBufferCase : public TransformFeedbackCase
251e5c31af7Sopenharmony_ci{
252e5c31af7Sopenharmony_cipublic:
253e5c31af7Sopenharmony_ci	TransformFeedbackSwitchingBufferCase (Context& context, const char* name, const char* description)
254e5c31af7Sopenharmony_ci		: TransformFeedbackCase(context, name, description)
255e5c31af7Sopenharmony_ci	{
256e5c31af7Sopenharmony_ci	}
257e5c31af7Sopenharmony_ci
258e5c31af7Sopenharmony_ci	void testTransformFeedback (void)
259e5c31af7Sopenharmony_ci	{
260e5c31af7Sopenharmony_ci		GLuint feedbackBuffers[3];
261e5c31af7Sopenharmony_ci		glGenBuffers(3, feedbackBuffers);
262e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
263e5c31af7Sopenharmony_ci
264e5c31af7Sopenharmony_ci		for (int i = 0; i < 3; ++i)
265e5c31af7Sopenharmony_ci		{
266e5c31af7Sopenharmony_ci			glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbacks[i]);
267e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
268e5c31af7Sopenharmony_ci			GLint value;
269e5c31af7Sopenharmony_ci			glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, 0, &value);
270e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
271e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, 0);
272e5c31af7Sopenharmony_ci			glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBuffers[i]);
273e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
274e5c31af7Sopenharmony_ci			// glBindBufferBase should also set the generic binding point.
275e5c31af7Sopenharmony_ci			glGetIntegerv(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, &value);
276e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
277e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, feedbackBuffers[i]);
278e5c31af7Sopenharmony_ci		}
279e5c31af7Sopenharmony_ci
280e5c31af7Sopenharmony_ci		for (int i = 0; i < 3; ++i)
281e5c31af7Sopenharmony_ci		{
282e5c31af7Sopenharmony_ci			// glBindTransformFeedback should change the indexed binding points, but
283e5c31af7Sopenharmony_ci			// not the generic one.
284e5c31af7Sopenharmony_ci			glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbacks[i]);
285e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
286e5c31af7Sopenharmony_ci			GLint value;
287e5c31af7Sopenharmony_ci			glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, 0, &value);
288e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
289e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, feedbackBuffers[i]);
290e5c31af7Sopenharmony_ci			glGetIntegerv(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, &value);
291e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
292e5c31af7Sopenharmony_ci			// Should be unchanged.
293e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, feedbackBuffers[2]);
294e5c31af7Sopenharmony_ci		}
295e5c31af7Sopenharmony_ci
296e5c31af7Sopenharmony_ci		glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbacks[0]);
297e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
298e5c31af7Sopenharmony_ci		glDeleteBuffers(3, feedbackBuffers);
299e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
300e5c31af7Sopenharmony_ci
301e5c31af7Sopenharmony_ci		// After deleting buffers the bound state should be changed but unbound
302e5c31af7Sopenharmony_ci		// state should be unchanged.
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ci		GLint value;
305e5c31af7Sopenharmony_ci		glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, 0, &value);
306e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
307e5c31af7Sopenharmony_ci		checkIntEquals(m_testCtx, value, 0);
308e5c31af7Sopenharmony_ci		glGetIntegerv(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, &value);
309e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
310e5c31af7Sopenharmony_ci		checkIntEquals(m_testCtx, value, 0);
311e5c31af7Sopenharmony_ci
312e5c31af7Sopenharmony_ci		for (int i = 1; i < 3; ++i)
313e5c31af7Sopenharmony_ci		{
314e5c31af7Sopenharmony_ci			glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedbacks[i]);
315e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
316e5c31af7Sopenharmony_ci			glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, 0, &value);
317e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
318e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, feedbackBuffers[i]);
319e5c31af7Sopenharmony_ci			glGetIntegerv(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, &value);
320e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
321e5c31af7Sopenharmony_ci			checkIntEquals(m_testCtx, value, 0);
322e5c31af7Sopenharmony_ci		}
323e5c31af7Sopenharmony_ci	}
324e5c31af7Sopenharmony_ci};
325e5c31af7Sopenharmony_ci
326e5c31af7Sopenharmony_ciclass UniformBufferCase : public ApiCase
327e5c31af7Sopenharmony_ci{
328e5c31af7Sopenharmony_cipublic:
329e5c31af7Sopenharmony_ci	UniformBufferCase (Context& context, const char* name, const char* description)
330e5c31af7Sopenharmony_ci		: ApiCase	(context, name, description)
331e5c31af7Sopenharmony_ci		, m_program	(0)
332e5c31af7Sopenharmony_ci	{
333e5c31af7Sopenharmony_ci	}
334e5c31af7Sopenharmony_ci
335e5c31af7Sopenharmony_ci	virtual void testUniformBuffers (void) = DE_NULL;
336e5c31af7Sopenharmony_ci
337e5c31af7Sopenharmony_ci	void test (void)
338e5c31af7Sopenharmony_ci	{
339e5c31af7Sopenharmony_ci		static const char* testVertSource	=	"#version 300 es\n"
340e5c31af7Sopenharmony_ci												"uniform highp vec4 input1;\n"
341e5c31af7Sopenharmony_ci												"uniform highp vec4 input2;\n"
342e5c31af7Sopenharmony_ci												"void main (void)\n"
343e5c31af7Sopenharmony_ci												"{\n"
344e5c31af7Sopenharmony_ci												"	gl_Position = input1 + input2;\n"
345e5c31af7Sopenharmony_ci												"}\n\0";
346e5c31af7Sopenharmony_ci		static const char* testFragSource	=	"#version 300 es\n"
347e5c31af7Sopenharmony_ci												"layout(location = 0) out mediump vec4 fragColor;"
348e5c31af7Sopenharmony_ci												"void main (void)\n"
349e5c31af7Sopenharmony_ci												"{\n"
350e5c31af7Sopenharmony_ci												"	fragColor = vec4(0.0);\n"
351e5c31af7Sopenharmony_ci												"}\n\0";
352e5c31af7Sopenharmony_ci
353e5c31af7Sopenharmony_ci		GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
354e5c31af7Sopenharmony_ci		GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
355e5c31af7Sopenharmony_ci
356e5c31af7Sopenharmony_ci		glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
357e5c31af7Sopenharmony_ci		glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
358e5c31af7Sopenharmony_ci
359e5c31af7Sopenharmony_ci		glCompileShader(shaderVert);
360e5c31af7Sopenharmony_ci		glCompileShader(shaderFrag);
361e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
362e5c31af7Sopenharmony_ci
363e5c31af7Sopenharmony_ci		m_program = glCreateProgram();
364e5c31af7Sopenharmony_ci		glAttachShader(m_program, shaderVert);
365e5c31af7Sopenharmony_ci		glAttachShader(m_program, shaderFrag);
366e5c31af7Sopenharmony_ci		glLinkProgram(m_program);
367e5c31af7Sopenharmony_ci		glUseProgram(m_program);
368e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
369e5c31af7Sopenharmony_ci
370e5c31af7Sopenharmony_ci		testUniformBuffers();
371e5c31af7Sopenharmony_ci
372e5c31af7Sopenharmony_ci		glUseProgram(0);
373e5c31af7Sopenharmony_ci		glDeleteShader(shaderVert);
374e5c31af7Sopenharmony_ci		glDeleteShader(shaderFrag);
375e5c31af7Sopenharmony_ci		glDeleteProgram(m_program);
376e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
377e5c31af7Sopenharmony_ci	}
378e5c31af7Sopenharmony_ci
379e5c31af7Sopenharmony_ciprotected:
380e5c31af7Sopenharmony_ci	GLuint	m_program;
381e5c31af7Sopenharmony_ci};
382e5c31af7Sopenharmony_ci
383e5c31af7Sopenharmony_ciclass UniformBufferBindingCase : public UniformBufferCase
384e5c31af7Sopenharmony_ci{
385e5c31af7Sopenharmony_cipublic:
386e5c31af7Sopenharmony_ci	UniformBufferBindingCase (Context& context, const char* name, const char* description)
387e5c31af7Sopenharmony_ci		: UniformBufferCase(context, name, description)
388e5c31af7Sopenharmony_ci	{
389e5c31af7Sopenharmony_ci	}
390e5c31af7Sopenharmony_ci
391e5c31af7Sopenharmony_ci	void testUniformBuffers (void)
392e5c31af7Sopenharmony_ci	{
393e5c31af7Sopenharmony_ci		const char* uniformNames[] =
394e5c31af7Sopenharmony_ci		{
395e5c31af7Sopenharmony_ci			"input1",
396e5c31af7Sopenharmony_ci			"input2"
397e5c31af7Sopenharmony_ci		};
398e5c31af7Sopenharmony_ci		GLuint uniformIndices[2] = {0};
399e5c31af7Sopenharmony_ci		glGetUniformIndices(m_program, 2, uniformNames, uniformIndices);
400e5c31af7Sopenharmony_ci
401e5c31af7Sopenharmony_ci		GLuint buffers[2];
402e5c31af7Sopenharmony_ci		glGenBuffers(2, buffers);
403e5c31af7Sopenharmony_ci
404e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < 2; ++ndx)
405e5c31af7Sopenharmony_ci		{
406e5c31af7Sopenharmony_ci			glBindBuffer(GL_UNIFORM_BUFFER, buffers[ndx]);
407e5c31af7Sopenharmony_ci			glBufferData(GL_UNIFORM_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
408e5c31af7Sopenharmony_ci			glBindBufferBase(GL_UNIFORM_BUFFER, uniformIndices[ndx], buffers[ndx]);
409e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
410e5c31af7Sopenharmony_ci		}
411e5c31af7Sopenharmony_ci
412e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < 2; ++ndx)
413e5c31af7Sopenharmony_ci		{
414e5c31af7Sopenharmony_ci			StateQueryMemoryWriteGuard<GLint> boundBuffer;
415e5c31af7Sopenharmony_ci			glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, uniformIndices[ndx], &boundBuffer);
416e5c31af7Sopenharmony_ci
417e5c31af7Sopenharmony_ci			if (boundBuffer.verifyValidity(m_testCtx))
418e5c31af7Sopenharmony_ci				checkIntEquals(m_testCtx, boundBuffer, buffers[ndx]);
419e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
420e5c31af7Sopenharmony_ci		}
421e5c31af7Sopenharmony_ci
422e5c31af7Sopenharmony_ci		glDeleteBuffers(2, buffers);
423e5c31af7Sopenharmony_ci	}
424e5c31af7Sopenharmony_ci};
425e5c31af7Sopenharmony_ci
426e5c31af7Sopenharmony_ciclass UniformBufferBufferCase : public UniformBufferCase
427e5c31af7Sopenharmony_ci{
428e5c31af7Sopenharmony_cipublic:
429e5c31af7Sopenharmony_ci	UniformBufferBufferCase (Context& context, const char* name, const char* description)
430e5c31af7Sopenharmony_ci		: UniformBufferCase(context, name, description)
431e5c31af7Sopenharmony_ci	{
432e5c31af7Sopenharmony_ci	}
433e5c31af7Sopenharmony_ci
434e5c31af7Sopenharmony_ci	void testUniformBuffers (void)
435e5c31af7Sopenharmony_ci	{
436e5c31af7Sopenharmony_ci		const char* uniformNames[] =
437e5c31af7Sopenharmony_ci		{
438e5c31af7Sopenharmony_ci			"input1",
439e5c31af7Sopenharmony_ci			"input2"
440e5c31af7Sopenharmony_ci		};
441e5c31af7Sopenharmony_ci		GLuint uniformIndices[2] = {0};
442e5c31af7Sopenharmony_ci		glGetUniformIndices(m_program, 2, uniformNames, uniformIndices);
443e5c31af7Sopenharmony_ci
444e5c31af7Sopenharmony_ci		const GLint alignment = GetAlignment();
445e5c31af7Sopenharmony_ci		if (alignment == -1) // cannot continue without this
446e5c31af7Sopenharmony_ci			return;
447e5c31af7Sopenharmony_ci
448e5c31af7Sopenharmony_ci		m_testCtx.getLog() << tcu::TestLog::Message << "Alignment is " << alignment << tcu::TestLog::EndMessage;
449e5c31af7Sopenharmony_ci
450e5c31af7Sopenharmony_ci		int rangeBufferOffset		= alignment;
451e5c31af7Sopenharmony_ci		int rangeBufferSize			= alignment * 2;
452e5c31af7Sopenharmony_ci		int rangeBufferTotalSize	= rangeBufferOffset + rangeBufferSize + 8; // + 8 has no special meaning, just to make it != with the size of the range
453e5c31af7Sopenharmony_ci
454e5c31af7Sopenharmony_ci		GLuint buffers[2];
455e5c31af7Sopenharmony_ci		glGenBuffers(2, buffers);
456e5c31af7Sopenharmony_ci
457e5c31af7Sopenharmony_ci		glBindBuffer(GL_UNIFORM_BUFFER, buffers[0]);
458e5c31af7Sopenharmony_ci		glBufferData(GL_UNIFORM_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
459e5c31af7Sopenharmony_ci		glBindBufferBase(GL_UNIFORM_BUFFER, uniformIndices[0], buffers[0]);
460e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
461e5c31af7Sopenharmony_ci
462e5c31af7Sopenharmony_ci		glBindBuffer(GL_UNIFORM_BUFFER, buffers[1]);
463e5c31af7Sopenharmony_ci		glBufferData(GL_UNIFORM_BUFFER, rangeBufferTotalSize, DE_NULL, GL_DYNAMIC_DRAW);
464e5c31af7Sopenharmony_ci		glBindBufferRange(GL_UNIFORM_BUFFER, uniformIndices[1], buffers[1], rangeBufferOffset, rangeBufferSize);
465e5c31af7Sopenharmony_ci		expectError(GL_NO_ERROR);
466e5c31af7Sopenharmony_ci
467e5c31af7Sopenharmony_ci		// test UNIFORM_BUFFER_START and UNIFORM_BUFFER_SIZE
468e5c31af7Sopenharmony_ci
469e5c31af7Sopenharmony_ci		const struct BufferRequirements
470e5c31af7Sopenharmony_ci		{
471e5c31af7Sopenharmony_ci			GLuint	index;
472e5c31af7Sopenharmony_ci			GLenum	pname;
473e5c31af7Sopenharmony_ci			GLint64 value;
474e5c31af7Sopenharmony_ci		} requirements[] =
475e5c31af7Sopenharmony_ci		{
476e5c31af7Sopenharmony_ci			{ uniformIndices[0], GL_UNIFORM_BUFFER_START,	0					},
477e5c31af7Sopenharmony_ci			{ uniformIndices[0], GL_UNIFORM_BUFFER_SIZE,	0					},
478e5c31af7Sopenharmony_ci			{ uniformIndices[1], GL_UNIFORM_BUFFER_START,	rangeBufferOffset	},
479e5c31af7Sopenharmony_ci			{ uniformIndices[1], GL_UNIFORM_BUFFER_SIZE,	rangeBufferSize		}
480e5c31af7Sopenharmony_ci		};
481e5c31af7Sopenharmony_ci
482e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requirements); ++ndx)
483e5c31af7Sopenharmony_ci		{
484e5c31af7Sopenharmony_ci			StateQueryMemoryWriteGuard<GLint64> state;
485e5c31af7Sopenharmony_ci			glGetInteger64i_v(requirements[ndx].pname, requirements[ndx].index, &state);
486e5c31af7Sopenharmony_ci
487e5c31af7Sopenharmony_ci			if (state.verifyValidity(m_testCtx))
488e5c31af7Sopenharmony_ci				checkIntEquals(m_testCtx, state, requirements[ndx].value);
489e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
490e5c31af7Sopenharmony_ci		}
491e5c31af7Sopenharmony_ci
492e5c31af7Sopenharmony_ci		glDeleteBuffers(2, buffers);
493e5c31af7Sopenharmony_ci	}
494e5c31af7Sopenharmony_ci
495e5c31af7Sopenharmony_ci	int GetAlignment()
496e5c31af7Sopenharmony_ci	{
497e5c31af7Sopenharmony_ci		StateQueryMemoryWriteGuard<GLint> state;
498e5c31af7Sopenharmony_ci		glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &state);
499e5c31af7Sopenharmony_ci
500e5c31af7Sopenharmony_ci		if (!state.verifyValidity(m_testCtx))
501e5c31af7Sopenharmony_ci			return -1;
502e5c31af7Sopenharmony_ci
503e5c31af7Sopenharmony_ci		if (state <= 256)
504e5c31af7Sopenharmony_ci			return state;
505e5c31af7Sopenharmony_ci
506e5c31af7Sopenharmony_ci		m_testCtx.getLog() << tcu::TestLog::Message << "// ERROR: UNIFORM_BUFFER_OFFSET_ALIGNMENT has a maximum value of 256." << tcu::TestLog::EndMessage;
507e5c31af7Sopenharmony_ci		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "invalid UNIFORM_BUFFER_OFFSET_ALIGNMENT value");
508e5c31af7Sopenharmony_ci
509e5c31af7Sopenharmony_ci		return -1;
510e5c31af7Sopenharmony_ci	}
511e5c31af7Sopenharmony_ci};
512e5c31af7Sopenharmony_ci
513e5c31af7Sopenharmony_ciconst char* getVerifierSuffix (QueryType type)
514e5c31af7Sopenharmony_ci{
515e5c31af7Sopenharmony_ci	switch (type)
516e5c31af7Sopenharmony_ci	{
517e5c31af7Sopenharmony_ci		case QUERY_INDEXED_INTEGER:			return "getintegeri_v";
518e5c31af7Sopenharmony_ci		case QUERY_INDEXED_INTEGER64:		return "getinteger64i_v";
519e5c31af7Sopenharmony_ci		case QUERY_INDEXED_INTEGER_VEC4:	return "getintegeri_v";
520e5c31af7Sopenharmony_ci		case QUERY_INDEXED_INTEGER64_VEC4:	return "getinteger64i_v";
521e5c31af7Sopenharmony_ci		case QUERY_INDEXED_ISENABLED:		return "isenabledi";
522e5c31af7Sopenharmony_ci		default:
523e5c31af7Sopenharmony_ci			DE_ASSERT(DE_FALSE);
524e5c31af7Sopenharmony_ci			return DE_NULL;
525e5c31af7Sopenharmony_ci	}
526e5c31af7Sopenharmony_ci}
527e5c31af7Sopenharmony_ci
528e5c31af7Sopenharmony_civoid isExtensionSupported (Context& context, std::string extensionName)
529e5c31af7Sopenharmony_ci{
530e5c31af7Sopenharmony_ci	if (contextSupports(context.getRenderContext().getType(), glu::ApiType::core(4, 5)))
531e5c31af7Sopenharmony_ci		return;
532e5c31af7Sopenharmony_ci
533e5c31af7Sopenharmony_ci	if (extensionName == "GL_EXT_draw_buffers_indexed" || extensionName == "GL_KHR_blend_equation_advanced")
534e5c31af7Sopenharmony_ci	{
535e5c31af7Sopenharmony_ci		if (!contextSupports(context.getRenderContext().getType(), glu::ApiType::es(3, 2)) && !context.getContextInfo().isExtensionSupported(extensionName.c_str()))
536e5c31af7Sopenharmony_ci			TCU_THROW(NotSupportedError, (std::string("Extension ") + extensionName + std::string(" not supported.")).c_str());
537e5c31af7Sopenharmony_ci	}
538e5c31af7Sopenharmony_ci	else if (!context.getContextInfo().isExtensionSupported(extensionName.c_str()))
539e5c31af7Sopenharmony_ci		TCU_THROW(NotSupportedError, (std::string("Extension ") + extensionName + std::string(" not supported.")).c_str());
540e5c31af7Sopenharmony_ci}
541e5c31af7Sopenharmony_ci
542e5c31af7Sopenharmony_ciclass EnableBlendCase : public TestCase
543e5c31af7Sopenharmony_ci{
544e5c31af7Sopenharmony_cipublic:
545e5c31af7Sopenharmony_ci	EnableBlendCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
546e5c31af7Sopenharmony_ci
547e5c31af7Sopenharmony_ci	void				init			(void);
548e5c31af7Sopenharmony_ciprivate:
549e5c31af7Sopenharmony_ci	IterateResult		iterate			(void);
550e5c31af7Sopenharmony_ci
551e5c31af7Sopenharmony_ci	const QueryType		m_verifierType;
552e5c31af7Sopenharmony_ci};
553e5c31af7Sopenharmony_ci
554e5c31af7Sopenharmony_ciEnableBlendCase::EnableBlendCase (Context& context, const char* name, const char* desc, QueryType verifierType)
555e5c31af7Sopenharmony_ci		: TestCase			(context, name, desc)
556e5c31af7Sopenharmony_ci		, m_verifierType	(verifierType)
557e5c31af7Sopenharmony_ci{
558e5c31af7Sopenharmony_ci}
559e5c31af7Sopenharmony_ci
560e5c31af7Sopenharmony_civoid EnableBlendCase::init (void)
561e5c31af7Sopenharmony_ci{
562e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
563e5c31af7Sopenharmony_ci}
564e5c31af7Sopenharmony_ci
565e5c31af7Sopenharmony_ciEnableBlendCase::IterateResult EnableBlendCase::iterate (void)
566e5c31af7Sopenharmony_ci{
567e5c31af7Sopenharmony_ci	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
568e5c31af7Sopenharmony_ci	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
569e5c31af7Sopenharmony_ci	deInt32					maxDrawBuffers = 0;
570e5c31af7Sopenharmony_ci
571e5c31af7Sopenharmony_ci	gl.enableLogging(true);
572e5c31af7Sopenharmony_ci
573e5c31af7Sopenharmony_ci	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
574e5c31af7Sopenharmony_ci	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
575e5c31af7Sopenharmony_ci
576e5c31af7Sopenharmony_ci	{
577e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
578e5c31af7Sopenharmony_ci
579e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
580e5c31af7Sopenharmony_ci			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, false, m_verifierType);
581e5c31af7Sopenharmony_ci	}
582e5c31af7Sopenharmony_ci	{
583e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
584e5c31af7Sopenharmony_ci
585e5c31af7Sopenharmony_ci		gl.glEnable(GL_BLEND);
586e5c31af7Sopenharmony_ci
587e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
588e5c31af7Sopenharmony_ci			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, true, m_verifierType);
589e5c31af7Sopenharmony_ci
590e5c31af7Sopenharmony_ci	}
591e5c31af7Sopenharmony_ci	{
592e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
593e5c31af7Sopenharmony_ci
594e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
595e5c31af7Sopenharmony_ci		{
596e5c31af7Sopenharmony_ci			if (ndx % 2 == 0)
597e5c31af7Sopenharmony_ci				gl.glEnablei(GL_BLEND, ndx);
598e5c31af7Sopenharmony_ci			else
599e5c31af7Sopenharmony_ci				gl.glDisablei(GL_BLEND, ndx);
600e5c31af7Sopenharmony_ci		}
601e5c31af7Sopenharmony_ci
602e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
603e5c31af7Sopenharmony_ci			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, (ndx % 2 == 0), m_verifierType);
604e5c31af7Sopenharmony_ci	}
605e5c31af7Sopenharmony_ci	{
606e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection	superSection	(m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
607e5c31af7Sopenharmony_ci
608e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
609e5c31af7Sopenharmony_ci		{
610e5c31af7Sopenharmony_ci			if (ndx % 2 == 0)
611e5c31af7Sopenharmony_ci				gl.glEnablei(GL_BLEND, ndx);
612e5c31af7Sopenharmony_ci			else
613e5c31af7Sopenharmony_ci				gl.glDisablei(GL_BLEND, ndx);
614e5c31af7Sopenharmony_ci		}
615e5c31af7Sopenharmony_ci
616e5c31af7Sopenharmony_ci		gl.glEnable(GL_BLEND);
617e5c31af7Sopenharmony_ci
618e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
619e5c31af7Sopenharmony_ci			verifyStateIndexedBoolean(result, gl, GL_BLEND, ndx, true, m_verifierType);
620e5c31af7Sopenharmony_ci	}
621e5c31af7Sopenharmony_ci
622e5c31af7Sopenharmony_ci	result.setTestContextResult(m_testCtx);
623e5c31af7Sopenharmony_ci	return STOP;
624e5c31af7Sopenharmony_ci}
625e5c31af7Sopenharmony_ci
626e5c31af7Sopenharmony_ciclass ColorMaskCase : public TestCase
627e5c31af7Sopenharmony_ci{
628e5c31af7Sopenharmony_cipublic:
629e5c31af7Sopenharmony_ci	ColorMaskCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
630e5c31af7Sopenharmony_ci
631e5c31af7Sopenharmony_ci	void				init			(void);
632e5c31af7Sopenharmony_ciprivate:
633e5c31af7Sopenharmony_ci	IterateResult		iterate			(void);
634e5c31af7Sopenharmony_ci
635e5c31af7Sopenharmony_ci	const QueryType		m_verifierType;
636e5c31af7Sopenharmony_ci};
637e5c31af7Sopenharmony_ci
638e5c31af7Sopenharmony_ciColorMaskCase::ColorMaskCase (Context& context, const char* name, const char* desc, QueryType verifierType)
639e5c31af7Sopenharmony_ci		: TestCase			(context, name, desc)
640e5c31af7Sopenharmony_ci		, m_verifierType	(verifierType)
641e5c31af7Sopenharmony_ci{
642e5c31af7Sopenharmony_ci}
643e5c31af7Sopenharmony_ci
644e5c31af7Sopenharmony_civoid ColorMaskCase::init (void)
645e5c31af7Sopenharmony_ci{
646e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
647e5c31af7Sopenharmony_ci}
648e5c31af7Sopenharmony_ci
649e5c31af7Sopenharmony_ciColorMaskCase::IterateResult ColorMaskCase::iterate (void)
650e5c31af7Sopenharmony_ci{
651e5c31af7Sopenharmony_ci	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
652e5c31af7Sopenharmony_ci	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
653e5c31af7Sopenharmony_ci	deInt32					maxDrawBuffers = 0;
654e5c31af7Sopenharmony_ci
655e5c31af7Sopenharmony_ci	gl.enableLogging(true);
656e5c31af7Sopenharmony_ci
657e5c31af7Sopenharmony_ci	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
658e5c31af7Sopenharmony_ci	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
659e5c31af7Sopenharmony_ci
660e5c31af7Sopenharmony_ci	{
661e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
662e5c31af7Sopenharmony_ci
663e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
664e5c31af7Sopenharmony_ci			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(true), m_verifierType);
665e5c31af7Sopenharmony_ci	}
666e5c31af7Sopenharmony_ci	{
667e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
668e5c31af7Sopenharmony_ci
669e5c31af7Sopenharmony_ci		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
670e5c31af7Sopenharmony_ci
671e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
672e5c31af7Sopenharmony_ci			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
673e5c31af7Sopenharmony_ci	}
674e5c31af7Sopenharmony_ci	{
675e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
676e5c31af7Sopenharmony_ci
677e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
678e5c31af7Sopenharmony_ci			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));
679e5c31af7Sopenharmony_ci
680e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
681e5c31af7Sopenharmony_ci			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, (ndx % 2 == 0 ? tcu::BVec4(true, false, true, false) : tcu::BVec4(false, true, false, true)), m_verifierType);
682e5c31af7Sopenharmony_ci	}
683e5c31af7Sopenharmony_ci	{
684e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
685e5c31af7Sopenharmony_ci
686e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
687e5c31af7Sopenharmony_ci			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));
688e5c31af7Sopenharmony_ci
689e5c31af7Sopenharmony_ci		gl.glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
690e5c31af7Sopenharmony_ci
691e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
692e5c31af7Sopenharmony_ci			verifyStateIndexedBooleanVec4(result, gl, GL_COLOR_WRITEMASK, ndx, tcu::BVec4(false, true, true, false), m_verifierType);
693e5c31af7Sopenharmony_ci	}
694e5c31af7Sopenharmony_ci
695e5c31af7Sopenharmony_ci	result.setTestContextResult(m_testCtx);
696e5c31af7Sopenharmony_ci	return STOP;
697e5c31af7Sopenharmony_ci}
698e5c31af7Sopenharmony_ci
699e5c31af7Sopenharmony_ciclass BlendFuncCase : public TestCase
700e5c31af7Sopenharmony_ci{
701e5c31af7Sopenharmony_cipublic:
702e5c31af7Sopenharmony_ci	BlendFuncCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
703e5c31af7Sopenharmony_ci
704e5c31af7Sopenharmony_ci	void				init			(void);
705e5c31af7Sopenharmony_ciprivate:
706e5c31af7Sopenharmony_ci	IterateResult		iterate			(void);
707e5c31af7Sopenharmony_ci
708e5c31af7Sopenharmony_ci	const QueryType		m_verifierType;
709e5c31af7Sopenharmony_ci};
710e5c31af7Sopenharmony_ci
711e5c31af7Sopenharmony_ciBlendFuncCase::BlendFuncCase (Context& context, const char* name, const char* desc, QueryType verifierType)
712e5c31af7Sopenharmony_ci		: TestCase			(context, name, desc)
713e5c31af7Sopenharmony_ci		, m_verifierType	(verifierType)
714e5c31af7Sopenharmony_ci{
715e5c31af7Sopenharmony_ci}
716e5c31af7Sopenharmony_ci
717e5c31af7Sopenharmony_civoid BlendFuncCase::init (void)
718e5c31af7Sopenharmony_ci{
719e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
720e5c31af7Sopenharmony_ci}
721e5c31af7Sopenharmony_ci
722e5c31af7Sopenharmony_ciBlendFuncCase::IterateResult BlendFuncCase::iterate (void)
723e5c31af7Sopenharmony_ci{
724e5c31af7Sopenharmony_ci	const deUint32 blendFuncs[] =
725e5c31af7Sopenharmony_ci			{
726e5c31af7Sopenharmony_ci					GL_ZERO,
727e5c31af7Sopenharmony_ci					GL_ONE,
728e5c31af7Sopenharmony_ci					GL_SRC_COLOR,
729e5c31af7Sopenharmony_ci					GL_ONE_MINUS_SRC_COLOR,
730e5c31af7Sopenharmony_ci					GL_DST_COLOR,
731e5c31af7Sopenharmony_ci					GL_ONE_MINUS_DST_COLOR,
732e5c31af7Sopenharmony_ci					GL_SRC_ALPHA,
733e5c31af7Sopenharmony_ci					GL_ONE_MINUS_SRC_ALPHA,
734e5c31af7Sopenharmony_ci					GL_DST_ALPHA,
735e5c31af7Sopenharmony_ci					GL_ONE_MINUS_DST_ALPHA,
736e5c31af7Sopenharmony_ci					GL_CONSTANT_COLOR,
737e5c31af7Sopenharmony_ci					GL_ONE_MINUS_CONSTANT_COLOR,
738e5c31af7Sopenharmony_ci					GL_CONSTANT_ALPHA,
739e5c31af7Sopenharmony_ci					GL_ONE_MINUS_CONSTANT_ALPHA,
740e5c31af7Sopenharmony_ci					GL_SRC_ALPHA_SATURATE
741e5c31af7Sopenharmony_ci			};
742e5c31af7Sopenharmony_ci
743e5c31af7Sopenharmony_ci	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
744e5c31af7Sopenharmony_ci	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
745e5c31af7Sopenharmony_ci	deInt32					maxDrawBuffers = 0;
746e5c31af7Sopenharmony_ci
747e5c31af7Sopenharmony_ci	gl.enableLogging(true);
748e5c31af7Sopenharmony_ci
749e5c31af7Sopenharmony_ci	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
750e5c31af7Sopenharmony_ci	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
751e5c31af7Sopenharmony_ci
752e5c31af7Sopenharmony_ci	{
753e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
754e5c31af7Sopenharmony_ci
755e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
756e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_ONE, m_verifierType);
757e5c31af7Sopenharmony_ci
758e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
759e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ZERO, m_verifierType);
760e5c31af7Sopenharmony_ci
761e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
762e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_ONE, m_verifierType);
763e5c31af7Sopenharmony_ci
764e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
765e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ZERO, m_verifierType);
766e5c31af7Sopenharmony_ci	}
767e5c31af7Sopenharmony_ci	{
768e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
769e5c31af7Sopenharmony_ci
770e5c31af7Sopenharmony_ci		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
771e5c31af7Sopenharmony_ci
772e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
773e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
774e5c31af7Sopenharmony_ci
775e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
776e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
777e5c31af7Sopenharmony_ci
778e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
779e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
780e5c31af7Sopenharmony_ci
781e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
782e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
783e5c31af7Sopenharmony_ci	}
784e5c31af7Sopenharmony_ci	{
785e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
786e5c31af7Sopenharmony_ci
787e5c31af7Sopenharmony_ci		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
788e5c31af7Sopenharmony_ci
789e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
790e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
791e5c31af7Sopenharmony_ci
792e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
793e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
794e5c31af7Sopenharmony_ci
795e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
796e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
797e5c31af7Sopenharmony_ci
798e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
799e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
800e5c31af7Sopenharmony_ci	}
801e5c31af7Sopenharmony_ci	{
802e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
803e5c31af7Sopenharmony_ci
804e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
805e5c31af7Sopenharmony_ci			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
806e5c31af7Sopenharmony_ci
807e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
808e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
809e5c31af7Sopenharmony_ci
810e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
811e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
812e5c31af7Sopenharmony_ci
813e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
814e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
815e5c31af7Sopenharmony_ci
816e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
817e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
818e5c31af7Sopenharmony_ci	}
819e5c31af7Sopenharmony_ci	{
820e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
821e5c31af7Sopenharmony_ci
822e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
823e5c31af7Sopenharmony_ci			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
824e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
825e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
826e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
827e5c31af7Sopenharmony_ci
828e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
829e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
830e5c31af7Sopenharmony_ci
831e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
832e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
833e5c31af7Sopenharmony_ci
834e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
835e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
836e5c31af7Sopenharmony_ci
837e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
838e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)], m_verifierType);
839e5c31af7Sopenharmony_ci
840e5c31af7Sopenharmony_ci	}
841e5c31af7Sopenharmony_ci	{
842e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
843e5c31af7Sopenharmony_ci
844e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
845e5c31af7Sopenharmony_ci			gl.glBlendFunci(ndx, blendFuncs[ndx % DE_LENGTH_OF_ARRAY(blendFuncs)], blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
846e5c31af7Sopenharmony_ci
847e5c31af7Sopenharmony_ci		gl.glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
848e5c31af7Sopenharmony_ci
849e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
850e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_ALPHA, m_verifierType);
851e5c31af7Sopenharmony_ci
852e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
853e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_DST_ALPHA, m_verifierType);
854e5c31af7Sopenharmony_ci
855e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
856e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_SRC_ALPHA, m_verifierType);
857e5c31af7Sopenharmony_ci
858e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
859e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_DST_ALPHA, m_verifierType);
860e5c31af7Sopenharmony_ci	}
861e5c31af7Sopenharmony_ci	{
862e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
863e5c31af7Sopenharmony_ci
864e5c31af7Sopenharmony_ci		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
865e5c31af7Sopenharmony_ci
866e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
867e5c31af7Sopenharmony_ci			gl.glBlendFuncSeparatei(ndx, blendFuncs[(ndx + 3) % DE_LENGTH_OF_ARRAY(blendFuncs)],
868e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 2) % DE_LENGTH_OF_ARRAY(blendFuncs)],
869e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendFuncs)],
870e5c31af7Sopenharmony_ci									blendFuncs[(ndx + 0) % DE_LENGTH_OF_ARRAY(blendFuncs)]);
871e5c31af7Sopenharmony_ci
872e5c31af7Sopenharmony_ci		gl.glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_DST_COLOR, GL_ONE_MINUS_DST_ALPHA);
873e5c31af7Sopenharmony_ci
874e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
875e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_RGB, ndx, GL_SRC_COLOR, m_verifierType);
876e5c31af7Sopenharmony_ci
877e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
878e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_RGB, ndx, GL_ONE_MINUS_SRC_ALPHA, m_verifierType);
879e5c31af7Sopenharmony_ci
880e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
881e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_SRC_ALPHA, ndx, GL_DST_COLOR, m_verifierType);
882e5c31af7Sopenharmony_ci
883e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
884e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_DST_ALPHA, ndx, GL_ONE_MINUS_DST_ALPHA, m_verifierType);
885e5c31af7Sopenharmony_ci	}
886e5c31af7Sopenharmony_ci
887e5c31af7Sopenharmony_ci	result.setTestContextResult(m_testCtx);
888e5c31af7Sopenharmony_ci	return STOP;
889e5c31af7Sopenharmony_ci}
890e5c31af7Sopenharmony_ci
891e5c31af7Sopenharmony_ciclass BlendEquationCase : public TestCase
892e5c31af7Sopenharmony_ci{
893e5c31af7Sopenharmony_cipublic:
894e5c31af7Sopenharmony_ci	BlendEquationCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
895e5c31af7Sopenharmony_ci
896e5c31af7Sopenharmony_ci	void				init				(void);
897e5c31af7Sopenharmony_ciprivate:
898e5c31af7Sopenharmony_ci	IterateResult		iterate				(void);
899e5c31af7Sopenharmony_ci
900e5c31af7Sopenharmony_ci	const QueryType		m_verifierType;
901e5c31af7Sopenharmony_ci};
902e5c31af7Sopenharmony_ci
903e5c31af7Sopenharmony_ciBlendEquationCase::BlendEquationCase (Context& context, const char* name, const char* desc, QueryType verifierType)
904e5c31af7Sopenharmony_ci		: TestCase			(context, name, desc)
905e5c31af7Sopenharmony_ci		, m_verifierType	(verifierType)
906e5c31af7Sopenharmony_ci{
907e5c31af7Sopenharmony_ci}
908e5c31af7Sopenharmony_ci
909e5c31af7Sopenharmony_civoid BlendEquationCase::init (void)
910e5c31af7Sopenharmony_ci{
911e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
912e5c31af7Sopenharmony_ci}
913e5c31af7Sopenharmony_ci
914e5c31af7Sopenharmony_ciBlendEquationCase::IterateResult BlendEquationCase::iterate (void)
915e5c31af7Sopenharmony_ci{
916e5c31af7Sopenharmony_ci	const deUint32 blendEquations[] =
917e5c31af7Sopenharmony_ci			{
918e5c31af7Sopenharmony_ci					GL_FUNC_ADD,
919e5c31af7Sopenharmony_ci					GL_FUNC_SUBTRACT,
920e5c31af7Sopenharmony_ci					GL_FUNC_REVERSE_SUBTRACT,
921e5c31af7Sopenharmony_ci					GL_MIN,
922e5c31af7Sopenharmony_ci					GL_MAX
923e5c31af7Sopenharmony_ci			};
924e5c31af7Sopenharmony_ci
925e5c31af7Sopenharmony_ci	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
926e5c31af7Sopenharmony_ci	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
927e5c31af7Sopenharmony_ci	deInt32					maxDrawBuffers = 0;
928e5c31af7Sopenharmony_ci
929e5c31af7Sopenharmony_ci	gl.enableLogging(true);
930e5c31af7Sopenharmony_ci
931e5c31af7Sopenharmony_ci	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
932e5c31af7Sopenharmony_ci	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
933e5c31af7Sopenharmony_ci
934e5c31af7Sopenharmony_ci	{
935e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial value");
936e5c31af7Sopenharmony_ci
937e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
938e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_ADD, m_verifierType);
939e5c31af7Sopenharmony_ci
940e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
941e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_ADD, m_verifierType);
942e5c31af7Sopenharmony_ci	}
943e5c31af7Sopenharmony_ci	{
944e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
945e5c31af7Sopenharmony_ci
946e5c31af7Sopenharmony_ci		gl.glBlendEquation(GL_FUNC_SUBTRACT);
947e5c31af7Sopenharmony_ci
948e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
949e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
950e5c31af7Sopenharmony_ci
951e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
952e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
953e5c31af7Sopenharmony_ci	}
954e5c31af7Sopenharmony_ci	{
955e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommonSeparate", "After setting common separate");
956e5c31af7Sopenharmony_ci
957e5c31af7Sopenharmony_ci		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
958e5c31af7Sopenharmony_ci
959e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
960e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
961e5c31af7Sopenharmony_ci
962e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
963e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
964e5c31af7Sopenharmony_ci	}
965e5c31af7Sopenharmony_ci	{
966e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
967e5c31af7Sopenharmony_ci
968e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
969e5c31af7Sopenharmony_ci			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
970e5c31af7Sopenharmony_ci
971e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
972e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
973e5c31af7Sopenharmony_ci
974e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
975e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
976e5c31af7Sopenharmony_ci	}
977e5c31af7Sopenharmony_ci	{
978e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexedSeparate", "After setting indexed separate");
979e5c31af7Sopenharmony_ci
980e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
981e5c31af7Sopenharmony_ci			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
982e5c31af7Sopenharmony_ci
983e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
984e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
985e5c31af7Sopenharmony_ci
986e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
987e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)], m_verifierType);
988e5c31af7Sopenharmony_ci	}
989e5c31af7Sopenharmony_ci	{
990e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
991e5c31af7Sopenharmony_ci
992e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
993e5c31af7Sopenharmony_ci			gl.glBlendEquationi(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)]);
994e5c31af7Sopenharmony_ci
995e5c31af7Sopenharmony_ci		gl.glBlendEquation(GL_FUNC_SUBTRACT);
996e5c31af7Sopenharmony_ci
997e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
998e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_SUBTRACT, m_verifierType);
999e5c31af7Sopenharmony_ci
1000e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1001e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1002e5c31af7Sopenharmony_ci	}
1003e5c31af7Sopenharmony_ci	{
1004e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommonSeparate", "After resetting indexed with common separate");
1005e5c31af7Sopenharmony_ci
1006e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1007e5c31af7Sopenharmony_ci			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1008e5c31af7Sopenharmony_ci
1009e5c31af7Sopenharmony_ci		gl.glBlendEquationSeparate(GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_SUBTRACT);
1010e5c31af7Sopenharmony_ci
1011e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1012e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_FUNC_REVERSE_SUBTRACT, m_verifierType);
1013e5c31af7Sopenharmony_ci
1014e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1015e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_FUNC_SUBTRACT, m_verifierType);
1016e5c31af7Sopenharmony_ci	}
1017e5c31af7Sopenharmony_ci
1018e5c31af7Sopenharmony_ci	result.setTestContextResult(m_testCtx);
1019e5c31af7Sopenharmony_ci	return STOP;
1020e5c31af7Sopenharmony_ci}
1021e5c31af7Sopenharmony_ci
1022e5c31af7Sopenharmony_ciclass BlendEquationAdvancedCase : public TestCase
1023e5c31af7Sopenharmony_ci{
1024e5c31af7Sopenharmony_cipublic:
1025e5c31af7Sopenharmony_ci	BlendEquationAdvancedCase	(Context& context, const char* name, const char* desc, QueryType verifierType);
1026e5c31af7Sopenharmony_ci
1027e5c31af7Sopenharmony_ci	void				init				(void);
1028e5c31af7Sopenharmony_ciprivate:
1029e5c31af7Sopenharmony_ci	IterateResult		iterate				(void);
1030e5c31af7Sopenharmony_ci
1031e5c31af7Sopenharmony_ci	const QueryType		m_verifierType;
1032e5c31af7Sopenharmony_ci};
1033e5c31af7Sopenharmony_ci
1034e5c31af7Sopenharmony_ciBlendEquationAdvancedCase::BlendEquationAdvancedCase (Context& context, const char* name, const char* desc, QueryType verifierType)
1035e5c31af7Sopenharmony_ci		: TestCase			(context, name, desc)
1036e5c31af7Sopenharmony_ci		, m_verifierType	(verifierType)
1037e5c31af7Sopenharmony_ci{
1038e5c31af7Sopenharmony_ci}
1039e5c31af7Sopenharmony_ci
1040e5c31af7Sopenharmony_civoid BlendEquationAdvancedCase::init (void)
1041e5c31af7Sopenharmony_ci{
1042e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_EXT_draw_buffers_indexed");
1043e5c31af7Sopenharmony_ci	isExtensionSupported(m_context, "GL_KHR_blend_equation_advanced");
1044e5c31af7Sopenharmony_ci}
1045e5c31af7Sopenharmony_ci
1046e5c31af7Sopenharmony_ciBlendEquationAdvancedCase::IterateResult BlendEquationAdvancedCase::iterate (void)
1047e5c31af7Sopenharmony_ci{
1048e5c31af7Sopenharmony_ci	const deUint32 blendEquations[] =
1049e5c31af7Sopenharmony_ci			{
1050e5c31af7Sopenharmony_ci					GL_FUNC_ADD,
1051e5c31af7Sopenharmony_ci					GL_FUNC_SUBTRACT,
1052e5c31af7Sopenharmony_ci					GL_FUNC_REVERSE_SUBTRACT,
1053e5c31af7Sopenharmony_ci					GL_MIN,
1054e5c31af7Sopenharmony_ci					GL_MAX
1055e5c31af7Sopenharmony_ci			};
1056e5c31af7Sopenharmony_ci
1057e5c31af7Sopenharmony_ci	const deUint32 blendEquationAdvanced[] =
1058e5c31af7Sopenharmony_ci			{
1059e5c31af7Sopenharmony_ci					GL_MULTIPLY,
1060e5c31af7Sopenharmony_ci					GL_SCREEN,
1061e5c31af7Sopenharmony_ci					GL_OVERLAY,
1062e5c31af7Sopenharmony_ci					GL_DARKEN,
1063e5c31af7Sopenharmony_ci					GL_LIGHTEN,
1064e5c31af7Sopenharmony_ci					GL_COLORDODGE,
1065e5c31af7Sopenharmony_ci					GL_COLORBURN,
1066e5c31af7Sopenharmony_ci					GL_HARDLIGHT,
1067e5c31af7Sopenharmony_ci					GL_SOFTLIGHT,
1068e5c31af7Sopenharmony_ci					GL_DIFFERENCE,
1069e5c31af7Sopenharmony_ci					GL_EXCLUSION,
1070e5c31af7Sopenharmony_ci					GL_HSL_HUE,
1071e5c31af7Sopenharmony_ci					GL_HSL_SATURATION,
1072e5c31af7Sopenharmony_ci					GL_HSL_COLOR,
1073e5c31af7Sopenharmony_ci					GL_HSL_LUMINOSITY
1074e5c31af7Sopenharmony_ci			};
1075e5c31af7Sopenharmony_ci
1076e5c31af7Sopenharmony_ci	glu::CallLogWrapper		gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
1077e5c31af7Sopenharmony_ci	tcu::ResultCollector	result			(m_testCtx.getLog(), " // ERROR: ");
1078e5c31af7Sopenharmony_ci	deInt32					maxDrawBuffers = 0;
1079e5c31af7Sopenharmony_ci
1080e5c31af7Sopenharmony_ci	gl.enableLogging(true);
1081e5c31af7Sopenharmony_ci
1082e5c31af7Sopenharmony_ci	gl.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1083e5c31af7Sopenharmony_ci	GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
1084e5c31af7Sopenharmony_ci
1085e5c31af7Sopenharmony_ci	{
1086e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingCommon", "After setting common");
1087e5c31af7Sopenharmony_ci
1088e5c31af7Sopenharmony_ci		gl.glBlendEquation(GL_SCREEN);
1089e5c31af7Sopenharmony_ci
1090e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1091e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_SCREEN, m_verifierType);
1092e5c31af7Sopenharmony_ci
1093e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1094e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_SCREEN, m_verifierType);
1095e5c31af7Sopenharmony_ci	}
1096e5c31af7Sopenharmony_ci	{
1097e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterSettingIndexed", "After setting indexed");
1098e5c31af7Sopenharmony_ci
1099e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1100e5c31af7Sopenharmony_ci			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1101e5c31af7Sopenharmony_ci
1102e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1103e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1104e5c31af7Sopenharmony_ci
1105e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1106e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)], m_verifierType);
1107e5c31af7Sopenharmony_ci	}
1108e5c31af7Sopenharmony_ci	{
1109e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedWithCommon", "After resetting indexed with common");
1110e5c31af7Sopenharmony_ci
1111e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1112e5c31af7Sopenharmony_ci			gl.glBlendEquationi(ndx, blendEquationAdvanced[ndx % DE_LENGTH_OF_ARRAY(blendEquationAdvanced)]);
1113e5c31af7Sopenharmony_ci
1114e5c31af7Sopenharmony_ci		gl.glBlendEquation(GL_MULTIPLY);
1115e5c31af7Sopenharmony_ci
1116e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1117e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_MULTIPLY, m_verifierType);
1118e5c31af7Sopenharmony_ci
1119e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1120e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_MULTIPLY, m_verifierType);
1121e5c31af7Sopenharmony_ci	}
1122e5c31af7Sopenharmony_ci	{
1123e5c31af7Sopenharmony_ci		const tcu::ScopedLogSection section (m_testCtx.getLog(), "AfterResettingIndexedSeparateWithCommon", "After resetting indexed separate with common");
1124e5c31af7Sopenharmony_ci
1125e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1126e5c31af7Sopenharmony_ci			gl.glBlendEquationSeparatei(ndx, blendEquations[ndx % DE_LENGTH_OF_ARRAY(blendEquations)], blendEquations[(ndx + 1) % DE_LENGTH_OF_ARRAY(blendEquations)]);
1127e5c31af7Sopenharmony_ci
1128e5c31af7Sopenharmony_ci		gl.glBlendEquation(GL_LIGHTEN);
1129e5c31af7Sopenharmony_ci
1130e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1131e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_RGB, ndx, GL_LIGHTEN, m_verifierType);
1132e5c31af7Sopenharmony_ci
1133e5c31af7Sopenharmony_ci		for (int ndx = 0; ndx < maxDrawBuffers; ++ndx)
1134e5c31af7Sopenharmony_ci			verifyStateIndexedInteger(result, gl, GL_BLEND_EQUATION_ALPHA, ndx, GL_LIGHTEN, m_verifierType);
1135e5c31af7Sopenharmony_ci	}
1136e5c31af7Sopenharmony_ci
1137e5c31af7Sopenharmony_ci	result.setTestContextResult(m_testCtx);
1138e5c31af7Sopenharmony_ci	return STOP;
1139e5c31af7Sopenharmony_ci}
1140e5c31af7Sopenharmony_ci
1141e5c31af7Sopenharmony_ci} // anonymous
1142e5c31af7Sopenharmony_ci
1143e5c31af7Sopenharmony_ciIndexedStateQueryTests::IndexedStateQueryTests (Context& context)
1144e5c31af7Sopenharmony_ci	: TestCaseGroup(context, "indexed", "Indexed Integer Values")
1145e5c31af7Sopenharmony_ci{
1146e5c31af7Sopenharmony_ci}
1147e5c31af7Sopenharmony_ci
1148e5c31af7Sopenharmony_civoid IndexedStateQueryTests::init (void)
1149e5c31af7Sopenharmony_ci{
1150e5c31af7Sopenharmony_ci	// transform feedback
1151e5c31af7Sopenharmony_ci	addChild(new TransformFeedbackBufferBindingCase(m_context, "transform_feedback_buffer_binding", "TRANSFORM_FEEDBACK_BUFFER_BINDING"));
1152e5c31af7Sopenharmony_ci	addChild(new TransformFeedbackBufferBufferCase(m_context, "transform_feedback_buffer_start_size", "TRANSFORM_FEEDBACK_BUFFER_START and TRANSFORM_FEEDBACK_BUFFER_SIZE"));
1153e5c31af7Sopenharmony_ci	addChild(new TransformFeedbackSwitchingBufferCase(m_context, "transform_feedback_switching_buffer", "TRANSFORM_FEEDBACK_BUFFER_BINDING while switching transform feedback objects"));
1154e5c31af7Sopenharmony_ci
1155e5c31af7Sopenharmony_ci	// uniform buffers
1156e5c31af7Sopenharmony_ci	addChild(new UniformBufferBindingCase(m_context, "uniform_buffer_binding", "UNIFORM_BUFFER_BINDING"));
1157e5c31af7Sopenharmony_ci	addChild(new UniformBufferBufferCase(m_context, "uniform_buffer_start_size", "UNIFORM_BUFFER_START and UNIFORM_BUFFER_SIZE"));
1158e5c31af7Sopenharmony_ci
1159e5c31af7Sopenharmony_ci	static const QueryType verifiers[] = { QUERY_INDEXED_INTEGER, QUERY_INDEXED_INTEGER64 };
1160e5c31af7Sopenharmony_ci	static const QueryType vec4Verifiers[] = { QUERY_INDEXED_INTEGER_VEC4, QUERY_INDEXED_INTEGER64_VEC4 };
1161e5c31af7Sopenharmony_ci
1162e5c31af7Sopenharmony_ci#define FOR_EACH_VERIFIER(X) \
1163e5c31af7Sopenharmony_ci	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)	\
1164e5c31af7Sopenharmony_ci	{																						\
1165e5c31af7Sopenharmony_ci		const QueryType verifier = verifiers[verifierNdx];									\
1166e5c31af7Sopenharmony_ci		const char* verifierSuffix = getVerifierSuffix(verifier);							\
1167e5c31af7Sopenharmony_ci		this->addChild(X);																	\
1168e5c31af7Sopenharmony_ci	}
1169e5c31af7Sopenharmony_ci
1170e5c31af7Sopenharmony_ci#define FOR_EACH_VEC4_VERIFIER(X) \
1171e5c31af7Sopenharmony_ci	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(vec4Verifiers); ++verifierNdx)	\
1172e5c31af7Sopenharmony_ci	{																							\
1173e5c31af7Sopenharmony_ci		const QueryType verifier = vec4Verifiers[verifierNdx];									\
1174e5c31af7Sopenharmony_ci		const char* verifierSuffix = getVerifierSuffix(verifier);								\
1175e5c31af7Sopenharmony_ci		this->addChild(X);																		\
1176e5c31af7Sopenharmony_ci	}
1177e5c31af7Sopenharmony_ci
1178e5c31af7Sopenharmony_ci	addChild(new EnableBlendCase(m_context, "blend_isenabledi", "BLEND", QUERY_INDEXED_ISENABLED));
1179e5c31af7Sopenharmony_ci	FOR_EACH_VEC4_VERIFIER(new ColorMaskCase		(m_context, (std::string() + "color_mask_" + verifierSuffix).c_str(),						"COLOR_WRITEMASK",						verifier))
1180e5c31af7Sopenharmony_ci	FOR_EACH_VERIFIER(new BlendFuncCase				(m_context, (std::string() + "blend_func_" + verifierSuffix).c_str(),						"BLEND_SRC and BLEND_DST",				verifier))
1181e5c31af7Sopenharmony_ci	FOR_EACH_VERIFIER(new BlendEquationCase			(m_context, (std::string() + "blend_equation_" + verifierSuffix).c_str(),					"BLEND_EQUATION_RGB and BLEND_DST",		verifier))
1182e5c31af7Sopenharmony_ci	FOR_EACH_VERIFIER(new BlendEquationAdvancedCase	(m_context, (std::string() + "blend_equation_advanced_" + verifierSuffix).c_str(),			"BLEND_EQUATION_RGB and BLEND_DST",		verifier))
1183e5c31af7Sopenharmony_ci}
1184e5c31af7Sopenharmony_ci
1185e5c31af7Sopenharmony_ci} // Functional
1186e5c31af7Sopenharmony_ci} // gles3
1187e5c31af7Sopenharmony_ci} // deqp
1188