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