1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 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 Stencil tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "es2fStencilTests.hpp"
25
26#include "tcuSurface.hpp"
27#include "tcuVector.hpp"
28#include "tcuTestLog.hpp"
29#include "tcuImageCompare.hpp"
30#include "tcuRenderTarget.hpp"
31
32#include "sglrContextUtil.hpp"
33#include "sglrGLContext.hpp"
34#include "sglrReferenceContext.hpp"
35
36#include "deRandom.hpp"
37#include "deMath.h"
38#include "deString.h"
39
40#include <vector>
41
42#include "glwEnums.hpp"
43#include "glwDefs.hpp"
44
45using tcu::Vec3;
46using tcu::IVec2;
47using tcu::IVec4;
48using std::vector;
49using namespace glw;
50
51namespace deqp
52{
53namespace gles2
54{
55namespace Functional
56{
57
58class StencilShader : public sglr::ShaderProgram
59{
60public:
61	StencilShader (void)
62		: sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
63									<< sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
64									<< sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
65									<< sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
66									<< sglr::pdec::Uniform("u_color", glu::TYPE_FLOAT_VEC4)
67									<< sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
68																"void main (void)\n"
69																"{\n"
70																"	gl_Position = a_position;\n"
71																"}\n")
72									<< sglr::pdec::FragmentSource("uniform mediump vec4 u_color;\n"
73																  "void main (void)\n"
74																  "{\n"
75																  "	gl_FragColor = u_color;\n"
76																  "}\n"))
77		, u_color	(getUniformByName("u_color"))
78	{
79	}
80
81	void setColor (sglr::Context& ctx, deUint32 program, const tcu::Vec4& color)
82	{
83		ctx.useProgram(program);
84		ctx.uniform4fv(ctx.getUniformLocation(program, "u_color"), 1, color.getPtr());
85	}
86
87private:
88	void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
89	{
90		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
91		{
92			rr::VertexPacket& packet = *packets[packetNdx];
93
94			packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
95		}
96	}
97
98	void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
99	{
100		const tcu::Vec4 color(u_color.value.f4);
101
102		DE_UNREF(packets);
103
104		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
105		for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
106			rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, color);
107	}
108
109	const sglr::UniformSlot& u_color;
110};
111
112class StencilOp
113{
114public:
115	enum Type
116	{
117		TYPE_CLEAR_STENCIL = 0,
118		TYPE_CLEAR_DEPTH,
119		TYPE_QUAD,
120
121		TYPE_LAST
122	};
123
124	Type		type;
125	GLenum		stencilTest;
126	int			stencil;	//!< Ref for quad op, clear value for clears
127	deUint32	stencilMask;
128	GLenum		depthTest;
129	float		depth;		//!< Quad depth or clear value
130	GLenum		sFail;
131	GLenum		dFail;
132	GLenum		dPass;
133
134	StencilOp (Type type_, GLenum stencilTest_ = GL_ALWAYS, int stencil_ = 0, GLenum depthTest_ = GL_ALWAYS, float depth_ = 1.0f, GLenum sFail_ = GL_KEEP, GLenum dFail_ = GL_KEEP, GLenum dPass_ = GL_KEEP)
135		: type			(type_)
136		, stencilTest	(stencilTest_)
137		, stencil		(stencil_)
138		, stencilMask	(0xffffffffu)
139		, depthTest		(depthTest_)
140		, depth			(depth_)
141		, sFail			(sFail_)
142		, dFail			(dFail_)
143		, dPass			(dPass_)
144	{
145	}
146
147	static StencilOp clearStencil (int stencil)
148	{
149		StencilOp op(TYPE_CLEAR_STENCIL);
150		op.stencil = stencil;
151		return op;
152	}
153
154	static StencilOp clearDepth (float depth)
155	{
156		StencilOp op(TYPE_CLEAR_DEPTH);
157		op.depth = depth;
158		return op;
159	}
160
161	static StencilOp quad (GLenum stencilTest, int stencil, GLenum depthTest, float depth, GLenum sFail, GLenum dFail, GLenum dPass)
162	{
163		return StencilOp(TYPE_QUAD, stencilTest, stencil, depthTest, depth, sFail, dFail, dPass);
164	}
165};
166
167class StencilCase : public TestCase
168{
169public:
170						StencilCase			(Context& context, const char* name, const char* description);
171	virtual				~StencilCase		(void);
172
173	void				init				(void);
174	void				deinit				(void);
175	IterateResult		iterate				(void);
176
177	virtual void		genOps				(vector<StencilOp>& dst, int stencilBits, int depthBits, int targetStencil) = DE_NULL;
178
179private:
180	void				executeOps			(sglr::Context& context, const IVec4& cell, const vector<StencilOp>& ops);
181	void				visualizeStencil	(sglr::Context& context, int stencilBits, int stencilStep);
182
183	StencilShader		m_shader;
184	deUint32			m_shaderID;
185};
186
187StencilCase::StencilCase (Context& context, const char* name, const char* description)
188	: TestCase		(context, name, description)
189	, m_shaderID	(0)
190{
191}
192
193StencilCase::~StencilCase (void)
194{
195}
196
197void StencilCase::init (void)
198{
199}
200
201void StencilCase::deinit (void)
202{
203}
204
205void StencilCase::executeOps (sglr::Context& context, const IVec4& cell, const vector<StencilOp>& ops)
206{
207	// For quadOps
208	float x0 = 2.0f*((float)cell.x() / (float)context.getWidth())-1.0f;
209	float y0 = 2.0f*((float)cell.y() / (float)context.getHeight())-1.0f;
210	float x1 = x0 + 2.0f*((float)cell.z() / (float)context.getWidth());
211	float y1 = y0 + 2.0f*((float)cell.w() / (float)context.getHeight());
212
213	m_shader.setColor(context, m_shaderID, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
214
215	for (vector<StencilOp>::const_iterator i = ops.begin(); i != ops.end(); i++)
216	{
217		const StencilOp& op = *i;
218
219		switch (op.type)
220		{
221			case StencilOp::TYPE_CLEAR_DEPTH:
222				context.enable(GL_SCISSOR_TEST);
223				context.scissor(cell.x(), cell.y(), cell.z(), cell.w());
224				context.clearDepthf(op.depth);
225				context.clear(GL_DEPTH_BUFFER_BIT);
226				context.disable(GL_SCISSOR_TEST);
227				break;
228
229			case StencilOp::TYPE_CLEAR_STENCIL:
230				context.enable(GL_SCISSOR_TEST);
231				context.scissor(cell.x(), cell.y(), cell.z(), cell.w());
232				context.clearStencil(op.stencil);
233				context.clear(GL_STENCIL_BUFFER_BIT);
234				context.disable(GL_SCISSOR_TEST);
235				break;
236
237			case StencilOp::TYPE_QUAD:
238				context.enable(GL_DEPTH_TEST);
239				context.enable(GL_STENCIL_TEST);
240				context.depthFunc(op.depthTest);
241				context.stencilFunc(op.stencilTest, op.stencil, op.stencilMask);
242				context.stencilOp(op.sFail, op.dFail, op.dPass);
243				sglr::drawQuad(context, m_shaderID, Vec3(x0, y0, op.depth), Vec3(x1, y1, op.depth));
244				context.disable(GL_STENCIL_TEST);
245				context.disable(GL_DEPTH_TEST);
246				break;
247
248			default:
249				DE_ASSERT(DE_FALSE);
250		}
251	}
252}
253
254void StencilCase::visualizeStencil (sglr::Context& context, int stencilBits, int stencilStep)
255{
256	int endVal				= 1<<stencilBits;
257	int numStencilValues	= endVal/stencilStep + 1;
258
259	context.enable(GL_STENCIL_TEST);
260	context.stencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
261
262	for (int ndx = 0; ndx < numStencilValues; ndx++)
263	{
264		int			value		= deMin32(ndx*stencilStep, endVal-1);
265		float		colorMix	= (float)value/(float)de::max(1, endVal-1);
266		tcu::Vec4	color		(0.0f, 1.0f-colorMix, colorMix, 1.0f);
267
268		m_shader.setColor(context, m_shaderID, color);
269		context.stencilFunc(GL_EQUAL, value, 0xffffffffu);
270		sglr::drawQuad(context, m_shaderID, Vec3(-1.0f, -1.0f, 0.0f), Vec3(+1.0f, +1.0f, 0.0f));
271	}
272}
273
274TestCase::IterateResult StencilCase::iterate (void)
275{
276	const tcu::RenderTarget&	renderTarget		= m_context.getRenderContext().getRenderTarget();
277	int							depthBits			= renderTarget.getDepthBits();
278	int							stencilBits			= renderTarget.getStencilBits();
279
280	int							stencilStep			= stencilBits == 8 ? 8 : 1;
281	int							numStencilValues	= (1<<stencilBits)/stencilStep + 1;
282
283	int							gridSize			= (int)deFloatCeil(deFloatSqrt((float)(numStencilValues+2)));
284
285	int							width				= deMin32(128, renderTarget.getWidth());
286	int							height				= deMin32(128, renderTarget.getHeight());
287
288	tcu::TestLog&				log					= m_testCtx.getLog();
289	de::Random					rnd					(deStringHash(m_name.c_str()));
290	int							viewportX			= rnd.getInt(0, renderTarget.getWidth()-width);
291	int							viewportY			= rnd.getInt(0, renderTarget.getHeight()-height);
292	IVec4						viewport			= IVec4(viewportX, viewportY, width, height);
293
294	tcu::Surface				gles2Frame			(width, height);
295	tcu::Surface				refFrame			(width, height);
296	GLenum						gles2Error;
297
298	const char*					failReason			= DE_NULL;
299
300	// Get ops for stencil values
301	vector<vector<StencilOp> >	ops(numStencilValues+2);
302	{
303		// Values from 0 to max
304		for (int ndx = 0; ndx < numStencilValues; ndx++)
305			genOps(ops[ndx], stencilBits, depthBits, deMin32(ndx*stencilStep, (1<<stencilBits)-1));
306
307		// -1 and max+1
308		genOps(ops[numStencilValues+0], stencilBits, depthBits, 1<<stencilBits);
309		genOps(ops[numStencilValues+1], stencilBits, depthBits, -1);
310	}
311
312	// Compute cells: (x, y, w, h)
313	vector<IVec4>				cells;
314	int							cellWidth			= width/gridSize;
315	int							cellHeight			= height/gridSize;
316	for (int y = 0; y < gridSize; y++)
317	for (int x = 0; x < gridSize; x++)
318		cells.push_back(IVec4(x*cellWidth, y*cellHeight, cellWidth, cellHeight));
319
320	DE_ASSERT(ops.size() <= cells.size());
321
322	// Execute for gles2 context
323	{
324		sglr::GLContext context(m_context.getRenderContext(), log, 0 /* don't log calls or program */, viewport);
325
326		m_shaderID = context.createProgram(&m_shader);
327
328		context.clearColor(1.0f, 0.0f, 0.0f, 1.0f);
329		context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
330
331		for (int ndx = 0; ndx < (int)ops.size(); ndx++)
332			executeOps(context, cells[ndx], ops[ndx]);
333
334		visualizeStencil(context, stencilBits, stencilStep);
335
336		gles2Error = context.getError();
337		context.readPixels(gles2Frame, 0, 0, width, height);
338	}
339
340	// Execute for reference context
341	{
342		sglr::ReferenceContextBuffers	buffers	(tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), renderTarget.getDepthBits(), renderTarget.getStencilBits(), width, height);
343		sglr::ReferenceContext			context	(sglr::ReferenceContextLimits(m_context.getRenderContext()), buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer());
344
345		m_shaderID = context.createProgram(&m_shader);
346
347		context.clearColor(1.0f, 0.0f, 0.0f, 1.0f);
348		context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
349
350		for (int ndx = 0; ndx < (int)ops.size(); ndx++)
351			executeOps(context, cells[ndx], ops[ndx]);
352
353		visualizeStencil(context, stencilBits, stencilStep);
354
355		context.readPixels(refFrame, 0, 0, width, height);
356	}
357
358	// Check error
359	bool errorCodeOk = (gles2Error == GL_NO_ERROR);
360	if (!errorCodeOk && !failReason)
361		failReason = "Got unexpected error";
362
363	// Compare images
364	const float		threshold	= 0.02f;
365	bool			imagesOk	= tcu::fuzzyCompare(log, "ComparisonResult", "Image comparison result", refFrame, gles2Frame, threshold, tcu::COMPARE_LOG_RESULT);
366
367	if (!imagesOk && !failReason)
368		failReason = "Image comparison failed";
369
370	// Store test result
371	bool isOk = errorCodeOk && imagesOk;
372	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
373							isOk ? "Pass"				: failReason);
374
375	return STOP;
376}
377
378StencilTests::StencilTests (Context& context)
379	: TestCaseGroup(context, "stencil", "Stencil Tests")
380{
381}
382
383StencilTests::~StencilTests (void)
384{
385}
386
387typedef void (*GenStencilOpsFunc) (vector<StencilOp>& dst, int stencilBits, int depthBits, int targetStencil);
388
389class SimpleStencilCase : public StencilCase
390{
391public:
392	SimpleStencilCase (Context& context, const char* name, const char* description, GenStencilOpsFunc genOpsFunc)
393		: StencilCase	(context, name, description)
394		, m_genOps		(genOpsFunc)
395	{
396	}
397
398	void genOps (vector<StencilOp>& dst, int stencilBits, int depthBits, int targetStencil)
399	{
400		m_genOps(dst, stencilBits, depthBits, targetStencil);
401	}
402
403private:
404	GenStencilOpsFunc	m_genOps;
405};
406
407void StencilTests::init (void)
408{
409#define STENCIL_CASE(NAME, DESCRIPTION, GEN_OPS_BODY)														\
410	do {																									\
411		struct Gen_##NAME {																					\
412			static void genOps (vector<StencilOp>& dst, int stencilBits, int depthBits, int targetStencil)	\
413			{																								\
414				DE_UNREF(stencilBits && depthBits);															\
415				GEN_OPS_BODY																				\
416			}																								\
417		};																									\
418		addChild(new SimpleStencilCase(m_context, #NAME, DESCRIPTION, Gen_##NAME::genOps));					\
419	} while (deGetFalse());
420
421	STENCIL_CASE(clear, "Stencil clear",
422		{
423			// \note Unused bits are set to 1, clear should mask them out
424			int mask = (1<<stencilBits)-1;
425			dst.push_back(StencilOp::clearStencil(targetStencil | ~mask));
426		});
427
428	// Replace in different points
429	STENCIL_CASE(stencil_fail_replace, "Set stencil on stencil fail",
430		{
431			dst.push_back(StencilOp::quad(GL_NEVER, targetStencil, GL_ALWAYS, 0.0f, GL_REPLACE, GL_KEEP, GL_KEEP));
432		});
433	STENCIL_CASE(depth_fail_replace, "Set stencil on depth fail",
434		{
435			dst.push_back(StencilOp::clearDepth(0.0f));
436			dst.push_back(StencilOp::quad(GL_ALWAYS, targetStencil, GL_LESS, 0.5f, GL_KEEP, GL_REPLACE, GL_KEEP));
437		});
438	STENCIL_CASE(depth_pass_replace, "Set stencil on depth pass",
439		{
440			dst.push_back(StencilOp::quad(GL_ALWAYS, targetStencil, GL_LESS, 0.0f, GL_KEEP, GL_KEEP, GL_REPLACE));
441		});
442
443	// Increment, decrement
444	STENCIL_CASE(incr_stencil_fail, "Increment on stencil fail",
445		{
446			if (targetStencil > 0)
447			{
448				dst.push_back(StencilOp::clearStencil(targetStencil-1));
449				dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_INCR, GL_KEEP, GL_KEEP));
450			}
451			else
452				dst.push_back(StencilOp::clearStencil(targetStencil));
453		});
454	STENCIL_CASE(decr_stencil_fail, "Decrement on stencil fail",
455		{
456			int maxStencil = (1<<stencilBits)-1;
457			if (targetStencil < maxStencil)
458			{
459				dst.push_back(StencilOp::clearStencil(targetStencil+1));
460				dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_DECR, GL_KEEP, GL_KEEP));
461			}
462			else
463				dst.push_back(StencilOp::clearStencil(targetStencil));
464		});
465	STENCIL_CASE(incr_wrap_stencil_fail, "Increment (wrap) on stencil fail",
466		{
467			int maxStencil = (1<<stencilBits)-1;
468			dst.push_back(StencilOp::clearStencil((targetStencil-1)&maxStencil));
469			dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_INCR_WRAP, GL_KEEP, GL_KEEP));
470		});
471	STENCIL_CASE(decr_wrap_stencil_fail, "Decrement (wrap) on stencil fail",
472		{
473			int maxStencil = (1<<stencilBits)-1;
474			dst.push_back(StencilOp::clearStencil((targetStencil+1)&maxStencil));
475			dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_DECR_WRAP, GL_KEEP, GL_KEEP));
476		});
477
478	// Zero, Invert
479	STENCIL_CASE(zero_stencil_fail, "Zero on stencil fail",
480		{
481			dst.push_back(StencilOp::clearStencil(targetStencil));
482			dst.push_back(StencilOp::quad(GL_NOTEQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_ZERO, GL_KEEP, GL_KEEP));
483			dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_REPLACE, GL_KEEP, GL_KEEP));
484		});
485	STENCIL_CASE(invert_stencil_fail, "Invert on stencil fail",
486		{
487			int mask = (1<<stencilBits)-1;
488			dst.push_back(StencilOp::clearStencil((~targetStencil)&mask));
489			dst.push_back(StencilOp::quad(GL_EQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_INVERT, GL_KEEP, GL_KEEP));
490		});
491
492	// Comparison modes
493	STENCIL_CASE(cmp_equal, "Equality comparison",
494		{
495			int mask = (1<<stencilBits)-1;
496			int inv  = (~targetStencil)&mask;
497			dst.push_back(StencilOp::clearStencil(inv));
498			dst.push_back(StencilOp::quad(GL_EQUAL, inv, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INVERT));
499			dst.push_back(StencilOp::quad(GL_EQUAL, inv, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INVERT));
500		});
501	STENCIL_CASE(cmp_not_equal, "Equality comparison",
502		{
503			int mask = (1<<stencilBits)-1;
504			int inv  = (~targetStencil)&mask;
505			dst.push_back(StencilOp::clearStencil(inv));
506			dst.push_back(StencilOp::quad(GL_NOTEQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INVERT));
507			dst.push_back(StencilOp::quad(GL_NOTEQUAL, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INVERT));
508		});
509	STENCIL_CASE(cmp_less_than, "Less than comparison",
510		{
511			int maxStencil = (1<<stencilBits)-1;
512			if (targetStencil < maxStencil)
513			{
514				dst.push_back(StencilOp::clearStencil(targetStencil+1));
515				dst.push_back(StencilOp::quad(GL_LESS, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_DECR));
516				dst.push_back(StencilOp::quad(GL_LESS, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_DECR));
517			}
518			else
519				dst.push_back(StencilOp::clearStencil(targetStencil));
520		});
521	STENCIL_CASE(cmp_less_or_equal, "Less or equal comparison",
522		{
523			int maxStencil = (1<<stencilBits)-1;
524			if (targetStencil < maxStencil)
525			{
526				dst.push_back(StencilOp::clearStencil(targetStencil+1));
527				dst.push_back(StencilOp::quad(GL_LEQUAL, targetStencil+1, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_DECR));
528				dst.push_back(StencilOp::quad(GL_LEQUAL, targetStencil+1, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_DECR));
529			}
530			else
531				dst.push_back(StencilOp::clearStencil(targetStencil));
532		});
533	STENCIL_CASE(cmp_greater_than, "Greater than comparison",
534		{
535			if (targetStencil > 0)
536			{
537				dst.push_back(StencilOp::clearStencil(targetStencil-1));
538				dst.push_back(StencilOp::quad(GL_GREATER, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INCR));
539				dst.push_back(StencilOp::quad(GL_GREATER, targetStencil, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INCR));
540			}
541			else
542				dst.push_back(StencilOp::clearStencil(targetStencil));
543		});
544	STENCIL_CASE(cmp_greater_or_equal, "Greater or equal comparison",
545		{
546			if (targetStencil > 0)
547			{
548				dst.push_back(StencilOp::clearStencil(targetStencil-1));
549				dst.push_back(StencilOp::quad(GL_GEQUAL, targetStencil-1, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INCR));
550				dst.push_back(StencilOp::quad(GL_GEQUAL, targetStencil-1, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INCR));
551			}
552			else
553				dst.push_back(StencilOp::clearStencil(targetStencil));
554		});
555	STENCIL_CASE(cmp_mask_equal, "Equality comparison with mask",
556		{
557			int valMask = (1<<stencilBits)-1;
558			int mask	= (1<<7)|(1<<5)|(1<<3)|(1<<1);
559			dst.push_back(StencilOp::clearStencil(~targetStencil));
560			StencilOp op = StencilOp::quad(GL_EQUAL, (~targetStencil | ~mask) & valMask, GL_ALWAYS, 0.0f, GL_KEEP, GL_KEEP, GL_INVERT);
561			op.stencilMask = mask;
562			dst.push_back(op);
563		});
564}
565
566} // Functional
567} // gles2
568} // deqp
569