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