1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.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 Multisampling tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fMultisampleTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
36*35238bceSAndroid Build Coastguard Worker #include "deString.h"
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker #include "glw.h"
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker #include <string>
41*35238bceSAndroid Build Coastguard Worker #include <vector>
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker namespace deqp
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker namespace gles2
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker namespace Functional
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker using std::vector;
51*35238bceSAndroid Build Coastguard Worker using tcu::IVec2;
52*35238bceSAndroid Build Coastguard Worker using tcu::IVec4;
53*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
54*35238bceSAndroid Build Coastguard Worker using tcu::Vec2;
55*35238bceSAndroid Build Coastguard Worker using tcu::Vec3;
56*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker static const float SQRT_HALF = 0.707107f;
59*35238bceSAndroid Build Coastguard Worker
60*35238bceSAndroid Build Coastguard Worker namespace
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker
63*35238bceSAndroid Build Coastguard Worker struct QuadCorners
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker Vec2 p0;
66*35238bceSAndroid Build Coastguard Worker Vec2 p1;
67*35238bceSAndroid Build Coastguard Worker Vec2 p2;
68*35238bceSAndroid Build Coastguard Worker Vec2 p3;
69*35238bceSAndroid Build Coastguard Worker
QuadCornersdeqp::gles2::Functional::__anon00595c970111::QuadCorners70*35238bceSAndroid Build Coastguard Worker QuadCorners(const Vec2 &p0_, const Vec2 &p1_, const Vec2 &p2_, const Vec2 &p3_) : p0(p0_), p1(p1_), p2(p2_), p3(p3_)
71*35238bceSAndroid Build Coastguard Worker {
72*35238bceSAndroid Build Coastguard Worker }
73*35238bceSAndroid Build Coastguard Worker };
74*35238bceSAndroid Build Coastguard Worker
75*35238bceSAndroid Build Coastguard Worker } // namespace
76*35238bceSAndroid Build Coastguard Worker
getIterationCount(const tcu::TestContext & ctx,int defaultCount)77*35238bceSAndroid Build Coastguard Worker static inline int getIterationCount(const tcu::TestContext &ctx, int defaultCount)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker int cmdLineValue = ctx.getCommandLine().getTestIterationCount();
80*35238bceSAndroid Build Coastguard Worker return cmdLineValue > 0 ? cmdLineValue : defaultCount;
81*35238bceSAndroid Build Coastguard Worker }
82*35238bceSAndroid Build Coastguard Worker
getGLInteger(GLenum name)83*35238bceSAndroid Build Coastguard Worker static inline int getGLInteger(GLenum name)
84*35238bceSAndroid Build Coastguard Worker {
85*35238bceSAndroid Build Coastguard Worker int result;
86*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glGetIntegerv(name, &result));
87*35238bceSAndroid Build Coastguard Worker return result;
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker template <typename T>
min4(T a,T b,T c,T d)91*35238bceSAndroid Build Coastguard Worker static inline T min4(T a, T b, T c, T d)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker return de::min(de::min(de::min(a, b), c), d);
94*35238bceSAndroid Build Coastguard Worker }
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker template <typename T>
max4(T a,T b,T c,T d)97*35238bceSAndroid Build Coastguard Worker static inline T max4(T a, T b, T c, T d)
98*35238bceSAndroid Build Coastguard Worker {
99*35238bceSAndroid Build Coastguard Worker return de::max(de::max(de::max(a, b), c), d);
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker
isInsideQuad(const IVec2 & point,const IVec2 & p0,const IVec2 & p1,const IVec2 & p2,const IVec2 & p3)102*35238bceSAndroid Build Coastguard Worker static inline bool isInsideQuad(const IVec2 &point, const IVec2 &p0, const IVec2 &p1, const IVec2 &p2, const IVec2 &p3)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker int dot0 = (point.x() - p0.x()) * (p1.y() - p0.y()) + (point.y() - p0.y()) * (p0.x() - p1.x());
105*35238bceSAndroid Build Coastguard Worker int dot1 = (point.x() - p1.x()) * (p2.y() - p1.y()) + (point.y() - p1.y()) * (p1.x() - p2.x());
106*35238bceSAndroid Build Coastguard Worker int dot2 = (point.x() - p2.x()) * (p3.y() - p2.y()) + (point.y() - p2.y()) * (p2.x() - p3.x());
107*35238bceSAndroid Build Coastguard Worker int dot3 = (point.x() - p3.x()) * (p0.y() - p3.y()) + (point.y() - p3.y()) * (p3.x() - p0.x());
108*35238bceSAndroid Build Coastguard Worker
109*35238bceSAndroid Build Coastguard Worker return (dot0 > 0) == (dot1 > 0) && (dot1 > 0) == (dot2 > 0) && (dot2 > 0) == (dot3 > 0);
110*35238bceSAndroid Build Coastguard Worker }
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
113*35238bceSAndroid Build Coastguard Worker * \brief Check if a region in an image is unicolored.
114*35238bceSAndroid Build Coastguard Worker *
115*35238bceSAndroid Build Coastguard Worker * Checks if the pixels in img inside the convex quadilateral defined by
116*35238bceSAndroid Build Coastguard Worker * p0, p1, p2 and p3 are all (approximately) of the same color.
117*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
isPixelRegionUnicolored(const tcu::Surface & img,const IVec2 & p0,const IVec2 & p1,const IVec2 & p2,const IVec2 & p3)118*35238bceSAndroid Build Coastguard Worker static bool isPixelRegionUnicolored(const tcu::Surface &img, const IVec2 &p0, const IVec2 &p1, const IVec2 &p2,
119*35238bceSAndroid Build Coastguard Worker const IVec2 &p3)
120*35238bceSAndroid Build Coastguard Worker {
121*35238bceSAndroid Build Coastguard Worker int xMin = de::clamp(min4(p0.x(), p1.x(), p2.x(), p3.x()), 0, img.getWidth() - 1);
122*35238bceSAndroid Build Coastguard Worker int yMin = de::clamp(min4(p0.y(), p1.y(), p2.y(), p3.y()), 0, img.getHeight() - 1);
123*35238bceSAndroid Build Coastguard Worker int xMax = de::clamp(max4(p0.x(), p1.x(), p2.x(), p3.x()), 0, img.getWidth() - 1);
124*35238bceSAndroid Build Coastguard Worker int yMax = de::clamp(max4(p0.y(), p1.y(), p2.y(), p3.y()), 0, img.getHeight() - 1);
125*35238bceSAndroid Build Coastguard Worker bool insideEncountered = false; //!< Whether we have already seen at least one pixel inside the region.
126*35238bceSAndroid Build Coastguard Worker tcu::RGBA insideColor; //!< Color of the first pixel inside the region.
127*35238bceSAndroid Build Coastguard Worker
128*35238bceSAndroid Build Coastguard Worker for (int y = yMin; y <= yMax; y++)
129*35238bceSAndroid Build Coastguard Worker for (int x = xMin; x <= xMax; x++)
130*35238bceSAndroid Build Coastguard Worker {
131*35238bceSAndroid Build Coastguard Worker if (isInsideQuad(IVec2(x, y), p0, p1, p2, p3))
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker tcu::RGBA pixColor = img.getPixel(x, y);
134*35238bceSAndroid Build Coastguard Worker
135*35238bceSAndroid Build Coastguard Worker if (insideEncountered)
136*35238bceSAndroid Build Coastguard Worker {
137*35238bceSAndroid Build Coastguard Worker if (!tcu::compareThreshold(
138*35238bceSAndroid Build Coastguard Worker pixColor, insideColor,
139*35238bceSAndroid Build Coastguard Worker tcu::RGBA(
140*35238bceSAndroid Build Coastguard Worker 3, 3, 3,
141*35238bceSAndroid Build Coastguard Worker 3))) // Pixel color differs from already-detected color inside same region - region not unicolored.
142*35238bceSAndroid Build Coastguard Worker return false;
143*35238bceSAndroid Build Coastguard Worker }
144*35238bceSAndroid Build Coastguard Worker else
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker insideEncountered = true;
147*35238bceSAndroid Build Coastguard Worker insideColor = pixColor;
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker }
150*35238bceSAndroid Build Coastguard Worker }
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker return true;
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker
drawUnicolorTestErrors(tcu::Surface & img,const tcu::PixelBufferAccess & errorImg,const IVec2 & p0,const IVec2 & p1,const IVec2 & p2,const IVec2 & p3)155*35238bceSAndroid Build Coastguard Worker static bool drawUnicolorTestErrors(tcu::Surface &img, const tcu::PixelBufferAccess &errorImg, const IVec2 &p0,
156*35238bceSAndroid Build Coastguard Worker const IVec2 &p1, const IVec2 &p2, const IVec2 &p3)
157*35238bceSAndroid Build Coastguard Worker {
158*35238bceSAndroid Build Coastguard Worker int xMin = de::clamp(min4(p0.x(), p1.x(), p2.x(), p3.x()), 0, img.getWidth() - 1);
159*35238bceSAndroid Build Coastguard Worker int yMin = de::clamp(min4(p0.y(), p1.y(), p2.y(), p3.y()), 0, img.getHeight() - 1);
160*35238bceSAndroid Build Coastguard Worker int xMax = de::clamp(max4(p0.x(), p1.x(), p2.x(), p3.x()), 0, img.getWidth() - 1);
161*35238bceSAndroid Build Coastguard Worker int yMax = de::clamp(max4(p0.y(), p1.y(), p2.y(), p3.y()), 0, img.getHeight() - 1);
162*35238bceSAndroid Build Coastguard Worker tcu::RGBA refColor = img.getPixel((xMin + xMax) / 2, (yMin + yMax) / 2);
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker for (int y = yMin; y <= yMax; y++)
165*35238bceSAndroid Build Coastguard Worker for (int x = xMin; x <= xMax; x++)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker if (isInsideQuad(IVec2(x, y), p0, p1, p2, p3))
168*35238bceSAndroid Build Coastguard Worker {
169*35238bceSAndroid Build Coastguard Worker if (!tcu::compareThreshold(img.getPixel(x, y), refColor, tcu::RGBA(3, 3, 3, 3)))
170*35238bceSAndroid Build Coastguard Worker {
171*35238bceSAndroid Build Coastguard Worker img.setPixel(x, y, tcu::RGBA::red());
172*35238bceSAndroid Build Coastguard Worker errorImg.setPixel(Vec4(1.0f, 0.0f, 0.0f, 1.0f), x, y);
173*35238bceSAndroid Build Coastguard Worker }
174*35238bceSAndroid Build Coastguard Worker }
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker return true;
178*35238bceSAndroid Build Coastguard Worker }
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
181*35238bceSAndroid Build Coastguard Worker * \brief Abstract base class handling common stuff for multisample cases.
182*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
183*35238bceSAndroid Build Coastguard Worker class MultisampleCase : public TestCase
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker public:
186*35238bceSAndroid Build Coastguard Worker MultisampleCase(Context &context, const char *name, const char *desc);
187*35238bceSAndroid Build Coastguard Worker virtual ~MultisampleCase(void);
188*35238bceSAndroid Build Coastguard Worker
189*35238bceSAndroid Build Coastguard Worker virtual void init(void);
190*35238bceSAndroid Build Coastguard Worker virtual void deinit(void);
191*35238bceSAndroid Build Coastguard Worker
192*35238bceSAndroid Build Coastguard Worker protected:
193*35238bceSAndroid Build Coastguard Worker virtual int getDesiredViewportSize(void) const = 0;
194*35238bceSAndroid Build Coastguard Worker
195*35238bceSAndroid Build Coastguard Worker void renderTriangle(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec4 &c0, const Vec4 &c1,
196*35238bceSAndroid Build Coastguard Worker const Vec4 &c2) const;
197*35238bceSAndroid Build Coastguard Worker void renderTriangle(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec4 &color) const;
198*35238bceSAndroid Build Coastguard Worker void renderTriangle(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec4 &c0, const Vec4 &c1,
199*35238bceSAndroid Build Coastguard Worker const Vec4 &c2) const;
200*35238bceSAndroid Build Coastguard Worker void renderTriangle(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec4 &color) const;
201*35238bceSAndroid Build Coastguard Worker void renderQuad(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec4 &c0, const Vec4 &c1,
202*35238bceSAndroid Build Coastguard Worker const Vec4 &c2, const Vec4 &c3) const;
203*35238bceSAndroid Build Coastguard Worker void renderQuad(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec4 &color) const;
204*35238bceSAndroid Build Coastguard Worker void renderLine(const Vec2 &p0, const Vec2 &p1, const Vec4 &color) const;
205*35238bceSAndroid Build Coastguard Worker
206*35238bceSAndroid Build Coastguard Worker void randomizeViewport(void);
207*35238bceSAndroid Build Coastguard Worker void readImage(tcu::Surface &dst) const;
208*35238bceSAndroid Build Coastguard Worker
209*35238bceSAndroid Build Coastguard Worker int m_numSamples;
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker int m_viewportSize;
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker private:
214*35238bceSAndroid Build Coastguard Worker MultisampleCase(const MultisampleCase &other);
215*35238bceSAndroid Build Coastguard Worker MultisampleCase &operator=(const MultisampleCase &other);
216*35238bceSAndroid Build Coastguard Worker
217*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram *m_program;
218*35238bceSAndroid Build Coastguard Worker int m_attrPositionLoc;
219*35238bceSAndroid Build Coastguard Worker int m_attrColorLoc;
220*35238bceSAndroid Build Coastguard Worker
221*35238bceSAndroid Build Coastguard Worker int m_viewportX;
222*35238bceSAndroid Build Coastguard Worker int m_viewportY;
223*35238bceSAndroid Build Coastguard Worker de::Random m_rnd;
224*35238bceSAndroid Build Coastguard Worker };
225*35238bceSAndroid Build Coastguard Worker
MultisampleCase(Context & context,const char * name,const char * desc)226*35238bceSAndroid Build Coastguard Worker MultisampleCase::MultisampleCase(Context &context, const char *name, const char *desc)
227*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
228*35238bceSAndroid Build Coastguard Worker , m_numSamples(0)
229*35238bceSAndroid Build Coastguard Worker , m_viewportSize(0)
230*35238bceSAndroid Build Coastguard Worker , m_program(DE_NULL)
231*35238bceSAndroid Build Coastguard Worker , m_attrPositionLoc(-1)
232*35238bceSAndroid Build Coastguard Worker , m_attrColorLoc(-1)
233*35238bceSAndroid Build Coastguard Worker , m_viewportX(0)
234*35238bceSAndroid Build Coastguard Worker , m_viewportY(0)
235*35238bceSAndroid Build Coastguard Worker , m_rnd(deStringHash(name))
236*35238bceSAndroid Build Coastguard Worker {
237*35238bceSAndroid Build Coastguard Worker }
238*35238bceSAndroid Build Coastguard Worker
renderTriangle(const Vec3 & p0,const Vec3 & p1,const Vec3 & p2,const Vec4 & c0,const Vec4 & c1,const Vec4 & c2) const239*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderTriangle(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec4 &c0, const Vec4 &c1,
240*35238bceSAndroid Build Coastguard Worker const Vec4 &c2) const
241*35238bceSAndroid Build Coastguard Worker {
242*35238bceSAndroid Build Coastguard Worker float vertexPositions[] = {p0.x(), p0.y(), p0.z(), 1.0f, p1.x(), p1.y(),
243*35238bceSAndroid Build Coastguard Worker p1.z(), 1.0f, p2.x(), p2.y(), p2.z(), 1.0f};
244*35238bceSAndroid Build Coastguard Worker float vertexColors[] = {
245*35238bceSAndroid Build Coastguard Worker c0.x(), c0.y(), c0.z(), c0.w(), c1.x(), c1.y(), c1.z(), c1.w(), c2.x(), c2.y(), c2.z(), c2.w(),
246*35238bceSAndroid Build Coastguard Worker };
247*35238bceSAndroid Build Coastguard Worker
248*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnableVertexAttribArray(m_attrPositionLoc));
249*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glVertexAttribPointer(m_attrPositionLoc, 4, GL_FLOAT, false, 0, &vertexPositions[0]));
250*35238bceSAndroid Build Coastguard Worker
251*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnableVertexAttribArray(m_attrColorLoc));
252*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glVertexAttribPointer(m_attrColorLoc, 4, GL_FLOAT, false, 0, &vertexColors[0]));
253*35238bceSAndroid Build Coastguard Worker
254*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glUseProgram(m_program->getProgram()));
255*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, 3));
256*35238bceSAndroid Build Coastguard Worker }
257*35238bceSAndroid Build Coastguard Worker
renderTriangle(const Vec3 & p0,const Vec3 & p1,const Vec3 & p2,const Vec4 & color) const258*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderTriangle(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec4 &color) const
259*35238bceSAndroid Build Coastguard Worker {
260*35238bceSAndroid Build Coastguard Worker renderTriangle(p0, p1, p2, color, color, color);
261*35238bceSAndroid Build Coastguard Worker }
262*35238bceSAndroid Build Coastguard Worker
renderTriangle(const Vec2 & p0,const Vec2 & p1,const Vec2 & p2,const Vec4 & c0,const Vec4 & c1,const Vec4 & c2) const263*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderTriangle(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec4 &c0, const Vec4 &c1,
264*35238bceSAndroid Build Coastguard Worker const Vec4 &c2) const
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker renderTriangle(Vec3(p0.x(), p0.y(), 0.0f), Vec3(p1.x(), p1.y(), 0.0f), Vec3(p2.x(), p2.y(), 0.0f), c0, c1, c2);
267*35238bceSAndroid Build Coastguard Worker }
268*35238bceSAndroid Build Coastguard Worker
renderTriangle(const Vec2 & p0,const Vec2 & p1,const Vec2 & p2,const Vec4 & color) const269*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderTriangle(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec4 &color) const
270*35238bceSAndroid Build Coastguard Worker {
271*35238bceSAndroid Build Coastguard Worker renderTriangle(p0, p1, p2, color, color, color);
272*35238bceSAndroid Build Coastguard Worker }
273*35238bceSAndroid Build Coastguard Worker
renderQuad(const Vec2 & p0,const Vec2 & p1,const Vec2 & p2,const Vec2 & p3,const Vec4 & c0,const Vec4 & c1,const Vec4 & c2,const Vec4 & c3) const274*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderQuad(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec4 &c0,
275*35238bceSAndroid Build Coastguard Worker const Vec4 &c1, const Vec4 &c2, const Vec4 &c3) const
276*35238bceSAndroid Build Coastguard Worker {
277*35238bceSAndroid Build Coastguard Worker renderTriangle(p0, p1, p2, c0, c1, c2);
278*35238bceSAndroid Build Coastguard Worker renderTriangle(p2, p1, p3, c2, c1, c3);
279*35238bceSAndroid Build Coastguard Worker }
280*35238bceSAndroid Build Coastguard Worker
renderQuad(const Vec2 & p0,const Vec2 & p1,const Vec2 & p2,const Vec2 & p3,const Vec4 & color) const281*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderQuad(const Vec2 &p0, const Vec2 &p1, const Vec2 &p2, const Vec2 &p3,
282*35238bceSAndroid Build Coastguard Worker const Vec4 &color) const
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker renderQuad(p0, p1, p2, p3, color, color, color, color);
285*35238bceSAndroid Build Coastguard Worker }
286*35238bceSAndroid Build Coastguard Worker
renderLine(const Vec2 & p0,const Vec2 & p1,const Vec4 & color) const287*35238bceSAndroid Build Coastguard Worker void MultisampleCase::renderLine(const Vec2 &p0, const Vec2 &p1, const Vec4 &color) const
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker float vertexPositions[] = {p0.x(), p0.y(), 0.0f, 1.0f, p1.x(), p1.y(), 0.0f, 1.0f};
290*35238bceSAndroid Build Coastguard Worker float vertexColors[] = {color.x(), color.y(), color.z(), color.w(), color.x(), color.y(), color.z(), color.w()};
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnableVertexAttribArray(m_attrPositionLoc));
293*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glVertexAttribPointer(m_attrPositionLoc, 4, GL_FLOAT, false, 0, &vertexPositions[0]));
294*35238bceSAndroid Build Coastguard Worker
295*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnableVertexAttribArray(m_attrColorLoc));
296*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glVertexAttribPointer(m_attrColorLoc, 4, GL_FLOAT, false, 0, &vertexColors[0]));
297*35238bceSAndroid Build Coastguard Worker
298*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glUseProgram(m_program->getProgram()));
299*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glDrawArrays(GL_LINES, 0, 2));
300*35238bceSAndroid Build Coastguard Worker }
301*35238bceSAndroid Build Coastguard Worker
randomizeViewport(void)302*35238bceSAndroid Build Coastguard Worker void MultisampleCase::randomizeViewport(void)
303*35238bceSAndroid Build Coastguard Worker {
304*35238bceSAndroid Build Coastguard Worker m_viewportX = m_rnd.getInt(0, m_context.getRenderTarget().getWidth() - m_viewportSize);
305*35238bceSAndroid Build Coastguard Worker m_viewportY = m_rnd.getInt(0, m_context.getRenderTarget().getHeight() - m_viewportSize);
306*35238bceSAndroid Build Coastguard Worker
307*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glViewport(m_viewportX, m_viewportY, m_viewportSize, m_viewportSize));
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker
readImage(tcu::Surface & dst) const310*35238bceSAndroid Build Coastguard Worker void MultisampleCase::readImage(tcu::Surface &dst) const
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), m_viewportX, m_viewportY, dst.getAccess());
313*35238bceSAndroid Build Coastguard Worker }
314*35238bceSAndroid Build Coastguard Worker
init(void)315*35238bceSAndroid Build Coastguard Worker void MultisampleCase::init(void)
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker static const char *vertShaderSource = "attribute highp vec4 a_position;\n"
318*35238bceSAndroid Build Coastguard Worker "attribute mediump vec4 a_color;\n"
319*35238bceSAndroid Build Coastguard Worker "varying mediump vec4 v_color;\n"
320*35238bceSAndroid Build Coastguard Worker "void main()\n"
321*35238bceSAndroid Build Coastguard Worker "{\n"
322*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
323*35238bceSAndroid Build Coastguard Worker " v_color = a_color;\n"
324*35238bceSAndroid Build Coastguard Worker "}\n";
325*35238bceSAndroid Build Coastguard Worker
326*35238bceSAndroid Build Coastguard Worker static const char *fragShaderSource = "varying mediump vec4 v_color;\n"
327*35238bceSAndroid Build Coastguard Worker "void main()\n"
328*35238bceSAndroid Build Coastguard Worker "{\n"
329*35238bceSAndroid Build Coastguard Worker " gl_FragColor = v_color;\n"
330*35238bceSAndroid Build Coastguard Worker "}\n";
331*35238bceSAndroid Build Coastguard Worker
332*35238bceSAndroid Build Coastguard Worker // Check multisample support.
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker if (m_context.getRenderTarget().getNumSamples() <= 1)
335*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("No multisample buffers");
336*35238bceSAndroid Build Coastguard Worker
337*35238bceSAndroid Build Coastguard Worker // Prepare program.
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!m_program);
340*35238bceSAndroid Build Coastguard Worker
341*35238bceSAndroid Build Coastguard Worker m_program = new glu::ShaderProgram(m_context.getRenderContext(),
342*35238bceSAndroid Build Coastguard Worker glu::makeVtxFragSources(vertShaderSource, fragShaderSource));
343*35238bceSAndroid Build Coastguard Worker if (!m_program->isOk())
344*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("Failed to compile program", DE_NULL, __FILE__, __LINE__);
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(m_attrPositionLoc = glGetAttribLocation(m_program->getProgram(), "a_position"));
347*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(m_attrColorLoc = glGetAttribLocation(m_program->getProgram(), "a_color"));
348*35238bceSAndroid Build Coastguard Worker
349*35238bceSAndroid Build Coastguard Worker if (m_attrPositionLoc < 0 || m_attrColorLoc < 0)
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker delete m_program;
352*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("Invalid attribute locations", DE_NULL, __FILE__, __LINE__);
353*35238bceSAndroid Build Coastguard Worker }
354*35238bceSAndroid Build Coastguard Worker
355*35238bceSAndroid Build Coastguard Worker // Get suitable viewport size.
356*35238bceSAndroid Build Coastguard Worker
357*35238bceSAndroid Build Coastguard Worker m_viewportSize = de::min<int>(getDesiredViewportSize(), de::min(m_context.getRenderTarget().getWidth(),
358*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getHeight()));
359*35238bceSAndroid Build Coastguard Worker randomizeViewport();
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker // Query and log number of samples per pixel.
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker m_numSamples = getGLInteger(GL_SAMPLES);
364*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "GL_SAMPLES = " << m_numSamples << TestLog::EndMessage;
365*35238bceSAndroid Build Coastguard Worker }
366*35238bceSAndroid Build Coastguard Worker
~MultisampleCase(void)367*35238bceSAndroid Build Coastguard Worker MultisampleCase::~MultisampleCase(void)
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker delete m_program;
370*35238bceSAndroid Build Coastguard Worker }
371*35238bceSAndroid Build Coastguard Worker
deinit(void)372*35238bceSAndroid Build Coastguard Worker void MultisampleCase::deinit(void)
373*35238bceSAndroid Build Coastguard Worker {
374*35238bceSAndroid Build Coastguard Worker delete m_program;
375*35238bceSAndroid Build Coastguard Worker
376*35238bceSAndroid Build Coastguard Worker m_program = DE_NULL;
377*35238bceSAndroid Build Coastguard Worker }
378*35238bceSAndroid Build Coastguard Worker
379*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
380*35238bceSAndroid Build Coastguard Worker * \brief Base class for cases testing the value of GL_SAMPLES.
381*35238bceSAndroid Build Coastguard Worker *
382*35238bceSAndroid Build Coastguard Worker * Draws a test pattern (defined by renderPattern() of an inheriting class)
383*35238bceSAndroid Build Coastguard Worker * and counts the number of distinct colors in the resulting image. That
384*35238bceSAndroid Build Coastguard Worker * number should be at least the value of GL_SAMPLES plus one. This is
385*35238bceSAndroid Build Coastguard Worker * repeated with increased values of m_currentIteration until this correct
386*35238bceSAndroid Build Coastguard Worker * number of colors is detected or m_currentIteration reaches
387*35238bceSAndroid Build Coastguard Worker * m_maxNumIterations.
388*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
389*35238bceSAndroid Build Coastguard Worker class NumSamplesCase : public MultisampleCase
390*35238bceSAndroid Build Coastguard Worker {
391*35238bceSAndroid Build Coastguard Worker public:
392*35238bceSAndroid Build Coastguard Worker NumSamplesCase(Context &context, const char *name, const char *description);
~NumSamplesCase(void)393*35238bceSAndroid Build Coastguard Worker ~NumSamplesCase(void)
394*35238bceSAndroid Build Coastguard Worker {
395*35238bceSAndroid Build Coastguard Worker }
396*35238bceSAndroid Build Coastguard Worker
397*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const400*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker return 256;
403*35238bceSAndroid Build Coastguard Worker }
404*35238bceSAndroid Build Coastguard Worker virtual void renderPattern(void) const = 0;
405*35238bceSAndroid Build Coastguard Worker
406*35238bceSAndroid Build Coastguard Worker int m_currentIteration;
407*35238bceSAndroid Build Coastguard Worker
408*35238bceSAndroid Build Coastguard Worker private:
409*35238bceSAndroid Build Coastguard Worker enum
410*35238bceSAndroid Build Coastguard Worker {
411*35238bceSAndroid Build Coastguard Worker DEFAULT_MAX_NUM_ITERATIONS = 16
412*35238bceSAndroid Build Coastguard Worker };
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker const int m_maxNumIterations;
415*35238bceSAndroid Build Coastguard Worker vector<tcu::RGBA> m_detectedColors;
416*35238bceSAndroid Build Coastguard Worker };
417*35238bceSAndroid Build Coastguard Worker
NumSamplesCase(Context & context,const char * name,const char * description)418*35238bceSAndroid Build Coastguard Worker NumSamplesCase::NumSamplesCase(Context &context, const char *name, const char *description)
419*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
420*35238bceSAndroid Build Coastguard Worker , m_currentIteration(0)
421*35238bceSAndroid Build Coastguard Worker , m_maxNumIterations(getIterationCount(m_testCtx, DEFAULT_MAX_NUM_ITERATIONS))
422*35238bceSAndroid Build Coastguard Worker {
423*35238bceSAndroid Build Coastguard Worker }
424*35238bceSAndroid Build Coastguard Worker
iterate(void)425*35238bceSAndroid Build Coastguard Worker NumSamplesCase::IterateResult NumSamplesCase::iterate(void)
426*35238bceSAndroid Build Coastguard Worker {
427*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
428*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImg(m_viewportSize, m_viewportSize);
429*35238bceSAndroid Build Coastguard Worker
430*35238bceSAndroid Build Coastguard Worker randomizeViewport();
431*35238bceSAndroid Build Coastguard Worker
432*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
433*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
434*35238bceSAndroid Build Coastguard Worker
435*35238bceSAndroid Build Coastguard Worker renderPattern();
436*35238bceSAndroid Build Coastguard Worker
437*35238bceSAndroid Build Coastguard Worker // Read and log rendered image.
438*35238bceSAndroid Build Coastguard Worker
439*35238bceSAndroid Build Coastguard Worker readImage(renderedImg);
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImage", "Rendered image", renderedImg, QP_IMAGE_COMPRESSION_MODE_PNG);
442*35238bceSAndroid Build Coastguard Worker
443*35238bceSAndroid Build Coastguard Worker // Detect new, previously unseen colors from image.
444*35238bceSAndroid Build Coastguard Worker
445*35238bceSAndroid Build Coastguard Worker int requiredNumDistinctColors = m_numSamples + 1;
446*35238bceSAndroid Build Coastguard Worker
447*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < renderedImg.getHeight() && (int)m_detectedColors.size() < requiredNumDistinctColors; y++)
448*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < renderedImg.getWidth() && (int)m_detectedColors.size() < requiredNumDistinctColors; x++)
449*35238bceSAndroid Build Coastguard Worker {
450*35238bceSAndroid Build Coastguard Worker tcu::RGBA color = renderedImg.getPixel(x, y);
451*35238bceSAndroid Build Coastguard Worker
452*35238bceSAndroid Build Coastguard Worker int i;
453*35238bceSAndroid Build Coastguard Worker for (i = 0; i < (int)m_detectedColors.size(); i++)
454*35238bceSAndroid Build Coastguard Worker {
455*35238bceSAndroid Build Coastguard Worker if (tcu::compareThreshold(color, m_detectedColors[i], tcu::RGBA(3, 3, 3, 3)))
456*35238bceSAndroid Build Coastguard Worker break;
457*35238bceSAndroid Build Coastguard Worker }
458*35238bceSAndroid Build Coastguard Worker
459*35238bceSAndroid Build Coastguard Worker if (i == (int)m_detectedColors.size())
460*35238bceSAndroid Build Coastguard Worker m_detectedColors.push_back(color); // Color not previously detected.
461*35238bceSAndroid Build Coastguard Worker }
462*35238bceSAndroid Build Coastguard Worker
463*35238bceSAndroid Build Coastguard Worker // Log results.
464*35238bceSAndroid Build Coastguard Worker
465*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of distinct colors detected so far: "
466*35238bceSAndroid Build Coastguard Worker << ((int)m_detectedColors.size() >= requiredNumDistinctColors ? "at least " : "")
467*35238bceSAndroid Build Coastguard Worker << de::toString(m_detectedColors.size()) << TestLog::EndMessage;
468*35238bceSAndroid Build Coastguard Worker
469*35238bceSAndroid Build Coastguard Worker if ((int)m_detectedColors.size() < requiredNumDistinctColors)
470*35238bceSAndroid Build Coastguard Worker {
471*35238bceSAndroid Build Coastguard Worker // Haven't detected enough different colors yet.
472*35238bceSAndroid Build Coastguard Worker
473*35238bceSAndroid Build Coastguard Worker m_currentIteration++;
474*35238bceSAndroid Build Coastguard Worker
475*35238bceSAndroid Build Coastguard Worker if (m_currentIteration >= m_maxNumIterations)
476*35238bceSAndroid Build Coastguard Worker {
477*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: Number of distinct colors detected is lower than GL_SAMPLES+1"
478*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
479*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
480*35238bceSAndroid Build Coastguard Worker return STOP;
481*35238bceSAndroid Build Coastguard Worker }
482*35238bceSAndroid Build Coastguard Worker else
483*35238bceSAndroid Build Coastguard Worker {
484*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
485*35238bceSAndroid Build Coastguard Worker << "The number of distinct colors detected is lower than GL_SAMPLES+1 - trying again with a slightly "
486*35238bceSAndroid Build Coastguard Worker "altered pattern"
487*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
488*35238bceSAndroid Build Coastguard Worker return CONTINUE;
489*35238bceSAndroid Build Coastguard Worker }
490*35238bceSAndroid Build Coastguard Worker }
491*35238bceSAndroid Build Coastguard Worker else
492*35238bceSAndroid Build Coastguard Worker {
493*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Success: The number of distinct colors detected is at least GL_SAMPLES+1"
494*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
495*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed");
496*35238bceSAndroid Build Coastguard Worker return STOP;
497*35238bceSAndroid Build Coastguard Worker }
498*35238bceSAndroid Build Coastguard Worker }
499*35238bceSAndroid Build Coastguard Worker
500*35238bceSAndroid Build Coastguard Worker class PolygonNumSamplesCase : public NumSamplesCase
501*35238bceSAndroid Build Coastguard Worker {
502*35238bceSAndroid Build Coastguard Worker public:
503*35238bceSAndroid Build Coastguard Worker PolygonNumSamplesCase(Context &context, const char *name, const char *description);
~PolygonNumSamplesCase(void)504*35238bceSAndroid Build Coastguard Worker ~PolygonNumSamplesCase(void)
505*35238bceSAndroid Build Coastguard Worker {
506*35238bceSAndroid Build Coastguard Worker }
507*35238bceSAndroid Build Coastguard Worker
508*35238bceSAndroid Build Coastguard Worker protected:
509*35238bceSAndroid Build Coastguard Worker void renderPattern(void) const;
510*35238bceSAndroid Build Coastguard Worker };
511*35238bceSAndroid Build Coastguard Worker
PolygonNumSamplesCase(Context & context,const char * name,const char * description)512*35238bceSAndroid Build Coastguard Worker PolygonNumSamplesCase::PolygonNumSamplesCase(Context &context, const char *name, const char *description)
513*35238bceSAndroid Build Coastguard Worker : NumSamplesCase(context, name, description)
514*35238bceSAndroid Build Coastguard Worker {
515*35238bceSAndroid Build Coastguard Worker }
516*35238bceSAndroid Build Coastguard Worker
renderPattern(void) const517*35238bceSAndroid Build Coastguard Worker void PolygonNumSamplesCase::renderPattern(void) const
518*35238bceSAndroid Build Coastguard Worker {
519*35238bceSAndroid Build Coastguard Worker // The test pattern consists of several triangles with edges at different angles.
520*35238bceSAndroid Build Coastguard Worker
521*35238bceSAndroid Build Coastguard Worker const int numTriangles = 25;
522*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numTriangles; i++)
523*35238bceSAndroid Build Coastguard Worker {
524*35238bceSAndroid Build Coastguard Worker float angle0 = 2.0f * DE_PI * (float)i / (float)numTriangles + 0.001f * (float)m_currentIteration;
525*35238bceSAndroid Build Coastguard Worker float angle1 = 2.0f * DE_PI * ((float)i + 0.5f) / (float)numTriangles + 0.001f * (float)m_currentIteration;
526*35238bceSAndroid Build Coastguard Worker
527*35238bceSAndroid Build Coastguard Worker renderTriangle(Vec2(0.0f, 0.0f), Vec2(deFloatCos(angle0) * 0.95f, deFloatSin(angle0) * 0.95f),
528*35238bceSAndroid Build Coastguard Worker Vec2(deFloatCos(angle1) * 0.95f, deFloatSin(angle1) * 0.95f), Vec4(1.0f));
529*35238bceSAndroid Build Coastguard Worker }
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker
532*35238bceSAndroid Build Coastguard Worker class LineNumSamplesCase : public NumSamplesCase
533*35238bceSAndroid Build Coastguard Worker {
534*35238bceSAndroid Build Coastguard Worker public:
535*35238bceSAndroid Build Coastguard Worker LineNumSamplesCase(Context &context, const char *name, const char *description);
~LineNumSamplesCase(void)536*35238bceSAndroid Build Coastguard Worker ~LineNumSamplesCase(void)
537*35238bceSAndroid Build Coastguard Worker {
538*35238bceSAndroid Build Coastguard Worker }
539*35238bceSAndroid Build Coastguard Worker
540*35238bceSAndroid Build Coastguard Worker protected:
541*35238bceSAndroid Build Coastguard Worker void renderPattern(void) const;
542*35238bceSAndroid Build Coastguard Worker };
543*35238bceSAndroid Build Coastguard Worker
LineNumSamplesCase(Context & context,const char * name,const char * description)544*35238bceSAndroid Build Coastguard Worker LineNumSamplesCase::LineNumSamplesCase(Context &context, const char *name, const char *description)
545*35238bceSAndroid Build Coastguard Worker : NumSamplesCase(context, name, description)
546*35238bceSAndroid Build Coastguard Worker {
547*35238bceSAndroid Build Coastguard Worker }
548*35238bceSAndroid Build Coastguard Worker
renderPattern(void) const549*35238bceSAndroid Build Coastguard Worker void LineNumSamplesCase::renderPattern(void) const
550*35238bceSAndroid Build Coastguard Worker {
551*35238bceSAndroid Build Coastguard Worker // The test pattern consists of several lines at different angles.
552*35238bceSAndroid Build Coastguard Worker
553*35238bceSAndroid Build Coastguard Worker // We scale the number of lines based on the viewport size. This is because a gl line's thickness is
554*35238bceSAndroid Build Coastguard Worker // constant in pixel units, i.e. they get relatively thicker as viewport size decreases. Thus we must
555*35238bceSAndroid Build Coastguard Worker // decrease the number of lines in order to decrease the extent of overlap among the lines in the
556*35238bceSAndroid Build Coastguard Worker // center of the pattern.
557*35238bceSAndroid Build Coastguard Worker const int numLines = (int)(100.0f * deFloatSqrt((float)m_viewportSize / 256.0f));
558*35238bceSAndroid Build Coastguard Worker
559*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numLines; i++)
560*35238bceSAndroid Build Coastguard Worker {
561*35238bceSAndroid Build Coastguard Worker float angle = 2.0f * DE_PI * (float)i / (float)numLines + 0.001f * (float)m_currentIteration;
562*35238bceSAndroid Build Coastguard Worker renderLine(Vec2(0.0f, 0.0f), Vec2(deFloatCos(angle) * 0.95f, deFloatSin(angle) * 0.95f), Vec4(1.0f));
563*35238bceSAndroid Build Coastguard Worker }
564*35238bceSAndroid Build Coastguard Worker }
565*35238bceSAndroid Build Coastguard Worker
566*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
567*35238bceSAndroid Build Coastguard Worker * \brief Case testing behaviour of common edges when multisampling.
568*35238bceSAndroid Build Coastguard Worker *
569*35238bceSAndroid Build Coastguard Worker * Draws a number of test patterns, each with a number of quads, each made
570*35238bceSAndroid Build Coastguard Worker * of two triangles, rotated at different angles. The inner edge inside the
571*35238bceSAndroid Build Coastguard Worker * quad (i.e. the common edge of the two triangles) still should not be
572*35238bceSAndroid Build Coastguard Worker * visible, despite multisampling - i.e. the two triangles forming the quad
573*35238bceSAndroid Build Coastguard Worker * should never get any common coverage bits in any pixel.
574*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
575*35238bceSAndroid Build Coastguard Worker class CommonEdgeCase : public MultisampleCase
576*35238bceSAndroid Build Coastguard Worker {
577*35238bceSAndroid Build Coastguard Worker public:
578*35238bceSAndroid Build Coastguard Worker enum CaseType
579*35238bceSAndroid Build Coastguard Worker {
580*35238bceSAndroid Build Coastguard Worker CASETYPE_SMALL_QUADS = 0, //!< Draw several small quads per iteration.
581*35238bceSAndroid Build Coastguard Worker CASETYPE_BIGGER_THAN_VIEWPORT_QUAD, //!< Draw one bigger-than-viewport quad per iteration.
582*35238bceSAndroid Build Coastguard Worker CASETYPE_FIT_VIEWPORT_QUAD, //!< Draw one exactly viewport-sized, axis aligned quad per iteration.
583*35238bceSAndroid Build Coastguard Worker
584*35238bceSAndroid Build Coastguard Worker CASETYPE_LAST
585*35238bceSAndroid Build Coastguard Worker };
586*35238bceSAndroid Build Coastguard Worker
587*35238bceSAndroid Build Coastguard Worker CommonEdgeCase(Context &context, const char *name, const char *description, CaseType caseType);
~CommonEdgeCase(void)588*35238bceSAndroid Build Coastguard Worker ~CommonEdgeCase(void)
589*35238bceSAndroid Build Coastguard Worker {
590*35238bceSAndroid Build Coastguard Worker }
591*35238bceSAndroid Build Coastguard Worker
592*35238bceSAndroid Build Coastguard Worker void init(void);
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
595*35238bceSAndroid Build Coastguard Worker
596*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const597*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
598*35238bceSAndroid Build Coastguard Worker {
599*35238bceSAndroid Build Coastguard Worker return m_caseType == CASETYPE_SMALL_QUADS ? 128 : 32;
600*35238bceSAndroid Build Coastguard Worker }
601*35238bceSAndroid Build Coastguard Worker
602*35238bceSAndroid Build Coastguard Worker private:
603*35238bceSAndroid Build Coastguard Worker enum
604*35238bceSAndroid Build Coastguard Worker {
605*35238bceSAndroid Build Coastguard Worker DEFAULT_SMALL_QUADS_ITERATIONS = 16,
606*35238bceSAndroid Build Coastguard Worker DEFAULT_BIGGER_THAN_VIEWPORT_QUAD_ITERATIONS = 8 * 8
607*35238bceSAndroid Build Coastguard Worker // \note With CASETYPE_FIT_VIEWPORT_QUAD, we don't do rotations other than multiples of 90 deg -> constant number of iterations.
608*35238bceSAndroid Build Coastguard Worker };
609*35238bceSAndroid Build Coastguard Worker
610*35238bceSAndroid Build Coastguard Worker const CaseType m_caseType;
611*35238bceSAndroid Build Coastguard Worker
612*35238bceSAndroid Build Coastguard Worker const int m_numIterations;
613*35238bceSAndroid Build Coastguard Worker int m_currentIteration;
614*35238bceSAndroid Build Coastguard Worker };
615*35238bceSAndroid Build Coastguard Worker
CommonEdgeCase(Context & context,const char * name,const char * description,CaseType caseType)616*35238bceSAndroid Build Coastguard Worker CommonEdgeCase::CommonEdgeCase(Context &context, const char *name, const char *description, CaseType caseType)
617*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
618*35238bceSAndroid Build Coastguard Worker , m_caseType(caseType)
619*35238bceSAndroid Build Coastguard Worker , m_numIterations(caseType == CASETYPE_SMALL_QUADS ?
620*35238bceSAndroid Build Coastguard Worker getIterationCount(m_testCtx, DEFAULT_SMALL_QUADS_ITERATIONS) :
621*35238bceSAndroid Build Coastguard Worker caseType == CASETYPE_BIGGER_THAN_VIEWPORT_QUAD ?
622*35238bceSAndroid Build Coastguard Worker getIterationCount(m_testCtx, DEFAULT_BIGGER_THAN_VIEWPORT_QUAD_ITERATIONS) :
623*35238bceSAndroid Build Coastguard Worker 8)
624*35238bceSAndroid Build Coastguard Worker , m_currentIteration(0)
625*35238bceSAndroid Build Coastguard Worker {
626*35238bceSAndroid Build Coastguard Worker }
627*35238bceSAndroid Build Coastguard Worker
init(void)628*35238bceSAndroid Build Coastguard Worker void CommonEdgeCase::init(void)
629*35238bceSAndroid Build Coastguard Worker {
630*35238bceSAndroid Build Coastguard Worker MultisampleCase::init();
631*35238bceSAndroid Build Coastguard Worker
632*35238bceSAndroid Build Coastguard Worker if (m_caseType == CASETYPE_SMALL_QUADS)
633*35238bceSAndroid Build Coastguard Worker {
634*35238bceSAndroid Build Coastguard Worker // Check for a big enough viewport. With too small viewports the test case can't analyze the resulting image well enough.
635*35238bceSAndroid Build Coastguard Worker
636*35238bceSAndroid Build Coastguard Worker const int minViewportSize = 32;
637*35238bceSAndroid Build Coastguard Worker
638*35238bceSAndroid Build Coastguard Worker DE_ASSERT(minViewportSize <= getDesiredViewportSize());
639*35238bceSAndroid Build Coastguard Worker
640*35238bceSAndroid Build Coastguard Worker if (m_viewportSize < minViewportSize)
641*35238bceSAndroid Build Coastguard Worker throw tcu::InternalError("Render target width or height too low (is " + de::toString(m_viewportSize) +
642*35238bceSAndroid Build Coastguard Worker ", should be at least " + de::toString(minViewportSize) + ")");
643*35238bceSAndroid Build Coastguard Worker }
644*35238bceSAndroid Build Coastguard Worker
645*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_BLEND));
646*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glBlendEquation(GL_FUNC_ADD));
647*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glBlendFunc(GL_ONE, GL_ONE));
648*35238bceSAndroid Build Coastguard Worker
649*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
650*35238bceSAndroid Build Coastguard Worker << "Additive blending enabled in order to detect (erroneously) overlapping samples"
651*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
652*35238bceSAndroid Build Coastguard Worker }
653*35238bceSAndroid Build Coastguard Worker
iterate(void)654*35238bceSAndroid Build Coastguard Worker CommonEdgeCase::IterateResult CommonEdgeCase::iterate(void)
655*35238bceSAndroid Build Coastguard Worker {
656*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
657*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImg(m_viewportSize, m_viewportSize);
658*35238bceSAndroid Build Coastguard Worker tcu::Surface errorImg(m_viewportSize, m_viewportSize);
659*35238bceSAndroid Build Coastguard Worker
660*35238bceSAndroid Build Coastguard Worker randomizeViewport();
661*35238bceSAndroid Build Coastguard Worker
662*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
663*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
664*35238bceSAndroid Build Coastguard Worker
665*35238bceSAndroid Build Coastguard Worker // Draw test pattern. Test patterns consist of quads formed with two triangles.
666*35238bceSAndroid Build Coastguard Worker // After drawing the pattern, we check that the interior pixels of each quad are
667*35238bceSAndroid Build Coastguard Worker // all the same color - this is meant to verify that there are no artifacts on the inner edge.
668*35238bceSAndroid Build Coastguard Worker
669*35238bceSAndroid Build Coastguard Worker vector<QuadCorners> unicoloredRegions;
670*35238bceSAndroid Build Coastguard Worker
671*35238bceSAndroid Build Coastguard Worker if (m_caseType == CASETYPE_SMALL_QUADS)
672*35238bceSAndroid Build Coastguard Worker {
673*35238bceSAndroid Build Coastguard Worker // Draw several quads, rotated at different angles.
674*35238bceSAndroid Build Coastguard Worker
675*35238bceSAndroid Build Coastguard Worker const float quadDiagLen = 2.0f / 3.0f * 0.9f; // \note Fit 3 quads in both x and y directions.
676*35238bceSAndroid Build Coastguard Worker float angleCos;
677*35238bceSAndroid Build Coastguard Worker float angleSin;
678*35238bceSAndroid Build Coastguard Worker
679*35238bceSAndroid Build Coastguard Worker // \note First and second iteration get exact 0 (and 90, 180, 270) and 45 (and 135, 225, 315) angle quads, as they are kind of a special case.
680*35238bceSAndroid Build Coastguard Worker
681*35238bceSAndroid Build Coastguard Worker if (m_currentIteration == 0)
682*35238bceSAndroid Build Coastguard Worker {
683*35238bceSAndroid Build Coastguard Worker angleCos = 1.0f;
684*35238bceSAndroid Build Coastguard Worker angleSin = 0.0f;
685*35238bceSAndroid Build Coastguard Worker }
686*35238bceSAndroid Build Coastguard Worker else if (m_currentIteration == 1)
687*35238bceSAndroid Build Coastguard Worker {
688*35238bceSAndroid Build Coastguard Worker angleCos = SQRT_HALF;
689*35238bceSAndroid Build Coastguard Worker angleSin = SQRT_HALF;
690*35238bceSAndroid Build Coastguard Worker }
691*35238bceSAndroid Build Coastguard Worker else
692*35238bceSAndroid Build Coastguard Worker {
693*35238bceSAndroid Build Coastguard Worker float angle = 0.5f * DE_PI * (float)(m_currentIteration - 1) / (float)(m_numIterations - 1);
694*35238bceSAndroid Build Coastguard Worker angleCos = deFloatCos(angle);
695*35238bceSAndroid Build Coastguard Worker angleSin = deFloatSin(angle);
696*35238bceSAndroid Build Coastguard Worker }
697*35238bceSAndroid Build Coastguard Worker
698*35238bceSAndroid Build Coastguard Worker Vec2 corners[4] = {
699*35238bceSAndroid Build Coastguard Worker 0.5f * quadDiagLen * Vec2(angleCos, angleSin), 0.5f * quadDiagLen * Vec2(-angleSin, angleCos),
700*35238bceSAndroid Build Coastguard Worker 0.5f * quadDiagLen * Vec2(-angleCos, -angleSin), 0.5f * quadDiagLen * Vec2(angleSin, -angleCos)};
701*35238bceSAndroid Build Coastguard Worker
702*35238bceSAndroid Build Coastguard Worker unicoloredRegions.reserve(8);
703*35238bceSAndroid Build Coastguard Worker
704*35238bceSAndroid Build Coastguard Worker // Draw 8 quads.
705*35238bceSAndroid Build Coastguard Worker // First four are rotated at angles angle+0, angle+90, angle+180 and angle+270.
706*35238bceSAndroid Build Coastguard Worker // Last four are rotated the same angles as the first four, but the ordering of the last triangle's vertices is reversed.
707*35238bceSAndroid Build Coastguard Worker
708*35238bceSAndroid Build Coastguard Worker for (int quadNdx = 0; quadNdx < 8; quadNdx++)
709*35238bceSAndroid Build Coastguard Worker {
710*35238bceSAndroid Build Coastguard Worker Vec2 center = (2.0f - quadDiagLen) * Vec2((float)(quadNdx % 3), (float)(quadNdx / 3)) / 2.0f -
711*35238bceSAndroid Build Coastguard Worker 0.5f * (2.0f - quadDiagLen);
712*35238bceSAndroid Build Coastguard Worker
713*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadNdx) % 4] + center, corners[(1 + quadNdx) % 4] + center,
714*35238bceSAndroid Build Coastguard Worker corners[(2 + quadNdx) % 4] + center, Vec4(0.5f, 0.5f, 0.5f, 1.0f));
715*35238bceSAndroid Build Coastguard Worker
716*35238bceSAndroid Build Coastguard Worker if (quadNdx >= 4)
717*35238bceSAndroid Build Coastguard Worker {
718*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(3 + quadNdx) % 4] + center, corners[(2 + quadNdx) % 4] + center,
719*35238bceSAndroid Build Coastguard Worker corners[(0 + quadNdx) % 4] + center, Vec4(0.5f, 0.5f, 0.5f, 1.0f));
720*35238bceSAndroid Build Coastguard Worker }
721*35238bceSAndroid Build Coastguard Worker else
722*35238bceSAndroid Build Coastguard Worker {
723*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadNdx) % 4] + center, corners[(2 + quadNdx) % 4] + center,
724*35238bceSAndroid Build Coastguard Worker corners[(3 + quadNdx) % 4] + center, Vec4(0.5f, 0.5f, 0.5f, 1.0f));
725*35238bceSAndroid Build Coastguard Worker }
726*35238bceSAndroid Build Coastguard Worker
727*35238bceSAndroid Build Coastguard Worker // The size of the "interior" of a quad is assumed to be approximately unicolorRegionScale*<actual size of quad>.
728*35238bceSAndroid Build Coastguard Worker // By "interior" we here mean the region of non-boundary pixels of the rendered quad for which we can safely assume
729*35238bceSAndroid Build Coastguard Worker // that it has all coverage bits set to 1, for every pixel.
730*35238bceSAndroid Build Coastguard Worker float unicolorRegionScale = 1.0f - 6.0f * 2.0f / (float)m_viewportSize / quadDiagLen;
731*35238bceSAndroid Build Coastguard Worker unicoloredRegions.push_back(
732*35238bceSAndroid Build Coastguard Worker QuadCorners((center + corners[0] * unicolorRegionScale), (center + corners[1] * unicolorRegionScale),
733*35238bceSAndroid Build Coastguard Worker (center + corners[2] * unicolorRegionScale), (center + corners[3] * unicolorRegionScale)));
734*35238bceSAndroid Build Coastguard Worker }
735*35238bceSAndroid Build Coastguard Worker }
736*35238bceSAndroid Build Coastguard Worker else if (m_caseType == CASETYPE_BIGGER_THAN_VIEWPORT_QUAD)
737*35238bceSAndroid Build Coastguard Worker {
738*35238bceSAndroid Build Coastguard Worker // Draw a bigger-than-viewport quad, rotated at an angle depending on m_currentIteration.
739*35238bceSAndroid Build Coastguard Worker
740*35238bceSAndroid Build Coastguard Worker int quadBaseAngleNdx = m_currentIteration / 8;
741*35238bceSAndroid Build Coastguard Worker int quadSubAngleNdx = m_currentIteration % 8;
742*35238bceSAndroid Build Coastguard Worker float angleCos;
743*35238bceSAndroid Build Coastguard Worker float angleSin;
744*35238bceSAndroid Build Coastguard Worker
745*35238bceSAndroid Build Coastguard Worker if (quadBaseAngleNdx == 0)
746*35238bceSAndroid Build Coastguard Worker {
747*35238bceSAndroid Build Coastguard Worker angleCos = 1.0f;
748*35238bceSAndroid Build Coastguard Worker angleSin = 0.0f;
749*35238bceSAndroid Build Coastguard Worker }
750*35238bceSAndroid Build Coastguard Worker else if (quadBaseAngleNdx == 1)
751*35238bceSAndroid Build Coastguard Worker {
752*35238bceSAndroid Build Coastguard Worker angleCos = SQRT_HALF;
753*35238bceSAndroid Build Coastguard Worker angleSin = SQRT_HALF;
754*35238bceSAndroid Build Coastguard Worker }
755*35238bceSAndroid Build Coastguard Worker else
756*35238bceSAndroid Build Coastguard Worker {
757*35238bceSAndroid Build Coastguard Worker float angle = 0.5f * DE_PI * (float)(m_currentIteration - 1) / (float)(m_numIterations - 1);
758*35238bceSAndroid Build Coastguard Worker angleCos = deFloatCos(angle);
759*35238bceSAndroid Build Coastguard Worker angleSin = deFloatSin(angle);
760*35238bceSAndroid Build Coastguard Worker }
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker float quadDiagLen = 2.5f / de::max(angleCos, angleSin);
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker Vec2 corners[4] = {
765*35238bceSAndroid Build Coastguard Worker 0.5f * quadDiagLen * Vec2(angleCos, angleSin), 0.5f * quadDiagLen * Vec2(-angleSin, angleCos),
766*35238bceSAndroid Build Coastguard Worker 0.5f * quadDiagLen * Vec2(-angleCos, -angleSin), 0.5f * quadDiagLen * Vec2(angleSin, -angleCos)};
767*35238bceSAndroid Build Coastguard Worker
768*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadSubAngleNdx) % 4], corners[(1 + quadSubAngleNdx) % 4],
769*35238bceSAndroid Build Coastguard Worker corners[(2 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
770*35238bceSAndroid Build Coastguard Worker
771*35238bceSAndroid Build Coastguard Worker if (quadSubAngleNdx >= 4)
772*35238bceSAndroid Build Coastguard Worker {
773*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(3 + quadSubAngleNdx) % 4], corners[(2 + quadSubAngleNdx) % 4],
774*35238bceSAndroid Build Coastguard Worker corners[(0 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
775*35238bceSAndroid Build Coastguard Worker }
776*35238bceSAndroid Build Coastguard Worker else
777*35238bceSAndroid Build Coastguard Worker {
778*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadSubAngleNdx) % 4], corners[(2 + quadSubAngleNdx) % 4],
779*35238bceSAndroid Build Coastguard Worker corners[(3 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
780*35238bceSAndroid Build Coastguard Worker }
781*35238bceSAndroid Build Coastguard Worker
782*35238bceSAndroid Build Coastguard Worker float unicolorRegionScale = 1.0f - 6.0f * 2.0f / (float)m_viewportSize / quadDiagLen;
783*35238bceSAndroid Build Coastguard Worker unicoloredRegions.push_back(QuadCorners((corners[0] * unicolorRegionScale), (corners[1] * unicolorRegionScale),
784*35238bceSAndroid Build Coastguard Worker (corners[2] * unicolorRegionScale),
785*35238bceSAndroid Build Coastguard Worker (corners[3] * unicolorRegionScale)));
786*35238bceSAndroid Build Coastguard Worker }
787*35238bceSAndroid Build Coastguard Worker else if (m_caseType == CASETYPE_FIT_VIEWPORT_QUAD)
788*35238bceSAndroid Build Coastguard Worker {
789*35238bceSAndroid Build Coastguard Worker // Draw an exactly viewport-sized quad, rotated by multiples of 90 degrees angle depending on m_currentIteration.
790*35238bceSAndroid Build Coastguard Worker
791*35238bceSAndroid Build Coastguard Worker int quadSubAngleNdx = m_currentIteration % 8;
792*35238bceSAndroid Build Coastguard Worker
793*35238bceSAndroid Build Coastguard Worker Vec2 corners[4] = {Vec2(1.0f, 1.0f), Vec2(-1.0f, 1.0f), Vec2(-1.0f, -1.0f), Vec2(1.0f, -1.0f)};
794*35238bceSAndroid Build Coastguard Worker
795*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadSubAngleNdx) % 4], corners[(1 + quadSubAngleNdx) % 4],
796*35238bceSAndroid Build Coastguard Worker corners[(2 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
797*35238bceSAndroid Build Coastguard Worker
798*35238bceSAndroid Build Coastguard Worker if (quadSubAngleNdx >= 4)
799*35238bceSAndroid Build Coastguard Worker {
800*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(3 + quadSubAngleNdx) % 4], corners[(2 + quadSubAngleNdx) % 4],
801*35238bceSAndroid Build Coastguard Worker corners[(0 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
802*35238bceSAndroid Build Coastguard Worker }
803*35238bceSAndroid Build Coastguard Worker else
804*35238bceSAndroid Build Coastguard Worker {
805*35238bceSAndroid Build Coastguard Worker renderTriangle(corners[(0 + quadSubAngleNdx) % 4], corners[(2 + quadSubAngleNdx) % 4],
806*35238bceSAndroid Build Coastguard Worker corners[(3 + quadSubAngleNdx) % 4], Vec4(0.5f, 0.5f, 0.5f, 1.0f));
807*35238bceSAndroid Build Coastguard Worker }
808*35238bceSAndroid Build Coastguard Worker
809*35238bceSAndroid Build Coastguard Worker unicoloredRegions.push_back(QuadCorners(corners[0], corners[1], corners[2], corners[3]));
810*35238bceSAndroid Build Coastguard Worker }
811*35238bceSAndroid Build Coastguard Worker else
812*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
813*35238bceSAndroid Build Coastguard Worker
814*35238bceSAndroid Build Coastguard Worker // Read pixels and check unicolored regions.
815*35238bceSAndroid Build Coastguard Worker
816*35238bceSAndroid Build Coastguard Worker readImage(renderedImg);
817*35238bceSAndroid Build Coastguard Worker
818*35238bceSAndroid Build Coastguard Worker tcu::clear(errorImg.getAccess(), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
819*35238bceSAndroid Build Coastguard Worker
820*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImage", "Rendered image", renderedImg, QP_IMAGE_COMPRESSION_MODE_PNG);
821*35238bceSAndroid Build Coastguard Worker
822*35238bceSAndroid Build Coastguard Worker bool errorsDetected = false;
823*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < (int)unicoloredRegions.size(); i++)
824*35238bceSAndroid Build Coastguard Worker {
825*35238bceSAndroid Build Coastguard Worker const QuadCorners ®ion = unicoloredRegions[i];
826*35238bceSAndroid Build Coastguard Worker IVec2 p0Win = ((region.p0 + 1.0f) * 0.5f * (float)(m_viewportSize - 1) + 0.5f).asInt();
827*35238bceSAndroid Build Coastguard Worker IVec2 p1Win = ((region.p1 + 1.0f) * 0.5f * (float)(m_viewportSize - 1) + 0.5f).asInt();
828*35238bceSAndroid Build Coastguard Worker IVec2 p2Win = ((region.p2 + 1.0f) * 0.5f * (float)(m_viewportSize - 1) + 0.5f).asInt();
829*35238bceSAndroid Build Coastguard Worker IVec2 p3Win = ((region.p3 + 1.0f) * 0.5f * (float)(m_viewportSize - 1) + 0.5f).asInt();
830*35238bceSAndroid Build Coastguard Worker bool errorsInCurrentRegion = !isPixelRegionUnicolored(renderedImg, p0Win, p1Win, p2Win, p3Win);
831*35238bceSAndroid Build Coastguard Worker
832*35238bceSAndroid Build Coastguard Worker if (errorsInCurrentRegion)
833*35238bceSAndroid Build Coastguard Worker drawUnicolorTestErrors(renderedImg, errorImg.getAccess(), p0Win, p1Win, p2Win, p3Win);
834*35238bceSAndroid Build Coastguard Worker
835*35238bceSAndroid Build Coastguard Worker errorsDetected = errorsDetected || errorsInCurrentRegion;
836*35238bceSAndroid Build Coastguard Worker }
837*35238bceSAndroid Build Coastguard Worker
838*35238bceSAndroid Build Coastguard Worker m_currentIteration++;
839*35238bceSAndroid Build Coastguard Worker
840*35238bceSAndroid Build Coastguard Worker if (errorsDetected)
841*35238bceSAndroid Build Coastguard Worker {
842*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: Not all quad interiors seem unicolored - common-edge artifacts?"
843*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
844*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Erroneous pixels are drawn red in the following image" << TestLog::EndMessage;
845*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImageWithErrors", "Rendered image with errors marked", renderedImg,
846*35238bceSAndroid Build Coastguard Worker QP_IMAGE_COMPRESSION_MODE_PNG);
847*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("ErrorsOnly", "Image with error pixels only", errorImg, QP_IMAGE_COMPRESSION_MODE_PNG);
848*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
849*35238bceSAndroid Build Coastguard Worker return STOP;
850*35238bceSAndroid Build Coastguard Worker }
851*35238bceSAndroid Build Coastguard Worker else if (m_currentIteration < m_numIterations)
852*35238bceSAndroid Build Coastguard Worker {
853*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Quads seem OK - moving on to next pattern" << TestLog::EndMessage;
854*35238bceSAndroid Build Coastguard Worker return CONTINUE;
855*35238bceSAndroid Build Coastguard Worker }
856*35238bceSAndroid Build Coastguard Worker else
857*35238bceSAndroid Build Coastguard Worker {
858*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Success: All quad interiors seem unicolored (no common-edge artifacts)"
859*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
860*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed");
861*35238bceSAndroid Build Coastguard Worker return STOP;
862*35238bceSAndroid Build Coastguard Worker }
863*35238bceSAndroid Build Coastguard Worker }
864*35238bceSAndroid Build Coastguard Worker
865*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
866*35238bceSAndroid Build Coastguard Worker * \brief Test that depth values are per-sample.
867*35238bceSAndroid Build Coastguard Worker *
868*35238bceSAndroid Build Coastguard Worker * Draws intersecting, differently-colored polygons and checks that there
869*35238bceSAndroid Build Coastguard Worker * are at least GL_SAMPLES+1 distinct colors present, due to some of the
870*35238bceSAndroid Build Coastguard Worker * samples at the intersection line belonging to one and some to another
871*35238bceSAndroid Build Coastguard Worker * polygon.
872*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
873*35238bceSAndroid Build Coastguard Worker class SampleDepthCase : public NumSamplesCase
874*35238bceSAndroid Build Coastguard Worker {
875*35238bceSAndroid Build Coastguard Worker public:
876*35238bceSAndroid Build Coastguard Worker SampleDepthCase(Context &context, const char *name, const char *description);
~SampleDepthCase(void)877*35238bceSAndroid Build Coastguard Worker ~SampleDepthCase(void)
878*35238bceSAndroid Build Coastguard Worker {
879*35238bceSAndroid Build Coastguard Worker }
880*35238bceSAndroid Build Coastguard Worker
881*35238bceSAndroid Build Coastguard Worker void init(void);
882*35238bceSAndroid Build Coastguard Worker
883*35238bceSAndroid Build Coastguard Worker protected:
884*35238bceSAndroid Build Coastguard Worker void renderPattern(void) const;
885*35238bceSAndroid Build Coastguard Worker };
886*35238bceSAndroid Build Coastguard Worker
SampleDepthCase(Context & context,const char * name,const char * description)887*35238bceSAndroid Build Coastguard Worker SampleDepthCase::SampleDepthCase(Context &context, const char *name, const char *description)
888*35238bceSAndroid Build Coastguard Worker : NumSamplesCase(context, name, description)
889*35238bceSAndroid Build Coastguard Worker {
890*35238bceSAndroid Build Coastguard Worker }
891*35238bceSAndroid Build Coastguard Worker
init(void)892*35238bceSAndroid Build Coastguard Worker void SampleDepthCase::init(void)
893*35238bceSAndroid Build Coastguard Worker {
894*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
895*35238bceSAndroid Build Coastguard Worker
896*35238bceSAndroid Build Coastguard Worker if (m_context.getRenderTarget().getDepthBits() == 0)
897*35238bceSAndroid Build Coastguard Worker TCU_THROW(NotSupportedError, "Test requires depth buffer");
898*35238bceSAndroid Build Coastguard Worker
899*35238bceSAndroid Build Coastguard Worker MultisampleCase::init();
900*35238bceSAndroid Build Coastguard Worker
901*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_DEPTH_TEST));
902*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glDepthFunc(GL_LESS));
903*35238bceSAndroid Build Coastguard Worker
904*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Depth test enabled, depth func is GL_LESS" << TestLog::EndMessage;
905*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Drawing several bigger-than-viewport black or white polygons intersecting each other"
906*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
907*35238bceSAndroid Build Coastguard Worker }
908*35238bceSAndroid Build Coastguard Worker
renderPattern(void) const909*35238bceSAndroid Build Coastguard Worker void SampleDepthCase::renderPattern(void) const
910*35238bceSAndroid Build Coastguard Worker {
911*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
912*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearDepthf(1.0f));
913*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
914*35238bceSAndroid Build Coastguard Worker
915*35238bceSAndroid Build Coastguard Worker {
916*35238bceSAndroid Build Coastguard Worker const int numPolygons = 50;
917*35238bceSAndroid Build Coastguard Worker
918*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numPolygons; i++)
919*35238bceSAndroid Build Coastguard Worker {
920*35238bceSAndroid Build Coastguard Worker Vec4 color = i % 2 == 0 ? Vec4(1.0f, 1.0f, 1.0f, 1.0f) : Vec4(0.0f, 0.0f, 0.0f, 1.0f);
921*35238bceSAndroid Build Coastguard Worker float angle = 2.0f * DE_PI * (float)i / (float)numPolygons + 0.001f * (float)m_currentIteration;
922*35238bceSAndroid Build Coastguard Worker Vec3 pt0(3.0f * deFloatCos(angle + 2.0f * DE_PI * 0.0f / 3.0f),
923*35238bceSAndroid Build Coastguard Worker 3.0f * deFloatSin(angle + 2.0f * DE_PI * 0.0f / 3.0f), 1.0f);
924*35238bceSAndroid Build Coastguard Worker Vec3 pt1(3.0f * deFloatCos(angle + 2.0f * DE_PI * 1.0f / 3.0f),
925*35238bceSAndroid Build Coastguard Worker 3.0f * deFloatSin(angle + 2.0f * DE_PI * 1.0f / 3.0f), 0.0f);
926*35238bceSAndroid Build Coastguard Worker Vec3 pt2(3.0f * deFloatCos(angle + 2.0f * DE_PI * 2.0f / 3.0f),
927*35238bceSAndroid Build Coastguard Worker 3.0f * deFloatSin(angle + 2.0f * DE_PI * 2.0f / 3.0f), 0.0f);
928*35238bceSAndroid Build Coastguard Worker
929*35238bceSAndroid Build Coastguard Worker renderTriangle(pt0, pt1, pt2, color);
930*35238bceSAndroid Build Coastguard Worker }
931*35238bceSAndroid Build Coastguard Worker }
932*35238bceSAndroid Build Coastguard Worker }
933*35238bceSAndroid Build Coastguard Worker
934*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
935*35238bceSAndroid Build Coastguard Worker * \brief Test that stencil buffer values are per-sample.
936*35238bceSAndroid Build Coastguard Worker *
937*35238bceSAndroid Build Coastguard Worker * Draws a unicolored pattern and marks drawn samples in stencil buffer;
938*35238bceSAndroid Build Coastguard Worker * then clears and draws a viewport-size quad with that color and with
939*35238bceSAndroid Build Coastguard Worker * proper stencil test such that the resulting image should be exactly the
940*35238bceSAndroid Build Coastguard Worker * same as after the pattern was first drawn.
941*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
942*35238bceSAndroid Build Coastguard Worker class SampleStencilCase : public MultisampleCase
943*35238bceSAndroid Build Coastguard Worker {
944*35238bceSAndroid Build Coastguard Worker public:
945*35238bceSAndroid Build Coastguard Worker SampleStencilCase(Context &context, const char *name, const char *description);
~SampleStencilCase(void)946*35238bceSAndroid Build Coastguard Worker ~SampleStencilCase(void)
947*35238bceSAndroid Build Coastguard Worker {
948*35238bceSAndroid Build Coastguard Worker }
949*35238bceSAndroid Build Coastguard Worker
950*35238bceSAndroid Build Coastguard Worker void init(void);
951*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
952*35238bceSAndroid Build Coastguard Worker
953*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const954*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
955*35238bceSAndroid Build Coastguard Worker {
956*35238bceSAndroid Build Coastguard Worker return 256;
957*35238bceSAndroid Build Coastguard Worker }
958*35238bceSAndroid Build Coastguard Worker };
959*35238bceSAndroid Build Coastguard Worker
SampleStencilCase(Context & context,const char * name,const char * description)960*35238bceSAndroid Build Coastguard Worker SampleStencilCase::SampleStencilCase(Context &context, const char *name, const char *description)
961*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
962*35238bceSAndroid Build Coastguard Worker {
963*35238bceSAndroid Build Coastguard Worker }
964*35238bceSAndroid Build Coastguard Worker
init(void)965*35238bceSAndroid Build Coastguard Worker void SampleStencilCase::init(void)
966*35238bceSAndroid Build Coastguard Worker {
967*35238bceSAndroid Build Coastguard Worker if (m_context.getRenderTarget().getStencilBits() == 0)
968*35238bceSAndroid Build Coastguard Worker TCU_THROW(NotSupportedError, "Test requires stencil buffer");
969*35238bceSAndroid Build Coastguard Worker
970*35238bceSAndroid Build Coastguard Worker MultisampleCase::init();
971*35238bceSAndroid Build Coastguard Worker }
972*35238bceSAndroid Build Coastguard Worker
iterate(void)973*35238bceSAndroid Build Coastguard Worker SampleStencilCase::IterateResult SampleStencilCase::iterate(void)
974*35238bceSAndroid Build Coastguard Worker {
975*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
976*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImgFirst(m_viewportSize, m_viewportSize);
977*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImgSecond(m_viewportSize, m_viewportSize);
978*35238bceSAndroid Build Coastguard Worker
979*35238bceSAndroid Build Coastguard Worker randomizeViewport();
980*35238bceSAndroid Build Coastguard Worker
981*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
982*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearStencil(0));
983*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
984*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_STENCIL_TEST));
985*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glStencilFunc(GL_ALWAYS, 1, 1));
986*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE));
987*35238bceSAndroid Build Coastguard Worker
988*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
989*35238bceSAndroid Build Coastguard Worker << "Drawing a pattern with glStencilFunc(GL_ALWAYS, 1, 1) and glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE)"
990*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
991*35238bceSAndroid Build Coastguard Worker
992*35238bceSAndroid Build Coastguard Worker {
993*35238bceSAndroid Build Coastguard Worker const int numTriangles = 25;
994*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numTriangles; i++)
995*35238bceSAndroid Build Coastguard Worker {
996*35238bceSAndroid Build Coastguard Worker float angle0 = 2.0f * DE_PI * (float)i / (float)numTriangles;
997*35238bceSAndroid Build Coastguard Worker float angle1 = 2.0f * DE_PI * ((float)i + 0.5f) / (float)numTriangles;
998*35238bceSAndroid Build Coastguard Worker
999*35238bceSAndroid Build Coastguard Worker renderTriangle(Vec2(0.0f, 0.0f), Vec2(deFloatCos(angle0) * 0.95f, deFloatSin(angle0) * 0.95f),
1000*35238bceSAndroid Build Coastguard Worker Vec2(deFloatCos(angle1) * 0.95f, deFloatSin(angle1) * 0.95f), Vec4(1.0f));
1001*35238bceSAndroid Build Coastguard Worker }
1002*35238bceSAndroid Build Coastguard Worker }
1003*35238bceSAndroid Build Coastguard Worker
1004*35238bceSAndroid Build Coastguard Worker readImage(renderedImgFirst);
1005*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImgFirst", "First image rendered", renderedImgFirst, QP_IMAGE_COMPRESSION_MODE_PNG);
1006*35238bceSAndroid Build Coastguard Worker
1007*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Clearing color buffer to black" << TestLog::EndMessage;
1008*35238bceSAndroid Build Coastguard Worker
1009*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
1010*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glStencilFunc(GL_EQUAL, 1, 1));
1011*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP));
1012*35238bceSAndroid Build Coastguard Worker
1013*35238bceSAndroid Build Coastguard Worker {
1014*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Checking that color buffer was actually cleared to black" << TestLog::EndMessage;
1015*35238bceSAndroid Build Coastguard Worker
1016*35238bceSAndroid Build Coastguard Worker tcu::Surface clearedImg(m_viewportSize, m_viewportSize);
1017*35238bceSAndroid Build Coastguard Worker readImage(clearedImg);
1018*35238bceSAndroid Build Coastguard Worker
1019*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < clearedImg.getHeight(); y++)
1020*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < clearedImg.getWidth(); x++)
1021*35238bceSAndroid Build Coastguard Worker {
1022*35238bceSAndroid Build Coastguard Worker const tcu::RGBA &clr = clearedImg.getPixel(x, y);
1023*35238bceSAndroid Build Coastguard Worker if (clr != tcu::RGBA::black())
1024*35238bceSAndroid Build Coastguard Worker {
1025*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: first non-black pixel, color " << clr
1026*35238bceSAndroid Build Coastguard Worker << ", detected at coordinates (" << x << ", " << y << ")" << TestLog::EndMessage;
1027*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("ClearedImg", "Image after clearing, erroneously non-black", clearedImg);
1028*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
1029*35238bceSAndroid Build Coastguard Worker return STOP;
1030*35238bceSAndroid Build Coastguard Worker }
1031*35238bceSAndroid Build Coastguard Worker }
1032*35238bceSAndroid Build Coastguard Worker }
1033*35238bceSAndroid Build Coastguard Worker
1034*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1035*35238bceSAndroid Build Coastguard Worker << "Drawing a viewport-sized quad with glStencilFunc(GL_EQUAL, 1, 1) and glStencilOp(GL_KEEP, GL_KEEP, "
1036*35238bceSAndroid Build Coastguard Worker "GL_KEEP) - should result in same image as the first"
1037*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1038*35238bceSAndroid Build Coastguard Worker
1039*35238bceSAndroid Build Coastguard Worker renderQuad(Vec2(-1.0f, -1.0f), Vec2(1.0f, -1.0f), Vec2(-1.0f, 1.0f), Vec2(1.0f, 1.0f), Vec4(1.0f));
1040*35238bceSAndroid Build Coastguard Worker
1041*35238bceSAndroid Build Coastguard Worker readImage(renderedImgSecond);
1042*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImgSecond", "Second image rendered", renderedImgSecond,
1043*35238bceSAndroid Build Coastguard Worker QP_IMAGE_COMPRESSION_MODE_PNG);
1044*35238bceSAndroid Build Coastguard Worker
1045*35238bceSAndroid Build Coastguard Worker bool passed = tcu::pixelThresholdCompare(log, "ImageCompare", "Image comparison", renderedImgFirst,
1046*35238bceSAndroid Build Coastguard Worker renderedImgSecond, tcu::RGBA(0), tcu::COMPARE_LOG_ON_ERROR);
1047*35238bceSAndroid Build Coastguard Worker
1048*35238bceSAndroid Build Coastguard Worker if (passed)
1049*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Success: The two images rendered are identical" << TestLog::EndMessage;
1050*35238bceSAndroid Build Coastguard Worker
1051*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(passed ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1052*35238bceSAndroid Build Coastguard Worker passed ? "Passed" : "Failed");
1053*35238bceSAndroid Build Coastguard Worker
1054*35238bceSAndroid Build Coastguard Worker return STOP;
1055*35238bceSAndroid Build Coastguard Worker }
1056*35238bceSAndroid Build Coastguard Worker
1057*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
1058*35238bceSAndroid Build Coastguard Worker * \brief Tests coverage mask generation proportionality property.
1059*35238bceSAndroid Build Coastguard Worker *
1060*35238bceSAndroid Build Coastguard Worker * Tests that the number of coverage bits in a coverage mask created by
1061*35238bceSAndroid Build Coastguard Worker * GL_SAMPLE_ALPHA_TO_COVERAGE or GL_SAMPLE_COVERAGE is, on average,
1062*35238bceSAndroid Build Coastguard Worker * proportional to the alpha or coverage value, respectively. Draws
1063*35238bceSAndroid Build Coastguard Worker * multiple frames, each time increasing the alpha or coverage value used,
1064*35238bceSAndroid Build Coastguard Worker * and checks that the average color is changing appropriately.
1065*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
1066*35238bceSAndroid Build Coastguard Worker class MaskProportionalityCase : public MultisampleCase
1067*35238bceSAndroid Build Coastguard Worker {
1068*35238bceSAndroid Build Coastguard Worker public:
1069*35238bceSAndroid Build Coastguard Worker enum CaseType
1070*35238bceSAndroid Build Coastguard Worker {
1071*35238bceSAndroid Build Coastguard Worker CASETYPE_ALPHA_TO_COVERAGE = 0,
1072*35238bceSAndroid Build Coastguard Worker CASETYPE_SAMPLE_COVERAGE,
1073*35238bceSAndroid Build Coastguard Worker CASETYPE_SAMPLE_COVERAGE_INVERTED,
1074*35238bceSAndroid Build Coastguard Worker
1075*35238bceSAndroid Build Coastguard Worker CASETYPE_LAST
1076*35238bceSAndroid Build Coastguard Worker };
1077*35238bceSAndroid Build Coastguard Worker
1078*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase(Context &context, const char *name, const char *description, CaseType type);
~MaskProportionalityCase(void)1079*35238bceSAndroid Build Coastguard Worker ~MaskProportionalityCase(void)
1080*35238bceSAndroid Build Coastguard Worker {
1081*35238bceSAndroid Build Coastguard Worker }
1082*35238bceSAndroid Build Coastguard Worker
1083*35238bceSAndroid Build Coastguard Worker void init(void);
1084*35238bceSAndroid Build Coastguard Worker
1085*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
1086*35238bceSAndroid Build Coastguard Worker
1087*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const1088*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
1089*35238bceSAndroid Build Coastguard Worker {
1090*35238bceSAndroid Build Coastguard Worker return 32;
1091*35238bceSAndroid Build Coastguard Worker }
1092*35238bceSAndroid Build Coastguard Worker
1093*35238bceSAndroid Build Coastguard Worker private:
1094*35238bceSAndroid Build Coastguard Worker const CaseType m_type;
1095*35238bceSAndroid Build Coastguard Worker
1096*35238bceSAndroid Build Coastguard Worker int m_numIterations;
1097*35238bceSAndroid Build Coastguard Worker int m_currentIteration;
1098*35238bceSAndroid Build Coastguard Worker
1099*35238bceSAndroid Build Coastguard Worker int32_t m_previousIterationColorSum;
1100*35238bceSAndroid Build Coastguard Worker };
1101*35238bceSAndroid Build Coastguard Worker
MaskProportionalityCase(Context & context,const char * name,const char * description,CaseType type)1102*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase::MaskProportionalityCase(Context &context, const char *name, const char *description,
1103*35238bceSAndroid Build Coastguard Worker CaseType type)
1104*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
1105*35238bceSAndroid Build Coastguard Worker , m_type(type)
1106*35238bceSAndroid Build Coastguard Worker , m_numIterations(0)
1107*35238bceSAndroid Build Coastguard Worker , m_currentIteration(0)
1108*35238bceSAndroid Build Coastguard Worker , m_previousIterationColorSum(-1)
1109*35238bceSAndroid Build Coastguard Worker {
1110*35238bceSAndroid Build Coastguard Worker }
1111*35238bceSAndroid Build Coastguard Worker
init(void)1112*35238bceSAndroid Build Coastguard Worker void MaskProportionalityCase::init(void)
1113*35238bceSAndroid Build Coastguard Worker {
1114*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1115*35238bceSAndroid Build Coastguard Worker
1116*35238bceSAndroid Build Coastguard Worker MultisampleCase::init();
1117*35238bceSAndroid Build Coastguard Worker
1118*35238bceSAndroid Build Coastguard Worker if (m_type == CASETYPE_ALPHA_TO_COVERAGE)
1119*35238bceSAndroid Build Coastguard Worker {
1120*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE));
1121*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "GL_SAMPLE_ALPHA_TO_COVERAGE is enabled" << TestLog::EndMessage;
1122*35238bceSAndroid Build Coastguard Worker }
1123*35238bceSAndroid Build Coastguard Worker else
1124*35238bceSAndroid Build Coastguard Worker {
1125*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_type == CASETYPE_SAMPLE_COVERAGE || m_type == CASETYPE_SAMPLE_COVERAGE_INVERTED);
1126*35238bceSAndroid Build Coastguard Worker
1127*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_SAMPLE_COVERAGE));
1128*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "GL_SAMPLE_COVERAGE is enabled" << TestLog::EndMessage;
1129*35238bceSAndroid Build Coastguard Worker }
1130*35238bceSAndroid Build Coastguard Worker
1131*35238bceSAndroid Build Coastguard Worker m_numIterations = de::max(2, getIterationCount(m_testCtx, m_numSamples * 5));
1132*35238bceSAndroid Build Coastguard Worker
1133*35238bceSAndroid Build Coastguard Worker randomizeViewport(); // \note Using the same viewport for every iteration since coverage mask may depend on window-relative pixel coordinate.
1134*35238bceSAndroid Build Coastguard Worker }
1135*35238bceSAndroid Build Coastguard Worker
iterate(void)1136*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase::IterateResult MaskProportionalityCase::iterate(void)
1137*35238bceSAndroid Build Coastguard Worker {
1138*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1139*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImg(m_viewportSize, m_viewportSize);
1140*35238bceSAndroid Build Coastguard Worker int32_t numPixels = (int32_t)renderedImg.getWidth() * (int32_t)renderedImg.getHeight();
1141*35238bceSAndroid Build Coastguard Worker
1142*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Clearing color to black" << TestLog::EndMessage;
1143*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE));
1144*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
1145*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
1146*35238bceSAndroid Build Coastguard Worker
1147*35238bceSAndroid Build Coastguard Worker if (m_type == CASETYPE_ALPHA_TO_COVERAGE)
1148*35238bceSAndroid Build Coastguard Worker {
1149*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE));
1150*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Using color mask TRUE, TRUE, TRUE, FALSE" << TestLog::EndMessage;
1151*35238bceSAndroid Build Coastguard Worker }
1152*35238bceSAndroid Build Coastguard Worker
1153*35238bceSAndroid Build Coastguard Worker // Draw quad.
1154*35238bceSAndroid Build Coastguard Worker
1155*35238bceSAndroid Build Coastguard Worker {
1156*35238bceSAndroid Build Coastguard Worker const Vec2 pt0(-1.0f, -1.0f);
1157*35238bceSAndroid Build Coastguard Worker const Vec2 pt1(1.0f, -1.0f);
1158*35238bceSAndroid Build Coastguard Worker const Vec2 pt2(-1.0f, 1.0f);
1159*35238bceSAndroid Build Coastguard Worker const Vec2 pt3(1.0f, 1.0f);
1160*35238bceSAndroid Build Coastguard Worker Vec4 quadColor(1.0f, 0.0f, 0.0f, 1.0f);
1161*35238bceSAndroid Build Coastguard Worker float alphaOrCoverageValue = (float)m_currentIteration / (float)(m_numIterations - 1);
1162*35238bceSAndroid Build Coastguard Worker
1163*35238bceSAndroid Build Coastguard Worker if (m_type == CASETYPE_ALPHA_TO_COVERAGE)
1164*35238bceSAndroid Build Coastguard Worker {
1165*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1166*35238bceSAndroid Build Coastguard Worker << "Drawing a red quad using alpha value " + de::floatToString(alphaOrCoverageValue, 2)
1167*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1168*35238bceSAndroid Build Coastguard Worker quadColor.w() = alphaOrCoverageValue;
1169*35238bceSAndroid Build Coastguard Worker }
1170*35238bceSAndroid Build Coastguard Worker else
1171*35238bceSAndroid Build Coastguard Worker {
1172*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_type == CASETYPE_SAMPLE_COVERAGE || m_type == CASETYPE_SAMPLE_COVERAGE_INVERTED);
1173*35238bceSAndroid Build Coastguard Worker
1174*35238bceSAndroid Build Coastguard Worker bool isInverted = m_type == CASETYPE_SAMPLE_COVERAGE_INVERTED;
1175*35238bceSAndroid Build Coastguard Worker float coverageValue = isInverted ? 1.0f - alphaOrCoverageValue : alphaOrCoverageValue;
1176*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1177*35238bceSAndroid Build Coastguard Worker << "Drawing a red quad using sample coverage value " + de::floatToString(coverageValue, 2)
1178*35238bceSAndroid Build Coastguard Worker << (isInverted ? " (inverted)" : "") << TestLog::EndMessage;
1179*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glSampleCoverage(coverageValue, isInverted ? GL_TRUE : GL_FALSE));
1180*35238bceSAndroid Build Coastguard Worker }
1181*35238bceSAndroid Build Coastguard Worker
1182*35238bceSAndroid Build Coastguard Worker renderQuad(pt0, pt1, pt2, pt3, quadColor);
1183*35238bceSAndroid Build Coastguard Worker }
1184*35238bceSAndroid Build Coastguard Worker
1185*35238bceSAndroid Build Coastguard Worker // Read ang log image.
1186*35238bceSAndroid Build Coastguard Worker
1187*35238bceSAndroid Build Coastguard Worker readImage(renderedImg);
1188*35238bceSAndroid Build Coastguard Worker
1189*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImage", "Rendered image", renderedImg, QP_IMAGE_COMPRESSION_MODE_PNG);
1190*35238bceSAndroid Build Coastguard Worker
1191*35238bceSAndroid Build Coastguard Worker // Compute average red component in rendered image.
1192*35238bceSAndroid Build Coastguard Worker
1193*35238bceSAndroid Build Coastguard Worker int32_t sumRed = 0;
1194*35238bceSAndroid Build Coastguard Worker
1195*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < renderedImg.getHeight(); y++)
1196*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < renderedImg.getWidth(); x++)
1197*35238bceSAndroid Build Coastguard Worker sumRed += renderedImg.getPixel(x, y).getRed();
1198*35238bceSAndroid Build Coastguard Worker
1199*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1200*35238bceSAndroid Build Coastguard Worker << "Average red color component: " << de::floatToString((float)sumRed / 255.0f / (float)numPixels, 2)
1201*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1202*35238bceSAndroid Build Coastguard Worker
1203*35238bceSAndroid Build Coastguard Worker // Check if average color has decreased from previous frame's color.
1204*35238bceSAndroid Build Coastguard Worker
1205*35238bceSAndroid Build Coastguard Worker if (sumRed < m_previousIterationColorSum)
1206*35238bceSAndroid Build Coastguard Worker {
1207*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: Current average red color component is lower than previous"
1208*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1209*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
1210*35238bceSAndroid Build Coastguard Worker return STOP;
1211*35238bceSAndroid Build Coastguard Worker }
1212*35238bceSAndroid Build Coastguard Worker
1213*35238bceSAndroid Build Coastguard Worker // Check if coverage mask is not all-zeros if alpha or coverage value is 0 (or 1, if inverted).
1214*35238bceSAndroid Build Coastguard Worker
1215*35238bceSAndroid Build Coastguard Worker if (m_currentIteration == 0 && sumRed != 0)
1216*35238bceSAndroid Build Coastguard Worker {
1217*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: Image should be completely black" << TestLog::EndMessage;
1218*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
1219*35238bceSAndroid Build Coastguard Worker return STOP;
1220*35238bceSAndroid Build Coastguard Worker }
1221*35238bceSAndroid Build Coastguard Worker
1222*35238bceSAndroid Build Coastguard Worker if (m_currentIteration == m_numIterations - 1 && sumRed != 0xff * numPixels)
1223*35238bceSAndroid Build Coastguard Worker {
1224*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Failure: Image should be completely red" << TestLog::EndMessage;
1225*35238bceSAndroid Build Coastguard Worker
1226*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
1227*35238bceSAndroid Build Coastguard Worker return STOP;
1228*35238bceSAndroid Build Coastguard Worker }
1229*35238bceSAndroid Build Coastguard Worker
1230*35238bceSAndroid Build Coastguard Worker m_previousIterationColorSum = sumRed;
1231*35238bceSAndroid Build Coastguard Worker
1232*35238bceSAndroid Build Coastguard Worker m_currentIteration++;
1233*35238bceSAndroid Build Coastguard Worker
1234*35238bceSAndroid Build Coastguard Worker if (m_currentIteration >= m_numIterations)
1235*35238bceSAndroid Build Coastguard Worker {
1236*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1237*35238bceSAndroid Build Coastguard Worker << "Success: Number of coverage mask bits set appears to be, on average, proportional to "
1238*35238bceSAndroid Build Coastguard Worker << (m_type == CASETYPE_ALPHA_TO_COVERAGE ? "alpha" :
1239*35238bceSAndroid Build Coastguard Worker m_type == CASETYPE_SAMPLE_COVERAGE ? "sample coverage value" :
1240*35238bceSAndroid Build Coastguard Worker "inverted sample coverage value")
1241*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1242*35238bceSAndroid Build Coastguard Worker
1243*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed");
1244*35238bceSAndroid Build Coastguard Worker return STOP;
1245*35238bceSAndroid Build Coastguard Worker }
1246*35238bceSAndroid Build Coastguard Worker else
1247*35238bceSAndroid Build Coastguard Worker return CONTINUE;
1248*35238bceSAndroid Build Coastguard Worker }
1249*35238bceSAndroid Build Coastguard Worker
1250*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
1251*35238bceSAndroid Build Coastguard Worker * \brief Tests coverage mask generation constancy property.
1252*35238bceSAndroid Build Coastguard Worker *
1253*35238bceSAndroid Build Coastguard Worker * Tests that the coverage mask created by GL_SAMPLE_ALPHA_TO_COVERAGE or
1254*35238bceSAndroid Build Coastguard Worker * GL_SAMPLE_COVERAGE is constant at given pixel coordinates, with a given
1255*35238bceSAndroid Build Coastguard Worker * alpha component or coverage value, respectively. Draws two quads, with
1256*35238bceSAndroid Build Coastguard Worker * the second one fully overlapping the first one such that at any given
1257*35238bceSAndroid Build Coastguard Worker * pixel, both quads have the same alpha or coverage value. This way, if
1258*35238bceSAndroid Build Coastguard Worker * the constancy property is fulfilled, only the second quad should be
1259*35238bceSAndroid Build Coastguard Worker * visible.
1260*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
1261*35238bceSAndroid Build Coastguard Worker class MaskConstancyCase : public MultisampleCase
1262*35238bceSAndroid Build Coastguard Worker {
1263*35238bceSAndroid Build Coastguard Worker public:
1264*35238bceSAndroid Build Coastguard Worker enum CaseType
1265*35238bceSAndroid Build Coastguard Worker {
1266*35238bceSAndroid Build Coastguard Worker CASETYPE_ALPHA_TO_COVERAGE = 0, //!< Use only alpha-to-coverage.
1267*35238bceSAndroid Build Coastguard Worker CASETYPE_SAMPLE_COVERAGE, //!< Use only sample coverage.
1268*35238bceSAndroid Build Coastguard Worker CASETYPE_SAMPLE_COVERAGE_INVERTED, //!< Use only inverted sample coverage.
1269*35238bceSAndroid Build Coastguard Worker CASETYPE_BOTH, //!< Use both alpha-to-coverage and sample coverage.
1270*35238bceSAndroid Build Coastguard Worker CASETYPE_BOTH_INVERTED, //!< Use both alpha-to-coverage and inverted sample coverage.
1271*35238bceSAndroid Build Coastguard Worker
1272*35238bceSAndroid Build Coastguard Worker CASETYPE_LAST
1273*35238bceSAndroid Build Coastguard Worker };
1274*35238bceSAndroid Build Coastguard Worker
1275*35238bceSAndroid Build Coastguard Worker MaskConstancyCase(Context &context, const char *name, const char *description, CaseType type);
~MaskConstancyCase(void)1276*35238bceSAndroid Build Coastguard Worker ~MaskConstancyCase(void)
1277*35238bceSAndroid Build Coastguard Worker {
1278*35238bceSAndroid Build Coastguard Worker }
1279*35238bceSAndroid Build Coastguard Worker
1280*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
1281*35238bceSAndroid Build Coastguard Worker
1282*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const1283*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
1284*35238bceSAndroid Build Coastguard Worker {
1285*35238bceSAndroid Build Coastguard Worker return 256;
1286*35238bceSAndroid Build Coastguard Worker }
1287*35238bceSAndroid Build Coastguard Worker
1288*35238bceSAndroid Build Coastguard Worker private:
1289*35238bceSAndroid Build Coastguard Worker const bool m_isAlphaToCoverageCase;
1290*35238bceSAndroid Build Coastguard Worker const bool m_isSampleCoverageCase;
1291*35238bceSAndroid Build Coastguard Worker const bool m_isInvertedSampleCoverageCase;
1292*35238bceSAndroid Build Coastguard Worker };
1293*35238bceSAndroid Build Coastguard Worker
MaskConstancyCase(Context & context,const char * name,const char * description,CaseType type)1294*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::MaskConstancyCase(Context &context, const char *name, const char *description, CaseType type)
1295*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
1296*35238bceSAndroid Build Coastguard Worker , m_isAlphaToCoverageCase(type == CASETYPE_ALPHA_TO_COVERAGE || type == CASETYPE_BOTH ||
1297*35238bceSAndroid Build Coastguard Worker type == CASETYPE_BOTH_INVERTED)
1298*35238bceSAndroid Build Coastguard Worker , m_isSampleCoverageCase(type == CASETYPE_SAMPLE_COVERAGE || type == CASETYPE_SAMPLE_COVERAGE_INVERTED ||
1299*35238bceSAndroid Build Coastguard Worker type == CASETYPE_BOTH || type == CASETYPE_BOTH_INVERTED)
1300*35238bceSAndroid Build Coastguard Worker , m_isInvertedSampleCoverageCase(type == CASETYPE_SAMPLE_COVERAGE_INVERTED || type == CASETYPE_BOTH_INVERTED)
1301*35238bceSAndroid Build Coastguard Worker {
1302*35238bceSAndroid Build Coastguard Worker }
1303*35238bceSAndroid Build Coastguard Worker
iterate(void)1304*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::IterateResult MaskConstancyCase::iterate(void)
1305*35238bceSAndroid Build Coastguard Worker {
1306*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1307*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImg(m_viewportSize, m_viewportSize);
1308*35238bceSAndroid Build Coastguard Worker
1309*35238bceSAndroid Build Coastguard Worker randomizeViewport();
1310*35238bceSAndroid Build Coastguard Worker
1311*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Clearing color to black" << TestLog::EndMessage;
1312*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
1313*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
1314*35238bceSAndroid Build Coastguard Worker
1315*35238bceSAndroid Build Coastguard Worker if (m_isAlphaToCoverageCase)
1316*35238bceSAndroid Build Coastguard Worker {
1317*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE));
1318*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE));
1319*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "GL_SAMPLE_ALPHA_TO_COVERAGE is enabled" << TestLog::EndMessage;
1320*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Color mask is TRUE, TRUE, TRUE, FALSE" << TestLog::EndMessage;
1321*35238bceSAndroid Build Coastguard Worker }
1322*35238bceSAndroid Build Coastguard Worker
1323*35238bceSAndroid Build Coastguard Worker if (m_isSampleCoverageCase)
1324*35238bceSAndroid Build Coastguard Worker {
1325*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_SAMPLE_COVERAGE));
1326*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "GL_SAMPLE_COVERAGE is enabled" << TestLog::EndMessage;
1327*35238bceSAndroid Build Coastguard Worker }
1328*35238bceSAndroid Build Coastguard Worker
1329*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Drawing several green quads, each fully overlapped by a red quad with the same "
1330*35238bceSAndroid Build Coastguard Worker << (m_isAlphaToCoverageCase ? "alpha" : "")
1331*35238bceSAndroid Build Coastguard Worker << (m_isAlphaToCoverageCase && m_isSampleCoverageCase ? " and " : "")
1332*35238bceSAndroid Build Coastguard Worker << (m_isInvertedSampleCoverageCase ? "inverted " : "") << (m_isSampleCoverageCase ? "sample coverage" : "")
1333*35238bceSAndroid Build Coastguard Worker << " values" << TestLog::EndMessage;
1334*35238bceSAndroid Build Coastguard Worker
1335*35238bceSAndroid Build Coastguard Worker const int numQuadRowsCols = m_numSamples * 4;
1336*35238bceSAndroid Build Coastguard Worker
1337*35238bceSAndroid Build Coastguard Worker for (int row = 0; row < numQuadRowsCols; row++)
1338*35238bceSAndroid Build Coastguard Worker {
1339*35238bceSAndroid Build Coastguard Worker for (int col = 0; col < numQuadRowsCols; col++)
1340*35238bceSAndroid Build Coastguard Worker {
1341*35238bceSAndroid Build Coastguard Worker float x0 = (float)(col + 0) / (float)numQuadRowsCols * 2.0f - 1.0f;
1342*35238bceSAndroid Build Coastguard Worker float x1 = (float)(col + 1) / (float)numQuadRowsCols * 2.0f - 1.0f;
1343*35238bceSAndroid Build Coastguard Worker float y0 = (float)(row + 0) / (float)numQuadRowsCols * 2.0f - 1.0f;
1344*35238bceSAndroid Build Coastguard Worker float y1 = (float)(row + 1) / (float)numQuadRowsCols * 2.0f - 1.0f;
1345*35238bceSAndroid Build Coastguard Worker const Vec4 baseGreen(0.0f, 1.0f, 0.0f, 0.0f);
1346*35238bceSAndroid Build Coastguard Worker const Vec4 baseRed(1.0f, 0.0f, 0.0f, 0.0f);
1347*35238bceSAndroid Build Coastguard Worker Vec4 alpha0(0.0f, 0.0f, 0.0f, m_isAlphaToCoverageCase ? (float)col / (float)(numQuadRowsCols - 1) : 1.0f);
1348*35238bceSAndroid Build Coastguard Worker Vec4 alpha1(0.0f, 0.0f, 0.0f, m_isAlphaToCoverageCase ? (float)row / (float)(numQuadRowsCols - 1) : 1.0f);
1349*35238bceSAndroid Build Coastguard Worker
1350*35238bceSAndroid Build Coastguard Worker if (m_isSampleCoverageCase)
1351*35238bceSAndroid Build Coastguard Worker {
1352*35238bceSAndroid Build Coastguard Worker float value = (float)(row * numQuadRowsCols + col) / (float)(numQuadRowsCols * numQuadRowsCols - 1);
1353*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glSampleCoverage(m_isInvertedSampleCoverageCase ? 1.0f - value : value,
1354*35238bceSAndroid Build Coastguard Worker m_isInvertedSampleCoverageCase ? GL_TRUE : GL_FALSE));
1355*35238bceSAndroid Build Coastguard Worker }
1356*35238bceSAndroid Build Coastguard Worker
1357*35238bceSAndroid Build Coastguard Worker renderQuad(Vec2(x0, y0), Vec2(x1, y0), Vec2(x0, y1), Vec2(x1, y1), baseGreen + alpha0, baseGreen + alpha1,
1358*35238bceSAndroid Build Coastguard Worker baseGreen + alpha0, baseGreen + alpha1);
1359*35238bceSAndroid Build Coastguard Worker renderQuad(Vec2(x0, y0), Vec2(x1, y0), Vec2(x0, y1), Vec2(x1, y1), baseRed + alpha0, baseRed + alpha1,
1360*35238bceSAndroid Build Coastguard Worker baseRed + alpha0, baseRed + alpha1);
1361*35238bceSAndroid Build Coastguard Worker }
1362*35238bceSAndroid Build Coastguard Worker }
1363*35238bceSAndroid Build Coastguard Worker
1364*35238bceSAndroid Build Coastguard Worker readImage(renderedImg);
1365*35238bceSAndroid Build Coastguard Worker
1366*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImage", "Rendered image", renderedImg, QP_IMAGE_COMPRESSION_MODE_PNG);
1367*35238bceSAndroid Build Coastguard Worker
1368*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < renderedImg.getHeight(); y++)
1369*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < renderedImg.getWidth(); x++)
1370*35238bceSAndroid Build Coastguard Worker {
1371*35238bceSAndroid Build Coastguard Worker if (renderedImg.getPixel(x, y).getGreen() > 0)
1372*35238bceSAndroid Build Coastguard Worker {
1373*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1374*35238bceSAndroid Build Coastguard Worker << "Failure: Non-zero green color component detected - should have been completely overwritten by "
1375*35238bceSAndroid Build Coastguard Worker "red quad"
1376*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1377*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed");
1378*35238bceSAndroid Build Coastguard Worker return STOP;
1379*35238bceSAndroid Build Coastguard Worker }
1380*35238bceSAndroid Build Coastguard Worker }
1381*35238bceSAndroid Build Coastguard Worker
1382*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Success: Coverage mask appears to be constant at a given pixel coordinate with a given "
1383*35238bceSAndroid Build Coastguard Worker << (m_isAlphaToCoverageCase ? "alpha" : "")
1384*35238bceSAndroid Build Coastguard Worker << (m_isAlphaToCoverageCase && m_isSampleCoverageCase ? " and " : "")
1385*35238bceSAndroid Build Coastguard Worker << (m_isSampleCoverageCase ? "coverage value" : "") << TestLog::EndMessage;
1386*35238bceSAndroid Build Coastguard Worker
1387*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Passed");
1388*35238bceSAndroid Build Coastguard Worker
1389*35238bceSAndroid Build Coastguard Worker return STOP;
1390*35238bceSAndroid Build Coastguard Worker }
1391*35238bceSAndroid Build Coastguard Worker
1392*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
1393*35238bceSAndroid Build Coastguard Worker * \brief Tests coverage mask inversion validity.
1394*35238bceSAndroid Build Coastguard Worker *
1395*35238bceSAndroid Build Coastguard Worker * Tests that the coverage masks obtained by glSampleCoverage(..., GL_TRUE)
1396*35238bceSAndroid Build Coastguard Worker * and glSampleCoverage(..., GL_FALSE) are indeed each others' inverses.
1397*35238bceSAndroid Build Coastguard Worker * This is done by drawing a pattern, with varying coverage values,
1398*35238bceSAndroid Build Coastguard Worker * overlapped by a pattern that has inverted masks and is otherwise
1399*35238bceSAndroid Build Coastguard Worker * identical. The resulting image is compared to one obtained by drawing
1400*35238bceSAndroid Build Coastguard Worker * the same pattern but with all-ones coverage masks.
1401*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
1402*35238bceSAndroid Build Coastguard Worker class CoverageMaskInvertCase : public MultisampleCase
1403*35238bceSAndroid Build Coastguard Worker {
1404*35238bceSAndroid Build Coastguard Worker public:
1405*35238bceSAndroid Build Coastguard Worker CoverageMaskInvertCase(Context &context, const char *name, const char *description);
~CoverageMaskInvertCase(void)1406*35238bceSAndroid Build Coastguard Worker ~CoverageMaskInvertCase(void)
1407*35238bceSAndroid Build Coastguard Worker {
1408*35238bceSAndroid Build Coastguard Worker }
1409*35238bceSAndroid Build Coastguard Worker
1410*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
1411*35238bceSAndroid Build Coastguard Worker
1412*35238bceSAndroid Build Coastguard Worker protected:
getDesiredViewportSize(void) const1413*35238bceSAndroid Build Coastguard Worker int getDesiredViewportSize(void) const
1414*35238bceSAndroid Build Coastguard Worker {
1415*35238bceSAndroid Build Coastguard Worker return 256;
1416*35238bceSAndroid Build Coastguard Worker }
1417*35238bceSAndroid Build Coastguard Worker
1418*35238bceSAndroid Build Coastguard Worker private:
1419*35238bceSAndroid Build Coastguard Worker void drawPattern(bool invertSampleCoverage) const;
1420*35238bceSAndroid Build Coastguard Worker };
1421*35238bceSAndroid Build Coastguard Worker
CoverageMaskInvertCase(Context & context,const char * name,const char * description)1422*35238bceSAndroid Build Coastguard Worker CoverageMaskInvertCase::CoverageMaskInvertCase(Context &context, const char *name, const char *description)
1423*35238bceSAndroid Build Coastguard Worker : MultisampleCase(context, name, description)
1424*35238bceSAndroid Build Coastguard Worker {
1425*35238bceSAndroid Build Coastguard Worker }
1426*35238bceSAndroid Build Coastguard Worker
drawPattern(bool invertSampleCoverage) const1427*35238bceSAndroid Build Coastguard Worker void CoverageMaskInvertCase::drawPattern(bool invertSampleCoverage) const
1428*35238bceSAndroid Build Coastguard Worker {
1429*35238bceSAndroid Build Coastguard Worker const int numTriangles = 25;
1430*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numTriangles; i++)
1431*35238bceSAndroid Build Coastguard Worker {
1432*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(
1433*35238bceSAndroid Build Coastguard Worker glSampleCoverage((float)i / (float)(numTriangles - 1), invertSampleCoverage ? GL_TRUE : GL_FALSE));
1434*35238bceSAndroid Build Coastguard Worker
1435*35238bceSAndroid Build Coastguard Worker float angle0 = 2.0f * DE_PI * (float)i / (float)numTriangles;
1436*35238bceSAndroid Build Coastguard Worker float angle1 = 2.0f * DE_PI * ((float)i + 0.5f) / (float)numTriangles;
1437*35238bceSAndroid Build Coastguard Worker
1438*35238bceSAndroid Build Coastguard Worker renderTriangle(Vec2(0.0f, 0.0f), Vec2(deFloatCos(angle0) * 0.95f, deFloatSin(angle0) * 0.95f),
1439*35238bceSAndroid Build Coastguard Worker Vec2(deFloatCos(angle1) * 0.95f, deFloatSin(angle1) * 0.95f),
1440*35238bceSAndroid Build Coastguard Worker Vec4(0.4f + (float)i / (float)numTriangles * 0.6f, 0.5f + (float)i / (float)numTriangles * 0.3f,
1441*35238bceSAndroid Build Coastguard Worker 0.6f - (float)i / (float)numTriangles * 0.5f,
1442*35238bceSAndroid Build Coastguard Worker 0.7f - (float)i / (float)numTriangles * 0.7f));
1443*35238bceSAndroid Build Coastguard Worker }
1444*35238bceSAndroid Build Coastguard Worker }
1445*35238bceSAndroid Build Coastguard Worker
iterate(void)1446*35238bceSAndroid Build Coastguard Worker CoverageMaskInvertCase::IterateResult CoverageMaskInvertCase::iterate(void)
1447*35238bceSAndroid Build Coastguard Worker {
1448*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
1449*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImgNoSampleCoverage(m_viewportSize, m_viewportSize);
1450*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedImgSampleCoverage(m_viewportSize, m_viewportSize);
1451*35238bceSAndroid Build Coastguard Worker
1452*35238bceSAndroid Build Coastguard Worker randomizeViewport();
1453*35238bceSAndroid Build Coastguard Worker
1454*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_BLEND));
1455*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glBlendEquation(GL_FUNC_ADD));
1456*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glBlendFunc(GL_ONE, GL_ONE));
1457*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Additive blending enabled in order to detect (erroneously) overlapping samples"
1458*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1459*35238bceSAndroid Build Coastguard Worker
1460*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Clearing color to all-zeros" << TestLog::EndMessage;
1461*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
1462*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
1463*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Drawing the pattern with GL_SAMPLE_COVERAGE disabled" << TestLog::EndMessage;
1464*35238bceSAndroid Build Coastguard Worker drawPattern(false);
1465*35238bceSAndroid Build Coastguard Worker readImage(renderedImgNoSampleCoverage);
1466*35238bceSAndroid Build Coastguard Worker
1467*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImageNoSampleCoverage", "Rendered image with GL_SAMPLE_COVERAGE disabled",
1468*35238bceSAndroid Build Coastguard Worker renderedImgNoSampleCoverage, QP_IMAGE_COMPRESSION_MODE_PNG);
1469*35238bceSAndroid Build Coastguard Worker
1470*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Clearing color to all-zeros" << TestLog::EndMessage;
1471*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
1472*35238bceSAndroid Build Coastguard Worker GLU_CHECK_CALL(glEnable(GL_SAMPLE_COVERAGE));
1473*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Drawing the pattern with GL_SAMPLE_COVERAGE enabled, using non-inverted masks"
1474*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1475*35238bceSAndroid Build Coastguard Worker drawPattern(false);
1476*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
1477*35238bceSAndroid Build Coastguard Worker << "Drawing the pattern with GL_SAMPLE_COVERAGE enabled, using same sample coverage values but inverted masks"
1478*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1479*35238bceSAndroid Build Coastguard Worker drawPattern(true);
1480*35238bceSAndroid Build Coastguard Worker readImage(renderedImgSampleCoverage);
1481*35238bceSAndroid Build Coastguard Worker
1482*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("RenderedImageSampleCoverage", "Rendered image with GL_SAMPLE_COVERAGE enabled",
1483*35238bceSAndroid Build Coastguard Worker renderedImgSampleCoverage, QP_IMAGE_COMPRESSION_MODE_PNG);
1484*35238bceSAndroid Build Coastguard Worker
1485*35238bceSAndroid Build Coastguard Worker bool passed = tcu::pixelThresholdCompare(
1486*35238bceSAndroid Build Coastguard Worker log, "CoverageVsNoCoverage", "Comparison of same pattern with GL_SAMPLE_COVERAGE disabled and enabled",
1487*35238bceSAndroid Build Coastguard Worker renderedImgNoSampleCoverage, renderedImgSampleCoverage, tcu::RGBA(0), tcu::COMPARE_LOG_ON_ERROR);
1488*35238bceSAndroid Build Coastguard Worker
1489*35238bceSAndroid Build Coastguard Worker if (passed)
1490*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Success: The two images rendered are identical" << TestLog::EndMessage;
1491*35238bceSAndroid Build Coastguard Worker
1492*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().setTestResult(passed ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1493*35238bceSAndroid Build Coastguard Worker passed ? "Passed" : "Failed");
1494*35238bceSAndroid Build Coastguard Worker
1495*35238bceSAndroid Build Coastguard Worker return STOP;
1496*35238bceSAndroid Build Coastguard Worker }
1497*35238bceSAndroid Build Coastguard Worker
MultisampleTests(Context & context)1498*35238bceSAndroid Build Coastguard Worker MultisampleTests::MultisampleTests(Context &context) : TestCaseGroup(context, "multisample", "Multisampling tests")
1499*35238bceSAndroid Build Coastguard Worker {
1500*35238bceSAndroid Build Coastguard Worker }
1501*35238bceSAndroid Build Coastguard Worker
~MultisampleTests(void)1502*35238bceSAndroid Build Coastguard Worker MultisampleTests::~MultisampleTests(void)
1503*35238bceSAndroid Build Coastguard Worker {
1504*35238bceSAndroid Build Coastguard Worker }
1505*35238bceSAndroid Build Coastguard Worker
init(void)1506*35238bceSAndroid Build Coastguard Worker void MultisampleTests::init(void)
1507*35238bceSAndroid Build Coastguard Worker {
1508*35238bceSAndroid Build Coastguard Worker addChild(new PolygonNumSamplesCase(m_context, "num_samples_polygon",
1509*35238bceSAndroid Build Coastguard Worker "Test sanity of the value of GL_SAMPLES, with polygons"));
1510*35238bceSAndroid Build Coastguard Worker addChild(
1511*35238bceSAndroid Build Coastguard Worker new LineNumSamplesCase(m_context, "num_samples_line", "Test sanity of the value of GL_SAMPLES, with lines"));
1512*35238bceSAndroid Build Coastguard Worker addChild(new CommonEdgeCase(m_context, "common_edge_small_quads", "Test polygons' common edges with small quads",
1513*35238bceSAndroid Build Coastguard Worker CommonEdgeCase::CASETYPE_SMALL_QUADS));
1514*35238bceSAndroid Build Coastguard Worker addChild(new CommonEdgeCase(m_context, "common_edge_big_quad",
1515*35238bceSAndroid Build Coastguard Worker "Test polygons' common edges with bigger-than-viewport quads",
1516*35238bceSAndroid Build Coastguard Worker CommonEdgeCase::CASETYPE_BIGGER_THAN_VIEWPORT_QUAD));
1517*35238bceSAndroid Build Coastguard Worker addChild(new CommonEdgeCase(m_context, "common_edge_viewport_quad",
1518*35238bceSAndroid Build Coastguard Worker "Test polygons' common edges with exactly viewport-sized quads",
1519*35238bceSAndroid Build Coastguard Worker CommonEdgeCase::CASETYPE_FIT_VIEWPORT_QUAD));
1520*35238bceSAndroid Build Coastguard Worker addChild(new SampleDepthCase(m_context, "depth", "Test that depth values are per-sample"));
1521*35238bceSAndroid Build Coastguard Worker addChild(new SampleStencilCase(m_context, "stencil", "Test that stencil values are per-sample"));
1522*35238bceSAndroid Build Coastguard Worker addChild(new CoverageMaskInvertCase(
1523*35238bceSAndroid Build Coastguard Worker m_context, "sample_coverage_invert",
1524*35238bceSAndroid Build Coastguard Worker "Test that non-inverted and inverted sample coverage masks are each other's negations"));
1525*35238bceSAndroid Build Coastguard Worker
1526*35238bceSAndroid Build Coastguard Worker addChild(new MaskProportionalityCase(m_context, "proportionality_alpha_to_coverage",
1527*35238bceSAndroid Build Coastguard Worker "Test the proportionality property of GL_SAMPLE_ALPHA_TO_COVERAGE",
1528*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase::CASETYPE_ALPHA_TO_COVERAGE));
1529*35238bceSAndroid Build Coastguard Worker addChild(new MaskProportionalityCase(m_context, "proportionality_sample_coverage",
1530*35238bceSAndroid Build Coastguard Worker "Test the proportionality property of GL_SAMPLE_COVERAGE",
1531*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase::CASETYPE_SAMPLE_COVERAGE));
1532*35238bceSAndroid Build Coastguard Worker addChild(new MaskProportionalityCase(m_context, "proportionality_sample_coverage_inverted",
1533*35238bceSAndroid Build Coastguard Worker "Test the proportionality property of inverted-mask GL_SAMPLE_COVERAGE",
1534*35238bceSAndroid Build Coastguard Worker MaskProportionalityCase::CASETYPE_SAMPLE_COVERAGE_INVERTED));
1535*35238bceSAndroid Build Coastguard Worker
1536*35238bceSAndroid Build Coastguard Worker addChild(new MaskConstancyCase(m_context, "constancy_alpha_to_coverage",
1537*35238bceSAndroid Build Coastguard Worker "Test that coverage mask is constant at given coordinates with a given alpha or "
1538*35238bceSAndroid Build Coastguard Worker "coverage value, using GL_SAMPLE_ALPHA_TO_COVERAGE",
1539*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::CASETYPE_ALPHA_TO_COVERAGE));
1540*35238bceSAndroid Build Coastguard Worker addChild(new MaskConstancyCase(m_context, "constancy_sample_coverage",
1541*35238bceSAndroid Build Coastguard Worker "Test that coverage mask is constant at given coordinates with a given alpha or "
1542*35238bceSAndroid Build Coastguard Worker "coverage value, using GL_SAMPLE_COVERAGE",
1543*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::CASETYPE_SAMPLE_COVERAGE));
1544*35238bceSAndroid Build Coastguard Worker addChild(new MaskConstancyCase(m_context, "constancy_sample_coverage_inverted",
1545*35238bceSAndroid Build Coastguard Worker "Test that coverage mask is constant at given coordinates with a given alpha or "
1546*35238bceSAndroid Build Coastguard Worker "coverage value, using inverted-mask GL_SAMPLE_COVERAGE",
1547*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::CASETYPE_SAMPLE_COVERAGE_INVERTED));
1548*35238bceSAndroid Build Coastguard Worker addChild(new MaskConstancyCase(m_context, "constancy_both",
1549*35238bceSAndroid Build Coastguard Worker "Test that coverage mask is constant at given coordinates with a given alpha or "
1550*35238bceSAndroid Build Coastguard Worker "coverage value, using GL_SAMPLE_ALPHA_TO_COVERAGE and GL_SAMPLE_COVERAGE",
1551*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::CASETYPE_BOTH));
1552*35238bceSAndroid Build Coastguard Worker addChild(
1553*35238bceSAndroid Build Coastguard Worker new MaskConstancyCase(m_context, "constancy_both_inverted",
1554*35238bceSAndroid Build Coastguard Worker "Test that coverage mask is constant at given coordinates with a given alpha or coverage "
1555*35238bceSAndroid Build Coastguard Worker "value, using GL_SAMPLE_ALPHA_TO_COVERAGE and inverted-mask GL_SAMPLE_COVERAGE",
1556*35238bceSAndroid Build Coastguard Worker MaskConstancyCase::CASETYPE_BOTH_INVERTED));
1557*35238bceSAndroid Build Coastguard Worker }
1558*35238bceSAndroid Build Coastguard Worker
1559*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1560*35238bceSAndroid Build Coastguard Worker } // namespace gles2
1561*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1562