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 Clipping tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fClippingTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker #include "sglrReferenceContext.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "sglrGLContext.hpp"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
40*35238bceSAndroid Build Coastguard Worker
41*35238bceSAndroid Build Coastguard Worker namespace deqp
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace gles2
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker namespace Functional
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker namespace
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker using tcu::ConstPixelBufferAccess;
51*35238bceSAndroid Build Coastguard Worker using tcu::PixelBufferAccess;
52*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
53*35238bceSAndroid Build Coastguard Worker
54*35238bceSAndroid Build Coastguard Worker static const tcu::Vec4 MASK_COLOR_OK = tcu::Vec4(0.0f, 0.1f, 0.0f, 1.0f);
55*35238bceSAndroid Build Coastguard Worker static const tcu::Vec4 MASK_COLOR_DEV = tcu::Vec4(0.8f, 0.5f, 0.0f, 1.0f);
56*35238bceSAndroid Build Coastguard Worker static const tcu::Vec4 MASK_COLOR_FAIL = tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f);
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker const int TEST_CANVAS_SIZE = 200;
59*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle VIEWPORT_WHOLE(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
60*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle VIEWPORT_CENTER(TEST_CANVAS_SIZE / 4, TEST_CANVAS_SIZE / 4, TEST_CANVAS_SIZE / 2,
61*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE / 2);
62*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle VIEWPORT_CORNER(TEST_CANVAS_SIZE / 2, TEST_CANVAS_SIZE / 2, TEST_CANVAS_SIZE / 2,
63*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE / 2);
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker const char *shaderSourceVertex = "attribute highp vec4 a_position;\n"
66*35238bceSAndroid Build Coastguard Worker "attribute highp vec4 a_color;\n"
67*35238bceSAndroid Build Coastguard Worker "attribute highp float a_pointSize;\n"
68*35238bceSAndroid Build Coastguard Worker "varying mediump vec4 varFragColor;\n"
69*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
70*35238bceSAndroid Build Coastguard Worker "{\n"
71*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
72*35238bceSAndroid Build Coastguard Worker " gl_PointSize = a_pointSize;\n"
73*35238bceSAndroid Build Coastguard Worker " varFragColor = a_color;\n"
74*35238bceSAndroid Build Coastguard Worker "}\n";
75*35238bceSAndroid Build Coastguard Worker const char *shaderSourceFragment = "varying mediump vec4 varFragColor;\n"
76*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
77*35238bceSAndroid Build Coastguard Worker "{\n"
78*35238bceSAndroid Build Coastguard Worker " gl_FragColor = varFragColor;\n"
79*35238bceSAndroid Build Coastguard Worker "}\n";
80*35238bceSAndroid Build Coastguard Worker
isBlack(const tcu::IVec4 & a)81*35238bceSAndroid Build Coastguard Worker inline bool isBlack(const tcu::IVec4 &a)
82*35238bceSAndroid Build Coastguard Worker {
83*35238bceSAndroid Build Coastguard Worker return a.x() == 0 && a.y() == 0 && a.z() == 0;
84*35238bceSAndroid Build Coastguard Worker }
85*35238bceSAndroid Build Coastguard Worker
isHalfFilled(const tcu::IVec4 & a)86*35238bceSAndroid Build Coastguard Worker inline bool isHalfFilled(const tcu::IVec4 &a)
87*35238bceSAndroid Build Coastguard Worker {
88*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 halfFilled(127, 0, 0, 0);
89*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 threshold(20, 256, 256, 256);
90*35238bceSAndroid Build Coastguard Worker
91*35238bceSAndroid Build Coastguard Worker return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - halfFilled), threshold));
92*35238bceSAndroid Build Coastguard Worker }
93*35238bceSAndroid Build Coastguard Worker
isLessThanHalfFilled(const tcu::IVec4 & a)94*35238bceSAndroid Build Coastguard Worker inline bool isLessThanHalfFilled(const tcu::IVec4 &a)
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker const int halfFilled = 127;
97*35238bceSAndroid Build Coastguard Worker const int threshold = 20;
98*35238bceSAndroid Build Coastguard Worker
99*35238bceSAndroid Build Coastguard Worker return a.x() + threshold < halfFilled;
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker
compareBlackNonBlackPixels(const tcu::IVec4 & a,const tcu::IVec4 & b)102*35238bceSAndroid Build Coastguard Worker inline bool compareBlackNonBlackPixels(const tcu::IVec4 &a, const tcu::IVec4 &b)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker return isBlack(a) == isBlack(b);
105*35238bceSAndroid Build Coastguard Worker }
106*35238bceSAndroid Build Coastguard Worker
compareColoredPixels(const tcu::IVec4 & a,const tcu::IVec4 & b)107*35238bceSAndroid Build Coastguard Worker inline bool compareColoredPixels(const tcu::IVec4 &a, const tcu::IVec4 &b)
108*35238bceSAndroid Build Coastguard Worker {
109*35238bceSAndroid Build Coastguard Worker const bool aIsBlack = isBlack(a);
110*35238bceSAndroid Build Coastguard Worker const bool bIsBlack = isBlack(b);
111*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 threshold(20, 20, 20, 0);
112*35238bceSAndroid Build Coastguard Worker
113*35238bceSAndroid Build Coastguard Worker if (aIsBlack && bIsBlack)
114*35238bceSAndroid Build Coastguard Worker return true;
115*35238bceSAndroid Build Coastguard Worker if (aIsBlack != bIsBlack)
116*35238bceSAndroid Build Coastguard Worker return false;
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - b), threshold));
119*35238bceSAndroid Build Coastguard Worker }
120*35238bceSAndroid Build Coastguard Worker
blitImageOnBlackSurface(const ConstPixelBufferAccess & src,const PixelBufferAccess & dst)121*35238bceSAndroid Build Coastguard Worker void blitImageOnBlackSurface(const ConstPixelBufferAccess &src, const PixelBufferAccess &dst)
122*35238bceSAndroid Build Coastguard Worker {
123*35238bceSAndroid Build Coastguard Worker const int height = src.getHeight();
124*35238bceSAndroid Build Coastguard Worker const int width = src.getWidth();
125*35238bceSAndroid Build Coastguard Worker
126*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < height; y++)
127*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < width; x++)
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 cSrc = src.getPixelInt(x, y);
130*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 cDst = tcu::IVec4(cSrc.x(), cSrc.y(), cSrc.z(), 255);
131*35238bceSAndroid Build Coastguard Worker
132*35238bceSAndroid Build Coastguard Worker dst.setPixel(cDst, x, y);
133*35238bceSAndroid Build Coastguard Worker }
134*35238bceSAndroid Build Coastguard Worker }
135*35238bceSAndroid Build Coastguard Worker
136*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
137*35238bceSAndroid Build Coastguard Worker * \brief Pixelwise comparison of two images.
138*35238bceSAndroid Build Coastguard Worker * \note copied & modified from glsRasterizationTests
139*35238bceSAndroid Build Coastguard Worker *
140*35238bceSAndroid Build Coastguard Worker * Kernel radius defines maximum allowed distance. If radius is 0, only
141*35238bceSAndroid Build Coastguard Worker * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
142*35238bceSAndroid Build Coastguard Worker * equal if pixelCmp returns true..
143*35238bceSAndroid Build Coastguard Worker *
144*35238bceSAndroid Build Coastguard Worker * Return values: -1 = Perfect match
145*35238bceSAndroid Build Coastguard Worker * 0 = Deviation within kernel
146*35238bceSAndroid Build Coastguard Worker * >0 = Number of faulty pixels
147*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
compareImages(tcu::TestLog & log,const ConstPixelBufferAccess & test,const ConstPixelBufferAccess & ref,const PixelBufferAccess & diffMask,int kernelRadius,bool (* pixelCmp)(const tcu::IVec4 & a,const tcu::IVec4 & b))148*35238bceSAndroid Build Coastguard Worker inline int compareImages(tcu::TestLog &log, const ConstPixelBufferAccess &test, const ConstPixelBufferAccess &ref,
149*35238bceSAndroid Build Coastguard Worker const PixelBufferAccess &diffMask, int kernelRadius,
150*35238bceSAndroid Build Coastguard Worker bool (*pixelCmp)(const tcu::IVec4 &a, const tcu::IVec4 &b))
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker const int height = test.getHeight();
153*35238bceSAndroid Build Coastguard Worker const int width = test.getWidth();
154*35238bceSAndroid Build Coastguard Worker int deviatingPixels = 0;
155*35238bceSAndroid Build Coastguard Worker int faultyPixels = 0;
156*35238bceSAndroid Build Coastguard Worker int compareFailed = -1;
157*35238bceSAndroid Build Coastguard Worker
158*35238bceSAndroid Build Coastguard Worker tcu::clear(diffMask, MASK_COLOR_OK);
159*35238bceSAndroid Build Coastguard Worker
160*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < height; y++)
161*35238bceSAndroid Build Coastguard Worker {
162*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < width; x++)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 cRef = ref.getPixelInt(x, y);
165*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 cTest = test.getPixelInt(x, y);
166*35238bceSAndroid Build Coastguard Worker
167*35238bceSAndroid Build Coastguard Worker // Pixelwise match, no deviation or fault
168*35238bceSAndroid Build Coastguard Worker if ((*pixelCmp)(cRef, cTest))
169*35238bceSAndroid Build Coastguard Worker continue;
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker // Deviation
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker const int radius = kernelRadius;
174*35238bceSAndroid Build Coastguard Worker bool foundRef = false;
175*35238bceSAndroid Build Coastguard Worker bool foundTest = false;
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker // edges are considered a "deviation" too. The suitable pixel could be "behind" the edge
178*35238bceSAndroid Build Coastguard Worker if (y < radius || x < radius || y + radius >= height || x + radius >= width)
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker foundRef = true;
181*35238bceSAndroid Build Coastguard Worker foundTest = true;
182*35238bceSAndroid Build Coastguard Worker }
183*35238bceSAndroid Build Coastguard Worker else
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker // find ref
186*35238bceSAndroid Build Coastguard Worker for (int kY = y - radius; kY <= y + radius; kY++)
187*35238bceSAndroid Build Coastguard Worker for (int kX = x - radius; kX <= x + radius; kX++)
188*35238bceSAndroid Build Coastguard Worker {
189*35238bceSAndroid Build Coastguard Worker if ((*pixelCmp)(cRef, test.getPixelInt(kX, kY)))
190*35238bceSAndroid Build Coastguard Worker {
191*35238bceSAndroid Build Coastguard Worker foundRef = true;
192*35238bceSAndroid Build Coastguard Worker break;
193*35238bceSAndroid Build Coastguard Worker }
194*35238bceSAndroid Build Coastguard Worker }
195*35238bceSAndroid Build Coastguard Worker
196*35238bceSAndroid Build Coastguard Worker // find result
197*35238bceSAndroid Build Coastguard Worker for (int kY = y - radius; kY <= y + radius; kY++)
198*35238bceSAndroid Build Coastguard Worker for (int kX = x - radius; kX <= x + radius; kX++)
199*35238bceSAndroid Build Coastguard Worker {
200*35238bceSAndroid Build Coastguard Worker if ((*pixelCmp)(cTest, ref.getPixelInt(kX, kY)))
201*35238bceSAndroid Build Coastguard Worker {
202*35238bceSAndroid Build Coastguard Worker foundTest = true;
203*35238bceSAndroid Build Coastguard Worker break;
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker }
206*35238bceSAndroid Build Coastguard Worker }
207*35238bceSAndroid Build Coastguard Worker
208*35238bceSAndroid Build Coastguard Worker // A pixel is deviating if the reference color is found inside the kernel and (~= every pixel reference draws must be drawn by the gl too)
209*35238bceSAndroid Build Coastguard Worker // the result color is found in the reference image inside the kernel (~= every pixel gl draws must be drawn by the reference too)
210*35238bceSAndroid Build Coastguard Worker if (foundRef && foundTest)
211*35238bceSAndroid Build Coastguard Worker {
212*35238bceSAndroid Build Coastguard Worker diffMask.setPixel(MASK_COLOR_DEV, x, y);
213*35238bceSAndroid Build Coastguard Worker if (compareFailed == -1)
214*35238bceSAndroid Build Coastguard Worker compareFailed = 0;
215*35238bceSAndroid Build Coastguard Worker deviatingPixels++;
216*35238bceSAndroid Build Coastguard Worker continue;
217*35238bceSAndroid Build Coastguard Worker }
218*35238bceSAndroid Build Coastguard Worker }
219*35238bceSAndroid Build Coastguard Worker
220*35238bceSAndroid Build Coastguard Worker diffMask.setPixel(MASK_COLOR_FAIL, x, y);
221*35238bceSAndroid Build Coastguard Worker faultyPixels++; // The pixel is faulty if the color is not found
222*35238bceSAndroid Build Coastguard Worker compareFailed = 1;
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker }
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << deviatingPixels << " deviating pixel(s) found." << TestLog::EndMessage;
227*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << faultyPixels << " faulty pixel(s) found." << TestLog::EndMessage;
228*35238bceSAndroid Build Coastguard Worker
229*35238bceSAndroid Build Coastguard Worker return (compareFailed == 1 ? faultyPixels : compareFailed);
230*35238bceSAndroid Build Coastguard Worker }
231*35238bceSAndroid Build Coastguard Worker
232*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
233*35238bceSAndroid Build Coastguard Worker * \brief Pixelwise comparison of two images.
234*35238bceSAndroid Build Coastguard Worker *
235*35238bceSAndroid Build Coastguard Worker * Kernel radius defines maximum allowed distance. If radius is 0, only
236*35238bceSAndroid Build Coastguard Worker * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
237*35238bceSAndroid Build Coastguard Worker * equal if they both are black, or both are non-black.
238*35238bceSAndroid Build Coastguard Worker *
239*35238bceSAndroid Build Coastguard Worker * Return values: -1 = Perfect match
240*35238bceSAndroid Build Coastguard Worker * 0 = Deviation within kernel
241*35238bceSAndroid Build Coastguard Worker * >0 = Number of faulty pixels
242*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
compareBlackNonBlackImages(tcu::TestLog & log,const ConstPixelBufferAccess & test,const ConstPixelBufferAccess & ref,const PixelBufferAccess & diffMask,int kernelRadius)243*35238bceSAndroid Build Coastguard Worker int compareBlackNonBlackImages(tcu::TestLog &log, const ConstPixelBufferAccess &test, const ConstPixelBufferAccess &ref,
244*35238bceSAndroid Build Coastguard Worker const PixelBufferAccess &diffMask, int kernelRadius)
245*35238bceSAndroid Build Coastguard Worker {
246*35238bceSAndroid Build Coastguard Worker return compareImages(log, test, ref, diffMask, kernelRadius, compareBlackNonBlackPixels);
247*35238bceSAndroid Build Coastguard Worker }
248*35238bceSAndroid Build Coastguard Worker
249*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
250*35238bceSAndroid Build Coastguard Worker * \brief Pixelwise comparison of two images.
251*35238bceSAndroid Build Coastguard Worker *
252*35238bceSAndroid Build Coastguard Worker * Kernel radius defines maximum allowed distance. If radius is 0, only
253*35238bceSAndroid Build Coastguard Worker * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
254*35238bceSAndroid Build Coastguard Worker * equal if they both are black, or both are non-black with color values
255*35238bceSAndroid Build Coastguard Worker * close to each other.
256*35238bceSAndroid Build Coastguard Worker *
257*35238bceSAndroid Build Coastguard Worker * Return values: -1 = Perfect match
258*35238bceSAndroid Build Coastguard Worker * 0 = Deviation within kernel
259*35238bceSAndroid Build Coastguard Worker * >0 = Number of faulty pixels
260*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
compareColoredImages(tcu::TestLog & log,const ConstPixelBufferAccess & test,const ConstPixelBufferAccess & ref,const PixelBufferAccess & diffMask,int kernelRadius)261*35238bceSAndroid Build Coastguard Worker int compareColoredImages(tcu::TestLog &log, const ConstPixelBufferAccess &test, const ConstPixelBufferAccess &ref,
262*35238bceSAndroid Build Coastguard Worker const PixelBufferAccess &diffMask, int kernelRadius)
263*35238bceSAndroid Build Coastguard Worker {
264*35238bceSAndroid Build Coastguard Worker return compareImages(log, test, ref, diffMask, kernelRadius, compareColoredPixels);
265*35238bceSAndroid Build Coastguard Worker }
266*35238bceSAndroid Build Coastguard Worker
267*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
268*35238bceSAndroid Build Coastguard Worker * \brief Overdraw check verification
269*35238bceSAndroid Build Coastguard Worker *
270*35238bceSAndroid Build Coastguard Worker * Check that image does not have at any point a
271*35238bceSAndroid Build Coastguard Worker * pixel with red component value > 0.5
272*35238bceSAndroid Build Coastguard Worker *
273*35238bceSAndroid Build Coastguard Worker * Return values: false = area not filled, or leaking
274*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
checkHalfFilledImageOverdraw(tcu::TestLog & log,const tcu::RenderTarget & m_renderTarget,const ConstPixelBufferAccess & image,const PixelBufferAccess & output)275*35238bceSAndroid Build Coastguard Worker bool checkHalfFilledImageOverdraw(tcu::TestLog &log, const tcu::RenderTarget &m_renderTarget,
276*35238bceSAndroid Build Coastguard Worker const ConstPixelBufferAccess &image, const PixelBufferAccess &output)
277*35238bceSAndroid Build Coastguard Worker {
278*35238bceSAndroid Build Coastguard Worker const int height = image.getHeight();
279*35238bceSAndroid Build Coastguard Worker const int width = image.getWidth();
280*35238bceSAndroid Build Coastguard Worker
281*35238bceSAndroid Build Coastguard Worker bool faulty = false;
282*35238bceSAndroid Build Coastguard Worker
283*35238bceSAndroid Build Coastguard Worker tcu::clear(output, MASK_COLOR_OK);
284*35238bceSAndroid Build Coastguard Worker
285*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < height; y++)
286*35238bceSAndroid Build Coastguard Worker {
287*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < width; x++)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 cTest = image.getPixelInt(x, y);
290*35238bceSAndroid Build Coastguard Worker
291*35238bceSAndroid Build Coastguard Worker const bool pixelValid = isBlack(cTest) || isHalfFilled(cTest) ||
292*35238bceSAndroid Build Coastguard Worker (m_renderTarget.getNumSamples() > 1 && isLessThanHalfFilled(cTest));
293*35238bceSAndroid Build Coastguard Worker
294*35238bceSAndroid Build Coastguard Worker if (!pixelValid)
295*35238bceSAndroid Build Coastguard Worker {
296*35238bceSAndroid Build Coastguard Worker output.setPixel(MASK_COLOR_FAIL, x, y);
297*35238bceSAndroid Build Coastguard Worker faulty = true;
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker }
300*35238bceSAndroid Build Coastguard Worker }
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker if (faulty)
303*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Faulty pixel(s) found." << TestLog::EndMessage;
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker return !faulty;
306*35238bceSAndroid Build Coastguard Worker }
307*35238bceSAndroid Build Coastguard Worker
checkPointSize(const glw::Functions & gl,float pointSize)308*35238bceSAndroid Build Coastguard Worker void checkPointSize(const glw::Functions &gl, float pointSize)
309*35238bceSAndroid Build Coastguard Worker {
310*35238bceSAndroid Build Coastguard Worker GLfloat pointSizeRange[2] = {0, 0};
311*35238bceSAndroid Build Coastguard Worker gl.getFloatv(GL_ALIASED_POINT_SIZE_RANGE, pointSizeRange);
312*35238bceSAndroid Build Coastguard Worker if (pointSizeRange[1] < pointSize)
313*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Maximum point size is too low for this test");
314*35238bceSAndroid Build Coastguard Worker }
315*35238bceSAndroid Build Coastguard Worker
checkLineWidth(const glw::Functions & gl,float lineWidth)316*35238bceSAndroid Build Coastguard Worker void checkLineWidth(const glw::Functions &gl, float lineWidth)
317*35238bceSAndroid Build Coastguard Worker {
318*35238bceSAndroid Build Coastguard Worker GLfloat lineWidthRange[2] = {0, 0};
319*35238bceSAndroid Build Coastguard Worker gl.getFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
320*35238bceSAndroid Build Coastguard Worker if (lineWidthRange[1] < lineWidth)
321*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Maximum line width is too low for this test");
322*35238bceSAndroid Build Coastguard Worker }
323*35238bceSAndroid Build Coastguard Worker
IVec3ToVec3(const tcu::IVec3 & v)324*35238bceSAndroid Build Coastguard Worker tcu::Vec3 IVec3ToVec3(const tcu::IVec3 &v)
325*35238bceSAndroid Build Coastguard Worker {
326*35238bceSAndroid Build Coastguard Worker return tcu::Vec3((float)v.x(), (float)v.y(), (float)v.z());
327*35238bceSAndroid Build Coastguard Worker }
328*35238bceSAndroid Build Coastguard Worker
pointOnTriangle(const tcu::IVec3 & p,const tcu::IVec3 & t0,const tcu::IVec3 & t1,const tcu::IVec3 & t2)329*35238bceSAndroid Build Coastguard Worker bool pointOnTriangle(const tcu::IVec3 &p, const tcu::IVec3 &t0, const tcu::IVec3 &t1, const tcu::IVec3 &t2)
330*35238bceSAndroid Build Coastguard Worker {
331*35238bceSAndroid Build Coastguard Worker // Must be on the plane
332*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 n = tcu::cross(t1 - t0, t2 - t0);
333*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 d = (p - t0);
334*35238bceSAndroid Build Coastguard Worker
335*35238bceSAndroid Build Coastguard Worker if (tcu::dot(n, d))
336*35238bceSAndroid Build Coastguard Worker return false;
337*35238bceSAndroid Build Coastguard Worker
338*35238bceSAndroid Build Coastguard Worker // Must be within the triangle area
339*35238bceSAndroid Build Coastguard Worker if (deSign32(tcu::dot(n, tcu::cross(t1 - t0, p - t0))) == deSign32(tcu::dot(n, tcu::cross(t2 - t0, p - t0))))
340*35238bceSAndroid Build Coastguard Worker return false;
341*35238bceSAndroid Build Coastguard Worker if (deSign32(tcu::dot(n, tcu::cross(t2 - t1, p - t1))) == deSign32(tcu::dot(n, tcu::cross(t0 - t1, p - t1))))
342*35238bceSAndroid Build Coastguard Worker return false;
343*35238bceSAndroid Build Coastguard Worker if (deSign32(tcu::dot(n, tcu::cross(t0 - t2, p - t2))) == deSign32(tcu::dot(n, tcu::cross(t1 - t2, p - t2))))
344*35238bceSAndroid Build Coastguard Worker return false;
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker return true;
347*35238bceSAndroid Build Coastguard Worker }
348*35238bceSAndroid Build Coastguard Worker
pointsOnLine(const tcu::IVec2 & t0,const tcu::IVec2 & t1,const tcu::IVec2 & t2)349*35238bceSAndroid Build Coastguard Worker bool pointsOnLine(const tcu::IVec2 &t0, const tcu::IVec2 &t1, const tcu::IVec2 &t2)
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker return (t1 - t0).x() * (t2 - t0).y() - (t2 - t0).x() * (t1 - t0).y() == 0;
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker // returns true for cases where polygon is (almost) along xz or yz planes (normal.z < 0.1)
355*35238bceSAndroid Build Coastguard Worker // \note[jarkko] Doesn't have to be accurate, just to detect some obviously bad cases
twoPointClippedTriangleInvisible(const tcu::Vec3 & p,const tcu::IVec3 & dir1,const tcu::IVec3 & dir2)356*35238bceSAndroid Build Coastguard Worker bool twoPointClippedTriangleInvisible(const tcu::Vec3 &p, const tcu::IVec3 &dir1, const tcu::IVec3 &dir2)
357*35238bceSAndroid Build Coastguard Worker {
358*35238bceSAndroid Build Coastguard Worker // fixed-point-like coords
359*35238bceSAndroid Build Coastguard Worker const int64_t fixedScale = 64;
360*35238bceSAndroid Build Coastguard Worker const int64_t farValue = 1024;
361*35238bceSAndroid Build Coastguard Worker const tcu::Vector<int64_t, 3> d1 = tcu::Vector<int64_t, 3>(dir1.x(), dir1.y(), dir1.z());
362*35238bceSAndroid Build Coastguard Worker const tcu::Vector<int64_t, 3> d2 = tcu::Vector<int64_t, 3>(dir2.x(), dir2.y(), dir2.z());
363*35238bceSAndroid Build Coastguard Worker const tcu::Vector<int64_t, 3> pfixed =
364*35238bceSAndroid Build Coastguard Worker tcu::Vector<int64_t, 3>(deFloorFloatToInt32(p.x() * fixedScale), deFloorFloatToInt32(p.y() * fixedScale),
365*35238bceSAndroid Build Coastguard Worker deFloorFloatToInt32(p.z() * fixedScale));
366*35238bceSAndroid Build Coastguard Worker const tcu::Vector<int64_t, 3> normalDir = tcu::cross(d1 * farValue - pfixed, d2 * farValue - pfixed);
367*35238bceSAndroid Build Coastguard Worker const int64_t normalLen2 = tcu::lengthSquared(normalDir);
368*35238bceSAndroid Build Coastguard Worker
369*35238bceSAndroid Build Coastguard Worker return (normalDir.z() * normalDir.z() - normalLen2 / 100) < 0;
370*35238bceSAndroid Build Coastguard Worker }
371*35238bceSAndroid Build Coastguard Worker
genClippingPointInfoString(const tcu::Vec4 & p)372*35238bceSAndroid Build Coastguard Worker std::string genClippingPointInfoString(const tcu::Vec4 &p)
373*35238bceSAndroid Build Coastguard Worker {
374*35238bceSAndroid Build Coastguard Worker std::ostringstream msg;
375*35238bceSAndroid Build Coastguard Worker
376*35238bceSAndroid Build Coastguard Worker if (p.x() < -p.w())
377*35238bceSAndroid Build Coastguard Worker msg << "\t(-X clip)";
378*35238bceSAndroid Build Coastguard Worker if (p.x() > p.w())
379*35238bceSAndroid Build Coastguard Worker msg << "\t(+X clip)";
380*35238bceSAndroid Build Coastguard Worker if (p.y() < -p.w())
381*35238bceSAndroid Build Coastguard Worker msg << "\t(-Y clip)";
382*35238bceSAndroid Build Coastguard Worker if (p.y() > p.w())
383*35238bceSAndroid Build Coastguard Worker msg << "\t(+Y clip)";
384*35238bceSAndroid Build Coastguard Worker if (p.z() < -p.w())
385*35238bceSAndroid Build Coastguard Worker msg << "\t(-Z clip)";
386*35238bceSAndroid Build Coastguard Worker if (p.z() > p.w())
387*35238bceSAndroid Build Coastguard Worker msg << "\t(+Z clip)";
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker return msg.str();
390*35238bceSAndroid Build Coastguard Worker }
391*35238bceSAndroid Build Coastguard Worker
genColorString(const tcu::Vec4 & p)392*35238bceSAndroid Build Coastguard Worker std::string genColorString(const tcu::Vec4 &p)
393*35238bceSAndroid Build Coastguard Worker {
394*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white(1.0f, 1.0f, 1.0f, 1.0f);
395*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 red(1.0f, 0.0f, 0.0f, 1.0f);
396*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 yellow(1.0f, 1.0f, 0.0f, 1.0f);
397*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 blue(0.0f, 0.0f, 1.0f, 1.0f);
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker if (p == white)
400*35238bceSAndroid Build Coastguard Worker return "(white)";
401*35238bceSAndroid Build Coastguard Worker if (p == red)
402*35238bceSAndroid Build Coastguard Worker return "(red)";
403*35238bceSAndroid Build Coastguard Worker if (p == yellow)
404*35238bceSAndroid Build Coastguard Worker return "(yellow)";
405*35238bceSAndroid Build Coastguard Worker if (p == blue)
406*35238bceSAndroid Build Coastguard Worker return "(blue)";
407*35238bceSAndroid Build Coastguard Worker return "";
408*35238bceSAndroid Build Coastguard Worker }
409*35238bceSAndroid Build Coastguard Worker
410*35238bceSAndroid Build Coastguard Worker class PositionColorShader : public sglr::ShaderProgram
411*35238bceSAndroid Build Coastguard Worker {
412*35238bceSAndroid Build Coastguard Worker public:
413*35238bceSAndroid Build Coastguard Worker enum
414*35238bceSAndroid Build Coastguard Worker {
415*35238bceSAndroid Build Coastguard Worker VARYINGLOC_COLOR = 0
416*35238bceSAndroid Build Coastguard Worker };
417*35238bceSAndroid Build Coastguard Worker
418*35238bceSAndroid Build Coastguard Worker PositionColorShader(void);
419*35238bceSAndroid Build Coastguard Worker
420*35238bceSAndroid Build Coastguard Worker void shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets, const int numPackets) const;
421*35238bceSAndroid Build Coastguard Worker void shadeFragments(rr::FragmentPacket *packets, const int numPackets,
422*35238bceSAndroid Build Coastguard Worker const rr::FragmentShadingContext &context) const;
423*35238bceSAndroid Build Coastguard Worker };
424*35238bceSAndroid Build Coastguard Worker
PositionColorShader(void)425*35238bceSAndroid Build Coastguard Worker PositionColorShader::PositionColorShader(void)
426*35238bceSAndroid Build Coastguard Worker : sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
427*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
428*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_color", rr::GENERICVECTYPE_FLOAT)
429*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_pointSize", rr::GENERICVECTYPE_FLOAT)
430*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
431*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
432*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexSource(shaderSourceVertex)
433*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentSource(shaderSourceFragment))
434*35238bceSAndroid Build Coastguard Worker {
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker
shadeVertices(const rr::VertexAttrib * inputs,rr::VertexPacket * const * packets,const int numPackets) const437*35238bceSAndroid Build Coastguard Worker void PositionColorShader::shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets,
438*35238bceSAndroid Build Coastguard Worker const int numPackets) const
439*35238bceSAndroid Build Coastguard Worker {
440*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
441*35238bceSAndroid Build Coastguard Worker {
442*35238bceSAndroid Build Coastguard Worker const int positionAttrLoc = 0;
443*35238bceSAndroid Build Coastguard Worker const int colorAttrLoc = 1;
444*35238bceSAndroid Build Coastguard Worker const int pointSizeAttrLoc = 2;
445*35238bceSAndroid Build Coastguard Worker
446*35238bceSAndroid Build Coastguard Worker rr::VertexPacket &packet = *packets[packetNdx];
447*35238bceSAndroid Build Coastguard Worker
448*35238bceSAndroid Build Coastguard Worker // Transform to position
449*35238bceSAndroid Build Coastguard Worker packet.position = rr::readVertexAttribFloat(inputs[positionAttrLoc], packet.instanceNdx, packet.vertexNdx);
450*35238bceSAndroid Build Coastguard Worker
451*35238bceSAndroid Build Coastguard Worker // output point size
452*35238bceSAndroid Build Coastguard Worker packet.pointSize =
453*35238bceSAndroid Build Coastguard Worker rr::readVertexAttribFloat(inputs[pointSizeAttrLoc], packet.instanceNdx, packet.vertexNdx).x();
454*35238bceSAndroid Build Coastguard Worker
455*35238bceSAndroid Build Coastguard Worker // Pass color to FS
456*35238bceSAndroid Build Coastguard Worker packet.outputs[VARYINGLOC_COLOR] =
457*35238bceSAndroid Build Coastguard Worker rr::readVertexAttribFloat(inputs[colorAttrLoc], packet.instanceNdx, packet.vertexNdx);
458*35238bceSAndroid Build Coastguard Worker }
459*35238bceSAndroid Build Coastguard Worker }
460*35238bceSAndroid Build Coastguard Worker
shadeFragments(rr::FragmentPacket * packets,const int numPackets,const rr::FragmentShadingContext & context) const461*35238bceSAndroid Build Coastguard Worker void PositionColorShader::shadeFragments(rr::FragmentPacket *packets, const int numPackets,
462*35238bceSAndroid Build Coastguard Worker const rr::FragmentShadingContext &context) const
463*35238bceSAndroid Build Coastguard Worker {
464*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
465*35238bceSAndroid Build Coastguard Worker {
466*35238bceSAndroid Build Coastguard Worker rr::FragmentPacket &packet = packets[packetNdx];
467*35238bceSAndroid Build Coastguard Worker
468*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
469*35238bceSAndroid Build Coastguard Worker rr::writeFragmentOutput(context, packetNdx, fragNdx, 0,
470*35238bceSAndroid Build Coastguard Worker rr::readVarying<float>(packet, context, VARYINGLOC_COLOR, fragNdx));
471*35238bceSAndroid Build Coastguard Worker }
472*35238bceSAndroid Build Coastguard Worker }
473*35238bceSAndroid Build Coastguard Worker
474*35238bceSAndroid Build Coastguard Worker class RenderTestCase : public TestCase
475*35238bceSAndroid Build Coastguard Worker {
476*35238bceSAndroid Build Coastguard Worker public:
477*35238bceSAndroid Build Coastguard Worker RenderTestCase(Context &context, const char *name, const char *description);
478*35238bceSAndroid Build Coastguard Worker
479*35238bceSAndroid Build Coastguard Worker virtual void testRender(void) = DE_NULL;
init(void)480*35238bceSAndroid Build Coastguard Worker virtual void init(void)
481*35238bceSAndroid Build Coastguard Worker {
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
485*35238bceSAndroid Build Coastguard Worker };
486*35238bceSAndroid Build Coastguard Worker
RenderTestCase(Context & context,const char * name,const char * description)487*35238bceSAndroid Build Coastguard Worker RenderTestCase::RenderTestCase(Context &context, const char *name, const char *description)
488*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, description)
489*35238bceSAndroid Build Coastguard Worker {
490*35238bceSAndroid Build Coastguard Worker }
491*35238bceSAndroid Build Coastguard Worker
iterate(void)492*35238bceSAndroid Build Coastguard Worker RenderTestCase::IterateResult RenderTestCase::iterate(void)
493*35238bceSAndroid Build Coastguard Worker {
494*35238bceSAndroid Build Coastguard Worker const int width = m_context.getRenderTarget().getWidth();
495*35238bceSAndroid Build Coastguard Worker const int height = m_context.getRenderTarget().getHeight();
496*35238bceSAndroid Build Coastguard Worker
497*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Render target size: " << width << "x" << height << TestLog::EndMessage;
498*35238bceSAndroid Build Coastguard Worker if (width < TEST_CANVAS_SIZE || height < TEST_CANVAS_SIZE)
499*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError(std::string("Render target size must be at least ") +
500*35238bceSAndroid Build Coastguard Worker de::toString(TEST_CANVAS_SIZE) + "x" + de::toString(TEST_CANVAS_SIZE));
501*35238bceSAndroid Build Coastguard Worker
502*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // success by default
503*35238bceSAndroid Build Coastguard Worker testRender();
504*35238bceSAndroid Build Coastguard Worker
505*35238bceSAndroid Build Coastguard Worker return STOP;
506*35238bceSAndroid Build Coastguard Worker }
507*35238bceSAndroid Build Coastguard Worker
508*35238bceSAndroid Build Coastguard Worker class PointCase : public RenderTestCase
509*35238bceSAndroid Build Coastguard Worker {
510*35238bceSAndroid Build Coastguard Worker public:
511*35238bceSAndroid Build Coastguard Worker PointCase(Context &context, const char *name, const char *description, const tcu::Vec4 *pointsBegin,
512*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 *pointsEnd, float pointSize, const rr::WindowRectangle &viewport);
513*35238bceSAndroid Build Coastguard Worker
514*35238bceSAndroid Build Coastguard Worker void init(void);
515*35238bceSAndroid Build Coastguard Worker void testRender(void);
516*35238bceSAndroid Build Coastguard Worker
517*35238bceSAndroid Build Coastguard Worker private:
518*35238bceSAndroid Build Coastguard Worker const std::vector<tcu::Vec4> m_points;
519*35238bceSAndroid Build Coastguard Worker const float m_pointSize;
520*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle m_viewport;
521*35238bceSAndroid Build Coastguard Worker };
522*35238bceSAndroid Build Coastguard Worker
PointCase(Context & context,const char * name,const char * description,const tcu::Vec4 * pointsBegin,const tcu::Vec4 * pointsEnd,float pointSize,const rr::WindowRectangle & viewport)523*35238bceSAndroid Build Coastguard Worker PointCase::PointCase(Context &context, const char *name, const char *description, const tcu::Vec4 *pointsBegin,
524*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 *pointsEnd, float pointSize, const rr::WindowRectangle &viewport)
525*35238bceSAndroid Build Coastguard Worker : RenderTestCase(context, name, description)
526*35238bceSAndroid Build Coastguard Worker , m_points(pointsBegin, pointsEnd)
527*35238bceSAndroid Build Coastguard Worker , m_pointSize(pointSize)
528*35238bceSAndroid Build Coastguard Worker , m_viewport(viewport)
529*35238bceSAndroid Build Coastguard Worker {
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker
init(void)532*35238bceSAndroid Build Coastguard Worker void PointCase::init(void)
533*35238bceSAndroid Build Coastguard Worker {
534*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
535*35238bceSAndroid Build Coastguard Worker checkPointSize(gl, m_pointSize);
536*35238bceSAndroid Build Coastguard Worker }
537*35238bceSAndroid Build Coastguard Worker
testRender(void)538*35238bceSAndroid Build Coastguard Worker void PointCase::testRender(void)
539*35238bceSAndroid Build Coastguard Worker {
540*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
541*35238bceSAndroid Build Coastguard Worker
542*35238bceSAndroid Build Coastguard Worker const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
543*35238bceSAndroid Build Coastguard Worker
544*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
545*35238bceSAndroid Build Coastguard Worker sglr::GLContext glesContext(m_context.getRenderContext(), log, 0,
546*35238bceSAndroid Build Coastguard Worker tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
547*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextLimits limits;
548*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers buffers(m_context.getRenderTarget().getPixelFormat(),
549*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE,
550*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE, numSamples);
551*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext refContext(limits, buffers.getColorbuffer(), buffers.getDepthbuffer(),
552*35238bceSAndroid Build Coastguard Worker buffers.getStencilbuffer());
553*35238bceSAndroid Build Coastguard Worker PositionColorShader program;
554*35238bceSAndroid Build Coastguard Worker tcu::Surface testSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
555*35238bceSAndroid Build Coastguard Worker tcu::Surface refSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
556*35238bceSAndroid Build Coastguard Worker sglr::Context *contexts[2] = {&glesContext, &refContext};
557*35238bceSAndroid Build Coastguard Worker tcu::Surface *surfaces[2] = {&testSurface, &refSurface};
558*35238bceSAndroid Build Coastguard Worker
559*35238bceSAndroid Build Coastguard Worker // log the purpose of the test
560*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom
561*35238bceSAndroid Build Coastguard Worker << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
562*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Rendering points with point size " << m_pointSize
563*35238bceSAndroid Build Coastguard Worker << ". Coordinates:" << TestLog::EndMessage;
564*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < m_points.size(); ++ndx)
565*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tx=" << m_points[ndx].x() << "\ty=" << m_points[ndx].y()
566*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_points[ndx].z() << "\tw=" << m_points[ndx].w() << "\t"
567*35238bceSAndroid Build Coastguard Worker << genClippingPointInfoString(m_points[ndx]) << TestLog::EndMessage;
568*35238bceSAndroid Build Coastguard Worker
569*35238bceSAndroid Build Coastguard Worker for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
570*35238bceSAndroid Build Coastguard Worker {
571*35238bceSAndroid Build Coastguard Worker sglr::Context &ctx = *contexts[contextNdx];
572*35238bceSAndroid Build Coastguard Worker tcu::Surface &dstSurface = *surfaces[contextNdx];
573*35238bceSAndroid Build Coastguard Worker const uint32_t programId = ctx.createProgram(&program);
574*35238bceSAndroid Build Coastguard Worker const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
575*35238bceSAndroid Build Coastguard Worker const GLint pointSizeLoc = ctx.getAttribLocation(programId, "a_pointSize");
576*35238bceSAndroid Build Coastguard Worker const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
577*35238bceSAndroid Build Coastguard Worker
578*35238bceSAndroid Build Coastguard Worker ctx.clearColor(0, 0, 0, 1);
579*35238bceSAndroid Build Coastguard Worker ctx.clearDepthf(1.0f);
580*35238bceSAndroid Build Coastguard Worker ctx.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
581*35238bceSAndroid Build Coastguard Worker ctx.viewport(m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
582*35238bceSAndroid Build Coastguard Worker ctx.useProgram(programId);
583*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(positionLoc);
584*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, 0, &m_points[0]);
585*35238bceSAndroid Build Coastguard Worker ctx.vertexAttrib1f(pointSizeLoc, m_pointSize);
586*35238bceSAndroid Build Coastguard Worker ctx.vertexAttrib4f(colorLoc, 1.0f, 1.0f, 1.0f, 1.0f);
587*35238bceSAndroid Build Coastguard Worker ctx.drawArrays(GL_POINTS, 0, (glw::GLsizei)m_points.size());
588*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(positionLoc);
589*35238bceSAndroid Build Coastguard Worker ctx.useProgram(0);
590*35238bceSAndroid Build Coastguard Worker ctx.deleteProgram(programId);
591*35238bceSAndroid Build Coastguard Worker ctx.finish();
592*35238bceSAndroid Build Coastguard Worker
593*35238bceSAndroid Build Coastguard Worker ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
594*35238bceSAndroid Build Coastguard Worker }
595*35238bceSAndroid Build Coastguard Worker
596*35238bceSAndroid Build Coastguard Worker // do the comparison
597*35238bceSAndroid Build Coastguard Worker {
598*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
599*35238bceSAndroid Build Coastguard Worker const int kernelRadius = 1;
600*35238bceSAndroid Build Coastguard Worker int faultyPixels;
601*35238bceSAndroid Build Coastguard Worker
602*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
603*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed."
604*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
605*35238bceSAndroid Build Coastguard Worker
606*35238bceSAndroid Build Coastguard Worker faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(),
607*35238bceSAndroid Build Coastguard Worker diffMask.getAccess(), kernelRadius);
608*35238bceSAndroid Build Coastguard Worker
609*35238bceSAndroid Build Coastguard Worker if (faultyPixels > 0)
610*35238bceSAndroid Build Coastguard Worker {
611*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
612*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
613*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess())
614*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
615*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
616*35238bceSAndroid Build Coastguard Worker
617*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
618*35238bceSAndroid Build Coastguard Worker }
619*35238bceSAndroid Build Coastguard Worker }
620*35238bceSAndroid Build Coastguard Worker }
621*35238bceSAndroid Build Coastguard Worker
622*35238bceSAndroid Build Coastguard Worker class LineRenderTestCase : public RenderTestCase
623*35238bceSAndroid Build Coastguard Worker {
624*35238bceSAndroid Build Coastguard Worker public:
625*35238bceSAndroid Build Coastguard Worker struct ColoredLineData
626*35238bceSAndroid Build Coastguard Worker {
627*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p0;
628*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c0;
629*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p1;
630*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c1;
631*35238bceSAndroid Build Coastguard Worker };
632*35238bceSAndroid Build Coastguard Worker
633*35238bceSAndroid Build Coastguard Worker struct ColorlessLineData
634*35238bceSAndroid Build Coastguard Worker {
635*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p0;
636*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p1;
637*35238bceSAndroid Build Coastguard Worker };
638*35238bceSAndroid Build Coastguard Worker LineRenderTestCase(Context &context, const char *name, const char *description, const ColoredLineData *linesBegin,
639*35238bceSAndroid Build Coastguard Worker const ColoredLineData *linesEnd, float lineWidth, const rr::WindowRectangle &viewport);
640*35238bceSAndroid Build Coastguard Worker LineRenderTestCase(Context &context, const char *name, const char *description, const ColorlessLineData *linesBegin,
641*35238bceSAndroid Build Coastguard Worker const ColorlessLineData *linesEnd, float lineWidth, const rr::WindowRectangle &viewport);
642*35238bceSAndroid Build Coastguard Worker
643*35238bceSAndroid Build Coastguard Worker virtual void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
644*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess) = DE_NULL;
645*35238bceSAndroid Build Coastguard Worker void init(void);
646*35238bceSAndroid Build Coastguard Worker void testRender(void);
647*35238bceSAndroid Build Coastguard Worker
648*35238bceSAndroid Build Coastguard Worker protected:
649*35238bceSAndroid Build Coastguard Worker const float m_lineWidth;
650*35238bceSAndroid Build Coastguard Worker
651*35238bceSAndroid Build Coastguard Worker private:
652*35238bceSAndroid Build Coastguard Worker std::vector<ColoredLineData> convertToColoredLines(const ColorlessLineData *linesBegin,
653*35238bceSAndroid Build Coastguard Worker const ColorlessLineData *linesEnd);
654*35238bceSAndroid Build Coastguard Worker
655*35238bceSAndroid Build Coastguard Worker const std::vector<ColoredLineData> m_lines;
656*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle m_viewport;
657*35238bceSAndroid Build Coastguard Worker };
658*35238bceSAndroid Build Coastguard Worker
LineRenderTestCase(Context & context,const char * name,const char * description,const ColoredLineData * linesBegin,const ColoredLineData * linesEnd,float lineWidth,const rr::WindowRectangle & viewport)659*35238bceSAndroid Build Coastguard Worker LineRenderTestCase::LineRenderTestCase(Context &context, const char *name, const char *description,
660*35238bceSAndroid Build Coastguard Worker const ColoredLineData *linesBegin, const ColoredLineData *linesEnd,
661*35238bceSAndroid Build Coastguard Worker float lineWidth, const rr::WindowRectangle &viewport)
662*35238bceSAndroid Build Coastguard Worker : RenderTestCase(context, name, description)
663*35238bceSAndroid Build Coastguard Worker , m_lineWidth(lineWidth)
664*35238bceSAndroid Build Coastguard Worker , m_lines(linesBegin, linesEnd)
665*35238bceSAndroid Build Coastguard Worker , m_viewport(viewport)
666*35238bceSAndroid Build Coastguard Worker {
667*35238bceSAndroid Build Coastguard Worker }
668*35238bceSAndroid Build Coastguard Worker
LineRenderTestCase(Context & context,const char * name,const char * description,const ColorlessLineData * linesBegin,const ColorlessLineData * linesEnd,float lineWidth,const rr::WindowRectangle & viewport)669*35238bceSAndroid Build Coastguard Worker LineRenderTestCase::LineRenderTestCase(Context &context, const char *name, const char *description,
670*35238bceSAndroid Build Coastguard Worker const ColorlessLineData *linesBegin, const ColorlessLineData *linesEnd,
671*35238bceSAndroid Build Coastguard Worker float lineWidth, const rr::WindowRectangle &viewport)
672*35238bceSAndroid Build Coastguard Worker : RenderTestCase(context, name, description)
673*35238bceSAndroid Build Coastguard Worker , m_lineWidth(lineWidth)
674*35238bceSAndroid Build Coastguard Worker , m_lines(convertToColoredLines(linesBegin, linesEnd))
675*35238bceSAndroid Build Coastguard Worker , m_viewport(viewport)
676*35238bceSAndroid Build Coastguard Worker {
677*35238bceSAndroid Build Coastguard Worker }
678*35238bceSAndroid Build Coastguard Worker
init(void)679*35238bceSAndroid Build Coastguard Worker void LineRenderTestCase::init(void)
680*35238bceSAndroid Build Coastguard Worker {
681*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
682*35238bceSAndroid Build Coastguard Worker checkLineWidth(gl, m_lineWidth);
683*35238bceSAndroid Build Coastguard Worker }
684*35238bceSAndroid Build Coastguard Worker
testRender(void)685*35238bceSAndroid Build Coastguard Worker void LineRenderTestCase::testRender(void)
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
688*35238bceSAndroid Build Coastguard Worker
689*35238bceSAndroid Build Coastguard Worker const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
690*35238bceSAndroid Build Coastguard Worker const int verticesPerLine = 2;
691*35238bceSAndroid Build Coastguard Worker
692*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
693*35238bceSAndroid Build Coastguard Worker sglr::GLContext glesContext(m_context.getRenderContext(), log, 0,
694*35238bceSAndroid Build Coastguard Worker tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
695*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextLimits limits;
696*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers buffers(m_context.getRenderTarget().getPixelFormat(),
697*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE,
698*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE, numSamples);
699*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext refContext(limits, buffers.getColorbuffer(), buffers.getDepthbuffer(),
700*35238bceSAndroid Build Coastguard Worker buffers.getStencilbuffer());
701*35238bceSAndroid Build Coastguard Worker PositionColorShader program;
702*35238bceSAndroid Build Coastguard Worker tcu::Surface testSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
703*35238bceSAndroid Build Coastguard Worker tcu::Surface refSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
704*35238bceSAndroid Build Coastguard Worker sglr::Context *contexts[2] = {&glesContext, &refContext};
705*35238bceSAndroid Build Coastguard Worker tcu::Surface *surfaces[2] = {&testSurface, &refSurface};
706*35238bceSAndroid Build Coastguard Worker
707*35238bceSAndroid Build Coastguard Worker // log the purpose of the test
708*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom
709*35238bceSAndroid Build Coastguard Worker << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
710*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Rendering lines with line width " << m_lineWidth
711*35238bceSAndroid Build Coastguard Worker << ". Coordinates:" << TestLog::EndMessage;
712*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < m_lines.size(); ++ndx)
713*35238bceSAndroid Build Coastguard Worker {
714*35238bceSAndroid Build Coastguard Worker const std::string fromProperties = genClippingPointInfoString(m_lines[ndx].p0);
715*35238bceSAndroid Build Coastguard Worker const std::string toProperties = genClippingPointInfoString(m_lines[ndx].p1);
716*35238bceSAndroid Build Coastguard Worker
717*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tfrom (x=" << m_lines[ndx].p0.x() << "\ty=" << m_lines[ndx].p0.y()
718*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_lines[ndx].p0.z() << "\tw=" << m_lines[ndx].p0.w() << ")\t" << fromProperties
719*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
720*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tto (x=" << m_lines[ndx].p1.x() << "\ty=" << m_lines[ndx].p1.y()
721*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_lines[ndx].p1.z() << "\tw=" << m_lines[ndx].p1.w() << ")\t" << toProperties
722*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
723*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
724*35238bceSAndroid Build Coastguard Worker }
725*35238bceSAndroid Build Coastguard Worker
726*35238bceSAndroid Build Coastguard Worker // render test image
727*35238bceSAndroid Build Coastguard Worker for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
728*35238bceSAndroid Build Coastguard Worker {
729*35238bceSAndroid Build Coastguard Worker sglr::Context &ctx = *contexts[contextNdx];
730*35238bceSAndroid Build Coastguard Worker tcu::Surface &dstSurface = *surfaces[contextNdx];
731*35238bceSAndroid Build Coastguard Worker const uint32_t programId = ctx.createProgram(&program);
732*35238bceSAndroid Build Coastguard Worker const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
733*35238bceSAndroid Build Coastguard Worker const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
734*35238bceSAndroid Build Coastguard Worker
735*35238bceSAndroid Build Coastguard Worker ctx.clearColor(0, 0, 0, 1);
736*35238bceSAndroid Build Coastguard Worker ctx.clearDepthf(1.0f);
737*35238bceSAndroid Build Coastguard Worker ctx.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
738*35238bceSAndroid Build Coastguard Worker ctx.viewport(m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
739*35238bceSAndroid Build Coastguard Worker ctx.useProgram(programId);
740*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(positionLoc);
741*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(colorLoc);
742*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].p0);
743*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].c0);
744*35238bceSAndroid Build Coastguard Worker ctx.lineWidth(m_lineWidth);
745*35238bceSAndroid Build Coastguard Worker ctx.drawArrays(GL_LINES, 0, verticesPerLine * (glw::GLsizei)m_lines.size());
746*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(positionLoc);
747*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(colorLoc);
748*35238bceSAndroid Build Coastguard Worker ctx.useProgram(0);
749*35238bceSAndroid Build Coastguard Worker ctx.deleteProgram(programId);
750*35238bceSAndroid Build Coastguard Worker ctx.finish();
751*35238bceSAndroid Build Coastguard Worker
752*35238bceSAndroid Build Coastguard Worker ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
753*35238bceSAndroid Build Coastguard Worker }
754*35238bceSAndroid Build Coastguard Worker
755*35238bceSAndroid Build Coastguard Worker // compare
756*35238bceSAndroid Build Coastguard Worker verifyImage(testSurface.getAccess(), refSurface.getAccess());
757*35238bceSAndroid Build Coastguard Worker }
758*35238bceSAndroid Build Coastguard Worker
convertToColoredLines(const ColorlessLineData * linesBegin,const ColorlessLineData * linesEnd)759*35238bceSAndroid Build Coastguard Worker std::vector<LineRenderTestCase::ColoredLineData> LineRenderTestCase::convertToColoredLines(
760*35238bceSAndroid Build Coastguard Worker const ColorlessLineData *linesBegin, const ColorlessLineData *linesEnd)
761*35238bceSAndroid Build Coastguard Worker {
762*35238bceSAndroid Build Coastguard Worker std::vector<ColoredLineData> ret;
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker for (const ColorlessLineData *it = linesBegin; it != linesEnd; ++it)
765*35238bceSAndroid Build Coastguard Worker {
766*35238bceSAndroid Build Coastguard Worker ColoredLineData r;
767*35238bceSAndroid Build Coastguard Worker
768*35238bceSAndroid Build Coastguard Worker r.p0 = (*it).p0;
769*35238bceSAndroid Build Coastguard Worker r.c0 = tcu::Vec4(1, 1, 1, 1);
770*35238bceSAndroid Build Coastguard Worker r.p1 = (*it).p1;
771*35238bceSAndroid Build Coastguard Worker r.c1 = tcu::Vec4(1, 1, 1, 1);
772*35238bceSAndroid Build Coastguard Worker
773*35238bceSAndroid Build Coastguard Worker ret.push_back(r);
774*35238bceSAndroid Build Coastguard Worker }
775*35238bceSAndroid Build Coastguard Worker
776*35238bceSAndroid Build Coastguard Worker return ret;
777*35238bceSAndroid Build Coastguard Worker }
778*35238bceSAndroid Build Coastguard Worker
779*35238bceSAndroid Build Coastguard Worker class LineCase : public LineRenderTestCase
780*35238bceSAndroid Build Coastguard Worker {
781*35238bceSAndroid Build Coastguard Worker public:
782*35238bceSAndroid Build Coastguard Worker LineCase(Context &context, const char *name, const char *description,
783*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData *linesBegin,
784*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData *linesEnd, float lineWidth,
785*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport, int searchKernelSize = 1);
786*35238bceSAndroid Build Coastguard Worker
787*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
788*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess);
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker private:
791*35238bceSAndroid Build Coastguard Worker const int m_searchKernelSize;
792*35238bceSAndroid Build Coastguard Worker };
793*35238bceSAndroid Build Coastguard Worker
LineCase(Context & context,const char * name,const char * description,const LineRenderTestCase::ColorlessLineData * linesBegin,const LineRenderTestCase::ColorlessLineData * linesEnd,float lineWidth,const rr::WindowRectangle & viewport,int searchKernelSize)794*35238bceSAndroid Build Coastguard Worker LineCase::LineCase(Context &context, const char *name, const char *description,
795*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData *linesBegin,
796*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData *linesEnd, float lineWidth,
797*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport, int searchKernelSize)
798*35238bceSAndroid Build Coastguard Worker : LineRenderTestCase(context, name, description, linesBegin, linesEnd, lineWidth, viewport)
799*35238bceSAndroid Build Coastguard Worker , m_searchKernelSize(searchKernelSize)
800*35238bceSAndroid Build Coastguard Worker {
801*35238bceSAndroid Build Coastguard Worker }
802*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::ConstPixelBufferAccess & testImageAccess,const tcu::ConstPixelBufferAccess & referenceImageAccess)803*35238bceSAndroid Build Coastguard Worker void LineCase::verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
804*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess)
805*35238bceSAndroid Build Coastguard Worker {
806*35238bceSAndroid Build Coastguard Worker const int faultyLimit = 6;
807*35238bceSAndroid Build Coastguard Worker int faultyPixels;
808*35238bceSAndroid Build Coastguard Worker
809*35238bceSAndroid Build Coastguard Worker const bool isMsaa = m_context.getRenderTarget().getNumSamples() > 1;
810*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
811*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
812*35238bceSAndroid Build Coastguard Worker
813*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
814*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << m_searchKernelSize << " is allowed."
815*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
816*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
817*35238bceSAndroid Build Coastguard Worker
818*35238bceSAndroid Build Coastguard Worker faultyPixels = compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(),
819*35238bceSAndroid Build Coastguard Worker m_searchKernelSize);
820*35238bceSAndroid Build Coastguard Worker
821*35238bceSAndroid Build Coastguard Worker if (faultyPixels > faultyLimit)
822*35238bceSAndroid Build Coastguard Worker {
823*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
824*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testImageAccess)
825*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
826*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
827*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker if (m_lineWidth != 1.0f && isMsaa)
830*35238bceSAndroid Build Coastguard Worker {
831*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Wide line support is optional, reporting compatibility warning."
832*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
833*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Wide line clipping failed");
834*35238bceSAndroid Build Coastguard Worker }
835*35238bceSAndroid Build Coastguard Worker else
836*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
837*35238bceSAndroid Build Coastguard Worker }
838*35238bceSAndroid Build Coastguard Worker }
839*35238bceSAndroid Build Coastguard Worker
840*35238bceSAndroid Build Coastguard Worker class ColoredLineCase : public LineRenderTestCase
841*35238bceSAndroid Build Coastguard Worker {
842*35238bceSAndroid Build Coastguard Worker public:
843*35238bceSAndroid Build Coastguard Worker ColoredLineCase(Context &context, const char *name, const char *description,
844*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColoredLineData *linesBegin,
845*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColoredLineData *linesEnd, float lineWidth,
846*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport);
847*35238bceSAndroid Build Coastguard Worker
848*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
849*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess);
850*35238bceSAndroid Build Coastguard Worker };
851*35238bceSAndroid Build Coastguard Worker
ColoredLineCase(Context & context,const char * name,const char * description,const LineRenderTestCase::ColoredLineData * linesBegin,const LineRenderTestCase::ColoredLineData * linesEnd,float lineWidth,const rr::WindowRectangle & viewport)852*35238bceSAndroid Build Coastguard Worker ColoredLineCase::ColoredLineCase(Context &context, const char *name, const char *description,
853*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColoredLineData *linesBegin,
854*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColoredLineData *linesEnd, float lineWidth,
855*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport)
856*35238bceSAndroid Build Coastguard Worker : LineRenderTestCase(context, name, description, linesBegin, linesEnd, lineWidth, viewport)
857*35238bceSAndroid Build Coastguard Worker {
858*35238bceSAndroid Build Coastguard Worker }
859*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::ConstPixelBufferAccess & testImageAccess,const tcu::ConstPixelBufferAccess & referenceImageAccess)860*35238bceSAndroid Build Coastguard Worker void ColoredLineCase::verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
861*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess)
862*35238bceSAndroid Build Coastguard Worker {
863*35238bceSAndroid Build Coastguard Worker const bool msaa = m_context.getRenderTarget().getNumSamples() > 1;
864*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
865*35238bceSAndroid Build Coastguard Worker
866*35238bceSAndroid Build Coastguard Worker if (!msaa)
867*35238bceSAndroid Build Coastguard Worker {
868*35238bceSAndroid Build Coastguard Worker const int kernelRadius = 1;
869*35238bceSAndroid Build Coastguard Worker const int faultyLimit = 6;
870*35238bceSAndroid Build Coastguard Worker int faultyPixels;
871*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
872*35238bceSAndroid Build Coastguard Worker
873*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
874*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed."
875*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
876*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
877*35238bceSAndroid Build Coastguard Worker
878*35238bceSAndroid Build Coastguard Worker faultyPixels =
879*35238bceSAndroid Build Coastguard Worker compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
880*35238bceSAndroid Build Coastguard Worker
881*35238bceSAndroid Build Coastguard Worker if (faultyPixels > faultyLimit)
882*35238bceSAndroid Build Coastguard Worker {
883*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
884*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testImageAccess)
885*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
886*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
887*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
888*35238bceSAndroid Build Coastguard Worker
889*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
890*35238bceSAndroid Build Coastguard Worker }
891*35238bceSAndroid Build Coastguard Worker }
892*35238bceSAndroid Build Coastguard Worker else
893*35238bceSAndroid Build Coastguard Worker {
894*35238bceSAndroid Build Coastguard Worker const float threshold = 0.3f;
895*35238bceSAndroid Build Coastguard Worker if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold,
896*35238bceSAndroid Build Coastguard Worker tcu::COMPARE_LOG_ON_ERROR))
897*35238bceSAndroid Build Coastguard Worker {
898*35238bceSAndroid Build Coastguard Worker if (m_lineWidth != 1.0f)
899*35238bceSAndroid Build Coastguard Worker {
900*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Wide line support is optional, reporting compatibility warning."
901*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
902*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Wide line clipping failed");
903*35238bceSAndroid Build Coastguard Worker }
904*35238bceSAndroid Build Coastguard Worker else
905*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
906*35238bceSAndroid Build Coastguard Worker }
907*35238bceSAndroid Build Coastguard Worker }
908*35238bceSAndroid Build Coastguard Worker }
909*35238bceSAndroid Build Coastguard Worker
910*35238bceSAndroid Build Coastguard Worker class TriangleCaseBase : public RenderTestCase
911*35238bceSAndroid Build Coastguard Worker {
912*35238bceSAndroid Build Coastguard Worker public:
913*35238bceSAndroid Build Coastguard Worker struct TriangleData
914*35238bceSAndroid Build Coastguard Worker {
915*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p0;
916*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c0;
917*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p1;
918*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c1;
919*35238bceSAndroid Build Coastguard Worker tcu::Vec4 p2;
920*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c2;
921*35238bceSAndroid Build Coastguard Worker };
922*35238bceSAndroid Build Coastguard Worker
923*35238bceSAndroid Build Coastguard Worker TriangleCaseBase(Context &context, const char *name, const char *description, const TriangleData *polysBegin,
924*35238bceSAndroid Build Coastguard Worker const TriangleData *polysEnd, const rr::WindowRectangle &viewport);
925*35238bceSAndroid Build Coastguard Worker
926*35238bceSAndroid Build Coastguard Worker virtual void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
927*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess) = DE_NULL;
928*35238bceSAndroid Build Coastguard Worker void testRender(void);
929*35238bceSAndroid Build Coastguard Worker
930*35238bceSAndroid Build Coastguard Worker private:
931*35238bceSAndroid Build Coastguard Worker const std::vector<TriangleData> m_polys;
932*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle m_viewport;
933*35238bceSAndroid Build Coastguard Worker };
934*35238bceSAndroid Build Coastguard Worker
TriangleCaseBase(Context & context,const char * name,const char * description,const TriangleData * polysBegin,const TriangleData * polysEnd,const rr::WindowRectangle & viewport)935*35238bceSAndroid Build Coastguard Worker TriangleCaseBase::TriangleCaseBase(Context &context, const char *name, const char *description,
936*35238bceSAndroid Build Coastguard Worker const TriangleData *polysBegin, const TriangleData *polysEnd,
937*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport)
938*35238bceSAndroid Build Coastguard Worker : RenderTestCase(context, name, description)
939*35238bceSAndroid Build Coastguard Worker , m_polys(polysBegin, polysEnd)
940*35238bceSAndroid Build Coastguard Worker , m_viewport(viewport)
941*35238bceSAndroid Build Coastguard Worker {
942*35238bceSAndroid Build Coastguard Worker }
943*35238bceSAndroid Build Coastguard Worker
testRender(void)944*35238bceSAndroid Build Coastguard Worker void TriangleCaseBase::testRender(void)
945*35238bceSAndroid Build Coastguard Worker {
946*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
947*35238bceSAndroid Build Coastguard Worker
948*35238bceSAndroid Build Coastguard Worker const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
949*35238bceSAndroid Build Coastguard Worker const int verticesPerTriangle = 3;
950*35238bceSAndroid Build Coastguard Worker
951*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
952*35238bceSAndroid Build Coastguard Worker sglr::GLContext glesContext(m_context.getRenderContext(), log, 0,
953*35238bceSAndroid Build Coastguard Worker tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
954*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextLimits limits;
955*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers buffers(m_context.getRenderTarget().getPixelFormat(),
956*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE,
957*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE, numSamples);
958*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext refContext(limits, buffers.getColorbuffer(), buffers.getDepthbuffer(),
959*35238bceSAndroid Build Coastguard Worker buffers.getStencilbuffer());
960*35238bceSAndroid Build Coastguard Worker PositionColorShader program;
961*35238bceSAndroid Build Coastguard Worker tcu::Surface testSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
962*35238bceSAndroid Build Coastguard Worker tcu::Surface refSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
963*35238bceSAndroid Build Coastguard Worker sglr::Context *contexts[2] = {&glesContext, &refContext};
964*35238bceSAndroid Build Coastguard Worker tcu::Surface *surfaces[2] = {&testSurface, &refSurface};
965*35238bceSAndroid Build Coastguard Worker
966*35238bceSAndroid Build Coastguard Worker // log the purpose of the test
967*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom
968*35238bceSAndroid Build Coastguard Worker << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
969*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage;
970*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < m_polys.size(); ++ndx)
971*35238bceSAndroid Build Coastguard Worker {
972*35238bceSAndroid Build Coastguard Worker const std::string v0Properties = genClippingPointInfoString(m_polys[ndx].p0);
973*35238bceSAndroid Build Coastguard Worker const std::string v1Properties = genClippingPointInfoString(m_polys[ndx].p1);
974*35238bceSAndroid Build Coastguard Worker const std::string v2Properties = genClippingPointInfoString(m_polys[ndx].p2);
975*35238bceSAndroid Build Coastguard Worker const std::string c0Properties = genColorString(m_polys[ndx].c0);
976*35238bceSAndroid Build Coastguard Worker const std::string c1Properties = genColorString(m_polys[ndx].c1);
977*35238bceSAndroid Build Coastguard Worker const std::string c2Properties = genColorString(m_polys[ndx].c2);
978*35238bceSAndroid Build Coastguard Worker
979*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv0 (x=" << m_polys[ndx].p0.x() << "\ty=" << m_polys[ndx].p0.y()
980*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_polys[ndx].p0.z() << "\tw=" << m_polys[ndx].p0.w() << ")\t" << v0Properties << "\t"
981*35238bceSAndroid Build Coastguard Worker << c0Properties << TestLog::EndMessage;
982*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv1 (x=" << m_polys[ndx].p1.x() << "\ty=" << m_polys[ndx].p1.y()
983*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_polys[ndx].p1.z() << "\tw=" << m_polys[ndx].p1.w() << ")\t" << v1Properties << "\t"
984*35238bceSAndroid Build Coastguard Worker << c1Properties << TestLog::EndMessage;
985*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv2 (x=" << m_polys[ndx].p2.x() << "\ty=" << m_polys[ndx].p2.y()
986*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_polys[ndx].p2.z() << "\tw=" << m_polys[ndx].p2.w() << ")\t" << v2Properties << "\t"
987*35238bceSAndroid Build Coastguard Worker << c2Properties << TestLog::EndMessage;
988*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
989*35238bceSAndroid Build Coastguard Worker }
990*35238bceSAndroid Build Coastguard Worker
991*35238bceSAndroid Build Coastguard Worker // render test image
992*35238bceSAndroid Build Coastguard Worker for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
993*35238bceSAndroid Build Coastguard Worker {
994*35238bceSAndroid Build Coastguard Worker sglr::Context &ctx = *contexts[contextNdx];
995*35238bceSAndroid Build Coastguard Worker tcu::Surface &dstSurface = *surfaces[contextNdx];
996*35238bceSAndroid Build Coastguard Worker const uint32_t programId = ctx.createProgram(&program);
997*35238bceSAndroid Build Coastguard Worker const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
998*35238bceSAndroid Build Coastguard Worker const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
999*35238bceSAndroid Build Coastguard Worker
1000*35238bceSAndroid Build Coastguard Worker ctx.clearColor(0, 0, 0, 1);
1001*35238bceSAndroid Build Coastguard Worker ctx.clearDepthf(1.0f);
1002*35238bceSAndroid Build Coastguard Worker ctx.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1003*35238bceSAndroid Build Coastguard Worker ctx.viewport(m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
1004*35238bceSAndroid Build Coastguard Worker ctx.useProgram(programId);
1005*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(positionLoc);
1006*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(colorLoc);
1007*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].p0);
1008*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].c0);
1009*35238bceSAndroid Build Coastguard Worker ctx.drawArrays(GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_polys.size());
1010*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(positionLoc);
1011*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(colorLoc);
1012*35238bceSAndroid Build Coastguard Worker ctx.useProgram(0);
1013*35238bceSAndroid Build Coastguard Worker ctx.deleteProgram(programId);
1014*35238bceSAndroid Build Coastguard Worker ctx.finish();
1015*35238bceSAndroid Build Coastguard Worker
1016*35238bceSAndroid Build Coastguard Worker ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1017*35238bceSAndroid Build Coastguard Worker }
1018*35238bceSAndroid Build Coastguard Worker
1019*35238bceSAndroid Build Coastguard Worker verifyImage(testSurface.getAccess(), refSurface.getAccess());
1020*35238bceSAndroid Build Coastguard Worker }
1021*35238bceSAndroid Build Coastguard Worker
1022*35238bceSAndroid Build Coastguard Worker class TriangleCase : public TriangleCaseBase
1023*35238bceSAndroid Build Coastguard Worker {
1024*35238bceSAndroid Build Coastguard Worker public:
1025*35238bceSAndroid Build Coastguard Worker TriangleCase(Context &context, const char *name, const char *description, const TriangleData *polysBegin,
1026*35238bceSAndroid Build Coastguard Worker const TriangleData *polysEnd, const rr::WindowRectangle &viewport);
1027*35238bceSAndroid Build Coastguard Worker
1028*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
1029*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess);
1030*35238bceSAndroid Build Coastguard Worker };
1031*35238bceSAndroid Build Coastguard Worker
TriangleCase(Context & context,const char * name,const char * description,const TriangleData * polysBegin,const TriangleData * polysEnd,const rr::WindowRectangle & viewport)1032*35238bceSAndroid Build Coastguard Worker TriangleCase::TriangleCase(Context &context, const char *name, const char *description, const TriangleData *polysBegin,
1033*35238bceSAndroid Build Coastguard Worker const TriangleData *polysEnd, const rr::WindowRectangle &viewport)
1034*35238bceSAndroid Build Coastguard Worker : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport)
1035*35238bceSAndroid Build Coastguard Worker {
1036*35238bceSAndroid Build Coastguard Worker }
1037*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::ConstPixelBufferAccess & testImageAccess,const tcu::ConstPixelBufferAccess & referenceImageAccess)1038*35238bceSAndroid Build Coastguard Worker void TriangleCase::verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
1039*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess)
1040*35238bceSAndroid Build Coastguard Worker {
1041*35238bceSAndroid Build Coastguard Worker const int kernelRadius = 1;
1042*35238bceSAndroid Build Coastguard Worker const int faultyLimit = 6;
1043*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
1044*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1045*35238bceSAndroid Build Coastguard Worker int faultyPixels;
1046*35238bceSAndroid Build Coastguard Worker
1047*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
1048*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
1049*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
1050*35238bceSAndroid Build Coastguard Worker
1051*35238bceSAndroid Build Coastguard Worker faultyPixels =
1052*35238bceSAndroid Build Coastguard Worker compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
1053*35238bceSAndroid Build Coastguard Worker
1054*35238bceSAndroid Build Coastguard Worker if (faultyPixels > faultyLimit)
1055*35238bceSAndroid Build Coastguard Worker {
1056*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
1057*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testImageAccess)
1058*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
1059*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
1060*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
1061*35238bceSAndroid Build Coastguard Worker
1062*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1063*35238bceSAndroid Build Coastguard Worker }
1064*35238bceSAndroid Build Coastguard Worker }
1065*35238bceSAndroid Build Coastguard Worker
1066*35238bceSAndroid Build Coastguard Worker class TriangleAttributeCase : public TriangleCaseBase
1067*35238bceSAndroid Build Coastguard Worker {
1068*35238bceSAndroid Build Coastguard Worker public:
1069*35238bceSAndroid Build Coastguard Worker TriangleAttributeCase(Context &context, const char *name, const char *description, const TriangleData *polysBegin,
1070*35238bceSAndroid Build Coastguard Worker const TriangleData *polysEnd, const rr::WindowRectangle &viewport);
1071*35238bceSAndroid Build Coastguard Worker
1072*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
1073*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess);
1074*35238bceSAndroid Build Coastguard Worker };
1075*35238bceSAndroid Build Coastguard Worker
TriangleAttributeCase(Context & context,const char * name,const char * description,const TriangleData * polysBegin,const TriangleData * polysEnd,const rr::WindowRectangle & viewport)1076*35238bceSAndroid Build Coastguard Worker TriangleAttributeCase::TriangleAttributeCase(Context &context, const char *name, const char *description,
1077*35238bceSAndroid Build Coastguard Worker const TriangleData *polysBegin, const TriangleData *polysEnd,
1078*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport)
1079*35238bceSAndroid Build Coastguard Worker : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport)
1080*35238bceSAndroid Build Coastguard Worker {
1081*35238bceSAndroid Build Coastguard Worker }
1082*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::ConstPixelBufferAccess & testImageAccess,const tcu::ConstPixelBufferAccess & referenceImageAccess)1083*35238bceSAndroid Build Coastguard Worker void TriangleAttributeCase::verifyImage(const tcu::ConstPixelBufferAccess &testImageAccess,
1084*35238bceSAndroid Build Coastguard Worker const tcu::ConstPixelBufferAccess &referenceImageAccess)
1085*35238bceSAndroid Build Coastguard Worker {
1086*35238bceSAndroid Build Coastguard Worker const bool msaa = m_context.getRenderTarget().getNumSamples() > 1;
1087*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
1088*35238bceSAndroid Build Coastguard Worker
1089*35238bceSAndroid Build Coastguard Worker if (!msaa)
1090*35238bceSAndroid Build Coastguard Worker {
1091*35238bceSAndroid Build Coastguard Worker const int kernelRadius = 1;
1092*35238bceSAndroid Build Coastguard Worker const int faultyLimit = 6;
1093*35238bceSAndroid Build Coastguard Worker int faultyPixels;
1094*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1095*35238bceSAndroid Build Coastguard Worker
1096*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
1097*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed."
1098*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1099*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
1100*35238bceSAndroid Build Coastguard Worker faultyPixels =
1101*35238bceSAndroid Build Coastguard Worker compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
1102*35238bceSAndroid Build Coastguard Worker
1103*35238bceSAndroid Build Coastguard Worker if (faultyPixels > faultyLimit)
1104*35238bceSAndroid Build Coastguard Worker {
1105*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
1106*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testImageAccess)
1107*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
1108*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
1109*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
1110*35238bceSAndroid Build Coastguard Worker
1111*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1112*35238bceSAndroid Build Coastguard Worker }
1113*35238bceSAndroid Build Coastguard Worker }
1114*35238bceSAndroid Build Coastguard Worker else
1115*35238bceSAndroid Build Coastguard Worker {
1116*35238bceSAndroid Build Coastguard Worker const float threshold = 0.3f;
1117*35238bceSAndroid Build Coastguard Worker if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold,
1118*35238bceSAndroid Build Coastguard Worker tcu::COMPARE_LOG_ON_ERROR))
1119*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1120*35238bceSAndroid Build Coastguard Worker }
1121*35238bceSAndroid Build Coastguard Worker }
1122*35238bceSAndroid Build Coastguard Worker
1123*35238bceSAndroid Build Coastguard Worker class FillTest : public RenderTestCase
1124*35238bceSAndroid Build Coastguard Worker {
1125*35238bceSAndroid Build Coastguard Worker public:
1126*35238bceSAndroid Build Coastguard Worker FillTest(Context &context, const char *name, const char *description, const rr::WindowRectangle &viewport);
1127*35238bceSAndroid Build Coastguard Worker
1128*35238bceSAndroid Build Coastguard Worker virtual void render(sglr::Context &ctx) = DE_NULL;
1129*35238bceSAndroid Build Coastguard Worker void testRender(void);
1130*35238bceSAndroid Build Coastguard Worker
1131*35238bceSAndroid Build Coastguard Worker protected:
1132*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle m_viewport;
1133*35238bceSAndroid Build Coastguard Worker };
1134*35238bceSAndroid Build Coastguard Worker
FillTest(Context & context,const char * name,const char * description,const rr::WindowRectangle & viewport)1135*35238bceSAndroid Build Coastguard Worker FillTest::FillTest(Context &context, const char *name, const char *description, const rr::WindowRectangle &viewport)
1136*35238bceSAndroid Build Coastguard Worker : RenderTestCase(context, name, description)
1137*35238bceSAndroid Build Coastguard Worker , m_viewport(viewport)
1138*35238bceSAndroid Build Coastguard Worker {
1139*35238bceSAndroid Build Coastguard Worker }
1140*35238bceSAndroid Build Coastguard Worker
testRender(void)1141*35238bceSAndroid Build Coastguard Worker void FillTest::testRender(void)
1142*35238bceSAndroid Build Coastguard Worker {
1143*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
1144*35238bceSAndroid Build Coastguard Worker
1145*35238bceSAndroid Build Coastguard Worker const int numSamples = 1;
1146*35238bceSAndroid Build Coastguard Worker
1147*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
1148*35238bceSAndroid Build Coastguard Worker sglr::GLContext glesContext(m_context.getRenderContext(), log, 0,
1149*35238bceSAndroid Build Coastguard Worker tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
1150*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextLimits limits;
1151*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers buffers(m_context.getRenderTarget().getPixelFormat(),
1152*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE,
1153*35238bceSAndroid Build Coastguard Worker TEST_CANVAS_SIZE, numSamples);
1154*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext refContext(limits, buffers.getColorbuffer(), buffers.getDepthbuffer(),
1155*35238bceSAndroid Build Coastguard Worker buffers.getStencilbuffer());
1156*35238bceSAndroid Build Coastguard Worker tcu::Surface testSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1157*35238bceSAndroid Build Coastguard Worker tcu::Surface refSurface(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1158*35238bceSAndroid Build Coastguard Worker
1159*35238bceSAndroid Build Coastguard Worker render(glesContext);
1160*35238bceSAndroid Build Coastguard Worker glesContext.readPixels(testSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1161*35238bceSAndroid Build Coastguard Worker
1162*35238bceSAndroid Build Coastguard Worker render(refContext);
1163*35238bceSAndroid Build Coastguard Worker refContext.readPixels(refSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1164*35238bceSAndroid Build Coastguard Worker
1165*35238bceSAndroid Build Coastguard Worker // check overdraw
1166*35238bceSAndroid Build Coastguard Worker {
1167*35238bceSAndroid Build Coastguard Worker bool overdrawOk;
1168*35238bceSAndroid Build Coastguard Worker tcu::Surface outputImage(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1169*35238bceSAndroid Build Coastguard Worker
1170*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Checking for overdraw " << TestLog::EndMessage;
1171*35238bceSAndroid Build Coastguard Worker overdrawOk = checkHalfFilledImageOverdraw(log, m_context.getRenderTarget(), testSurface.getAccess(),
1172*35238bceSAndroid Build Coastguard Worker outputImage.getAccess());
1173*35238bceSAndroid Build Coastguard Worker
1174*35238bceSAndroid Build Coastguard Worker if (!overdrawOk)
1175*35238bceSAndroid Build Coastguard Worker {
1176*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
1177*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
1178*35238bceSAndroid Build Coastguard Worker << TestLog::Image("InvalidPixels", "Invalid pixels", outputImage.getAccess()) << TestLog::EndImageSet
1179*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got overdraw." << tcu::TestLog::EndMessage;
1180*35238bceSAndroid Build Coastguard Worker
1181*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got overdraw");
1182*35238bceSAndroid Build Coastguard Worker }
1183*35238bceSAndroid Build Coastguard Worker }
1184*35238bceSAndroid Build Coastguard Worker
1185*35238bceSAndroid Build Coastguard Worker // compare & check missing pixels
1186*35238bceSAndroid Build Coastguard Worker {
1187*35238bceSAndroid Build Coastguard Worker const int kernelRadius = 1;
1188*35238bceSAndroid Build Coastguard Worker tcu::Surface diffMask(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1189*35238bceSAndroid Build Coastguard Worker int faultyPixels;
1190*35238bceSAndroid Build Coastguard Worker
1191*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
1192*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed."
1193*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1194*35238bceSAndroid Build Coastguard Worker
1195*35238bceSAndroid Build Coastguard Worker blitImageOnBlackSurface(refSurface.getAccess(), refSurface.getAccess()); // makes images look right in Candy
1196*35238bceSAndroid Build Coastguard Worker
1197*35238bceSAndroid Build Coastguard Worker faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(),
1198*35238bceSAndroid Build Coastguard Worker diffMask.getAccess(), kernelRadius);
1199*35238bceSAndroid Build Coastguard Worker
1200*35238bceSAndroid Build Coastguard Worker if (faultyPixels > 0)
1201*35238bceSAndroid Build Coastguard Worker {
1202*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("Images", "Image comparison")
1203*35238bceSAndroid Build Coastguard Worker << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
1204*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess())
1205*35238bceSAndroid Build Coastguard Worker << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) << TestLog::EndImageSet
1206*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
1207*35238bceSAndroid Build Coastguard Worker
1208*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1209*35238bceSAndroid Build Coastguard Worker }
1210*35238bceSAndroid Build Coastguard Worker }
1211*35238bceSAndroid Build Coastguard Worker }
1212*35238bceSAndroid Build Coastguard Worker
1213*35238bceSAndroid Build Coastguard Worker class TriangleFillTest : public FillTest
1214*35238bceSAndroid Build Coastguard Worker {
1215*35238bceSAndroid Build Coastguard Worker public:
1216*35238bceSAndroid Build Coastguard Worker struct FillTriangle
1217*35238bceSAndroid Build Coastguard Worker {
1218*35238bceSAndroid Build Coastguard Worker tcu::Vec4 v0;
1219*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c0;
1220*35238bceSAndroid Build Coastguard Worker tcu::Vec4 v1;
1221*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c1;
1222*35238bceSAndroid Build Coastguard Worker tcu::Vec4 v2;
1223*35238bceSAndroid Build Coastguard Worker tcu::Vec4 c2;
1224*35238bceSAndroid Build Coastguard Worker };
1225*35238bceSAndroid Build Coastguard Worker
1226*35238bceSAndroid Build Coastguard Worker TriangleFillTest(Context &context, const char *name, const char *description, const rr::WindowRectangle &viewport);
1227*35238bceSAndroid Build Coastguard Worker
1228*35238bceSAndroid Build Coastguard Worker void render(sglr::Context &ctx);
1229*35238bceSAndroid Build Coastguard Worker
1230*35238bceSAndroid Build Coastguard Worker protected:
1231*35238bceSAndroid Build Coastguard Worker std::vector<FillTriangle> m_triangles;
1232*35238bceSAndroid Build Coastguard Worker };
1233*35238bceSAndroid Build Coastguard Worker
TriangleFillTest(Context & context,const char * name,const char * description,const rr::WindowRectangle & viewport)1234*35238bceSAndroid Build Coastguard Worker TriangleFillTest::TriangleFillTest(Context &context, const char *name, const char *description,
1235*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport)
1236*35238bceSAndroid Build Coastguard Worker : FillTest(context, name, description, viewport)
1237*35238bceSAndroid Build Coastguard Worker {
1238*35238bceSAndroid Build Coastguard Worker }
1239*35238bceSAndroid Build Coastguard Worker
render(sglr::Context & ctx)1240*35238bceSAndroid Build Coastguard Worker void TriangleFillTest::render(sglr::Context &ctx)
1241*35238bceSAndroid Build Coastguard Worker {
1242*35238bceSAndroid Build Coastguard Worker const int verticesPerTriangle = 3;
1243*35238bceSAndroid Build Coastguard Worker PositionColorShader program;
1244*35238bceSAndroid Build Coastguard Worker const uint32_t programId = ctx.createProgram(&program);
1245*35238bceSAndroid Build Coastguard Worker const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
1246*35238bceSAndroid Build Coastguard Worker const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
1247*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
1248*35238bceSAndroid Build Coastguard Worker
1249*35238bceSAndroid Build Coastguard Worker // log the purpose of the test
1250*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom
1251*35238bceSAndroid Build Coastguard Worker << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
1252*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage;
1253*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < m_triangles.size(); ++ndx)
1254*35238bceSAndroid Build Coastguard Worker {
1255*35238bceSAndroid Build Coastguard Worker const std::string v0Properties = genClippingPointInfoString(m_triangles[ndx].v0);
1256*35238bceSAndroid Build Coastguard Worker const std::string v1Properties = genClippingPointInfoString(m_triangles[ndx].v1);
1257*35238bceSAndroid Build Coastguard Worker const std::string v2Properties = genClippingPointInfoString(m_triangles[ndx].v2);
1258*35238bceSAndroid Build Coastguard Worker
1259*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv0 (x=" << m_triangles[ndx].v0.x() << "\ty=" << m_triangles[ndx].v0.y()
1260*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_triangles[ndx].v0.z() << "\tw=" << m_triangles[ndx].v0.w() << ")\t" << v0Properties
1261*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1262*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv1 (x=" << m_triangles[ndx].v1.x() << "\ty=" << m_triangles[ndx].v1.y()
1263*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_triangles[ndx].v1.z() << "\tw=" << m_triangles[ndx].v1.w() << ")\t" << v1Properties
1264*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1265*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "\tv2 (x=" << m_triangles[ndx].v2.x() << "\ty=" << m_triangles[ndx].v2.y()
1266*35238bceSAndroid Build Coastguard Worker << "\tz=" << m_triangles[ndx].v2.z() << "\tw=" << m_triangles[ndx].v2.w() << ")\t" << v2Properties
1267*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1268*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
1269*35238bceSAndroid Build Coastguard Worker }
1270*35238bceSAndroid Build Coastguard Worker
1271*35238bceSAndroid Build Coastguard Worker ctx.clearColor(0, 0, 0, 1);
1272*35238bceSAndroid Build Coastguard Worker ctx.clearDepthf(1.0f);
1273*35238bceSAndroid Build Coastguard Worker ctx.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1274*35238bceSAndroid Build Coastguard Worker ctx.viewport(m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
1275*35238bceSAndroid Build Coastguard Worker ctx.useProgram(programId);
1276*35238bceSAndroid Build Coastguard Worker ctx.blendFunc(GL_ONE, GL_ONE);
1277*35238bceSAndroid Build Coastguard Worker ctx.enable(GL_BLEND);
1278*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(positionLoc);
1279*35238bceSAndroid Build Coastguard Worker ctx.enableVertexAttribArray(colorLoc);
1280*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].v0);
1281*35238bceSAndroid Build Coastguard Worker ctx.vertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].c0);
1282*35238bceSAndroid Build Coastguard Worker ctx.drawArrays(GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_triangles.size());
1283*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(positionLoc);
1284*35238bceSAndroid Build Coastguard Worker ctx.disableVertexAttribArray(colorLoc);
1285*35238bceSAndroid Build Coastguard Worker ctx.useProgram(0);
1286*35238bceSAndroid Build Coastguard Worker ctx.deleteProgram(programId);
1287*35238bceSAndroid Build Coastguard Worker ctx.finish();
1288*35238bceSAndroid Build Coastguard Worker }
1289*35238bceSAndroid Build Coastguard Worker
1290*35238bceSAndroid Build Coastguard Worker class QuadFillTest : public TriangleFillTest
1291*35238bceSAndroid Build Coastguard Worker {
1292*35238bceSAndroid Build Coastguard Worker public:
1293*35238bceSAndroid Build Coastguard Worker QuadFillTest(Context &context, const char *name, const char *description, const rr::WindowRectangle &viewport,
1294*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 &d1, const tcu::Vec3 &d2, const tcu::Vec3 ¢er_ = tcu::Vec3(0, 0, 0));
1295*35238bceSAndroid Build Coastguard Worker };
1296*35238bceSAndroid Build Coastguard Worker
QuadFillTest(Context & context,const char * name,const char * description,const rr::WindowRectangle & viewport,const tcu::Vec3 & d1,const tcu::Vec3 & d2,const tcu::Vec3 & center_)1297*35238bceSAndroid Build Coastguard Worker QuadFillTest::QuadFillTest(Context &context, const char *name, const char *description,
1298*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport, const tcu::Vec3 &d1, const tcu::Vec3 &d2,
1299*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 ¢er_)
1300*35238bceSAndroid Build Coastguard Worker : TriangleFillTest(context, name, description, viewport)
1301*35238bceSAndroid Build Coastguard Worker {
1302*35238bceSAndroid Build Coastguard Worker const float radius = 40000.0f;
1303*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 center = tcu::Vec4(center_.x(), center_.y(), center_.z(), 1.0f);
1304*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f);
1305*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 halfRed = tcu::Vec4(0.5f, 0.0f, 0.0f, 0.5f);
1306*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 e1 = radius * tcu::Vec4(d1.x(), d1.y(), d1.z(), 0.0f);
1307*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 e2 = radius * tcu::Vec4(d2.x(), d2.y(), d2.z(), 0.0f);
1308*35238bceSAndroid Build Coastguard Worker
1309*35238bceSAndroid Build Coastguard Worker FillTriangle triangle1;
1310*35238bceSAndroid Build Coastguard Worker FillTriangle triangle2;
1311*35238bceSAndroid Build Coastguard Worker
1312*35238bceSAndroid Build Coastguard Worker triangle1.c0 = halfWhite;
1313*35238bceSAndroid Build Coastguard Worker triangle1.c1 = halfWhite;
1314*35238bceSAndroid Build Coastguard Worker triangle1.c2 = halfWhite;
1315*35238bceSAndroid Build Coastguard Worker triangle1.v0 = center + e1 + e2;
1316*35238bceSAndroid Build Coastguard Worker triangle1.v1 = center + e1 - e2;
1317*35238bceSAndroid Build Coastguard Worker triangle1.v2 = center - e1 - e2;
1318*35238bceSAndroid Build Coastguard Worker m_triangles.push_back(triangle1);
1319*35238bceSAndroid Build Coastguard Worker
1320*35238bceSAndroid Build Coastguard Worker triangle2.c0 = halfRed;
1321*35238bceSAndroid Build Coastguard Worker triangle2.c1 = halfRed;
1322*35238bceSAndroid Build Coastguard Worker triangle2.c2 = halfRed;
1323*35238bceSAndroid Build Coastguard Worker triangle2.v0 = center + e1 + e2;
1324*35238bceSAndroid Build Coastguard Worker triangle2.v1 = center - e1 - e2;
1325*35238bceSAndroid Build Coastguard Worker triangle2.v2 = center - e1 + e2;
1326*35238bceSAndroid Build Coastguard Worker m_triangles.push_back(triangle2);
1327*35238bceSAndroid Build Coastguard Worker }
1328*35238bceSAndroid Build Coastguard Worker
1329*35238bceSAndroid Build Coastguard Worker class TriangleFanFillTest : public TriangleFillTest
1330*35238bceSAndroid Build Coastguard Worker {
1331*35238bceSAndroid Build Coastguard Worker public:
1332*35238bceSAndroid Build Coastguard Worker TriangleFanFillTest(Context &context, const char *name, const char *description,
1333*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport);
1334*35238bceSAndroid Build Coastguard Worker };
1335*35238bceSAndroid Build Coastguard Worker
TriangleFanFillTest(Context & context,const char * name,const char * description,const rr::WindowRectangle & viewport)1336*35238bceSAndroid Build Coastguard Worker TriangleFanFillTest::TriangleFanFillTest(Context &context, const char *name, const char *description,
1337*35238bceSAndroid Build Coastguard Worker const rr::WindowRectangle &viewport)
1338*35238bceSAndroid Build Coastguard Worker : TriangleFillTest(context, name, description, viewport)
1339*35238bceSAndroid Build Coastguard Worker {
1340*35238bceSAndroid Build Coastguard Worker const float radius = 70000.0f;
1341*35238bceSAndroid Build Coastguard Worker const int trianglesPerVisit = 40;
1342*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 center = tcu::Vec4(0, 0, 0, 1.0f);
1343*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f);
1344*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 oddSliceColor = tcu::Vec4(0.0f, 0.0f, 0.5f, 0.0f);
1345*35238bceSAndroid Build Coastguard Worker
1346*35238bceSAndroid Build Coastguard Worker // create a continuous surface that goes through all 6 clip planes
1347*35238bceSAndroid Build Coastguard Worker
1348*35238bceSAndroid Build Coastguard Worker /*
1349*35238bceSAndroid Build Coastguard Worker * / /
1350*35238bceSAndroid Build Coastguard Worker * /_ _ _ _ _ /x
1351*35238bceSAndroid Build Coastguard Worker * | | |
1352*35238bceSAndroid Build Coastguard Worker * | | /
1353*35238bceSAndroid Build Coastguard Worker * | / --xe /
1354*35238bceSAndroid Build Coastguard Worker * | | | /
1355*35238bceSAndroid Build Coastguard Worker * |_ _ _ e _ _|/
1356*35238bceSAndroid Build Coastguard Worker *
1357*35238bceSAndroid Build Coastguard Worker * e = enter
1358*35238bceSAndroid Build Coastguard Worker * x = exit
1359*35238bceSAndroid Build Coastguard Worker */
1360*35238bceSAndroid Build Coastguard Worker const struct ClipPlaneVisit
1361*35238bceSAndroid Build Coastguard Worker {
1362*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 corner;
1363*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 entryPoint;
1364*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 exitPoint;
1365*35238bceSAndroid Build Coastguard Worker } visits[] = {
1366*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, 1, 1), tcu::Vec3(0, 1, 1), tcu::Vec3(1, 0, 1)},
1367*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, -1, 1), tcu::Vec3(1, 0, 1), tcu::Vec3(1, -1, 0)},
1368*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, -1, -1), tcu::Vec3(1, -1, 0), tcu::Vec3(0, -1, -1)},
1369*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(-1, -1, -1), tcu::Vec3(0, -1, -1), tcu::Vec3(-1, 0, -1)},
1370*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(-1, 1, -1), tcu::Vec3(-1, 0, -1), tcu::Vec3(-1, 1, 0)},
1371*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(-1, 1, 1), tcu::Vec3(-1, 1, 0), tcu::Vec3(0, 1, 1)},
1372*35238bceSAndroid Build Coastguard Worker };
1373*35238bceSAndroid Build Coastguard Worker
1374*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(visits); ++ndx)
1375*35238bceSAndroid Build Coastguard Worker {
1376*35238bceSAndroid Build Coastguard Worker const ClipPlaneVisit &visit = visits[ndx];
1377*35238bceSAndroid Build Coastguard Worker
1378*35238bceSAndroid Build Coastguard Worker for (int tri = 0; tri < trianglesPerVisit; ++tri)
1379*35238bceSAndroid Build Coastguard Worker {
1380*35238bceSAndroid Build Coastguard Worker tcu::Vec3 vertex0;
1381*35238bceSAndroid Build Coastguard Worker tcu::Vec3 vertex1;
1382*35238bceSAndroid Build Coastguard Worker
1383*35238bceSAndroid Build Coastguard Worker if (tri == 0) // first vertex is magic
1384*35238bceSAndroid Build Coastguard Worker {
1385*35238bceSAndroid Build Coastguard Worker vertex0 = visit.entryPoint;
1386*35238bceSAndroid Build Coastguard Worker }
1387*35238bceSAndroid Build Coastguard Worker else
1388*35238bceSAndroid Build Coastguard Worker {
1389*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 v1 = visit.entryPoint - visit.corner;
1390*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 v2 = visit.exitPoint - visit.corner;
1391*35238bceSAndroid Build Coastguard Worker
1392*35238bceSAndroid Build Coastguard Worker vertex0 = visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri) / trianglesPerVisit)));
1393*35238bceSAndroid Build Coastguard Worker }
1394*35238bceSAndroid Build Coastguard Worker
1395*35238bceSAndroid Build Coastguard Worker if (tri == trianglesPerVisit - 1) // last vertex is magic
1396*35238bceSAndroid Build Coastguard Worker {
1397*35238bceSAndroid Build Coastguard Worker vertex1 = visit.exitPoint;
1398*35238bceSAndroid Build Coastguard Worker }
1399*35238bceSAndroid Build Coastguard Worker else
1400*35238bceSAndroid Build Coastguard Worker {
1401*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 v1 = visit.entryPoint - visit.corner;
1402*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 v2 = visit.exitPoint - visit.corner;
1403*35238bceSAndroid Build Coastguard Worker
1404*35238bceSAndroid Build Coastguard Worker vertex1 =
1405*35238bceSAndroid Build Coastguard Worker visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri + 1) / trianglesPerVisit)));
1406*35238bceSAndroid Build Coastguard Worker }
1407*35238bceSAndroid Build Coastguard Worker
1408*35238bceSAndroid Build Coastguard Worker // write vec out
1409*35238bceSAndroid Build Coastguard Worker {
1410*35238bceSAndroid Build Coastguard Worker FillTriangle triangle;
1411*35238bceSAndroid Build Coastguard Worker
1412*35238bceSAndroid Build Coastguard Worker triangle.c0 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1413*35238bceSAndroid Build Coastguard Worker triangle.c1 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1414*35238bceSAndroid Build Coastguard Worker triangle.c2 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1415*35238bceSAndroid Build Coastguard Worker triangle.v0 = center;
1416*35238bceSAndroid Build Coastguard Worker triangle.v1 = tcu::Vec4(vertex0.x() * radius, vertex0.y() * radius, vertex0.z() * radius, 1.0f);
1417*35238bceSAndroid Build Coastguard Worker triangle.v2 = tcu::Vec4(vertex1.x() * radius, vertex1.y() * radius, vertex1.z() * radius, 1.0f);
1418*35238bceSAndroid Build Coastguard Worker
1419*35238bceSAndroid Build Coastguard Worker m_triangles.push_back(triangle);
1420*35238bceSAndroid Build Coastguard Worker }
1421*35238bceSAndroid Build Coastguard Worker }
1422*35238bceSAndroid Build Coastguard Worker }
1423*35238bceSAndroid Build Coastguard Worker }
1424*35238bceSAndroid Build Coastguard Worker
1425*35238bceSAndroid Build Coastguard Worker class PointsTestGroup : public TestCaseGroup
1426*35238bceSAndroid Build Coastguard Worker {
1427*35238bceSAndroid Build Coastguard Worker public:
1428*35238bceSAndroid Build Coastguard Worker PointsTestGroup(Context &context);
1429*35238bceSAndroid Build Coastguard Worker
1430*35238bceSAndroid Build Coastguard Worker void init(void);
1431*35238bceSAndroid Build Coastguard Worker };
1432*35238bceSAndroid Build Coastguard Worker
PointsTestGroup(Context & context)1433*35238bceSAndroid Build Coastguard Worker PointsTestGroup::PointsTestGroup(Context &context) : TestCaseGroup(context, "point", "Point clipping tests")
1434*35238bceSAndroid Build Coastguard Worker {
1435*35238bceSAndroid Build Coastguard Worker }
1436*35238bceSAndroid Build Coastguard Worker
init(void)1437*35238bceSAndroid Build Coastguard Worker void PointsTestGroup::init(void)
1438*35238bceSAndroid Build Coastguard Worker {
1439*35238bceSAndroid Build Coastguard Worker const float littleOverViewport =
1440*35238bceSAndroid Build Coastguard Worker 1.0f +
1441*35238bceSAndroid Build Coastguard Worker (2.0f /
1442*35238bceSAndroid Build Coastguard Worker (TEST_CANVAS_SIZE)); // one pixel over the viewport edge in VIEWPORT_WHOLE, half pixels over in the reduced viewport.
1443*35238bceSAndroid Build Coastguard Worker
1444*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 viewportTestPoints[] = {
1445*35238bceSAndroid Build Coastguard Worker // in clip volume
1446*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),
1447*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f),
1448*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f),
1449*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f),
1450*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.1f, -0.1f, -0.1f, 1.0f),
1451*35238bceSAndroid Build Coastguard Worker
1452*35238bceSAndroid Build Coastguard Worker // in clip volume with w != 1
1453*35238bceSAndroid Build Coastguard Worker tcu::Vec4(2.0f, 2.0f, 2.0f, 3.0f),
1454*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-2.0f, -2.0f, 2.0f, 3.0f),
1455*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.5f, -0.5f, 0.5f, 0.7f),
1456*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.5f, 0.5f, -0.5f, 0.7f),
1457*35238bceSAndroid Build Coastguard Worker
1458*35238bceSAndroid Build Coastguard Worker // near the edge
1459*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-2.0f, -2.0f, 0.0f, 2.2f),
1460*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, -1.0f, 0.0f, 1.1f),
1461*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.1f),
1462*35238bceSAndroid Build Coastguard Worker
1463*35238bceSAndroid Build Coastguard Worker // not in the volume but still between near and far planes
1464*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.3f, 0.0f, 0.0f, 1.0f),
1465*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.3f, 0.0f, 0.0f, 1.0f),
1466*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, 1.3f, 0.0f, 1.0f),
1467*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -1.3f, 0.0f, 1.0f),
1468*35238bceSAndroid Build Coastguard Worker
1469*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.3f, -1.3f, 0.0f, 1.0f),
1470*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.3f, 1.3f, 0.0f, 1.0f),
1471*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.3f, 1.3f, 0.0f, 1.0f),
1472*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.3f, -1.3f, 0.0f, 1.0f),
1473*35238bceSAndroid Build Coastguard Worker
1474*35238bceSAndroid Build Coastguard Worker // outside the viewport, wide points have fragments in the viewport
1475*35238bceSAndroid Build Coastguard Worker tcu::Vec4(littleOverViewport, littleOverViewport, 0.0f, 1.0f),
1476*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, littleOverViewport, 0.0f, 1.0f),
1477*35238bceSAndroid Build Coastguard Worker tcu::Vec4(littleOverViewport, 0.0f, 0.0f, 1.0f),
1478*35238bceSAndroid Build Coastguard Worker };
1479*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 depthTestPoints[] = {// in clip volume
1480*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.1f, 0.1f, 0.1f, 1.0f),
1481*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f), tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f),
1482*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.1f, -0.1f, -0.1f, 1.0f),
1483*35238bceSAndroid Build Coastguard Worker
1484*35238bceSAndroid Build Coastguard Worker // not between the near and the far planes. These should be clipped
1485*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.1f, 0.0f, 1.1f, 1.0f), tcu::Vec4(-0.1f, 0.0f, -1.1f, 1.0f),
1486*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.0f, -0.1f, 1.1f, 1.0f), tcu::Vec4(0.0f, 0.1f, -1.1f, 1.0f)};
1487*35238bceSAndroid Build Coastguard Worker
1488*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints),
1489*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_WHOLE));
1490*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "point_z_clip_viewport_center", "point z clipping",
1491*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_CENTER));
1492*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "point_z_clip_viewport_corner", "point z clipping",
1493*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_CORNER));
1494*35238bceSAndroid Build Coastguard Worker
1495*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "point_clip_viewport_center", "point viewport clipping",
1496*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f,
1497*35238bceSAndroid Build Coastguard Worker VIEWPORT_CENTER));
1498*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "point_clip_viewport_corner", "point viewport clipping",
1499*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f,
1500*35238bceSAndroid Build Coastguard Worker VIEWPORT_CORNER));
1501*35238bceSAndroid Build Coastguard Worker
1502*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints),
1503*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_WHOLE));
1504*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_z_clip_viewport_center", "point z clipping",
1505*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_CENTER));
1506*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_z_clip_viewport_corner", "point z clipping",
1507*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_CORNER));
1508*35238bceSAndroid Build Coastguard Worker
1509*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_clip", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints),
1510*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(viewportTestPoints), 5.0f, VIEWPORT_WHOLE));
1511*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_clip_viewport_center", "point viewport clipping",
1512*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f,
1513*35238bceSAndroid Build Coastguard Worker VIEWPORT_CENTER));
1514*35238bceSAndroid Build Coastguard Worker addChild(new PointCase(m_context, "wide_point_clip_viewport_corner", "point viewport clipping",
1515*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f,
1516*35238bceSAndroid Build Coastguard Worker VIEWPORT_CORNER));
1517*35238bceSAndroid Build Coastguard Worker }
1518*35238bceSAndroid Build Coastguard Worker
1519*35238bceSAndroid Build Coastguard Worker class LinesTestGroup : public TestCaseGroup
1520*35238bceSAndroid Build Coastguard Worker {
1521*35238bceSAndroid Build Coastguard Worker public:
1522*35238bceSAndroid Build Coastguard Worker LinesTestGroup(Context &context);
1523*35238bceSAndroid Build Coastguard Worker
1524*35238bceSAndroid Build Coastguard Worker void init(void);
1525*35238bceSAndroid Build Coastguard Worker };
1526*35238bceSAndroid Build Coastguard Worker
LinesTestGroup(Context & context)1527*35238bceSAndroid Build Coastguard Worker LinesTestGroup::LinesTestGroup(Context &context) : TestCaseGroup(context, "line", "Line clipping tests")
1528*35238bceSAndroid Build Coastguard Worker {
1529*35238bceSAndroid Build Coastguard Worker }
1530*35238bceSAndroid Build Coastguard Worker
init(void)1531*35238bceSAndroid Build Coastguard Worker void LinesTestGroup::init(void)
1532*35238bceSAndroid Build Coastguard Worker {
1533*35238bceSAndroid Build Coastguard Worker const float littleOverViewport =
1534*35238bceSAndroid Build Coastguard Worker 1.0f +
1535*35238bceSAndroid Build Coastguard Worker (2.0f /
1536*35238bceSAndroid Build Coastguard Worker (TEST_CANVAS_SIZE)); // one pixel over the viewport edge in VIEWPORT_WHOLE, half pixels over in the reduced viewport.
1537*35238bceSAndroid Build Coastguard Worker
1538*35238bceSAndroid Build Coastguard Worker // lines
1539*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData viewportTestLines[] = {
1540*35238bceSAndroid Build Coastguard Worker // from center to outside of viewport
1541*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 1.5f, 0.0f, 1.0f)},
1542*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 1.0f, 0.0f, 1.0f)},
1543*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 0.0f, 0.0f, 1.0f)},
1544*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.2f, 0.4f, 1.5f, 1.0f)},
1545*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-2.0f, -1.0f, 0.0f, 1.0f)},
1546*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.1f, 0.0f, 0.6f)},
1547*35238bceSAndroid Build Coastguard Worker
1548*35238bceSAndroid Build Coastguard Worker // from outside to inside of viewport
1549*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(1.5f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.8f, -0.2f, 0.0f, 1.0f)},
1550*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, -1.5f, 0.0f, 1.0f), tcu::Vec4(0.9f, -0.7f, 0.0f, 1.0f)},
1551*35238bceSAndroid Build Coastguard Worker
1552*35238bceSAndroid Build Coastguard Worker // from outside to outside
1553*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, -1.3f, 0.0f, 1.0f), tcu::Vec4(1.3f, 0.0f, 0.0f, 1.0f)},
1554*35238bceSAndroid Build Coastguard Worker
1555*35238bceSAndroid Build Coastguard Worker // outside the viewport, wide lines have fragments in the viewport
1556*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.8f, -littleOverViewport, 0.0f, 1.0f), tcu::Vec4(0.0f, -littleOverViewport, 0.0f, 1.0f)},
1557*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-littleOverViewport - 1.0f, 0.0f, 0.0f, 1.0f),
1558*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -littleOverViewport - 1.0f, 0.0f, 1.0f)},
1559*35238bceSAndroid Build Coastguard Worker };
1560*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData depthTestLines[] = {
1561*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.3f, 1.0f, 2.0f, 1.0f)},
1562*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.3f, -1.0f, 2.0f, 1.0f)},
1563*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, -1.1f, -2.0f, 1.0f)},
1564*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, 1.1f, -2.0f, 1.0f)},
1565*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.1f, 2.0f, 0.6f)},
1566*35238bceSAndroid Build Coastguard Worker };
1567*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColorlessLineData longTestLines[] = {
1568*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-41000.0f, -40000.0f, -1000000.0f, 1.0f), tcu::Vec4(41000.0f, 40000.0f, 1000000.0f, 1.0f)},
1569*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(41000.0f, -40000.0f, 1000000.0f, 1.0f), tcu::Vec4(-41000.0f, 40000.0f, -1000000.0f, 1.0f)},
1570*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.5f, -40000.0f, 100000.0f, 1.0f), tcu::Vec4(0.5f, 40000.0f, -100000.0f, 1.0f)},
1571*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.5f, 40000.0f, 100000.0f, 1.0f), tcu::Vec4(-0.5f, -40000.0f, -100000.0f, 1.0f)},
1572*35238bceSAndroid Build Coastguard Worker };
1573*35238bceSAndroid Build Coastguard Worker
1574*35238bceSAndroid Build Coastguard Worker // line attribute clipping
1575*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 red(1.0f, 0.0f, 0.0f, 1.0f);
1576*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 yellow(1.0f, 1.0f, 0.0f, 1.0f);
1577*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 lightBlue(0.3f, 0.3f, 1.0f, 1.0f);
1578*35238bceSAndroid Build Coastguard Worker const LineRenderTestCase::ColoredLineData colorTestLines[] = {
1579*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(1.3f, 1.0f, 2.0f, 1.0f), yellow},
1580*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(1.3f, -1.0f, 2.0f, 1.0f), lightBlue},
1581*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, -1.0f, -2.0f, 1.0f), yellow},
1582*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, 1.0f, -2.0f, 1.0f), lightBlue},
1583*35238bceSAndroid Build Coastguard Worker };
1584*35238bceSAndroid Build Coastguard Worker
1585*35238bceSAndroid Build Coastguard Worker // line clipping
1586*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines),
1587*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_WHOLE));
1588*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "line_z_clip_viewport_center", "line z clipping", DE_ARRAY_BEGIN(depthTestLines),
1589*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_CENTER));
1590*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "line_z_clip_viewport_corner", "line z clipping", DE_ARRAY_BEGIN(depthTestLines),
1591*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_CORNER));
1592*35238bceSAndroid Build Coastguard Worker
1593*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "line_clip_viewport_center", "line viewport clipping",
1594*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CENTER));
1595*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "line_clip_viewport_corner", "line viewport clipping",
1596*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CORNER));
1597*35238bceSAndroid Build Coastguard Worker
1598*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines),
1599*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_WHOLE));
1600*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_z_clip_viewport_center", "line z clipping",
1601*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_CENTER));
1602*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_z_clip_viewport_corner", "line z clipping",
1603*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_CORNER));
1604*35238bceSAndroid Build Coastguard Worker
1605*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines),
1606*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_WHOLE));
1607*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_clip_viewport_center", "line viewport clipping",
1608*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_CENTER));
1609*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "wide_line_clip_viewport_corner", "line viewport clipping",
1610*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_CORNER));
1611*35238bceSAndroid Build Coastguard Worker
1612*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "long_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(longTestLines),
1613*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(longTestLines), 1.0f, VIEWPORT_WHOLE, 2));
1614*35238bceSAndroid Build Coastguard Worker addChild(new LineCase(m_context, "long_wide_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(longTestLines),
1615*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(longTestLines), 5.0f, VIEWPORT_WHOLE, 2));
1616*35238bceSAndroid Build Coastguard Worker
1617*35238bceSAndroid Build Coastguard Worker // line attribute clipping
1618*35238bceSAndroid Build Coastguard Worker addChild(new ColoredLineCase(m_context, "line_attrib_clip", "line attribute clipping",
1619*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 1.0f, VIEWPORT_WHOLE));
1620*35238bceSAndroid Build Coastguard Worker addChild(new ColoredLineCase(m_context, "wide_line_attrib_clip", "line attribute clipping",
1621*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 5.0f, VIEWPORT_WHOLE));
1622*35238bceSAndroid Build Coastguard Worker }
1623*35238bceSAndroid Build Coastguard Worker
1624*35238bceSAndroid Build Coastguard Worker class PolysTestGroup : public TestCaseGroup
1625*35238bceSAndroid Build Coastguard Worker {
1626*35238bceSAndroid Build Coastguard Worker public:
1627*35238bceSAndroid Build Coastguard Worker PolysTestGroup(Context &context);
1628*35238bceSAndroid Build Coastguard Worker
1629*35238bceSAndroid Build Coastguard Worker void init(void);
1630*35238bceSAndroid Build Coastguard Worker };
1631*35238bceSAndroid Build Coastguard Worker
PolysTestGroup(Context & context)1632*35238bceSAndroid Build Coastguard Worker PolysTestGroup::PolysTestGroup(Context &context) : TestCaseGroup(context, "polygon", "Polygon clipping tests")
1633*35238bceSAndroid Build Coastguard Worker {
1634*35238bceSAndroid Build Coastguard Worker }
1635*35238bceSAndroid Build Coastguard Worker
init(void)1636*35238bceSAndroid Build Coastguard Worker void PolysTestGroup::init(void)
1637*35238bceSAndroid Build Coastguard Worker {
1638*35238bceSAndroid Build Coastguard Worker const float large = 100000.0f;
1639*35238bceSAndroid Build Coastguard Worker const float offset = 0.9f;
1640*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white(1.0f, 1.0f, 1.0f, 1.0f);
1641*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 red(1.0f, 0.0f, 0.0f, 1.0f);
1642*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 yellow(1.0f, 1.0f, 0.0f, 1.0f);
1643*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 blue(0.0f, 0.0f, 1.0f, 1.0f);
1644*35238bceSAndroid Build Coastguard Worker
1645*35238bceSAndroid Build Coastguard Worker // basic cases
1646*35238bceSAndroid Build Coastguard Worker {
1647*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData viewportPolys[] = {
1648*35238bceSAndroid Build Coastguard Worker // one vertex clipped
1649*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.8f, -0.2f, 0.0f, 1.0f), white, tcu::Vec4(-0.8f, 0.2f, 0.0f, 1.0f), white,
1650*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.3f, 0.05f, 0.0f, 1.0f), white},
1651*35238bceSAndroid Build Coastguard Worker
1652*35238bceSAndroid Build Coastguard Worker // two vertices clipped
1653*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), white, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), white,
1654*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), white},
1655*35238bceSAndroid Build Coastguard Worker
1656*35238bceSAndroid Build Coastguard Worker // three vertices clipped
1657*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.1f, 0.6f, 0.0f, 1.0f), white, tcu::Vec4(-1.1f, 1.1f, 0.0f, 1.0f), white,
1658*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 1.1f, 0.0f, 1.0f), white},
1659*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.8f, 1.1f, 0.0f, 1.0f), white, tcu::Vec4(0.95f, -1.1f, 0.0f, 1.0f), white,
1660*35238bceSAndroid Build Coastguard Worker tcu::Vec4(3.0f, 0.0f, 0.0f, 1.0f), white},
1661*35238bceSAndroid Build Coastguard Worker };
1662*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData depthPolys[] = {
1663*35238bceSAndroid Build Coastguard Worker // one vertex clipped to Z+
1664*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, 0.7f, 0.0f, 1.0f), white, tcu::Vec4(0.2f, 0.7f, 0.0f, 1.0f), white,
1665*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, 0.9f, 2.0f, 1.0f), white},
1666*35238bceSAndroid Build Coastguard Worker
1667*35238bceSAndroid Build Coastguard Worker // two vertices clipped to Z-
1668*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.9f, 0.4f, -1.5f, 1.0f), white, tcu::Vec4(0.9f, -0.4f, -1.5f, 1.0f), white,
1669*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.0f, 0.0f, 1.0f), white},
1670*35238bceSAndroid Build Coastguard Worker
1671*35238bceSAndroid Build Coastguard Worker // three vertices clipped
1672*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.9f, 0.6f, -2.0f, 1.0f), white, tcu::Vec4(-0.9f, -0.6f, -2.0f, 1.0f), white,
1673*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.4f, 0.0f, 2.0f, 1.0f), white},
1674*35238bceSAndroid Build Coastguard Worker
1675*35238bceSAndroid Build Coastguard Worker // three vertices clipped by X, Y and Z
1676*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, -1.2f, 0.0f, 1.0f), white, tcu::Vec4(0.0f, 0.5f, -1.5f, 1.0f), white,
1677*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.2f, -0.9f, 0.0f, 1.0f), white},
1678*35238bceSAndroid Build Coastguard Worker };
1679*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData largePolys[] = {
1680*35238bceSAndroid Build Coastguard Worker // one vertex clipped
1681*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), white,
1682*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -large, 2.0f, 1.0f), white},
1683*35238bceSAndroid Build Coastguard Worker
1684*35238bceSAndroid Build Coastguard Worker // two vertices clipped
1685*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.5f, 0.5f, 0.0f, 1.0f), white, tcu::Vec4(large, 0.5f, 0.0f, 1.0f), white,
1686*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.5f, large, 0.0f, 1.0f), white},
1687*35238bceSAndroid Build Coastguard Worker
1688*35238bceSAndroid Build Coastguard Worker // three vertices clipped
1689*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.9f, -large, 0.0f, 1.0f), white, tcu::Vec4(-1.1f, -large, 0.0f, 1.0f), white,
1690*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.9f, large, 0.0f, 1.0f), white},
1691*35238bceSAndroid Build Coastguard Worker };
1692*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData largeDepthPolys[] = {
1693*35238bceSAndroid Build Coastguard Worker // one vertex clipped
1694*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), white,
1695*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -large, large, 1.0f), white},
1696*35238bceSAndroid Build Coastguard Worker
1697*35238bceSAndroid Build Coastguard Worker // two vertices clipped
1698*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.5f, 0.5f, 0.0f, 1.0f), white, tcu::Vec4(0.9f, large / 2, -large, 1.0f), white,
1699*35238bceSAndroid Build Coastguard Worker tcu::Vec4(large / 4, 0.0f, -large, 1.0f), white},
1700*35238bceSAndroid Build Coastguard Worker
1701*35238bceSAndroid Build Coastguard Worker // three vertices clipped
1702*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.9f, large / 4, large, 1.0f), white, tcu::Vec4(-0.5f, -large / 4, -large, 1.0f), white,
1703*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.2f, large / 4, large, 1.0f), white},
1704*35238bceSAndroid Build Coastguard Worker };
1705*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData attribPolys[] = {
1706*35238bceSAndroid Build Coastguard Worker // one vertex clipped to edge, large
1707*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1708*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -large, 2.0f, 1.0f), blue},
1709*35238bceSAndroid Build Coastguard Worker
1710*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1711*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1712*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1713*35238bceSAndroid Build Coastguard Worker
1714*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges, with non-uniform w
1715*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1716*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1717*35238bceSAndroid Build Coastguard Worker
1718*35238bceSAndroid Build Coastguard Worker // three vertices clipped, large, Z
1719*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.9f, large / 4, large, 1.0f), red, tcu::Vec4(-0.5f, -large / 4, -large, 1.0f), yellow,
1720*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.2f, large / 4, large, 1.0f), blue},
1721*35238bceSAndroid Build Coastguard Worker };
1722*35238bceSAndroid Build Coastguard Worker
1723*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "poly_clip_viewport_center", "polygon viewport clipping",
1724*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CENTER));
1725*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "poly_clip_viewport_corner", "polygon viewport clipping",
1726*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CORNER));
1727*35238bceSAndroid Build Coastguard Worker
1728*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys),
1729*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(depthPolys), VIEWPORT_WHOLE));
1730*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "poly_z_clip_viewport_center", "polygon z clipping",
1731*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CENTER));
1732*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "poly_z_clip_viewport_corner", "polygon z clipping",
1733*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CORNER));
1734*35238bceSAndroid Build Coastguard Worker
1735*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "large_poly_clip_viewport_center", "polygon viewport clipping",
1736*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CENTER));
1737*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "large_poly_clip_viewport_corner", "polygon viewport clipping",
1738*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CORNER));
1739*35238bceSAndroid Build Coastguard Worker
1740*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "large_poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys),
1741*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(largeDepthPolys), VIEWPORT_WHOLE));
1742*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_center", "polygon z clipping",
1743*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CENTER));
1744*35238bceSAndroid Build Coastguard Worker addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_corner", "polygon z clipping",
1745*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CORNER));
1746*35238bceSAndroid Build Coastguard Worker
1747*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip", "polygon clipping",
1748*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_WHOLE));
1749*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_center", "polygon clipping",
1750*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CENTER));
1751*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_corner", "polygon clipping",
1752*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CORNER));
1753*35238bceSAndroid Build Coastguard Worker }
1754*35238bceSAndroid Build Coastguard Worker
1755*35238bceSAndroid Build Coastguard Worker // multiple polygons
1756*35238bceSAndroid Build Coastguard Worker {
1757*35238bceSAndroid Build Coastguard Worker {
1758*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1759*35238bceSAndroid Build Coastguard Worker // one vertex clipped to edge
1760*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1761*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
1762*35238bceSAndroid Build Coastguard Worker
1763*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1764*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1765*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1766*35238bceSAndroid Build Coastguard Worker
1767*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges, with non-uniform w
1768*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1769*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1770*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1771*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1772*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1773*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1774*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1775*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1776*35238bceSAndroid Build Coastguard Worker
1777*35238bceSAndroid Build Coastguard Worker // three vertices clipped, Z
1778*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.9f, offset / 4, offset, 1.0f), red, tcu::Vec4(-0.5f, -offset / 4, -offset, 1.0f), yellow,
1779*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.2f, offset / 4, offset, 1.0f), blue},
1780*35238bceSAndroid Build Coastguard Worker };
1781*35238bceSAndroid Build Coastguard Worker
1782*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_0", "polygon clipping", DE_ARRAY_BEGIN(polys),
1783*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1784*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_center", "polygon clipping",
1785*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1786*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_corner", "polygon clipping",
1787*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1788*35238bceSAndroid Build Coastguard Worker }
1789*35238bceSAndroid Build Coastguard Worker
1790*35238bceSAndroid Build Coastguard Worker {
1791*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1792*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1793*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1794*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
1795*35238bceSAndroid Build Coastguard Worker
1796*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1797*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1798*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1799*35238bceSAndroid Build Coastguard Worker
1800*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges, with non-uniform w
1801*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1802*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1803*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1804*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1805*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1806*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1807*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1808*35238bceSAndroid Build Coastguard Worker 16.0f * tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1809*35238bceSAndroid Build Coastguard Worker };
1810*35238bceSAndroid Build Coastguard Worker
1811*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_1", "polygon clipping", DE_ARRAY_BEGIN(polys),
1812*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1813*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_center", "polygon clipping",
1814*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1815*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_corner", "polygon clipping",
1816*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1817*35238bceSAndroid Build Coastguard Worker }
1818*35238bceSAndroid Build Coastguard Worker
1819*35238bceSAndroid Build Coastguard Worker {
1820*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1821*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1822*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1823*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
1824*35238bceSAndroid Build Coastguard Worker
1825*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1826*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1827*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1828*35238bceSAndroid Build Coastguard Worker
1829*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1830*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1831*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1832*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1833*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1834*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1835*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1836*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1837*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1838*35238bceSAndroid Build Coastguard Worker };
1839*35238bceSAndroid Build Coastguard Worker
1840*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_2", "polygon clipping", DE_ARRAY_BEGIN(polys),
1841*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1842*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_center", "polygon clipping",
1843*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1844*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_corner", "polygon clipping",
1845*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1846*35238bceSAndroid Build Coastguard Worker }
1847*35238bceSAndroid Build Coastguard Worker
1848*35238bceSAndroid Build Coastguard Worker {
1849*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1850*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1851*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1852*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, -2.0f, 1.0f), blue},
1853*35238bceSAndroid Build Coastguard Worker
1854*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1855*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1856*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1857*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1858*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1859*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1860*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1861*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1862*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1863*35238bceSAndroid Build Coastguard Worker };
1864*35238bceSAndroid Build Coastguard Worker
1865*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_3", "polygon clipping", DE_ARRAY_BEGIN(polys),
1866*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1867*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_center", "polygon clipping",
1868*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1869*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_corner", "polygon clipping",
1870*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1871*35238bceSAndroid Build Coastguard Worker }
1872*35238bceSAndroid Build Coastguard Worker
1873*35238bceSAndroid Build Coastguard Worker {
1874*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1875*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1876*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.3f, 0.2f, 0.0f, 1.0f), red, tcu::Vec4(0.3f, -0.2f, 0.0f, 1.0f), yellow,
1877*35238bceSAndroid Build Coastguard Worker tcu::Vec4(offset, 0.0f, 2.0f, 1.0f), blue},
1878*35238bceSAndroid Build Coastguard Worker
1879*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1880*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1881*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1882*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1883*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1884*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1885*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1886*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1887*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1888*35238bceSAndroid Build Coastguard Worker };
1889*35238bceSAndroid Build Coastguard Worker
1890*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_4", "polygon clipping", DE_ARRAY_BEGIN(polys),
1891*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1892*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_center", "polygon clipping",
1893*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1894*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_corner", "polygon clipping",
1895*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1896*35238bceSAndroid Build Coastguard Worker }
1897*35238bceSAndroid Build Coastguard Worker
1898*35238bceSAndroid Build Coastguard Worker {
1899*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1900*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1901*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.3f, 0.2f, 0.0f, 1.0f), red, tcu::Vec4(-0.3f, -0.2f, 0.0f, 1.0f), yellow,
1902*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-offset, 0.0f, 2.0f, 1.0f), blue},
1903*35238bceSAndroid Build Coastguard Worker
1904*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1905*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1906*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1907*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1908*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1909*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1910*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1911*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1912*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1913*35238bceSAndroid Build Coastguard Worker };
1914*35238bceSAndroid Build Coastguard Worker
1915*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_5", "polygon clipping", DE_ARRAY_BEGIN(polys),
1916*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1917*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_center", "polygon clipping",
1918*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1919*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_corner", "polygon clipping",
1920*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1921*35238bceSAndroid Build Coastguard Worker }
1922*35238bceSAndroid Build Coastguard Worker
1923*35238bceSAndroid Build Coastguard Worker {
1924*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1925*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1926*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, 0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, 0.3f, 0.0f, 1.0f), yellow,
1927*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, offset, 2.0f, 1.0f), blue},
1928*35238bceSAndroid Build Coastguard Worker
1929*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1930*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1931*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1932*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1933*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1934*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1935*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1936*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1937*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1938*35238bceSAndroid Build Coastguard Worker };
1939*35238bceSAndroid Build Coastguard Worker
1940*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_6", "polygon clipping", DE_ARRAY_BEGIN(polys),
1941*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1942*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_center", "polygon clipping",
1943*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1944*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_corner", "polygon clipping",
1945*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1946*35238bceSAndroid Build Coastguard Worker }
1947*35238bceSAndroid Build Coastguard Worker
1948*35238bceSAndroid Build Coastguard Worker {
1949*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1950*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1951*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1952*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1953*35238bceSAndroid Build Coastguard Worker
1954*35238bceSAndroid Build Coastguard Worker // two vertices clipped to edges
1955*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, -0.6f, 0.0f, 1.0f), yellow,
1956*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, -0.6f, 0.0f, 1.0f), blue},
1957*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(1.2f, 0.6f, 0.0f, 1.0f), yellow,
1958*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.6f, 0.6f, 0.0f, 1.0f), blue},
1959*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow,
1960*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1961*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow,
1962*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1963*35238bceSAndroid Build Coastguard Worker };
1964*35238bceSAndroid Build Coastguard Worker
1965*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_7", "polygon clipping", DE_ARRAY_BEGIN(polys),
1966*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1967*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_center", "polygon clipping",
1968*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1969*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_corner", "polygon clipping",
1970*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1971*35238bceSAndroid Build Coastguard Worker }
1972*35238bceSAndroid Build Coastguard Worker
1973*35238bceSAndroid Build Coastguard Worker {
1974*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1975*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1976*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1977*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
1978*35238bceSAndroid Build Coastguard Worker
1979*35238bceSAndroid Build Coastguard Worker // fill
1980*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), white,
1981*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), white},
1982*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), blue, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), blue,
1983*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), blue},
1984*35238bceSAndroid Build Coastguard Worker };
1985*35238bceSAndroid Build Coastguard Worker
1986*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_8", "polygon clipping", DE_ARRAY_BEGIN(polys),
1987*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1988*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_center", "polygon clipping",
1989*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1990*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_corner", "polygon clipping",
1991*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1992*35238bceSAndroid Build Coastguard Worker }
1993*35238bceSAndroid Build Coastguard Worker
1994*35238bceSAndroid Build Coastguard Worker {
1995*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
1996*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
1997*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
1998*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
1999*35238bceSAndroid Build Coastguard Worker
2000*35238bceSAndroid Build Coastguard Worker // fill
2001*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), red,
2002*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), red},
2003*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), blue,
2004*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), blue},
2005*35238bceSAndroid Build Coastguard Worker };
2006*35238bceSAndroid Build Coastguard Worker
2007*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_9", "polygon clipping", DE_ARRAY_BEGIN(polys),
2008*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
2009*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_center", "polygon clipping",
2010*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
2011*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_corner", "polygon clipping",
2012*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
2013*35238bceSAndroid Build Coastguard Worker }
2014*35238bceSAndroid Build Coastguard Worker
2015*35238bceSAndroid Build Coastguard Worker {
2016*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
2017*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
2018*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
2019*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
2020*35238bceSAndroid Build Coastguard Worker
2021*35238bceSAndroid Build Coastguard Worker // fill
2022*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), white,
2023*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), white},
2024*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), red,
2025*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), red},
2026*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), blue,
2027*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), blue},
2028*35238bceSAndroid Build Coastguard Worker };
2029*35238bceSAndroid Build Coastguard Worker
2030*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_10", "polygon clipping", DE_ARRAY_BEGIN(polys),
2031*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
2032*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_center", "polygon clipping",
2033*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
2034*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_corner", "polygon clipping",
2035*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
2036*35238bceSAndroid Build Coastguard Worker }
2037*35238bceSAndroid Build Coastguard Worker
2038*35238bceSAndroid Build Coastguard Worker {
2039*35238bceSAndroid Build Coastguard Worker const TriangleAttributeCase::TriangleData polys[] = {
2040*35238bceSAndroid Build Coastguard Worker // one vertex clipped to z
2041*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4(0.2f, -0.3f, 0.0f, 1.0f), yellow,
2042*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.0f, -offset, 2.0f, 1.0f), blue},
2043*35238bceSAndroid Build Coastguard Worker
2044*35238bceSAndroid Build Coastguard Worker // fill
2045*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), white,
2046*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), white},
2047*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), red,
2048*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), red},
2049*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), blue,
2050*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), blue},
2051*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f), yellow, tcu::Vec4(1.0f, -1.0f, 0.0f, 1.0f), yellow,
2052*35238bceSAndroid Build Coastguard Worker tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), yellow},
2053*35238bceSAndroid Build Coastguard Worker };
2054*35238bceSAndroid Build Coastguard Worker
2055*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_11", "polygon clipping", DE_ARRAY_BEGIN(polys),
2056*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(polys), VIEWPORT_WHOLE));
2057*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_center", "polygon clipping",
2058*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
2059*35238bceSAndroid Build Coastguard Worker addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_corner", "polygon clipping",
2060*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
2061*35238bceSAndroid Build Coastguard Worker }
2062*35238bceSAndroid Build Coastguard Worker }
2063*35238bceSAndroid Build Coastguard Worker }
2064*35238bceSAndroid Build Coastguard Worker
2065*35238bceSAndroid Build Coastguard Worker class PolyEdgesTestGroup : public TestCaseGroup
2066*35238bceSAndroid Build Coastguard Worker {
2067*35238bceSAndroid Build Coastguard Worker public:
2068*35238bceSAndroid Build Coastguard Worker PolyEdgesTestGroup(Context &context);
2069*35238bceSAndroid Build Coastguard Worker
2070*35238bceSAndroid Build Coastguard Worker void init(void);
2071*35238bceSAndroid Build Coastguard Worker };
2072*35238bceSAndroid Build Coastguard Worker
PolyEdgesTestGroup(Context & context)2073*35238bceSAndroid Build Coastguard Worker PolyEdgesTestGroup::PolyEdgesTestGroup(Context &context)
2074*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "polygon_edge", "Polygon clipping edge tests")
2075*35238bceSAndroid Build Coastguard Worker {
2076*35238bceSAndroid Build Coastguard Worker }
2077*35238bceSAndroid Build Coastguard Worker
init(void)2078*35238bceSAndroid Build Coastguard Worker void PolyEdgesTestGroup::init(void)
2079*35238bceSAndroid Build Coastguard Worker {
2080*35238bceSAndroid Build Coastguard Worker // Quads via origin
2081*35238bceSAndroid Build Coastguard Worker const struct Quad
2082*35238bceSAndroid Build Coastguard Worker {
2083*35238bceSAndroid Build Coastguard Worker tcu::Vec3 d1; // tangent
2084*35238bceSAndroid Build Coastguard Worker tcu::Vec3 d2; // bi-tangent
2085*35238bceSAndroid Build Coastguard Worker } quads[] = {
2086*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, 1, 1), tcu::Vec3(1, -1, 1)}, {tcu::Vec3(1, 1, 1), tcu::Vec3(-1, 1.1f, 1)},
2087*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, 1, 0), tcu::Vec3(-1, 1, 0)}, {tcu::Vec3(0, 1, 0), tcu::Vec3(1, 0, 0)},
2088*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(0, 1, 0), tcu::Vec3(1, 0.1f, 0)},
2089*35238bceSAndroid Build Coastguard Worker };
2090*35238bceSAndroid Build Coastguard Worker
2091*35238bceSAndroid Build Coastguard Worker // Quad near edge
2092*35238bceSAndroid Build Coastguard Worker const struct EdgeQuad
2093*35238bceSAndroid Build Coastguard Worker {
2094*35238bceSAndroid Build Coastguard Worker tcu::Vec3 d1; // tangent
2095*35238bceSAndroid Build Coastguard Worker tcu::Vec3 d2; // bi-tangent
2096*35238bceSAndroid Build Coastguard Worker tcu::Vec3 center; // center
2097*35238bceSAndroid Build Coastguard Worker } edgeQuads[] = {
2098*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, 0.01f, 0), tcu::Vec3(0, 0.01f, 0), tcu::Vec3(0, 0.99f, 0)}, // edge near x-plane
2099*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(0.01f, 1, 0), tcu::Vec3(0.01f, 0, 0), tcu::Vec3(0.99f, 0, 0)}, // edge near y-plane
2100*35238bceSAndroid Build Coastguard Worker {tcu::Vec3(1, 1, 0.01f), tcu::Vec3(0.01f, -0.01f, 0), tcu::Vec3(0, 0, 0.99f)}, // edge near z-plane
2101*35238bceSAndroid Build Coastguard Worker };
2102*35238bceSAndroid Build Coastguard Worker
2103*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(quads); ++ndx)
2104*35238bceSAndroid Build Coastguard Worker addChild(new QuadFillTest(m_context, (std::string("quad_at_origin_") + de::toString(ndx)).c_str(),
2105*35238bceSAndroid Build Coastguard Worker "polygon edge clipping", VIEWPORT_CENTER, quads[ndx].d1, quads[ndx].d2));
2106*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(edgeQuads); ++ndx)
2107*35238bceSAndroid Build Coastguard Worker addChild(new QuadFillTest(m_context, (std::string("quad_near_edge_") + de::toString(ndx)).c_str(),
2108*35238bceSAndroid Build Coastguard Worker "polygon edge clipping", VIEWPORT_CENTER, edgeQuads[ndx].d1, edgeQuads[ndx].d2,
2109*35238bceSAndroid Build Coastguard Worker edgeQuads[ndx].center));
2110*35238bceSAndroid Build Coastguard Worker
2111*35238bceSAndroid Build Coastguard Worker // Polyfan
2112*35238bceSAndroid Build Coastguard Worker addChild(new TriangleFanFillTest(m_context, "poly_fan", "polygon edge clipping", VIEWPORT_CENTER));
2113*35238bceSAndroid Build Coastguard Worker }
2114*35238bceSAndroid Build Coastguard Worker
2115*35238bceSAndroid Build Coastguard Worker class PolyVertexClipTestGroup : public TestCaseGroup
2116*35238bceSAndroid Build Coastguard Worker {
2117*35238bceSAndroid Build Coastguard Worker public:
2118*35238bceSAndroid Build Coastguard Worker PolyVertexClipTestGroup(Context &context);
2119*35238bceSAndroid Build Coastguard Worker
2120*35238bceSAndroid Build Coastguard Worker void init(void);
2121*35238bceSAndroid Build Coastguard Worker };
2122*35238bceSAndroid Build Coastguard Worker
PolyVertexClipTestGroup(Context & context)2123*35238bceSAndroid Build Coastguard Worker PolyVertexClipTestGroup::PolyVertexClipTestGroup(Context &context)
2124*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "triangle_vertex", "Clip n vertices")
2125*35238bceSAndroid Build Coastguard Worker {
2126*35238bceSAndroid Build Coastguard Worker }
2127*35238bceSAndroid Build Coastguard Worker
init(void)2128*35238bceSAndroid Build Coastguard Worker void PolyVertexClipTestGroup::init(void)
2129*35238bceSAndroid Build Coastguard Worker {
2130*35238bceSAndroid Build Coastguard Worker const float far = 30000.0f;
2131*35238bceSAndroid Build Coastguard Worker const float farForThreeVertex = 20000.0f; // 3 vertex clipping tests use smaller triangles
2132*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 outside[] = {
2133*35238bceSAndroid Build Coastguard Worker // outside one clipping plane
2134*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 0, 0),
2135*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 0, 0),
2136*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, 1, 0),
2137*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, -1, 0),
2138*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, 0, 1),
2139*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, 0, -1),
2140*35238bceSAndroid Build Coastguard Worker
2141*35238bceSAndroid Build Coastguard Worker // outside two clipping planes
2142*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, -1, 0),
2143*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, -1, 0),
2144*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 1, 0),
2145*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 1, 0),
2146*35238bceSAndroid Build Coastguard Worker
2147*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 0, -1),
2148*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 0, -1),
2149*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 0, 1),
2150*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 0, 1),
2151*35238bceSAndroid Build Coastguard Worker
2152*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, -1, -1),
2153*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, 1, -1),
2154*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, 1, 1),
2155*35238bceSAndroid Build Coastguard Worker tcu::IVec3(0, -1, 1),
2156*35238bceSAndroid Build Coastguard Worker
2157*35238bceSAndroid Build Coastguard Worker // outside three clipping planes
2158*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, -1, 1),
2159*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, -1, 1),
2160*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 1, 1),
2161*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 1, 1),
2162*35238bceSAndroid Build Coastguard Worker
2163*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, -1, -1),
2164*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, -1, -1),
2165*35238bceSAndroid Build Coastguard Worker tcu::IVec3(1, 1, -1),
2166*35238bceSAndroid Build Coastguard Worker tcu::IVec3(-1, 1, -1),
2167*35238bceSAndroid Build Coastguard Worker };
2168*35238bceSAndroid Build Coastguard Worker
2169*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
2170*35238bceSAndroid Build Coastguard Worker
2171*35238bceSAndroid Build Coastguard Worker TestCaseGroup *clipOne = new TestCaseGroup(m_context, "clip_one", "Clip one vertex");
2172*35238bceSAndroid Build Coastguard Worker TestCaseGroup *clipTwo = new TestCaseGroup(m_context, "clip_two", "Clip two vertices");
2173*35238bceSAndroid Build Coastguard Worker TestCaseGroup *clipThree = new TestCaseGroup(m_context, "clip_three", "Clip three vertices");
2174*35238bceSAndroid Build Coastguard Worker
2175*35238bceSAndroid Build Coastguard Worker addChild(clipOne);
2176*35238bceSAndroid Build Coastguard Worker addChild(clipTwo);
2177*35238bceSAndroid Build Coastguard Worker addChild(clipThree);
2178*35238bceSAndroid Build Coastguard Worker
2179*35238bceSAndroid Build Coastguard Worker // Test 1 point clipped
2180*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(outside); ++ndx)
2181*35238bceSAndroid Build Coastguard Worker {
2182*35238bceSAndroid Build Coastguard Worker const float w0 = rnd.getFloat(0.2f, 16.0f);
2183*35238bceSAndroid Build Coastguard Worker const float w1 = rnd.getFloat(0.2f, 16.0f);
2184*35238bceSAndroid Build Coastguard Worker const float w2 = rnd.getFloat(0.2f, 16.0f);
2185*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white = tcu::Vec4(1, 1, 1, 1);
2186*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 r0 = tcu::Vec3(0.2f, 0.3f, 0);
2187*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 r1 = tcu::Vec3(-0.3f, -0.4f, 0);
2188*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 r2 = IVec3ToVec3(outside[ndx]) * far;
2189*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0);
2190*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p1 = tcu::Vec4(r1.x() * w1, r1.y() * w1, r1.z() * w1, w1);
2191*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p2 = tcu::Vec4(r2.x() * w2, r2.y() * w2, r2.z() * w2, w2);
2192*35238bceSAndroid Build Coastguard Worker
2193*35238bceSAndroid Build Coastguard Worker const std::string name = std::string("clip") +
2194*35238bceSAndroid Build Coastguard Worker (outside[ndx].x() > 0 ? "_pos_x" : (outside[ndx].x() < 0 ? "_neg_x" : "")) +
2195*35238bceSAndroid Build Coastguard Worker (outside[ndx].y() > 0 ? "_pos_y" : (outside[ndx].y() < 0 ? "_neg_y" : "")) +
2196*35238bceSAndroid Build Coastguard Worker (outside[ndx].z() > 0 ? "_pos_z" : (outside[ndx].z() < 0 ? "_neg_z" : ""));
2197*35238bceSAndroid Build Coastguard Worker
2198*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
2199*35238bceSAndroid Build Coastguard Worker
2200*35238bceSAndroid Build Coastguard Worker // don't try to test with degenerate (or almost degenerate) triangles
2201*35238bceSAndroid Build Coastguard Worker if (outside[ndx].x() == 0 && outside[ndx].y() == 0)
2202*35238bceSAndroid Build Coastguard Worker continue;
2203*35238bceSAndroid Build Coastguard Worker
2204*35238bceSAndroid Build Coastguard Worker clipOne->addChild(
2205*35238bceSAndroid Build Coastguard Worker new TriangleCase(m_context, name.c_str(), "clip one vertex", &triangle, &triangle + 1, VIEWPORT_CENTER));
2206*35238bceSAndroid Build Coastguard Worker }
2207*35238bceSAndroid Build Coastguard Worker
2208*35238bceSAndroid Build Coastguard Worker // Special triangles for "clip_z" cases, default triangles is not good, since it has very small visible area => problems with MSAA
2209*35238bceSAndroid Build Coastguard Worker {
2210*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white = tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
2211*35238bceSAndroid Build Coastguard Worker
2212*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData posZTriangle = {tcu::Vec4(0.0f, -0.7f, -0.9f, 1.0f), white,
2213*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.8f, 0.0f, -0.7f, 1.0f), white,
2214*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.9f, 0.9f, 3.0f, 1.0f), white};
2215*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData negZTriangle = {tcu::Vec4(0.0f, -0.7f, 0.9f, 1.0f), white,
2216*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.4f, 0.0f, 0.7f, 1.0f), white,
2217*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.9f, 0.9f, -3.0f, 1.0f), white};
2218*35238bceSAndroid Build Coastguard Worker
2219*35238bceSAndroid Build Coastguard Worker clipOne->addChild(new TriangleCase(m_context, "clip_pos_z", "clip one vertex", &posZTriangle, &posZTriangle + 1,
2220*35238bceSAndroid Build Coastguard Worker VIEWPORT_CENTER));
2221*35238bceSAndroid Build Coastguard Worker clipOne->addChild(new TriangleCase(m_context, "clip_neg_z", "clip one vertex", &negZTriangle, &negZTriangle + 1,
2222*35238bceSAndroid Build Coastguard Worker VIEWPORT_CENTER));
2223*35238bceSAndroid Build Coastguard Worker }
2224*35238bceSAndroid Build Coastguard Worker
2225*35238bceSAndroid Build Coastguard Worker // Test 2 points clipped
2226*35238bceSAndroid Build Coastguard Worker for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1)
2227*35238bceSAndroid Build Coastguard Worker for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2)
2228*35238bceSAndroid Build Coastguard Worker {
2229*35238bceSAndroid Build Coastguard Worker const float w0 = rnd.getFloat(0.2f, 16.0f);
2230*35238bceSAndroid Build Coastguard Worker const float w1 = rnd.getFloat(0.2f, 16.0f);
2231*35238bceSAndroid Build Coastguard Worker const float w2 = rnd.getFloat(0.2f, 16.0f);
2232*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white = tcu::Vec4(1, 1, 1, 1);
2233*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 r0 = tcu::Vec3(0.2f, 0.3f, 0);
2234*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 r1 = outside[ndx1];
2235*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 r2 = outside[ndx2];
2236*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0);
2237*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p1 =
2238*35238bceSAndroid Build Coastguard Worker tcu::Vec4(float(r1.x()) * far * w1, float(r1.y()) * far * w1, float(r1.z()) * far * w1, w1);
2239*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p2 =
2240*35238bceSAndroid Build Coastguard Worker tcu::Vec4(float(r2.x()) * far * w2, float(r2.y()) * far * w2, float(r2.z()) * far * w2, w2);
2241*35238bceSAndroid Build Coastguard Worker
2242*35238bceSAndroid Build Coastguard Worker const std::string name =
2243*35238bceSAndroid Build Coastguard Worker std::string("clip") + (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) +
2244*35238bceSAndroid Build Coastguard Worker (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) +
2245*35238bceSAndroid Build Coastguard Worker (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) + "_and" +
2246*35238bceSAndroid Build Coastguard Worker (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) +
2247*35238bceSAndroid Build Coastguard Worker (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) +
2248*35238bceSAndroid Build Coastguard Worker (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : ""));
2249*35238bceSAndroid Build Coastguard Worker
2250*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
2251*35238bceSAndroid Build Coastguard Worker
2252*35238bceSAndroid Build Coastguard Worker if (twoPointClippedTriangleInvisible(r0, r1, r2))
2253*35238bceSAndroid Build Coastguard Worker continue;
2254*35238bceSAndroid Build Coastguard Worker
2255*35238bceSAndroid Build Coastguard Worker clipTwo->addChild(new TriangleCase(m_context, name.c_str(), "clip two vertices", &triangle, &triangle + 1,
2256*35238bceSAndroid Build Coastguard Worker VIEWPORT_CENTER));
2257*35238bceSAndroid Build Coastguard Worker }
2258*35238bceSAndroid Build Coastguard Worker
2259*35238bceSAndroid Build Coastguard Worker // Test 3 points clipped
2260*35238bceSAndroid Build Coastguard Worker for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1)
2261*35238bceSAndroid Build Coastguard Worker for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2)
2262*35238bceSAndroid Build Coastguard Worker for (int ndx3 = ndx2 + 1; ndx3 < DE_LENGTH_OF_ARRAY(outside); ++ndx3)
2263*35238bceSAndroid Build Coastguard Worker {
2264*35238bceSAndroid Build Coastguard Worker const float w0 = rnd.getFloat(0.2f, 16.0f);
2265*35238bceSAndroid Build Coastguard Worker const float w1 = rnd.getFloat(0.2f, 16.0f);
2266*35238bceSAndroid Build Coastguard Worker const float w2 = rnd.getFloat(0.2f, 16.0f);
2267*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 white = tcu::Vec4(1, 1, 1, 1);
2268*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 r0 = outside[ndx1];
2269*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 r1 = outside[ndx2];
2270*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 r2 = outside[ndx3];
2271*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p0 =
2272*35238bceSAndroid Build Coastguard Worker tcu::Vec4(float(r0.x()) * farForThreeVertex * w0, float(r0.y()) * farForThreeVertex * w0,
2273*35238bceSAndroid Build Coastguard Worker float(r0.z()) * farForThreeVertex * w0, w0);
2274*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p1 =
2275*35238bceSAndroid Build Coastguard Worker tcu::Vec4(float(r1.x()) * farForThreeVertex * w1, float(r1.y()) * farForThreeVertex * w1,
2276*35238bceSAndroid Build Coastguard Worker float(r1.z()) * farForThreeVertex * w1, w1);
2277*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 p2 =
2278*35238bceSAndroid Build Coastguard Worker tcu::Vec4(float(r2.x()) * farForThreeVertex * w2, float(r2.y()) * farForThreeVertex * w2,
2279*35238bceSAndroid Build Coastguard Worker float(r2.z()) * farForThreeVertex * w2, w2);
2280*35238bceSAndroid Build Coastguard Worker
2281*35238bceSAndroid Build Coastguard Worker // ignore cases where polygon is along xz or yz planes
2282*35238bceSAndroid Build Coastguard Worker if (pointsOnLine(r0.swizzle(0, 1), r1.swizzle(0, 1), r2.swizzle(0, 1)))
2283*35238bceSAndroid Build Coastguard Worker continue;
2284*35238bceSAndroid Build Coastguard Worker
2285*35238bceSAndroid Build Coastguard Worker // triangle is visible only if it intersects the origin
2286*35238bceSAndroid Build Coastguard Worker if (pointOnTriangle(tcu::IVec3(0, 0, 0), r0, r1, r2))
2287*35238bceSAndroid Build Coastguard Worker {
2288*35238bceSAndroid Build Coastguard Worker const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
2289*35238bceSAndroid Build Coastguard Worker const std::string name =
2290*35238bceSAndroid Build Coastguard Worker std::string("clip") +
2291*35238bceSAndroid Build Coastguard Worker (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) +
2292*35238bceSAndroid Build Coastguard Worker (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) +
2293*35238bceSAndroid Build Coastguard Worker (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) + "_and" +
2294*35238bceSAndroid Build Coastguard Worker (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) +
2295*35238bceSAndroid Build Coastguard Worker (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) +
2296*35238bceSAndroid Build Coastguard Worker (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : "")) + "_and" +
2297*35238bceSAndroid Build Coastguard Worker (outside[ndx3].x() > 0 ? "_pos_x" : (outside[ndx3].x() < 0 ? "_neg_x" : "")) +
2298*35238bceSAndroid Build Coastguard Worker (outside[ndx3].y() > 0 ? "_pos_y" : (outside[ndx3].y() < 0 ? "_neg_y" : "")) +
2299*35238bceSAndroid Build Coastguard Worker (outside[ndx3].z() > 0 ? "_pos_z" : (outside[ndx3].z() < 0 ? "_neg_z" : ""));
2300*35238bceSAndroid Build Coastguard Worker
2301*35238bceSAndroid Build Coastguard Worker clipThree->addChild(new TriangleCase(m_context, name.c_str(), "clip three vertices", &triangle,
2302*35238bceSAndroid Build Coastguard Worker &triangle + 1, VIEWPORT_CENTER));
2303*35238bceSAndroid Build Coastguard Worker }
2304*35238bceSAndroid Build Coastguard Worker }
2305*35238bceSAndroid Build Coastguard Worker }
2306*35238bceSAndroid Build Coastguard Worker
2307*35238bceSAndroid Build Coastguard Worker } // namespace
2308*35238bceSAndroid Build Coastguard Worker
ClippingTests(Context & context)2309*35238bceSAndroid Build Coastguard Worker ClippingTests::ClippingTests(Context &context) : TestCaseGroup(context, "clipping", "Clipping tests")
2310*35238bceSAndroid Build Coastguard Worker {
2311*35238bceSAndroid Build Coastguard Worker }
2312*35238bceSAndroid Build Coastguard Worker
~ClippingTests(void)2313*35238bceSAndroid Build Coastguard Worker ClippingTests::~ClippingTests(void)
2314*35238bceSAndroid Build Coastguard Worker {
2315*35238bceSAndroid Build Coastguard Worker }
2316*35238bceSAndroid Build Coastguard Worker
init(void)2317*35238bceSAndroid Build Coastguard Worker void ClippingTests::init(void)
2318*35238bceSAndroid Build Coastguard Worker {
2319*35238bceSAndroid Build Coastguard Worker addChild(new PointsTestGroup(m_context));
2320*35238bceSAndroid Build Coastguard Worker addChild(new LinesTestGroup(m_context));
2321*35238bceSAndroid Build Coastguard Worker addChild(new PolysTestGroup(m_context));
2322*35238bceSAndroid Build Coastguard Worker addChild(new PolyEdgesTestGroup(m_context));
2323*35238bceSAndroid Build Coastguard Worker addChild(new PolyVertexClipTestGroup(m_context));
2324*35238bceSAndroid Build Coastguard Worker }
2325*35238bceSAndroid Build Coastguard Worker
2326*35238bceSAndroid Build Coastguard Worker } // namespace Functional
2327*35238bceSAndroid Build Coastguard Worker } // namespace gles2
2328*35238bceSAndroid Build Coastguard Worker } // namespace deqp
2329