1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Clipping tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es2fClippingTests.hpp"
25 #include "tcuRenderTarget.hpp"
26 #include "tcuTextureUtil.hpp"
27 #include "tcuImageCompare.hpp"
28 #include "tcuVectorUtil.hpp"
29 #include "deStringUtil.hpp"
30 #include "deRandom.hpp"
32 #include "sglrReferenceContext.hpp"
33 #include "sglrGLContext.hpp"
35 #include "glwEnums.hpp"
36 #include "glwDefs.hpp"
37 #include "glwFunctions.hpp"
39 using namespace glw; // GLint and other GL types
50 using tcu::PixelBufferAccess;
51 using tcu::ConstPixelBufferAccess;
54 static const tcu::Vec4 MASK_COLOR_OK = tcu::Vec4(0.0f, 0.1f, 0.0f, 1.0f);
55 static const tcu::Vec4 MASK_COLOR_DEV = tcu::Vec4(0.8f, 0.5f, 0.0f, 1.0f);
56 static const tcu::Vec4 MASK_COLOR_FAIL = tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f);
58 const int TEST_CANVAS_SIZE = 200;
59 const rr::WindowRectangle VIEWPORT_WHOLE (0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
60 const rr::WindowRectangle VIEWPORT_CENTER (TEST_CANVAS_SIZE/4, TEST_CANVAS_SIZE/4, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2);
61 const rr::WindowRectangle VIEWPORT_CORNER (TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2);
64 const char* shaderSourceVertex = "attribute highp vec4 a_position;\n"
65 "attribute highp vec4 a_color;\n"
66 "attribute highp float a_pointSize;\n"
67 "varying mediump vec4 varFragColor;\n"
70 " gl_Position = a_position;\n"
71 " gl_PointSize = a_pointSize;\n"
72 " varFragColor = a_color;\n"
74 const char* shaderSourceFragment = "varying mediump vec4 varFragColor;\n"
77 " gl_FragColor = varFragColor;\n"
80 inline bool isBlack (const tcu::IVec4& a)
82 return a.x() == 0 && a.y() == 0 && a.z() == 0;
85 inline bool isHalfFilled (const tcu::IVec4& a)
87 const tcu::IVec4 halfFilled (127, 0, 0, 0);
88 const tcu::IVec4 threshold (20, 256, 256, 256);
90 return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - halfFilled), threshold));
93 inline bool isLessThanHalfFilled (const tcu::IVec4& a)
95 const int halfFilled = 127;
96 const int threshold = 20;
98 return a.x() + threshold < halfFilled;
101 inline bool compareBlackNonBlackPixels (const tcu::IVec4& a, const tcu::IVec4& b)
103 return isBlack(a) == isBlack(b);
106 inline bool compareColoredPixels (const tcu::IVec4& a, const tcu::IVec4& b)
108 const bool aIsBlack = isBlack(a);
109 const bool bIsBlack = isBlack(b);
110 const tcu::IVec4 threshold(20, 20, 20, 0);
112 if (aIsBlack && bIsBlack)
114 if (aIsBlack != bIsBlack)
117 return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - b), threshold));
120 void blitImageOnBlackSurface(const ConstPixelBufferAccess& src, const PixelBufferAccess& dst)
122 const int height = src.getHeight();
123 const int width = src.getWidth();
125 for (int y = 0; y < height; y++)
126 for (int x = 0; x < width; x++)
128 const tcu::IVec4 cSrc = src.getPixelInt(x, y);
129 const tcu::IVec4 cDst = tcu::IVec4(cSrc.x(), cSrc.y(), cSrc.z(), 255);
131 dst.setPixel(cDst, x, y);
135 /*--------------------------------------------------------------------*//*!
136 * \brief Pixelwise comparison of two images.
137 * \note copied & modified from glsRasterizationTests
139 * Kernel radius defines maximum allowed distance. If radius is 0, only
140 * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
141 * equal if pixelCmp returns true..
143 * Return values: -1 = Perfect match
144 * 0 = Deviation within kernel
145 * >0 = Number of faulty pixels
146 *//*--------------------------------------------------------------------*/
147 inline int 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))
149 const int height = test.getHeight();
150 const int width = test.getWidth();
151 int deviatingPixels = 0;
152 int faultyPixels = 0;
153 int compareFailed = -1;
155 tcu::clear(diffMask, MASK_COLOR_OK);
157 for (int y = 0; y < height; y++)
159 for (int x = 0; x < width; x++)
161 const tcu::IVec4 cRef = ref.getPixelInt(x, y);
162 const tcu::IVec4 cTest = test.getPixelInt(x, y);
164 // Pixelwise match, no deviation or fault
165 if ((*pixelCmp)(cRef, cTest))
170 const int radius = kernelRadius;
171 bool foundRef = false;
172 bool foundTest = false;
174 // edges are considered a "deviation" too. The suitable pixel could be "behind" the edge
175 if (y < radius || x < radius || y + radius >= height || x + radius >= width)
183 for (int kY = y - radius; kY <= y + radius; kY++)
184 for (int kX = x - radius; kX <= x + radius; kX++)
186 if ((*pixelCmp)(cRef, test.getPixelInt(kX, kY)))
194 for (int kY = y - radius; kY <= y + radius; kY++)
195 for (int kX = x - radius; kX <= x + radius; kX++)
197 if ((*pixelCmp)(cTest, ref.getPixelInt(kX, kY)))
205 // 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)
206 // the result color is found in the reference image inside the kernel (~= every pixel gl draws must be drawn by the reference too)
207 if (foundRef && foundTest)
209 diffMask.setPixel(MASK_COLOR_DEV, x, y);
210 if (compareFailed == -1)
217 diffMask.setPixel(MASK_COLOR_FAIL, x, y);
218 faultyPixels++; // The pixel is faulty if the color is not found
223 log << TestLog::Message << deviatingPixels << " deviating pixel(s) found." << TestLog::EndMessage;
224 log << TestLog::Message << faultyPixels << " faulty pixel(s) found." << TestLog::EndMessage;
226 return (compareFailed == 1 ? faultyPixels : compareFailed);
229 /*--------------------------------------------------------------------*//*!
230 * \brief Pixelwise comparison of two images.
232 * Kernel radius defines maximum allowed distance. If radius is 0, only
233 * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
234 * equal if they both are black, or both are non-black.
236 * Return values: -1 = Perfect match
237 * 0 = Deviation within kernel
238 * >0 = Number of faulty pixels
239 *//*--------------------------------------------------------------------*/
240 int compareBlackNonBlackImages (tcu::TestLog& log, const ConstPixelBufferAccess& test, const ConstPixelBufferAccess& ref, const PixelBufferAccess& diffMask, int kernelRadius)
242 return compareImages(log, test, ref, diffMask, kernelRadius, compareBlackNonBlackPixels);
245 /*--------------------------------------------------------------------*//*!
246 * \brief Pixelwise comparison of two images.
248 * Kernel radius defines maximum allowed distance. If radius is 0, only
249 * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are
250 * equal if they both are black, or both are non-black with color values
251 * close to each other.
253 * Return values: -1 = Perfect match
254 * 0 = Deviation within kernel
255 * >0 = Number of faulty pixels
256 *//*--------------------------------------------------------------------*/
257 int compareColoredImages (tcu::TestLog& log, const ConstPixelBufferAccess& test, const ConstPixelBufferAccess& ref, const PixelBufferAccess& diffMask, int kernelRadius)
259 return compareImages(log, test, ref, diffMask, kernelRadius, compareColoredPixels);
262 /*--------------------------------------------------------------------*//*!
263 * \brief Overdraw check verification
265 * Check that image does not have at any point a
266 * pixel with red component value > 0.5
268 * Return values: false = area not filled, or leaking
269 *//*--------------------------------------------------------------------*/
270 bool checkHalfFilledImageOverdraw (tcu::TestLog& log, const tcu::RenderTarget& m_renderTarget, const ConstPixelBufferAccess& image, const PixelBufferAccess& output)
272 const int height = image.getHeight();
273 const int width = image.getWidth();
277 tcu::clear(output, MASK_COLOR_OK);
279 for (int y = 0; y < height; y++)
281 for (int x = 0; x < width; x++)
283 const tcu::IVec4 cTest = image.getPixelInt(x, y);
285 const bool pixelValid = isBlack(cTest) || isHalfFilled(cTest) || (m_renderTarget.getNumSamples() > 1 && isLessThanHalfFilled(cTest));
289 output.setPixel(MASK_COLOR_FAIL, x, y);
296 log << TestLog::Message << "Faulty pixel(s) found." << TestLog::EndMessage;
301 void checkPointSize (const glw::Functions& gl, float pointSize)
303 GLfloat pointSizeRange[2] = {0,0};
304 gl.getFloatv(GL_ALIASED_POINT_SIZE_RANGE, pointSizeRange);
305 if (pointSizeRange[1] < pointSize)
306 throw tcu::NotSupportedError("Maximum point size is too low for this test");
309 void checkLineWidth (const glw::Functions& gl, float lineWidth)
311 GLfloat lineWidthRange[2] = {0,0};
312 gl.getFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange);
313 if (lineWidthRange[1] < lineWidth)
314 throw tcu::NotSupportedError("Maximum line width is too low for this test");
317 tcu::Vec3 IVec3ToVec3 (const tcu::IVec3& v)
319 return tcu::Vec3((float)v.x(), (float)v.y(), (float)v.z());
322 bool pointOnTriangle (const tcu::IVec3& p, const tcu::IVec3& t0, const tcu::IVec3& t1, const tcu::IVec3& t2)
324 // Must be on the plane
325 const tcu::IVec3 n = tcu::cross(t1 - t0, t2 - t0);
326 const tcu::IVec3 d = (p - t0);
331 // Must be within the triangle area
332 if (deSign32(tcu::dot(n, tcu::cross(t1 - t0, p - t0))) == deSign32(tcu::dot(n, tcu::cross(t2 - t0, p - t0))))
334 if (deSign32(tcu::dot(n, tcu::cross(t2 - t1, p - t1))) == deSign32(tcu::dot(n, tcu::cross(t0 - t1, p - t1))))
336 if (deSign32(tcu::dot(n, tcu::cross(t0 - t2, p - t2))) == deSign32(tcu::dot(n, tcu::cross(t1 - t2, p - t2))))
342 bool pointsOnLine (const tcu::IVec2& t0, const tcu::IVec2& t1, const tcu::IVec2& t2)
344 return (t1 - t0).x() * (t2 - t0).y() - (t2 - t0).x() * (t1 - t0).y() == 0;
347 // returns true for cases where polygon is (almost) along xz or yz planes (normal.z < 0.1)
348 // \note[jarkko] Doesn't have to be accurate, just to detect some obviously bad cases
349 bool twoPointClippedTriangleInvisible(const tcu::Vec3& p, const tcu::IVec3& dir1, const tcu::IVec3& dir2)
351 // fixed-point-like coords
352 const deInt64 fixedScale = 64;
353 const deInt64 farValue = 1024;
354 const tcu::Vector<deInt64, 3> d1 = tcu::Vector<deInt64, 3>(dir1.x(), dir1.y(), dir1.z());
355 const tcu::Vector<deInt64, 3> d2 = tcu::Vector<deInt64, 3>(dir2.x(), dir2.y(), dir2.z());
356 const tcu::Vector<deInt64, 3> pfixed = tcu::Vector<deInt64, 3>(deFloorFloatToInt32(p.x() * fixedScale), deFloorFloatToInt32(p.y() * fixedScale), deFloorFloatToInt32(p.z() * fixedScale));
357 const tcu::Vector<deInt64, 3> normalDir = tcu::cross(d1*farValue - pfixed, d2*farValue - pfixed);
358 const deInt64 normalLen2 = tcu::lengthSquared(normalDir);
360 return (normalDir.z() * normalDir.z() - normalLen2/100) < 0;
363 std::string genClippingPointInfoString(const tcu::Vec4& p)
365 std::ostringstream msg;
367 if (p.x() < -p.w()) msg << "\t(-X clip)";
368 if (p.x() > p.w()) msg << "\t(+X clip)";
369 if (p.y() < -p.w()) msg << "\t(-Y clip)";
370 if (p.y() > p.w()) msg << "\t(+Y clip)";
371 if (p.z() < -p.w()) msg << "\t(-Z clip)";
372 if (p.z() > p.w()) msg << "\t(+Z clip)";
377 std::string genColorString(const tcu::Vec4& p)
379 const tcu::Vec4 white (1.0f, 1.0f, 1.0f, 1.0f);
380 const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
381 const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f);
382 const tcu::Vec4 blue (0.0f, 0.0f, 1.0f, 1.0f);
384 if (p == white) return "(white)";
385 if (p == red) return "(red)";
386 if (p == yellow) return "(yellow)";
387 if (p == blue) return "(blue)";
391 class PositionColorShader : public sglr::ShaderProgram
399 PositionColorShader (void);
401 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const;
402 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const;
405 PositionColorShader::PositionColorShader (void)
406 : sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
407 << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
408 << sglr::pdec::VertexAttribute("a_color", rr::GENERICVECTYPE_FLOAT)
409 << sglr::pdec::VertexAttribute("a_pointSize", rr::GENERICVECTYPE_FLOAT)
410 << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
411 << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
412 << sglr::pdec::VertexSource(shaderSourceVertex)
413 << sglr::pdec::FragmentSource(shaderSourceFragment))
417 void PositionColorShader::shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
419 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
421 const int positionAttrLoc = 0;
422 const int colorAttrLoc = 1;
423 const int pointSizeAttrLoc = 2;
425 rr::VertexPacket& packet = *packets[packetNdx];
427 // Transform to position
428 packet.position = rr::readVertexAttribFloat(inputs[positionAttrLoc], packet.instanceNdx, packet.vertexNdx);
431 packet.pointSize = rr::readVertexAttribFloat(inputs[pointSizeAttrLoc], packet.instanceNdx, packet.vertexNdx).x();
434 packet.outputs[VARYINGLOC_COLOR] = rr::readVertexAttribFloat(inputs[colorAttrLoc], packet.instanceNdx, packet.vertexNdx);
438 void PositionColorShader::shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
440 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
442 rr::FragmentPacket& packet = packets[packetNdx];
444 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
445 rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, rr::readVarying<float>(packet, context, VARYINGLOC_COLOR, fragNdx));
449 class RenderTestCase : public TestCase
452 RenderTestCase (Context& context, const char* name, const char* description);
454 virtual void testRender (void) = DE_NULL;
455 virtual void init (void) { }
457 IterateResult iterate (void);
460 RenderTestCase::RenderTestCase (Context& context, const char* name, const char* description)
461 : TestCase (context, name, description)
465 RenderTestCase::IterateResult RenderTestCase::iterate (void)
467 const int width = m_context.getRenderTarget().getWidth();
468 const int height = m_context.getRenderTarget().getHeight();
470 m_testCtx.getLog() << TestLog::Message << "Render target size: " << width << "x" << height << TestLog::EndMessage;
471 if (width < TEST_CANVAS_SIZE || height < TEST_CANVAS_SIZE)
472 throw tcu::NotSupportedError(std::string("Render target size must be at least ") + de::toString(TEST_CANVAS_SIZE) + "x" + de::toString(TEST_CANVAS_SIZE));
474 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // success by default
480 class PointCase : public RenderTestCase
483 PointCase (Context& context, const char* name, const char* description, const tcu::Vec4* pointsBegin, const tcu::Vec4* pointsEnd, float pointSize, const rr::WindowRectangle& viewport);
486 void testRender (void);
489 const std::vector<tcu::Vec4> m_points;
490 const float m_pointSize;
491 const rr::WindowRectangle m_viewport;
494 PointCase::PointCase (Context& context, const char* name, const char* description, const tcu::Vec4* pointsBegin, const tcu::Vec4* pointsEnd, float pointSize, const rr::WindowRectangle& viewport)
495 : RenderTestCase(context, name, description)
496 , m_points (pointsBegin, pointsEnd)
497 , m_pointSize (pointSize)
498 , m_viewport (viewport)
502 void PointCase::init (void)
504 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
505 checkPointSize (gl, m_pointSize);
508 void PointCase::testRender (void)
512 const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
514 tcu::TestLog& log = m_testCtx.getLog();
515 sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
516 sglr::ReferenceContextLimits limits;
517 sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples);
518 sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer());
519 PositionColorShader program;
520 tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
521 tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
522 sglr::Context* contexts[2] = {&glesContext, &refContext};
523 tcu::Surface* surfaces[2] = {&testSurface, &refSurface};
525 // log the purpose of the test
526 log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
527 log << TestLog::Message << "Rendering points with point size " << m_pointSize << ". Coordinates:" << TestLog::EndMessage;
528 for (size_t ndx = 0; ndx < m_points.size(); ++ndx)
529 log << TestLog::Message
530 << "\tx=" << m_points[ndx].x()
531 << "\ty=" << m_points[ndx].y()
532 << "\tz=" << m_points[ndx].z()
533 << "\tw=" << m_points[ndx].w()
534 << "\t" << genClippingPointInfoString(m_points[ndx])
535 << TestLog::EndMessage;
537 for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
539 sglr::Context& ctx = *contexts[contextNdx];
540 tcu::Surface& dstSurface = *surfaces[contextNdx];
541 const deUint32 programId = ctx.createProgram(&program);
542 const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
543 const GLint pointSizeLoc = ctx.getAttribLocation(programId, "a_pointSize");
544 const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
546 ctx.clearColor (0, 0, 0, 1);
547 ctx.clearDepthf (1.0f);
548 ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
549 ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
550 ctx.useProgram (programId);
551 ctx.enableVertexAttribArray (positionLoc);
552 ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, 0, &m_points[0]);
553 ctx.vertexAttrib1f (pointSizeLoc, m_pointSize);
554 ctx.vertexAttrib4f (colorLoc, 1.0f, 1.0f, 1.0f, 1.0f);
555 ctx.drawArrays (GL_POINTS, 0, (glw::GLsizei)m_points.size());
556 ctx.disableVertexAttribArray (positionLoc);
558 ctx.deleteProgram (programId);
561 ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
566 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
567 const int kernelRadius = 1;
570 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
571 log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
573 faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(), diffMask.getAccess(), kernelRadius);
575 if (faultyPixels > 0)
577 log << TestLog::ImageSet("Images", "Image comparison")
578 << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
579 << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess())
580 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
581 << TestLog::EndImageSet
582 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
584 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
589 class LineRenderTestCase : public RenderTestCase
592 struct ColoredLineData
600 struct ColorlessLineData
605 LineRenderTestCase (Context& context, const char* name, const char* description, const ColoredLineData* linesBegin, const ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport);
606 LineRenderTestCase (Context& context, const char* name, const char* description, const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport);
608 virtual void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) = DE_NULL;
610 void testRender (void);
613 std::vector<ColoredLineData> convertToColoredLines (const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd);
615 const std::vector<ColoredLineData> m_lines;
616 const float m_lineWidth;
617 const rr::WindowRectangle m_viewport;
620 LineRenderTestCase::LineRenderTestCase (Context& context, const char* name, const char* description, const ColoredLineData* linesBegin, const ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport)
621 : RenderTestCase (context, name, description)
622 , m_lines (linesBegin, linesEnd)
623 , m_lineWidth (lineWidth)
624 , m_viewport (viewport)
628 LineRenderTestCase::LineRenderTestCase (Context& context, const char* name, const char* description, const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport)
629 : RenderTestCase (context, name, description)
630 , m_lines (convertToColoredLines(linesBegin, linesEnd))
631 , m_lineWidth (lineWidth)
632 , m_viewport (viewport)
636 void LineRenderTestCase::init (void)
638 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
639 checkLineWidth (gl, m_lineWidth);
642 void LineRenderTestCase::testRender (void)
646 const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
647 const int verticesPerLine = 2;
649 tcu::TestLog& log = m_testCtx.getLog();
650 sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
651 sglr::ReferenceContextLimits limits;
652 sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples);
653 sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer());
654 PositionColorShader program;
655 tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
656 tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
657 sglr::Context* contexts[2] = {&glesContext, &refContext};
658 tcu::Surface* surfaces[2] = {&testSurface, &refSurface};
660 // log the purpose of the test
661 log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
662 log << TestLog::Message << "Rendering lines with line width " << m_lineWidth << ". Coordinates:" << TestLog::EndMessage;
663 for (size_t ndx = 0; ndx < m_lines.size(); ++ndx)
665 const std::string fromProperties = genClippingPointInfoString(m_lines[ndx].p0);
666 const std::string toProperties = genClippingPointInfoString(m_lines[ndx].p1);
668 log << TestLog::Message << "\tfrom (x=" << m_lines[ndx].p0.x() << "\ty=" << m_lines[ndx].p0.y() << "\tz=" << m_lines[ndx].p0.z() << "\tw=" << m_lines[ndx].p0.w() << ")\t" << fromProperties << TestLog::EndMessage;
669 log << TestLog::Message << "\tto (x=" << m_lines[ndx].p1.x() << "\ty=" << m_lines[ndx].p1.y() << "\tz=" << m_lines[ndx].p1.z() << "\tw=" << m_lines[ndx].p1.w() << ")\t" << toProperties << TestLog::EndMessage;
670 log << TestLog::Message << TestLog::EndMessage;
674 for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
676 sglr::Context& ctx = *contexts[contextNdx];
677 tcu::Surface& dstSurface = *surfaces[contextNdx];
678 const deUint32 programId = ctx.createProgram(&program);
679 const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
680 const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
682 ctx.clearColor (0, 0, 0, 1);
683 ctx.clearDepthf (1.0f);
684 ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
685 ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
686 ctx.useProgram (programId);
687 ctx.enableVertexAttribArray (positionLoc);
688 ctx.enableVertexAttribArray (colorLoc);
689 ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].p0);
690 ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].c0);
691 ctx.lineWidth (m_lineWidth);
692 ctx.drawArrays (GL_LINES, 0, verticesPerLine * (glw::GLsizei)m_lines.size());
693 ctx.disableVertexAttribArray (positionLoc);
694 ctx.disableVertexAttribArray (colorLoc);
696 ctx.deleteProgram (programId);
699 ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
703 verifyImage(testSurface.getAccess(), refSurface.getAccess());
706 std::vector<LineRenderTestCase::ColoredLineData> LineRenderTestCase::convertToColoredLines(const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd)
708 std::vector<ColoredLineData> ret;
710 for (const ColorlessLineData* it = linesBegin; it != linesEnd; ++it)
715 r.c0 = tcu::Vec4(1, 1, 1, 1);
717 r.c1 = tcu::Vec4(1, 1, 1, 1);
725 class LineCase : public LineRenderTestCase
728 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 = 1);
730 void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess);
733 const int m_searchKernelSize;
736 LineCase::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)
737 : LineRenderTestCase (context, name, description, linesBegin, linesEnd, lineWidth, viewport)
738 , m_searchKernelSize (searchKernelSize)
742 void LineCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess)
744 const int faultyLimit = 6;
747 tcu::TestLog& log = m_testCtx.getLog();
748 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
750 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
751 log << TestLog::Message << "Deviation within radius of " << m_searchKernelSize << " is allowed." << TestLog::EndMessage;
752 log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
754 faultyPixels = compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), m_searchKernelSize);
756 if (faultyPixels > faultyLimit)
758 log << TestLog::ImageSet("Images", "Image comparison")
759 << TestLog::Image("TestImage", "Test image", testImageAccess)
760 << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
761 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
762 << TestLog::EndImageSet
763 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
765 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
769 class ColoredLineCase : public LineRenderTestCase
772 ColoredLineCase (Context& context, const char* name, const char* description, const LineRenderTestCase::ColoredLineData* linesBegin, const LineRenderTestCase::ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport);
774 void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess);
777 ColoredLineCase::ColoredLineCase (Context& context, const char* name, const char* description, const LineRenderTestCase::ColoredLineData* linesBegin, const LineRenderTestCase::ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport)
778 : LineRenderTestCase (context, name, description, linesBegin, linesEnd, lineWidth, viewport)
782 void ColoredLineCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess)
784 const bool msaa = m_context.getRenderTarget().getNumSamples() > 1;
785 tcu::TestLog& log = m_testCtx.getLog();
789 const int kernelRadius = 1;
790 const int faultyLimit = 6;
792 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
794 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
795 log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
796 log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
798 faultyPixels = compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
800 if (faultyPixels > faultyLimit)
802 log << TestLog::ImageSet("Images", "Image comparison")
803 << TestLog::Image("TestImage", "Test image", testImageAccess)
804 << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
805 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
806 << TestLog::EndImageSet
807 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
809 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
814 const float threshold = 0.3f;
815 if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold, tcu::COMPARE_LOG_ON_ERROR))
816 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
820 class TriangleCaseBase : public RenderTestCase
833 TriangleCaseBase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport);
835 virtual void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) = DE_NULL;
836 void testRender (void);
839 const std::vector<TriangleData> m_polys;
840 const rr::WindowRectangle m_viewport;
843 TriangleCaseBase::TriangleCaseBase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport)
844 : RenderTestCase(context, name, description)
845 , m_polys (polysBegin, polysEnd)
846 , m_viewport (viewport)
850 void TriangleCaseBase::testRender (void)
854 const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1);
855 const int verticesPerTriangle = 3;
857 tcu::TestLog& log = m_testCtx.getLog();
858 sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
859 sglr::ReferenceContextLimits limits;
860 sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples);
861 sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer());
862 PositionColorShader program;
863 tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
864 tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
865 sglr::Context* contexts[2] = {&glesContext, &refContext};
866 tcu::Surface* surfaces[2] = {&testSurface, &refSurface};
868 // log the purpose of the test
869 log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
870 log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage;
871 for (size_t ndx = 0; ndx < m_polys.size(); ++ndx)
873 const std::string v0Properties = genClippingPointInfoString(m_polys[ndx].p0);
874 const std::string v1Properties = genClippingPointInfoString(m_polys[ndx].p1);
875 const std::string v2Properties = genClippingPointInfoString(m_polys[ndx].p2);
876 const std::string c0Properties = genColorString(m_polys[ndx].c0);
877 const std::string c1Properties = genColorString(m_polys[ndx].c1);
878 const std::string c2Properties = genColorString(m_polys[ndx].c2);
880 log << TestLog::Message << "\tv0 (x=" << m_polys[ndx].p0.x() << "\ty=" << m_polys[ndx].p0.y() << "\tz=" << m_polys[ndx].p0.z() << "\tw=" << m_polys[ndx].p0.w() << ")\t" << v0Properties << "\t" << c0Properties << TestLog::EndMessage;
881 log << TestLog::Message << "\tv1 (x=" << m_polys[ndx].p1.x() << "\ty=" << m_polys[ndx].p1.y() << "\tz=" << m_polys[ndx].p1.z() << "\tw=" << m_polys[ndx].p1.w() << ")\t" << v1Properties << "\t" << c1Properties << TestLog::EndMessage;
882 log << TestLog::Message << "\tv2 (x=" << m_polys[ndx].p2.x() << "\ty=" << m_polys[ndx].p2.y() << "\tz=" << m_polys[ndx].p2.z() << "\tw=" << m_polys[ndx].p2.w() << ")\t" << v2Properties << "\t" << c2Properties << TestLog::EndMessage;
883 log << TestLog::Message << TestLog::EndMessage;
887 for (int contextNdx = 0; contextNdx < 2; ++contextNdx)
889 sglr::Context& ctx = *contexts[contextNdx];
890 tcu::Surface& dstSurface = *surfaces[contextNdx];
891 const deUint32 programId = ctx.createProgram(&program);
892 const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
893 const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
895 ctx.clearColor (0, 0, 0, 1);
896 ctx.clearDepthf (1.0f);
897 ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
898 ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
899 ctx.useProgram (programId);
900 ctx.enableVertexAttribArray (positionLoc);
901 ctx.enableVertexAttribArray (colorLoc);
902 ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].p0);
903 ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].c0);
904 ctx.drawArrays (GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_polys.size());
905 ctx.disableVertexAttribArray (positionLoc);
906 ctx.disableVertexAttribArray (colorLoc);
908 ctx.deleteProgram (programId);
911 ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
914 verifyImage(testSurface.getAccess(), refSurface.getAccess());
917 class TriangleCase : public TriangleCaseBase
920 TriangleCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport);
922 void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess);
925 TriangleCase::TriangleCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport)
926 : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport)
930 void TriangleCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess)
932 const int kernelRadius = 1;
933 const int faultyLimit = 6;
934 tcu::TestLog& log = m_testCtx.getLog();
935 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
938 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
939 log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
940 log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
942 faultyPixels = compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
944 if (faultyPixels > faultyLimit)
946 log << TestLog::ImageSet("Images", "Image comparison")
947 << TestLog::Image("TestImage", "Test image", testImageAccess)
948 << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
949 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
950 << TestLog::EndImageSet
951 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
953 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
957 class TriangleAttributeCase : public TriangleCaseBase
960 TriangleAttributeCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport);
962 void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess);
965 TriangleAttributeCase::TriangleAttributeCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport)
966 : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport)
970 void TriangleAttributeCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess)
972 const bool msaa = m_context.getRenderTarget().getNumSamples() > 1;
973 tcu::TestLog& log = m_testCtx.getLog();
977 const int kernelRadius = 1;
978 const int faultyLimit = 6;
980 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
982 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
983 log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
984 log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage;
985 faultyPixels = compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius);
987 if (faultyPixels > faultyLimit)
989 log << TestLog::ImageSet("Images", "Image comparison")
990 << TestLog::Image("TestImage", "Test image", testImageAccess)
991 << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess)
992 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
993 << TestLog::EndImageSet
994 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
996 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1001 const float threshold = 0.3f;
1002 if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold, tcu::COMPARE_LOG_ON_ERROR))
1003 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1007 class FillTest : public RenderTestCase
1010 FillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport);
1012 virtual void render (sglr::Context& ctx) = DE_NULL;
1013 void testRender (void);
1016 const rr::WindowRectangle m_viewport;
1019 FillTest::FillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport)
1020 : RenderTestCase(context, name, description)
1021 , m_viewport (viewport)
1025 void FillTest::testRender (void)
1029 const int numSamples = 1;
1031 tcu::TestLog& log = m_testCtx.getLog();
1032 sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE));
1033 sglr::ReferenceContextLimits limits;
1034 sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples);
1035 sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer());
1036 tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1037 tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1039 render(glesContext);
1040 glesContext.readPixels(testSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1043 refContext.readPixels(refSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1048 tcu::Surface outputImage(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1050 log << TestLog::Message << "Checking for overdraw " << TestLog::EndMessage;
1051 overdrawOk = checkHalfFilledImageOverdraw(log, m_context.getRenderTarget(), testSurface.getAccess(), outputImage.getAccess());
1055 log << TestLog::ImageSet("Images", "Image comparison")
1056 << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
1057 << TestLog::Image("InvalidPixels", "Invalid pixels", outputImage.getAccess())
1058 << TestLog::EndImageSet
1059 << tcu::TestLog::Message << "Got overdraw." << tcu::TestLog::EndMessage;
1061 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got overdraw");
1065 // compare & check missing pixels
1067 const int kernelRadius = 1;
1068 tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE);
1071 log << TestLog::Message << "Comparing images... " << TestLog::EndMessage;
1072 log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage;
1074 blitImageOnBlackSurface(refSurface.getAccess(), refSurface.getAccess()); // makes images look right in Candy
1076 faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(), diffMask.getAccess(), kernelRadius);
1078 if (faultyPixels > 0)
1080 log << TestLog::ImageSet("Images", "Image comparison")
1081 << TestLog::Image("TestImage", "Test image", testSurface.getAccess())
1082 << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess())
1083 << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess())
1084 << TestLog::EndImageSet
1085 << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage;
1087 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels");
1092 class TriangleFillTest : public FillTest
1105 TriangleFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport);
1107 void render (sglr::Context& ctx);
1110 std::vector<FillTriangle> m_triangles;
1113 TriangleFillTest::TriangleFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport)
1114 : FillTest(context, name, description, viewport)
1118 void TriangleFillTest::render (sglr::Context& ctx)
1120 const int verticesPerTriangle = 3;
1121 PositionColorShader program;
1122 const deUint32 programId = ctx.createProgram(&program);
1123 const GLint positionLoc = ctx.getAttribLocation(programId, "a_position");
1124 const GLint colorLoc = ctx.getAttribLocation(programId, "a_color");
1125 tcu::TestLog& log = m_testCtx.getLog();
1127 // log the purpose of the test
1128 log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage;
1129 log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage;
1130 for (size_t ndx = 0; ndx < m_triangles.size(); ++ndx)
1132 const std::string v0Properties = genClippingPointInfoString(m_triangles[ndx].v0);
1133 const std::string v1Properties = genClippingPointInfoString(m_triangles[ndx].v1);
1134 const std::string v2Properties = genClippingPointInfoString(m_triangles[ndx].v2);
1136 log << TestLog::Message << "\tv0 (x=" << m_triangles[ndx].v0.x() << "\ty=" << m_triangles[ndx].v0.y() << "\tz=" << m_triangles[ndx].v0.z() << "\tw=" << m_triangles[ndx].v0.w() << ")\t" << v0Properties << TestLog::EndMessage;
1137 log << TestLog::Message << "\tv1 (x=" << m_triangles[ndx].v1.x() << "\ty=" << m_triangles[ndx].v1.y() << "\tz=" << m_triangles[ndx].v1.z() << "\tw=" << m_triangles[ndx].v1.w() << ")\t" << v1Properties << TestLog::EndMessage;
1138 log << TestLog::Message << "\tv2 (x=" << m_triangles[ndx].v2.x() << "\ty=" << m_triangles[ndx].v2.y() << "\tz=" << m_triangles[ndx].v2.z() << "\tw=" << m_triangles[ndx].v2.w() << ")\t" << v2Properties << TestLog::EndMessage;
1139 log << TestLog::Message << TestLog::EndMessage;
1142 ctx.clearColor (0, 0, 0, 1);
1143 ctx.clearDepthf (1.0f);
1144 ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1145 ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height);
1146 ctx.useProgram (programId);
1147 ctx.blendFunc (GL_ONE, GL_ONE);
1148 ctx.enable (GL_BLEND);
1149 ctx.enableVertexAttribArray (positionLoc);
1150 ctx.enableVertexAttribArray (colorLoc);
1151 ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].v0);
1152 ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].c0);
1153 ctx.drawArrays (GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_triangles.size());
1154 ctx.disableVertexAttribArray (positionLoc);
1155 ctx.disableVertexAttribArray (colorLoc);
1157 ctx.deleteProgram (programId);
1161 class QuadFillTest : public TriangleFillTest
1164 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_ = tcu::Vec3(0, 0, 0));
1167 QuadFillTest::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_)
1168 : TriangleFillTest(context, name, description, viewport)
1170 const float radius = 40000.0f;
1171 const tcu::Vec4 center = tcu::Vec4(center_.x(), center_.y(), center_.z(), 1.0f);
1172 const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f);
1173 const tcu::Vec4 halfRed = tcu::Vec4(0.5f, 0.0f, 0.0f, 0.5f);
1174 const tcu::Vec4 e1 = radius * tcu::Vec4(d1.x(), d1.y(), d1.z(), 0.0f);
1175 const tcu::Vec4 e2 = radius * tcu::Vec4(d2.x(), d2.y(), d2.z(), 0.0f);
1177 FillTriangle triangle1;
1178 FillTriangle triangle2;
1180 triangle1.c0 = halfWhite;
1181 triangle1.c1 = halfWhite;
1182 triangle1.c2 = halfWhite;
1183 triangle1.v0 = center + e1 + e2;
1184 triangle1.v1 = center + e1 - e2;
1185 triangle1.v2 = center - e1 - e2;
1186 m_triangles.push_back(triangle1);
1188 triangle2.c0 = halfRed;
1189 triangle2.c1 = halfRed;
1190 triangle2.c2 = halfRed;
1191 triangle2.v0 = center + e1 + e2;
1192 triangle2.v1 = center - e1 - e2;
1193 triangle2.v2 = center - e1 + e2;
1194 m_triangles.push_back(triangle2);
1197 class TriangleFanFillTest : public TriangleFillTest
1200 TriangleFanFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport);
1203 TriangleFanFillTest::TriangleFanFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport)
1204 : TriangleFillTest(context, name, description, viewport)
1206 const float radius = 70000.0f;
1207 const int trianglesPerVisit = 40;
1208 const tcu::Vec4 center = tcu::Vec4(0, 0, 0, 1.0f);
1209 const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f);
1210 const tcu::Vec4 oddSliceColor = tcu::Vec4(0.0f, 0.0f, 0.5f, 0.0f);
1212 // create a continuous surface that goes through all 6 clip planes
1226 const struct ClipPlaneVisit
1228 const tcu::Vec3 corner;
1229 const tcu::Vec3 entryPoint;
1230 const tcu::Vec3 exitPoint;
1233 { tcu::Vec3( 1, 1, 1), tcu::Vec3( 0, 1, 1), tcu::Vec3( 1, 0, 1) },
1234 { tcu::Vec3( 1,-1, 1), tcu::Vec3( 1, 0, 1), tcu::Vec3( 1,-1, 0) },
1235 { tcu::Vec3( 1,-1,-1), tcu::Vec3( 1,-1, 0), tcu::Vec3( 0,-1,-1) },
1236 { tcu::Vec3(-1,-1,-1), tcu::Vec3( 0,-1,-1), tcu::Vec3(-1, 0,-1) },
1237 { tcu::Vec3(-1, 1,-1), tcu::Vec3(-1, 0,-1), tcu::Vec3(-1, 1, 0) },
1238 { tcu::Vec3(-1, 1, 1), tcu::Vec3(-1, 1, 0), tcu::Vec3( 0, 1, 1) },
1241 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(visits); ++ndx)
1243 const ClipPlaneVisit& visit = visits[ndx];
1245 for (int tri = 0; tri < trianglesPerVisit; ++tri)
1250 if (tri == 0) // first vertex is magic
1252 vertex0 = visit.entryPoint;
1256 const tcu::Vec3 v1 = visit.entryPoint - visit.corner;
1257 const tcu::Vec3 v2 = visit.exitPoint - visit.corner;
1259 vertex0 = visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri)/trianglesPerVisit)));
1262 if (tri == trianglesPerVisit-1) // last vertex is magic
1264 vertex1 = visit.exitPoint;
1268 const tcu::Vec3 v1 = visit.entryPoint - visit.corner;
1269 const tcu::Vec3 v2 = visit.exitPoint - visit.corner;
1271 vertex1 = visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri+1)/trianglesPerVisit)));
1276 FillTriangle triangle;
1278 triangle.c0 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1279 triangle.c1 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1280 triangle.c2 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor;
1281 triangle.v0 = center;
1282 triangle.v1 = tcu::Vec4(vertex0.x() * radius, vertex0.y() * radius, vertex0.z() * radius, 1.0f);
1283 triangle.v2 = tcu::Vec4(vertex1.x() * radius, vertex1.y() * radius, vertex1.z() * radius, 1.0f);
1285 m_triangles.push_back(triangle);
1292 class PointsTestGroup : public TestCaseGroup
1295 PointsTestGroup (Context& context);
1300 PointsTestGroup::PointsTestGroup (Context& context)
1301 : TestCaseGroup(context, "point", "Point clipping tests")
1305 void PointsTestGroup::init (void)
1307 const float littleOverViewport = 1.0f + (2.0f / (TEST_CANVAS_SIZE)); // one pixel over the viewport edge in VIEWPORT_WHOLE, half pixels over in the reduced viewport.
1309 const tcu::Vec4 viewportTestPoints[] =
1312 tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f),
1313 tcu::Vec4( 0.1f, 0.1f, 0.1f, 1.0f),
1314 tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f),
1315 tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f),
1316 tcu::Vec4( 0.1f, -0.1f, -0.1f, 1.0f),
1318 // in clip volume with w != 1
1319 tcu::Vec4( 2.0f, 2.0f, 2.0f, 3.0f),
1320 tcu::Vec4(-2.0f, -2.0f, 2.0f, 3.0f),
1321 tcu::Vec4( 0.5f, -0.5f, 0.5f, 0.7f),
1322 tcu::Vec4(-0.5f, 0.5f, -0.5f, 0.7f),
1325 tcu::Vec4(-2.0f, -2.0f, 0.0f, 2.2f),
1326 tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.1f),
1327 tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.1f),
1329 // not in the volume but still between near and far planes
1330 tcu::Vec4( 1.3f, 0.0f, 0.0f, 1.0f),
1331 tcu::Vec4(-1.3f, 0.0f, 0.0f, 1.0f),
1332 tcu::Vec4( 0.0f, 1.3f, 0.0f, 1.0f),
1333 tcu::Vec4( 0.0f, -1.3f, 0.0f, 1.0f),
1335 tcu::Vec4(-1.3f, -1.3f, 0.0f, 1.0f),
1336 tcu::Vec4(-1.3f, 1.3f, 0.0f, 1.0f),
1337 tcu::Vec4( 1.3f, 1.3f, 0.0f, 1.0f),
1338 tcu::Vec4( 1.3f, -1.3f, 0.0f, 1.0f),
1340 // outside the viewport, wide points have fragments in the viewport
1341 tcu::Vec4( littleOverViewport, littleOverViewport, 0.0f, 1.0f),
1342 tcu::Vec4( 0.0f, littleOverViewport, 0.0f, 1.0f),
1343 tcu::Vec4( littleOverViewport, 0.0f, 0.0f, 1.0f),
1345 const tcu::Vec4 depthTestPoints[] =
1348 tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f),
1349 tcu::Vec4( 0.1f, 0.1f, 0.1f, 1.0f),
1350 tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f),
1351 tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f),
1352 tcu::Vec4( 0.1f, -0.1f, -0.1f, 1.0f),
1354 // not between the near and the far planes. These should be clipped
1355 tcu::Vec4( 0.1f, 0.0f, 1.1f, 1.0f),
1356 tcu::Vec4(-0.1f, 0.0f, -1.1f, 1.0f),
1357 tcu::Vec4(-0.0f, -0.1f, 1.1f, 1.0f),
1358 tcu::Vec4( 0.0f, 0.1f, -1.1f, 1.0f)
1361 addChild(new PointCase(m_context, "point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_WHOLE));
1362 addChild(new PointCase(m_context, "point_z_clip_viewport_center", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_CENTER));
1363 addChild(new PointCase(m_context, "point_z_clip_viewport_corner", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_CORNER));
1365 addChild(new PointCase(m_context, "point_clip_viewport_center", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f, VIEWPORT_CENTER));
1366 addChild(new PointCase(m_context, "point_clip_viewport_corner", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f, VIEWPORT_CORNER));
1368 addChild(new PointCase(m_context, "wide_point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_WHOLE));
1369 addChild(new PointCase(m_context, "wide_point_z_clip_viewport_center", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_CENTER));
1370 addChild(new PointCase(m_context, "wide_point_z_clip_viewport_corner", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_CORNER));
1372 addChild(new PointCase(m_context, "wide_point_clip", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f, VIEWPORT_WHOLE));
1373 addChild(new PointCase(m_context, "wide_point_clip_viewport_center", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f, VIEWPORT_CENTER));
1374 addChild(new PointCase(m_context, "wide_point_clip_viewport_corner", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f, VIEWPORT_CORNER));
1377 class LinesTestGroup : public TestCaseGroup
1380 LinesTestGroup (Context& context);
1385 LinesTestGroup::LinesTestGroup (Context& context)
1386 : TestCaseGroup(context, "line", "Line clipping tests")
1390 void LinesTestGroup::init (void)
1392 const float littleOverViewport = 1.0f + (2.0f / (TEST_CANVAS_SIZE)); // one pixel over the viewport edge in VIEWPORT_WHOLE, half pixels over in the reduced viewport.
1395 const LineRenderTestCase::ColorlessLineData viewportTestLines[] =
1397 // from center to outside of viewport
1398 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.0f, 1.5f, 0.0f, 1.0f)},
1399 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 1.0f, 0.0f, 1.0f)},
1400 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 0.0f, 0.0f, 1.0f)},
1401 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.2f, 0.4f, 1.5f, 1.0f)},
1402 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-2.0f, -1.0f, 0.0f, 1.0f)},
1403 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.0f, 0.1f, 0.0f, 0.6f)},
1405 // from outside to inside of viewport
1406 {tcu::Vec4( 1.5f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.8f, -0.2f, 0.0f, 1.0f)},
1407 {tcu::Vec4( 0.0f, -1.5f, 0.0f, 1.0f), tcu::Vec4( 0.9f, -0.7f, 0.0f, 1.0f)},
1409 // from outside to outside
1410 {tcu::Vec4( 0.0f, -1.3f, 0.0f, 1.0f), tcu::Vec4( 1.3f, 0.0f, 0.0f, 1.0f)},
1412 // outside the viewport, wide lines have fragments in the viewport
1413 {tcu::Vec4(-0.8f, -littleOverViewport, 0.0f, 1.0f), tcu::Vec4( 0.0f, -littleOverViewport, 0.0f, 1.0f)},
1414 {tcu::Vec4(-littleOverViewport - 1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.0f, -littleOverViewport - 1.0f, 0.0f, 1.0f)},
1416 const LineRenderTestCase::ColorlessLineData depthTestLines[] =
1418 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.3f, 1.0f, 2.0f, 1.0f)},
1419 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.3f, -1.0f, 2.0f, 1.0f)},
1420 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, -1.1f, -2.0f, 1.0f)},
1421 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, 1.1f, -2.0f, 1.0f)},
1422 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.0f, 0.1f, 2.0f, 0.6f)},
1424 const LineRenderTestCase::ColorlessLineData longTestLines[] =
1426 {tcu::Vec4( -41000.0f, -40000.0f, -1000000.0f, 1.0f), tcu::Vec4( 41000.0f, 40000.0f, 1000000.0f, 1.0f)},
1427 {tcu::Vec4( 41000.0f, -40000.0f, 1000000.0f, 1.0f), tcu::Vec4(-41000.0f, 40000.0f, -1000000.0f, 1.0f)},
1428 {tcu::Vec4( 0.5f, -40000.0f, 100000.0f, 1.0f), tcu::Vec4( 0.5f, 40000.0f, -100000.0f, 1.0f)},
1429 {tcu::Vec4( -0.5f, 40000.0f, 100000.0f, 1.0f), tcu::Vec4(-0.5f, -40000.0f, -100000.0f, 1.0f)},
1432 // line attribute clipping
1433 const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
1434 const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f);
1435 const tcu::Vec4 lightBlue (0.3f, 0.3f, 1.0f, 1.0f);
1436 const LineRenderTestCase::ColoredLineData colorTestLines[] =
1438 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.3f, 1.0f, 2.0f, 1.0f), yellow },
1439 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.3f, -1.0f, 2.0f, 1.0f), lightBlue },
1440 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, -1.0f, -2.0f, 1.0f), yellow },
1441 {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, 1.0f, -2.0f, 1.0f), lightBlue },
1445 addChild(new LineCase(m_context, "line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_WHOLE));
1446 addChild(new LineCase(m_context, "line_z_clip_viewport_center", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_CENTER));
1447 addChild(new LineCase(m_context, "line_z_clip_viewport_corner", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_CORNER));
1449 addChild(new LineCase(m_context, "line_clip_viewport_center", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CENTER));
1450 addChild(new LineCase(m_context, "line_clip_viewport_corner", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CORNER));
1452 addChild(new LineCase(m_context, "wide_line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_WHOLE));
1453 addChild(new LineCase(m_context, "wide_line_z_clip_viewport_center", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_CENTER));
1454 addChild(new LineCase(m_context, "wide_line_z_clip_viewport_corner", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_CORNER));
1456 addChild(new LineCase(m_context, "wide_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_WHOLE));
1457 addChild(new LineCase(m_context, "wide_line_clip_viewport_center", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_CENTER));
1458 addChild(new LineCase(m_context, "wide_line_clip_viewport_corner", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_CORNER));
1460 addChild(new LineCase(m_context, "long_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(longTestLines), DE_ARRAY_END(longTestLines), 1.0f, VIEWPORT_WHOLE, 2));
1461 addChild(new LineCase(m_context, "long_wide_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(longTestLines), DE_ARRAY_END(longTestLines), 5.0f, VIEWPORT_WHOLE, 2));
1463 // line attribute clipping
1464 addChild(new ColoredLineCase(m_context, "line_attrib_clip", "line attribute clipping", DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 1.0f, VIEWPORT_WHOLE));
1465 addChild(new ColoredLineCase(m_context, "wide_line_attrib_clip", "line attribute clipping", DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 5.0f, VIEWPORT_WHOLE));
1468 class PolysTestGroup : public TestCaseGroup
1471 PolysTestGroup (Context& context);
1476 PolysTestGroup::PolysTestGroup (Context& context)
1477 : TestCaseGroup(context, "polygon", "Polygon clipping tests")
1481 void PolysTestGroup::init (void)
1483 const float large = 100000.0f;
1484 const float offset = 0.9f;
1485 const tcu::Vec4 white (1.0f, 1.0f, 1.0f, 1.0f);
1486 const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
1487 const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f);
1488 const tcu::Vec4 blue (0.0f, 0.0f, 1.0f, 1.0f);
1492 const TriangleCase::TriangleData viewportPolys[] =
1494 // one vertex clipped
1495 {tcu::Vec4(-0.8f, -0.2f, 0.0f, 1.0f), white, tcu::Vec4(-0.8f, 0.2f, 0.0f, 1.0f), white, tcu::Vec4(-1.3f, 0.05f, 0.0f, 1.0f), white},
1497 // two vertices clipped
1498 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), white, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), white, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), white},
1500 // three vertices clipped
1501 {tcu::Vec4(-1.1f, 0.6f, 0.0f, 1.0f), white, tcu::Vec4(-1.1f, 1.1f, 0.0f, 1.0f), white, tcu::Vec4(-0.6f, 1.1f, 0.0f, 1.0f), white},
1502 {tcu::Vec4( 0.8f, 1.1f, 0.0f, 1.0f), white, tcu::Vec4( 0.95f,-1.1f, 0.0f, 1.0f), white, tcu::Vec4( 3.0f, 0.0f, 0.0f, 1.0f), white},
1504 const TriangleCase::TriangleData depthPolys[] =
1506 // one vertex clipped to Z+
1507 {tcu::Vec4(-0.2f, 0.7f, 0.0f, 1.0f), white, tcu::Vec4( 0.2f, 0.7f, 0.0f, 1.0f), white, tcu::Vec4( 0.0f, 0.9f, 2.0f, 1.0f), white},
1509 // two vertices clipped to Z-
1510 {tcu::Vec4( 0.9f, 0.4f, -1.5f, 1.0f), white, tcu::Vec4( 0.9f, -0.4f, -1.5f, 1.0f), white, tcu::Vec4( 0.6f, 0.0f, 0.0f, 1.0f), white},
1512 // three vertices clipped
1513 {tcu::Vec4(-0.9f, 0.6f, -2.0f, 1.0f), white, tcu::Vec4(-0.9f, -0.6f, -2.0f, 1.0f), white, tcu::Vec4(-0.4f, 0.0f, 2.0f, 1.0f), white},
1515 // three vertices clipped by X, Y and Z
1516 {tcu::Vec4( 0.0f, -1.2f, 0.0f, 1.0f), white, tcu::Vec4( 0.0f, 0.5f, -1.5f, 1.0f), white, tcu::Vec4( 1.2f, -0.9f, 0.0f, 1.0f), white},
1518 const TriangleCase::TriangleData largePolys[] =
1520 // one vertex clipped
1521 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4( 0.0f, -large, 2.0f, 1.0f), white},
1523 // two vertices clipped
1524 {tcu::Vec4( 0.5f, 0.5f, 0.0f, 1.0f), white, tcu::Vec4( large, 0.5f, 0.0f, 1.0f), white, tcu::Vec4( 0.5f, large, 0.0f, 1.0f), white},
1526 // three vertices clipped
1527 {tcu::Vec4(-0.9f, -large, 0.0f, 1.0f), white, tcu::Vec4(-1.1f, -large, 0.0f, 1.0f), white, tcu::Vec4(-0.9f, large, 0.0f, 1.0f), white},
1529 const TriangleCase::TriangleData largeDepthPolys[] =
1531 // one vertex clipped
1532 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), white, tcu::Vec4( 0.0f, -large, large, 1.0f), white},
1534 // two vertices clipped
1535 {tcu::Vec4( 0.5f, 0.5f, 0.0f, 1.0f), white, tcu::Vec4( 0.9f, large/2, -large, 1.0f), white, tcu::Vec4( large/4, 0.0f, -large, 1.0f), white},
1537 // three vertices clipped
1538 {tcu::Vec4(-0.9f, large/4, large, 1.0f), white, tcu::Vec4(-0.5f, -large/4, -large, 1.0f), white, tcu::Vec4(-0.2f, large/4, large, 1.0f), white},
1540 const TriangleCase::TriangleData attribPolys[] =
1542 // one vertex clipped to edge, large
1543 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -large, 2.0f, 1.0f), blue},
1545 // two vertices clipped to edges
1546 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1548 // two vertices clipped to edges, with non-uniform w
1549 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1551 // three vertices clipped, large, Z
1552 {tcu::Vec4(-0.9f, large/4, large, 1.0f), red, tcu::Vec4(-0.5f, -large/4, -large, 1.0f), yellow, tcu::Vec4(-0.2f, large/4, large, 1.0f), blue},
1555 addChild(new TriangleCase(m_context, "poly_clip_viewport_center", "polygon viewport clipping", DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CENTER));
1556 addChild(new TriangleCase(m_context, "poly_clip_viewport_corner", "polygon viewport clipping", DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CORNER));
1558 addChild(new TriangleCase(m_context, "poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_WHOLE));
1559 addChild(new TriangleCase(m_context, "poly_z_clip_viewport_center", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CENTER));
1560 addChild(new TriangleCase(m_context, "poly_z_clip_viewport_corner", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CORNER));
1562 addChild(new TriangleCase(m_context, "large_poly_clip_viewport_center", "polygon viewport clipping", DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CENTER));
1563 addChild(new TriangleCase(m_context, "large_poly_clip_viewport_corner", "polygon viewport clipping", DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CORNER));
1565 addChild(new TriangleCase(m_context, "large_poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_WHOLE));
1566 addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_center", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CENTER));
1567 addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_corner", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CORNER));
1569 addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_WHOLE));
1570 addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CENTER));
1571 addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CORNER));
1574 // multiple polygons
1577 const TriangleAttributeCase::TriangleData polys[] =
1579 // one vertex clipped to edge
1580 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1582 // two vertices clipped to edges
1583 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1585 // two vertices clipped to edges, with non-uniform w
1586 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1587 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1588 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1589 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1591 // three vertices clipped, Z
1592 {tcu::Vec4(-0.9f, offset/4, offset, 1.0f), red, tcu::Vec4(-0.5f, -offset/4, -offset, 1.0f), yellow, tcu::Vec4(-0.2f, offset/4, offset, 1.0f), blue},
1595 addChild(new TriangleAttributeCase(m_context, "multiple_0", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1596 addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1597 addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1601 const TriangleAttributeCase::TriangleData polys[] =
1603 // one vertex clipped to z
1604 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1606 // two vertices clipped to edges
1607 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1609 // two vertices clipped to edges, with non-uniform w
1610 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1611 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1612 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1613 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, 16.0f*tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1616 addChild(new TriangleAttributeCase(m_context, "multiple_1", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1617 addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1618 addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1622 const TriangleAttributeCase::TriangleData polys[] =
1624 // one vertex clipped to z
1625 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1627 // two vertices clipped to edges
1628 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1630 // two vertices clipped to edges
1631 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1632 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1633 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1634 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1637 addChild(new TriangleAttributeCase(m_context, "multiple_2", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1638 addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1639 addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1643 const TriangleAttributeCase::TriangleData polys[] =
1645 // one vertex clipped to z
1646 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, -2.0f, 1.0f), blue},
1648 // two vertices clipped to edges
1649 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1650 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1651 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1652 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1655 addChild(new TriangleAttributeCase(m_context, "multiple_3", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1656 addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1657 addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1661 const TriangleAttributeCase::TriangleData polys[] =
1663 // one vertex clipped to z
1664 {tcu::Vec4(0.3f, 0.2f, 0.0f, 1.0f), red, tcu::Vec4( 0.3f, -0.2f, 0.0f, 1.0f), yellow, tcu::Vec4( offset, 0.0f, 2.0f, 1.0f), blue},
1666 // two vertices clipped to edges
1667 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1668 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1669 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1670 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1673 addChild(new TriangleAttributeCase(m_context, "multiple_4", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1674 addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1675 addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1679 const TriangleAttributeCase::TriangleData polys[] =
1681 // one vertex clipped to z
1682 {tcu::Vec4(-0.3f, 0.2f, 0.0f, 1.0f), red, tcu::Vec4(-0.3f, -0.2f, 0.0f, 1.0f), yellow, tcu::Vec4(-offset, 0.0f, 2.0f, 1.0f), blue},
1684 // two vertices clipped to edges
1685 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1686 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1687 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1688 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1691 addChild(new TriangleAttributeCase(m_context, "multiple_5", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1692 addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1693 addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1697 const TriangleAttributeCase::TriangleData polys[] =
1699 // one vertex clipped to z
1700 {tcu::Vec4(-0.2f, 0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, 0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, offset, 2.0f, 1.0f), blue},
1702 // two vertices clipped to edges
1703 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1704 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1705 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1706 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1709 addChild(new TriangleAttributeCase(m_context, "multiple_6", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1710 addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1711 addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1715 const TriangleAttributeCase::TriangleData polys[] =
1717 // two vertices clipped to edges
1718 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1720 // two vertices clipped to edges
1721 {tcu::Vec4( 0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, -0.6f, 0.0f, 1.0f), blue},
1722 {tcu::Vec4( 0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4( 1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.6f, 0.6f, 0.0f, 1.0f), blue},
1723 {tcu::Vec4(-0.6f, 1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, 0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, 0.6f, 0.0f, 1.0f), blue},
1724 {tcu::Vec4(-0.6f, -1.2f, 0.0f, 1.0f), red, tcu::Vec4(-1.2f, -0.6f, 0.0f, 1.0f), yellow, tcu::Vec4(-0.6f, -0.6f, 0.0f, 1.0f), blue},
1727 addChild(new TriangleAttributeCase(m_context, "multiple_7", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1728 addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1729 addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1733 const TriangleAttributeCase::TriangleData polys[] =
1735 // one vertex clipped to z
1736 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1739 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), white},
1740 {tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), blue, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), blue},
1743 addChild(new TriangleAttributeCase(m_context, "multiple_8", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1744 addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1745 addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1749 const TriangleAttributeCase::TriangleData polys[] =
1751 // one vertex clipped to z
1752 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1755 {tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), red},
1756 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), blue},
1759 addChild(new TriangleAttributeCase(m_context, "multiple_9", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1760 addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1761 addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1765 const TriangleAttributeCase::TriangleData polys[] =
1767 // one vertex clipped to z
1768 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1771 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), white},
1772 {tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), red},
1773 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), blue},
1776 addChild(new TriangleAttributeCase(m_context, "multiple_10", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1777 addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1778 addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1782 const TriangleAttributeCase::TriangleData polys[] =
1784 // one vertex clipped to z
1785 {tcu::Vec4(-0.2f, -0.3f, 0.0f, 1.0f), red, tcu::Vec4( 0.2f, -0.3f, 0.0f, 1.0f), yellow, tcu::Vec4( 0.0f, -offset, 2.0f, 1.0f), blue},
1788 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), white, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), white},
1789 {tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), red},
1790 {tcu::Vec4( -1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), blue, tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), blue},
1791 {tcu::Vec4( -1.0f, 1.0f, 0.0f, 1.0f), yellow, tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f), yellow, tcu::Vec4( 1.0f, 1.0f, 0.0f, 1.0f), yellow},
1794 addChild(new TriangleAttributeCase(m_context, "multiple_11", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE));
1795 addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER));
1796 addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER));
1801 class PolyEdgesTestGroup : public TestCaseGroup
1804 PolyEdgesTestGroup (Context& context);
1809 PolyEdgesTestGroup::PolyEdgesTestGroup (Context& context)
1810 : TestCaseGroup(context, "polygon_edge", "Polygon clipping edge tests")
1814 void PolyEdgesTestGroup::init (void)
1819 tcu::Vec3 d1; // tangent
1820 tcu::Vec3 d2; // bi-tangent
1823 { tcu::Vec3( 1, 1, 1), tcu::Vec3( 1, -1, 1) },
1824 { tcu::Vec3( 1, 1, 1), tcu::Vec3(-1, 1.1f, 1) },
1825 { tcu::Vec3( 1, 1, 0), tcu::Vec3(-1, 1, 0) },
1826 { tcu::Vec3( 0, 1, 0), tcu::Vec3( 1, 0, 0) },
1827 { tcu::Vec3( 0, 1, 0), tcu::Vec3( 1, 0.1f, 0) },
1831 const struct EdgeQuad
1833 tcu::Vec3 d1; // tangent
1834 tcu::Vec3 d2; // bi-tangent
1835 tcu::Vec3 center; // center
1838 { tcu::Vec3( 1, 0.01f, 0 ), tcu::Vec3( 0, 0.01f, 0), tcu::Vec3( 0, 0.99f, 0 ) }, // edge near x-plane
1839 { tcu::Vec3( 0.01f, 1, 0 ), tcu::Vec3( 0.01f, 0, 0), tcu::Vec3( 0.99f, 0, 0 ) }, // edge near y-plane
1840 { tcu::Vec3( 1, 1, 0.01f), tcu::Vec3( 0.01f, -0.01f, 0), tcu::Vec3( 0, 0, 0.99f) }, // edge near z-plane
1843 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(quads); ++ndx)
1844 addChild(new QuadFillTest(m_context, (std::string("quad_at_origin_") + de::toString(ndx)).c_str(), "polygon edge clipping", VIEWPORT_CENTER, quads[ndx].d1, quads[ndx].d2));
1845 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(edgeQuads); ++ndx)
1846 addChild(new QuadFillTest(m_context, (std::string("quad_near_edge_") + de::toString(ndx)).c_str(), "polygon edge clipping", VIEWPORT_CENTER, edgeQuads[ndx].d1, edgeQuads[ndx].d2, edgeQuads[ndx].center));
1849 addChild(new TriangleFanFillTest(m_context, "poly_fan", "polygon edge clipping", VIEWPORT_CENTER));
1852 class PolyVertexClipTestGroup : public TestCaseGroup
1855 PolyVertexClipTestGroup (Context& context);
1860 PolyVertexClipTestGroup::PolyVertexClipTestGroup (Context& context)
1861 : TestCaseGroup(context, "triangle_vertex", "Clip n vertices")
1865 void PolyVertexClipTestGroup::init (void)
1867 const float far = 30000.0f;
1868 const tcu::IVec3 outside[] =
1870 // outside one clipping plane
1871 tcu::IVec3(-1, 0, 0),
1872 tcu::IVec3( 1, 0, 0),
1873 tcu::IVec3( 0, 1, 0),
1874 tcu::IVec3( 0, -1, 0),
1875 tcu::IVec3( 0, 0, 1),
1876 tcu::IVec3( 0, 0, -1),
1878 // outside two clipping planes
1879 tcu::IVec3(-1, -1, 0),
1880 tcu::IVec3( 1, -1, 0),
1881 tcu::IVec3( 1, 1, 0),
1882 tcu::IVec3(-1, 1, 0),
1884 tcu::IVec3(-1, 0, -1),
1885 tcu::IVec3( 1, 0, -1),
1886 tcu::IVec3( 1, 0, 1),
1887 tcu::IVec3(-1, 0, 1),
1889 tcu::IVec3( 0, -1, -1),
1890 tcu::IVec3( 0, 1, -1),
1891 tcu::IVec3( 0, 1, 1),
1892 tcu::IVec3( 0, -1, 1),
1894 // outside three clipping planes
1895 tcu::IVec3(-1, -1, 1),
1896 tcu::IVec3( 1, -1, 1),
1897 tcu::IVec3( 1, 1, 1),
1898 tcu::IVec3(-1, 1, 1),
1900 tcu::IVec3(-1, -1, -1),
1901 tcu::IVec3( 1, -1, -1),
1902 tcu::IVec3( 1, 1, -1),
1903 tcu::IVec3(-1, 1, -1),
1906 de::Random rnd(0xabcdef);
1908 TestCaseGroup* clipOne = new TestCaseGroup(m_context, "clip_one", "Clip one vertex");
1909 TestCaseGroup* clipTwo = new TestCaseGroup(m_context, "clip_two", "Clip two vertices");
1910 TestCaseGroup* clipThree = new TestCaseGroup(m_context, "clip_three", "Clip three vertices");
1914 addChild(clipThree);
1916 // Test 1 point clipped
1917 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(outside); ++ndx)
1919 const float w0 = rnd.getFloat(0.2f, 16.0f);
1920 const float w1 = rnd.getFloat(0.2f, 16.0f);
1921 const float w2 = rnd.getFloat(0.2f, 16.0f);
1922 const tcu::Vec4 white = tcu::Vec4( 1, 1, 1, 1);
1923 const tcu::Vec3 r0 = tcu::Vec3( 0.2f, 0.3f, 0);
1924 const tcu::Vec3 r1 = tcu::Vec3(-0.3f, -0.4f, 0);
1925 const tcu::Vec3 r2 = IVec3ToVec3(outside[ndx]) * far;
1926 const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0);
1927 const tcu::Vec4 p1 = tcu::Vec4(r1.x() * w1, r1.y() * w1, r1.z() * w1, w1);
1928 const tcu::Vec4 p2 = tcu::Vec4(r2.x() * w2, r2.y() * w2, r2.z() * w2, w2);
1930 const std::string name = std::string("clip") +
1931 (outside[ndx].x() > 0 ? "_pos_x" : (outside[ndx].x() < 0 ? "_neg_x" : "")) +
1932 (outside[ndx].y() > 0 ? "_pos_y" : (outside[ndx].y() < 0 ? "_neg_y" : "")) +
1933 (outside[ndx].z() > 0 ? "_pos_z" : (outside[ndx].z() < 0 ? "_neg_z" : ""));
1935 const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
1937 // don't try to test with degenerate (or almost degenerate) triangles
1938 if (outside[ndx].x() == 0 && outside[ndx].y() == 0)
1941 clipOne->addChild(new TriangleCase(m_context, name.c_str(), "clip one vertex", &triangle, &triangle + 1, VIEWPORT_CENTER));
1944 // Special triangles for "clip_z" cases, default triangles is not good, since it has very small visible area => problems with MSAA
1946 const tcu::Vec4 white = tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
1948 const TriangleCase::TriangleData posZTriangle =
1950 tcu::Vec4( 0.0f, -0.7f, -0.9f, 1.0f), white,
1951 tcu::Vec4( 0.8f, 0.0f, -0.7f, 1.0f), white,
1952 tcu::Vec4(-0.9f, 0.9f, 3.0f, 1.0f), white
1954 const TriangleCase::TriangleData negZTriangle =
1956 tcu::Vec4( 0.0f, -0.7f, 0.9f, 1.0f), white,
1957 tcu::Vec4( 0.4f, 0.0f, 0.7f, 1.0f), white,
1958 tcu::Vec4(-0.9f, 0.9f, -3.0f, 1.0f), white
1961 clipOne->addChild(new TriangleCase(m_context, "clip_pos_z", "clip one vertex", &posZTriangle, &posZTriangle + 1, VIEWPORT_CENTER));
1962 clipOne->addChild(new TriangleCase(m_context, "clip_neg_z", "clip one vertex", &negZTriangle, &negZTriangle + 1, VIEWPORT_CENTER));
1965 // Test 2 points clipped
1966 for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1)
1967 for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2)
1969 const float w0 = rnd.getFloat(0.2f, 16.0f);
1970 const float w1 = rnd.getFloat(0.2f, 16.0f);
1971 const float w2 = rnd.getFloat(0.2f, 16.0f);
1972 const tcu::Vec4 white = tcu::Vec4( 1, 1, 1, 1);
1973 const tcu::Vec3 r0 = tcu::Vec3( 0.2f, 0.3f, 0);
1974 const tcu::IVec3 r1 = outside[ndx1];
1975 const tcu::IVec3 r2 = outside[ndx2];
1976 const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0);
1977 const tcu::Vec4 p1 = tcu::Vec4(r1.x() * far * w1, r1.y() * far * w1, r1.z() * far * w1, w1);
1978 const tcu::Vec4 p2 = tcu::Vec4(r2.x() * far * w2, r2.y() * far * w2, r2.z() * far * w2, w2);
1980 const std::string name = std::string("clip") +
1981 (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) +
1982 (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) +
1983 (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) +
1985 (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) +
1986 (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) +
1987 (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : ""));
1989 const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
1991 if (twoPointClippedTriangleInvisible(r0, r1, r2))
1994 clipTwo->addChild(new TriangleCase(m_context, name.c_str(), "clip two vertices", &triangle, &triangle + 1, VIEWPORT_CENTER));
1997 // Test 3 points clipped
1998 for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1)
1999 for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2)
2000 for (int ndx3 = ndx2 + 1; ndx3 < DE_LENGTH_OF_ARRAY(outside); ++ndx3)
2002 const float w0 = rnd.getFloat(0.2f, 16.0f);
2003 const float w1 = rnd.getFloat(0.2f, 16.0f);
2004 const float w2 = rnd.getFloat(0.2f, 16.0f);
2005 const tcu::Vec4 white = tcu::Vec4(1, 1, 1, 1);
2006 const tcu::IVec3 r0 = outside[ndx1];
2007 const tcu::IVec3 r1 = outside[ndx2];
2008 const tcu::IVec3 r2 = outside[ndx3];
2009 const tcu::Vec4 p0 = tcu::Vec4(r0.x() * far * w0, r0.y() * far * w0, r0.z() * far * w0, w0);
2010 const tcu::Vec4 p1 = tcu::Vec4(r1.x() * far * w1, r1.y() * far * w1, r1.z() * far * w1, w1);
2011 const tcu::Vec4 p2 = tcu::Vec4(r2.x() * far * w2, r2.y() * far * w2, r2.z() * far * w2, w2);
2013 // ignore cases where polygon is along xz or yz planes
2014 if (pointsOnLine(r0.swizzle(0, 1), r1.swizzle(0, 1), r2.swizzle(0, 1)))
2017 // triangle is visible only if it intersects the origin
2018 if (pointOnTriangle(tcu::IVec3(0, 0, 0), r0, r1, r2))
2020 const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white};
2021 const std::string name = std::string("clip") +
2022 (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) +
2023 (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) +
2024 (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) +
2026 (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) +
2027 (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) +
2028 (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : "")) +
2030 (outside[ndx3].x() > 0 ? "_pos_x" : (outside[ndx3].x() < 0 ? "_neg_x" : "")) +
2031 (outside[ndx3].y() > 0 ? "_pos_y" : (outside[ndx3].y() < 0 ? "_neg_y" : "")) +
2032 (outside[ndx3].z() > 0 ? "_pos_z" : (outside[ndx3].z() < 0 ? "_neg_z" : ""));
2034 clipThree->addChild(new TriangleCase(m_context, name.c_str(), "clip three vertices", &triangle, &triangle + 1, VIEWPORT_CENTER));
2041 ClippingTests::ClippingTests (Context& context)
2042 : TestCaseGroup(context, "clipping", "Clipping tests")
2046 ClippingTests::~ClippingTests (void)
2050 void ClippingTests::init (void)
2052 addChild(new PointsTestGroup (m_context));
2053 addChild(new LinesTestGroup (m_context));
2054 addChild(new PolysTestGroup (m_context));
2055 addChild(new PolyEdgesTestGroup (m_context));
2056 addChild(new PolyVertexClipTestGroup(m_context));